import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hibernate.annotations.Cascade;
import org.hibernate.search.annotations.FieldBridge;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.joda.time.DateTime;
+import org.joda.time.Partial;
import eu.etaxonomy.cdm.common.DOI;
import eu.etaxonomy.cdm.common.URI;
+import eu.etaxonomy.cdm.format.common.TimePeriodPartialFormatter;
import eu.etaxonomy.cdm.format.reference.NomenclaturalSourceFormatter;
import eu.etaxonomy.cdm.hibernate.search.DateTimeBridge;
import eu.etaxonomy.cdm.hibernate.search.DoiBridge;
"seriesPart",
"datePublished",
"publisher",
+ "publisher2",
"placePublished",
+ "placePublished2",
"institution",
"school",
"organization",
IIntextReferenceTarget {
private static final long serialVersionUID = -2034764545042691295L;
- private static final Logger logger = LogManager.getLogger(Reference.class);
+ private static final Logger logger = LogManager.getLogger();
// from E+M import (still needed?)
// @Column(length=255)
value = "eu.etaxonomy.cdm.model.reference.ReferenceType")}
)
@Audited
- protected ReferenceType type;
+ private ReferenceType type;
//Title of the reference
@XmlElement(name ="Title" )
//TODO Val #3379
// @NullOrNotEmpty
@Column(length=255)
- protected String editor;
+ private String editor;
@XmlElement(name = "Volume")
@Field
//TODO Val #3379
// @NullOrNotEmpty
@Column(length=255)
- protected String volume;
+ private String volume;
@XmlElement(name = "Pages")
@Field
//TODO Val #3379
// @NullOrNotEmpty
@Column(length=255)
- protected String pages;
+ private String pages;
@XmlElement(name = "Edition")
@Field
//TODO Val #3379
// @NullOrNotEmpty
@Column(length=255)
- protected String edition;
+ private String edition;
@XmlElement(name = "ISBN")
@Field
// @NullOrNotEmpty
@Column(length=255)
@Pattern(regexp = "(?=.{13}$)\\d{1,5}([- ])\\d{1,7}\\1\\d{1,6}\\1(\\d|X)$", groups = Level2.class, message = "{eu.etaxonomy.cdm.model.reference.Reference.isbn.message}")
- protected String isbn;
+ private String isbn;
@XmlElement(name = "Doi")
@Field
@FieldBridge(impl = DoiBridge.class)
@Type(type="doiUserType")
@Column(length=DOI.MAX_LENGTH)
- protected DOI doi;
-
+ private DOI doi;
@XmlElement(name = "ISSN")
@Field
// @NullOrNotEmpty
@Column(length=255)
@Pattern(regexp = "(?=.{9}$)\\d{4}([- ])\\d{4} (\\d|X)$", groups = Level2.class, message = "{eu.etaxonomy.cdm.model.reference.Reference.issn.message}")
- protected String issn;
+ private String issn;
@XmlElement(name = "SeriesPart")
@Field
//TODO Val #3379
// @NullOrNotEmpty
@Column(length=255)
- protected String seriesPart;
+ private String seriesPart;
@XmlElement(name = "Organization")
@Field
//TODO Val #3379
// @NullOrNotEmpty
@Column(length=255)
- protected String organization;
+ private String organization;
@XmlElement(name = "Publisher")
@Field
//TODO Val #3379
// @NullOrNotEmpty
@Column(length=255)
- protected String publisher;
+ private String publisher;
+ @XmlElement(name = "Publisher2")
+ @Field
+ @Column(length=255)
+ private String publisher2;
@XmlElement(name = "PlacePublished")
@Field
//TODO Val #3379
// @NullOrNotEmpty
@Column(length=255)
- protected String placePublished;
+ private String placePublished;
+
+ @XmlElement(name = "PlacePublished2")
+ @Field
+ @Column(length=255)
+ private String placePublished2;
@XmlElement(name = "Institution")
@XmlIDREF
@ManyToOne(fetch = FetchType.LAZY)
@IndexedEmbedded
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
- protected Institution institution;
+ private Institution institution;
@XmlElement(name = "School")
@XmlIDREF
@ManyToOne(fetch = FetchType.LAZY)
@IndexedEmbedded
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
- protected Institution school;
+ private Institution school;
@XmlElement(name = "InReference")
@XmlIDREF
@ManyToOne(fetch = FetchType.LAZY)
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
// @InReference(groups=Level2.class)
- protected Reference inReference;
+ private Reference inReference;
//********************************************************/
public String getPublisher() {
return publisher;
}
-
@Override
public void setPublisher(String publisher) {
- this.publisher = isBlank(publisher)? null : publisher;
+ this.publisher = StringUtils.truncate(isBlank(publisher)? null : publisher, 255);
}
-
- @Override
+ @Override
public void setPublisher(String publisher, String placePublished){
- this.publisher = publisher;
- this.placePublished = placePublished;
- }
+ this.publisher = publisher;
+ this.placePublished = placePublished;
+ }
+
+ @Override
+ public String getPublisher2() {
+ return publisher2;
+ }
+ @Override
+ public void setPublisher2(String publisher2) {
+ this.publisher2 = StringUtils.truncate(isBlank(publisher2)? null : publisher2, 255);
+ }
+ @Override
+ public void setPublisher2(String publisher2, String placePublished2){
+ this.publisher2 = publisher2;
+ this.placePublished2 = placePublished2;
+ }
@Override
public String getPlacePublished() {
return placePublished;
}
-
@Override
public void setPlacePublished(String placePublished) {
this.placePublished = isBlank(placePublished)? null: placePublished;
}
+ @Override
+ public String getPlacePublished2() {
+ return placePublished2;
+ }
+ @Override
+ public void setPlacePublished2(String placePublished2) {
+ this.placePublished2 = isBlank(placePublished2)? null: placePublished2;
+ }
+
@Override
public Institution getInstitution() {
return institution;
}
-
@Override
public void setInstitution(Institution institution) {
this.institution = institution;
public Institution getSchool() {
return school;
}
-
@Override
public void setSchool(Institution school) {
this.school = school;
public Reference getInReference() {
return inReference;
}
-
@Override
public void setInReference(Reference inReference) {
this.inReference = inReference;
/**
* Whether this reference is of the given type
- *
- * @param type
- * @return
*/
@Override
public boolean isOfType(ReferenceType type){
/**
* Returns a string representation for the year of publication / creation
* of <i>this</i> reference. If the {@link #getDatePublished() datePublished}
- * of this reference contains more date information then (starting) year
+ * of this reference contains more date information than (starting) year
* only the year is returned.
*/
@Override
}
}
+ /**
+ * Returns a sortable string of the datePublished.start attribute.<BR>
+ * If datePublished is null in-references are called recursively.
+ * Only structured publication data is considered, no freetext or
+ * verbatim date.
+ */
+ @Transient
+ public String getSortableDateString(){
+ VerbatimTimePeriod datePublished = this.getDatePublished();
+ if (datePublished != null ){
+ Partial partial = getDatePublished().getStart();
+ if (partial == null) {
+ partial = getDatePublished().getEnd();
+ }
+ if (partial != null ) {
+ return TimePeriodPartialFormatter.INSTANCE().printSortableDateString(partial);
+ }
+ }
+ if (this.inReference != null){
+ return this.inReference.getSortableDateString();
+ }else {
+ return "zzzz-zz-zz";
+ }
+ }
+
/**
* Convenience method that returns a string representation for the publication date / creation
* of <i>this</i> reference. The string is obtained by
public boolean isPrintedUnit() {
return this.getType().isPrintedUnit();
}
+ /**
+ * @return <code>true</code> if the type of this reference
+ * supports the {@link IDynamicReference} interface. Currently these are
+ * webpages, databases and maps.
+ */
+ public boolean isDynamic() {
+ return this.getType().isDynamic();
+ }
//*************************** CACHE STRATEGIES ******************************/