001 package edu.nrao.sss.model.proposal; 002 003 //XXX These packages need to be dealt with/replaced 004 //import edu.nrao.sss.util.XmlWrapper; 005 //import javax.xml.parsers.ParserConfigurationException; 006 //import javax.xml.xpath.XPathExpressionException; 007 //import org.xml.sax.InputSource; 008 //import org.xml.sax.SAXException; 009 //import java.io.IOException; 010 //import java.io.Reader; 011 //import java.io.Serializable; 012 //import java.io.StringReader; 013 014 import edu.nrao.sss.util.StringUtil; 015 import edu.nrao.sss.util.Identifiable; 016 import edu.nrao.sss.util.XmlSerializable; 017 018 /** <i>Placeholder for time when we integrate proposal work.</i> 019 * 020 */ 021 public class Author 022 implements Identifiable, XmlSerializable 023 { 024 025 private String affiliation = null; 026 private String firstName = null; 027 private String astronomerId = null; 028 private String lastName = null; 029 private String telephone = null; 030 private String graduationYear = null; 031 private String otherAwards = null; 032 private String email = null; 033 private String assignment = null; 034 private ProfessionalStatus professionalStatus = ProfessionalStatus.ALL_OTHERS; 035 private boolean observingForThesis = false; 036 private boolean domestic = false; 037 private boolean supportRequester = false; 038 private boolean supported = false; 039 private float stipend = 0; 040 041 042 private long key = 0; 043 private int displayPosition = 0; 044 private Proposal proposal = null; 045 046 047 public Author(){} 048 049 050 @SuppressWarnings("unused") 051 private void setId( long id ){ 052 key = id; 053 } 054 055 public Long getId(){ 056 return key; 057 } 058 059 public Proposal getProposal(){ 060 return proposal; 061 } 062 063 public void setProposal( Proposal prop ){ 064 proposal = prop; 065 } 066 067 public void setDisplayPosition( int value ){ 068 displayPosition = value; 069 } 070 071 public int getDisplayPosition(){ 072 return displayPosition; 073 } 074 075 public String getAffiliation(){ 076 return affiliation; 077 } 078 public boolean isDomestic(){ 079 return domestic; 080 } 081 082 083 public String getEmail(){ 084 return email; 085 } 086 public String getFirstName(){ 087 return firstName; 088 } 089 public String getAuthorId(){ 090 return astronomerId; 091 } 092 public String getLastName(){ 093 return lastName; 094 } 095 public ProfessionalStatus getProfessionalStatus(){ 096 return professionalStatus; 097 } 098 public String getTelephone(){ 099 return telephone; 100 } 101 102 public String getGraduationYear(){ 103 return graduationYear; 104 } 105 106 public boolean isStudentObservingForThesis(){ 107 return observingForThesis; 108 } 109 110 public void setAffiliation(String affil){ 111 affiliation = affil; 112 } 113 public void setDomestic(boolean domestics){ 114 domestic = domestics; 115 } 116 public void setEmail( String emails ){ 117 email = emails; 118 } 119 public void setFirstName(String firstNames){ 120 firstName = firstNames; 121 } 122 public void setAuthorId(String id){ 123 astronomerId = id; 124 } 125 126 public void setLastName(String lastNames){ 127 lastName = lastNames; 128 } 129 public void setProfessionalStatus(ProfessionalStatus professionalStat){ 130 professionalStatus = professionalStat; 131 } 132 public void setTelephone(String tele ){ 133 telephone = tele; 134 } 135 136 137 public void setGraduationYear( String yr ){ 138 graduationYear = yr; 139 } 140 141 public void setStudentObservingForThesis( boolean b ){ 142 observingForThesis = b; 143 } 144 145 public void setAssignment(String assign){ 146 assignment = assign; 147 } 148 public String getAssignment(){ 149 return assignment; 150 } 151 public void setStipend( float value ){ 152 stipend = value; 153 } 154 public float getStipend(){ 155 return stipend; 156 } 157 public void setOtherAwards(String otherAwards){ 158 this.otherAwards = otherAwards; 159 } 160 public String getOtherAwards(){ 161 return otherAwards; 162 } 163 164 public boolean isSupportRequester(){ 165 return supportRequester; 166 } 167 168 public void setSupportRequester( boolean b ){ 169 supportRequester = b; 170 } 171 172 public boolean isSupported(){ 173 return supported; 174 } 175 176 public void setSupported( boolean b ){ 177 supported = b; 178 } 179 180 //------------------------------------------------------------------ 181 // Overriden object methods 182 //------------------------------------------------------------------ 183 184 /** 185 * Returns true if the otherAuthor is an Author with the same email 186 * address and identifier; returns false otherwise. 187 * @param otherAuthor an object to compare this Author to. 188 * @return true if the otherAuthor is an Author with the same email and 189 * identifier as this Author; false otherwise. 190 */ 191 public boolean equals( Object otherAuthor){ 192 boolean result = false; 193 if ( otherAuthor != null ){ 194 if ( otherAuthor instanceof Author ){ 195 StringUtil util = StringUtil.getInstance(); 196 197 //Ids must be the same 198 Author otherAuth = (Author)otherAuthor; 199 String myId = getAuthorId(); 200 String authorId = otherAuth.getAuthorId(); 201 myId = util.normalizeString( myId ); 202 authorId = util.normalizeString( authorId ); 203 if ( myId.equals( authorId)){ 204 205 //Emails must be the same. 206 String myEmail = getEmail(); 207 String otherEmail = otherAuth.getEmail(); 208 if ( myEmail != null ){ 209 myEmail = util.normalizeString( myEmail ); 210 } 211 if ( otherEmail != null ){ 212 otherEmail = util.normalizeString( otherEmail ); 213 } 214 if ( myEmail.equals( otherEmail)){ 215 result = true; 216 } 217 } 218 } 219 } 220 return result; 221 } 222 223 public int hashCode(){ 224 StringUtil util = StringUtil.getInstance(); 225 226 String idStr = getAuthorId(); 227 idStr = util.normalizeString( idStr ); 228 String email = getEmail(); 229 email = util.normalizeString( email ); 230 String combStr = idStr + email; 231 return combStr.hashCode(); 232 } 233 234 /** 235 * Returns an xml representation of an Author. 236 * @param indent the number of spaces to indent the opening author xml tag. 237 * @return the xml representation of an author. 238 public String toXML( int indent ){ 239 StringUtil util = StringUtil.getInstance(); 240 241 String space = util.getSpacer( indent ); 242 StringBuilder sb = new StringBuilder( space + "<author>\n" ); 243 sb.append( space + " <astronomer_id>" + getAuthorId() + "</astronomer_id>\n" ); 244 sb.append( space + " <first_name>" + getFirstName() + "</first_name>\n" ); 245 sb.append( space + " <last_name>" + getLastName() + "</last_name>\n" ); 246 sb.append( space + " <affiliation domestic=\""+isDomestic() + "\">" + getAffiliation() + "</affiliation>\n" ); 247 sb.append( space + " <email>" + getEmail() + "</email>\n" ); 248 sb.append( space + " <professional_status type=\""+ getProfessionalStatus()+"\">\n" ); 249 sb.append( space + " <phd_year>" + getGraduationYear() + "</phd_year>\n" ); 250 sb.append( space + " <observe_for_thesis>" + isStudentObservingForThesis() + "</observe_for_thesis>\n"); 251 sb.append( space + " </professional_status>\n" ); 252 sb.append( space + " <telephone>" + getTelephone() + "</telephone>\n" ); 253 sb.append( space + "</author>\n" ); 254 return sb.toString(); 255 } 256 */ 257 258 /** 259 * XXX method stub 260 */ 261 public String toXml() 262 { 263 return null; 264 } 265 266 /** 267 * XXX method stub 268 */ 269 public void fromXml(String xml) {} 270 }