/*
 */
package org.datadryad.rest.legacymodels;

import javax.xml.bind.annotation.XmlRootElement;
import org.datadryad.rest.models.Author;
import org.datadryad.rest.models.Manuscript;

/**
 *
 * @author Dan Leehr <dan.leehr@nescent.org>
 */
@XmlRootElement(name="DryadEmailSubmission")
public class LegacyManuscript {
    public String Abstract;
    public String Journal;
    public String Article_Status;
    public LegacyAuthorsList Authors = new LegacyAuthorsList();
    public LegacySubmissionMetadata Submission_Metadata = new LegacySubmissionMetadata();
    public String Corresponding_Author;
    public String Email;
    public String Address_Line_1;
    public String Address_Line_2;
    public String Address_Line_3;
    public String City, State, Country, Zip;
    public LegacyClassifications Classification = new LegacyClassifications();

    public LegacyManuscript() {}
    public LegacyManuscript(Manuscript manuscript, String journalName) {
        this.Journal = journalName;
        this.Submission_Metadata.Manuscript = manuscript.manuscriptId;
        this.Submission_Metadata.Article_Title = manuscript.title;
        this.Article_Status = manuscript.status;
        for(Author author : manuscript.authors.author) {
            this.Authors.Author.add(author.fullName());
        }
        this.Corresponding_Author = manuscript.correspondingAuthor.author.fullName();
        this.Email = manuscript.correspondingAuthor.email;
        this.Address_Line_1 = manuscript.correspondingAuthor.address.addressLine1;
        this.Address_Line_2 = manuscript.correspondingAuthor.address.addressLine2;
        this.Address_Line_3 = manuscript.correspondingAuthor.address.addressLine3;
        this.City = manuscript.correspondingAuthor.address.city;
        this.State = manuscript.correspondingAuthor.address.state;
        this.Country = manuscript.correspondingAuthor.address.country;
        this.Zip = manuscript.correspondingAuthor.address.zip;
        this.Abstract = manuscript.manuscript_abstract;
        for(String keyword : manuscript.keywords.keyword) {
            this.Classification.keyword.add(keyword);
        }
    }

}

@@ -1294,24 +1294,149 @@
 ;%0A        %7D%0A
+        if(manuscript.correspondingAuthor != null) %7B%0A            if(manuscript.correspondingAuthor.author != null) %7B%0A        
         this
@@ -1505,24 +1505,42 @@
 fullName();%0A
+            %7D%0A    
         this
@@ -1582,24 +1582,97 @@
 thor.email;%0A
+            if(manuscript.correspondingAuthor.address != null) %7B%0A        
         this
@@ -1742,32 +1742,40 @@
 sLine1;%0A        
+   
+     
 this.Address_Lin
@@ -1833,32 +1833,40 @@
 sLine2;%0A        
+    
+    
 this.Address_Lin
@@ -1924,16 +1924,24 @@
 sLine3;%0A
+        
         
@@ -2001,24 +2001,32 @@
 ty;%0A        
+       
+ 
 this.State =
@@ -2072,16 +2072,24 @@
 .state;%0A
+        
         
@@ -2155,24 +2155,32 @@
 ry;%0A        
+ 
+       
 this.Zip = m
@@ -2218,24 +2218,48 @@
 ddress.zip;%0A
+            %7D%0A        %7D%0A
         this
@@ -2346,24 +2346,21 @@
 ipt.
-k
+getK
 eywords
-.keyword
+()
 ) %7B%0A

Check for nulls before building legacy manuscript xml