import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
+import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import org.apache.log4j.Logger;
+import org.hibernate.annotations.Cascade;
+import org.hibernate.annotations.CascadeType;
import org.hibernate.envers.Audited;
import org.hibernate.search.annotations.Indexed;
import eu.etaxonomy.cdm.model.common.Representation;
import eu.etaxonomy.cdm.model.location.NamedArea;
import eu.etaxonomy.cdm.model.media.Media;
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.cdm.model.taxon.Taxon;
/**
@Indexed(index = "eu.etaxonomy.cdm.model.media.Media")
@Audited
public class MediaKey extends Media implements IIdentificationKey{
-
private static final long serialVersionUID = -29095811051894471L;
@SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(MediaKey.class);
@XmlIDREF
@XmlSchemaType(name = "IDREF")
@ManyToMany(fetch = FetchType.LAZY)
+ @NotNull
private Set<Taxon> coveredTaxa = new HashSet<Taxon>();
@XmlElementWrapper( name = "GeographicalScope")
@XmlIDREF
@XmlSchemaType(name = "IDREF")
@ManyToMany(fetch = FetchType.LAZY)
+ @JoinTable(name="MediaKey_NamedArea")
+ @NotNull
private Set<NamedArea> geographicalScope = new HashSet<NamedArea>();
@XmlElementWrapper(name = "TaxonomicScope")
joinColumns=@JoinColumn(name="mediaKey_fk"),
inverseJoinColumns=@JoinColumn(name="taxon_fk")
)
+ @NotNull
private Set<Taxon> taxonomicScope = new HashSet<Taxon>();
@XmlElementWrapper( name = "ScopeRestrictions")
@XmlIDREF
@XmlSchemaType(name = "IDREF")
@ManyToMany(fetch = FetchType.LAZY)
+ @JoinTable(name="MediaKey_Scope")
+ @NotNull
private Set<Scope> scopeRestrictions = new HashSet<Scope>();
@XmlElementWrapper( name = "KeyRepresentations")
@XmlIDREF
@XmlSchemaType(name = "IDREF")
@ManyToMany(fetch = FetchType.LAZY)
+ @Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE,CascadeType.DELETE, CascadeType.DELETE_ORPHAN})
+ @NotNull
private Set<Representation> keyRepresentations = new HashSet<Representation>();
/**
* <i>this</i> identification key.
*/
public Set<Taxon> getCoveredTaxa() {
+ if(coveredTaxa == null) {
+ this.coveredTaxa = new HashSet<Taxon>();
+ }
return coveredTaxa;
}
/**
* data where <i>this</i> identification key is valid.
*/
public Set<NamedArea> getGeographicalScope() {
+ if(geographicalScope == null) {
+ this.geographicalScope = new HashSet<NamedArea>();
+ }
return geographicalScope;
}
* scope of <i>this</i> identification key
*/
public Set<Taxon> getTaxonomicScope() {
+ if(taxonomicScope == null) {
+ this.taxonomicScope = new HashSet<Taxon>();
+ }
return taxonomicScope;
}
* <i>this</i> identification key
*/
public Set<Representation> getKeyRepresentations() {
+ if(keyRepresentations == null) {
+ this.keyRepresentations = new HashSet<Representation>();
+ }
return keyRepresentations;
}
* <i>this</i> identification key
*/
public Set<Scope> getScopeRestrictions() {
+ if(scopeRestrictions == null) {
+ this.scopeRestrictions = new HashSet<Scope>();
+ }
return scopeRestrictions;
}