this.typifiedNames = typifiedNames;
}
public void addTypifiedName(TaxonNameBase typifiedName) {
- typifiedName.setHomotypicalGroup(this);
+ if (typifiedName != null){
+ typifiedName.setHomotypicalGroup(this);
+ typifiedNames.add(typifiedName);
+ }
}
public void removeTypifiedName(TaxonNameBase typifiedName) {
typifiedName.setHomotypicalGroup(null);
+ typifiedNames.remove(typifiedName);
}
package eu.etaxonomy.cdm.model.name;
-
-import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
+import eu.etaxonomy.cdm.model.common.RelationshipBase;
+import eu.etaxonomy.cdm.model.reference.ReferenceBase;
import org.apache.log4j.Logger;
-import org.hibernate.annotations.Cascade;
-import org.hibernate.annotations.CascadeType;
-
-import java.util.*;
import javax.persistence.*;
/**
* @created 08-Nov-2007 13:06:26
*/
@Entity
-public class HybridRelationship extends ReferencedEntityBase {
- static Logger logger = Logger.getLogger(HybridRelationship.class);
+public class HybridRelationship extends RelationshipBase<BotanicalName, BotanicalName, HybridRelationshipType> {
+ private static final Logger logger = Logger.getLogger(HybridRelationship.class);
//The nomenclatural code rule considered. The article/note/recommendation in the code in question that is commented on in
//the note property.
private String ruleConsidered;
- private BotanicalName parentName;
- private HybridRelationshipType type;
- private BotanicalName hybridName;
- @ManyToOne
- public HybridRelationshipType getType(){
- return this.type;
- }
- public void setType(HybridRelationshipType type){
- this.type = type;
+ //for hibernate, don't use
+ @Deprecated
+ private HybridRelationship(){
+ super();
}
- @ManyToOne
- @Cascade({CascadeType.SAVE_UPDATE})
+
+ /**
+ * creates a relationship between 2 names and adds this relationship object to the respective name relation sets
+ * @param toName
+ * @param fromName
+ * @param type
+ * @param ruleConsidered
+ */
+ protected HybridRelationship(BotanicalName hybridName, BotanicalName parentName, HybridRelationshipType type, String ruleConsidered) {
+ this(parentName, hybridName, type, null, null, ruleConsidered);
+ }
+
+ /**
+ * Constructor that adds immediately a relationship instance to both
+ * Creates a relationship between 2 names and adds this relationship object to the respective name relation sets
+ * @param toName
+ * @param fromName
+ * @param type
+ * @param citation
+ * @param citationMicroReference
+ * @param ruleConsidered
+ */
+ protected HybridRelationship(BotanicalName hybridName, BotanicalName parentName, HybridRelationshipType type, ReferenceBase citation, String citationMicroReference, String ruleConsidered) {
+ super(parentName, hybridName, type, citation, citationMicroReference);
+ this.setRuleConsidered(ruleConsidered);
+ }
+
public BotanicalName getParentName(){
- return this.parentName;
+ return super.getRelatedFrom();
}
public void setParentName(BotanicalName parentName){
- this.parentName = parentName;
+ super.setRelatedFrom(parentName);
}
- @ManyToOne
- @Cascade({CascadeType.SAVE_UPDATE})
public BotanicalName getHybridName(){
- return this.hybridName;
+ return super.getRelatedTo();
}
public void setHybridName(BotanicalName hybridName){
- this.hybridName = hybridName;
+ super.setRelatedTo(hybridName);
}
public String getRuleConsidered(){
package eu.etaxonomy.cdm.model.name;
-
-import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
-import eu.etaxonomy.cdm.model.taxon.Synonym;
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-
+import eu.etaxonomy.cdm.model.common.RelationshipBase;
+import eu.etaxonomy.cdm.model.reference.ReferenceBase;
import org.apache.log4j.Logger;
-import org.hibernate.annotations.Cascade;
-import org.hibernate.annotations.CascadeType;
-
-import java.util.*;
import javax.persistence.*;
/**
* @created 08-Nov-2007 13:06:37
*/
@Entity
-public class NameRelationship extends ReferencedEntityBase {
+public class NameRelationship extends RelationshipBase<TaxonNameBase, TaxonNameBase, NameRelationshipType> {
static Logger logger = Logger.getLogger(NameRelationship.class);
//The nomenclatural code rule considered. The article/note/recommendation in the code in question that is commented on in
//the note property.
private String ruleConsidered;
- private TaxonNameBase fromName;
private NameRelationshipType type;
- private TaxonNameBase toName;
+ //for hibernate, don't use
+ @Deprecated
private NameRelationship(){
super();
}
-
+
/**
* creates a relationship between 2 names and adds this relationship object to the respective name relation sets
* @param ruleConsidered
*/
protected NameRelationship(TaxonNameBase toName, TaxonNameBase fromName, NameRelationshipType type, String ruleConsidered) {
- super();
- setFromName(fromName);
- setToName(toName);
- setType(type);
- setRuleConsidered(ruleConsidered);
- fromName.addNameRelationship(this);
- toName.addNameRelationship(this);
+ this(toName, fromName, type, null, null, ruleConsidered);
}
- @ManyToOne
- @Cascade({CascadeType.SAVE_UPDATE})
+ /**
+ * Constructor that adds immediately a relationship instance to both
+ * Creates a relationship between 2 names and adds this relationship object to the respective name relation sets
+ * @param toName
+ * @param fromName
+ * @param type
+ * @param citation
+ * @param citationMicroReference
+ * @param ruleConsidered
+ */
+ protected NameRelationship(TaxonNameBase toName, TaxonNameBase fromName, NameRelationshipType type, ReferenceBase citation, String citationMicroReference, String ruleConsidered) {
+ super(fromName, toName, type, citation, citationMicroReference);
+ this.setRuleConsidered(ruleConsidered);
+ }
+
+ @Transient
public TaxonNameBase getFromName(){
- return this.fromName;
+ return super.getRelatedFrom();
}
private void setFromName(TaxonNameBase fromName){
- this.fromName = fromName;
- }
-
- @ManyToOne
- public NameRelationshipType getType(){
- return this.type;
- }
- private void setType(NameRelationshipType type){
- this.type = type;
+ super.setRelatedFrom(fromName);
}
- @ManyToOne
- @Cascade({CascadeType.SAVE_UPDATE})
+ @Transient
public TaxonNameBase getToName(){
- return this.toName;
+ return super.getRelatedTo();
}
private void setToName(TaxonNameBase toName){
- this.toName = toName;
+ super.setRelatedTo(toName);
}
public String getRuleConsidered(){
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
import eu.etaxonomy.cdm.model.common.IParsable;
+import eu.etaxonomy.cdm.model.common.IRelated;
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
import eu.etaxonomy.cdm.model.common.IReferencedEntity;
+import eu.etaxonomy.cdm.model.common.RelationshipBase;
import org.apache.log4j.Logger;
*/
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
-public abstract class TaxonNameBase<T extends TaxonNameBase> extends IdentifiableEntity<TaxonNameBase> implements IReferencedEntity, IParsable {
+public abstract class TaxonNameBase<T extends TaxonNameBase> extends IdentifiableEntity<TaxonNameBase> implements IReferencedEntity, IParsable, IRelated<NameRelationship> {
static Logger logger = Logger.getLogger(TaxonNameBase.class);
//The scientific name without author strings and year
private String nameCache;
protected INameCacheStrategy<T> cacheStrategy;
static Method methodTaxonBaseSetName;
-
-// /**
-// * Returns a TaxonNameBase instance
-// * @param fullName
-// */
-// abstract public static TaxonNameBase PARSED_NAME(String fullName);
-
// ************* CONSTRUCTORS *************/
/**
* Class constructor: creates a new empty taxon name instance.
}
+ public void addRelationship(NameRelationship relation) {
+ addNameRelationship(relation);
+ }
+
+
/**
* Returns the set of all {@link NameRelationship name relationships}
* in which this taxon name is involved as a source.
public HomotypicalGroup getHomotypicalGroup() {
return homotypicalGroup;
}
- public void setHomotypicalGroup(HomotypicalGroup newHomotypicalGroup) {
- if(this.homotypicalGroup == newHomotypicalGroup) return;
- if (homotypicalGroup != null) {
- homotypicalGroup.typifiedNames.remove(this);
- }
- if (newHomotypicalGroup!= null) {
- //hack for avoiding org.hibernate.LazyInitializationException: illegal access to loading collection
- if (newHomotypicalGroup.typifiedNames instanceof PersistentSet){
- //
- }else{
- newHomotypicalGroup.typifiedNames.add(this);
- }
- }
+ @Deprecated //only for bidirectional and persistence use
+ protected void setHomotypicalGroup(HomotypicalGroup newHomotypicalGroup) {
this.homotypicalGroup = newHomotypicalGroup;
}
return getRank().isInfraSpecific();
}
+
@Transient
abstract public NomenclaturalCode getNomeclaturalCode();
+
+ @Override
+ public String generateTitle() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
\ No newline at end of file
import org.apache.log4j.Logger;
-import java.util.*;
import javax.persistence.*;
/**
* @created 08-Nov-2007 13:07:02
*/
@Entity
-public class ViralName extends TaxonNameBase {
+public class ViralName extends TaxonNameBase<ViralName> {
static Logger logger = Logger.getLogger(ViralName.class);
//The accepted acronym for the Virus, e.g. PCV for Peanut Clump Virus
public NomenclaturalCode getNomeclaturalCode(){
return NomenclaturalCode.VIRAL();
}
+
}
\ No newline at end of file
public SynonymRelationship addHeterotypicSynonymName(TaxonNameBase synonymName, HomotypicalGroup homotypicalGroup){
Synonym synonym = Synonym.NewInstance(synonymName, this.getSec());
if (homotypicalGroup != null){
- synonymName.setHomotypicalGroup(homotypicalGroup);
+ homotypicalGroup.addTypifiedName(synonymName);
}
return addSynonym(synonym, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
}
public SynonymRelationship addHomotypicSynonymName(TaxonNameBase synonymName){
Synonym synonym = Synonym.NewInstance(synonymName, this.getSec());
if (this.getName() != null){
- synonymName.setHomotypicalGroup(this.getName().getHomotypicalGroup());
+ this.getName().getHomotypicalGroup().addTypifiedName(synonymName);
}
SynonymRelationship synRel = addSynonym(synonym, SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF());
return synRel;