import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
-import eu.etaxonomy.cdm.model.agent.Agent;
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
+import eu.etaxonomy.cdm.model.common.RelationshipBase;
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
-import eu.etaxonomy.cdm.strategy.BotanicNameDefaultCacheStrategy;
-import eu.etaxonomy.cdm.strategy.TaxonNameParserBotanicalNameImpl;
+import eu.etaxonomy.cdm.strategy.cache.BotanicNameDefaultCacheStrategy;
+import eu.etaxonomy.cdm.strategy.parser.INonViralNameParser;
+import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
import java.util.*;
-
-import javax.naming.NameParser;
import javax.persistence.*;
/**
*/
@Entity
public class BotanicalName extends NonViralName {
- static Logger logger = Logger.getLogger(BotanicalName.class);
+ private static final Logger logger = Logger.getLogger(BotanicalName.class);
//if set: this name is a hybrid formula (a hybrid that does not have an own name) and no other hybrid flags may be set. A
//hybrid name may not have either an authorteam nor other name components.
private boolean isHybridFormula = false;
private boolean isAnamorphic;
private Set<HybridRelationship> hybridRelationships = new HashSet();
+ static private INonViralNameParser nameParser = new NonViralNameParserImpl();
+
+
/**
* @param rank
* @return
*/
public static BotanicalName NewInstance(Rank rank){
- return new BotanicalName(rank);
+ return new BotanicalName(rank, null);
+ }
+
+
+ /**
+ * @param rank
+ * @param homotypicalGroup
+ * @return
+ */
+ public static BotanicalName NewInstance(Rank rank, HomotypicalGroup homotypicalGroup){
+ return new BotanicalName(rank, homotypicalGroup);
+ }
+
+ public static BotanicalName NewInstance(Rank rank, String genusOrUninomial, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
+ return new BotanicalName(rank, genusOrUninomial, specificEpithet, infraSpecificEpithet, combinationAuthorTeam, nomenclaturalReference, nomenclMicroRef, homotypicalGroup);
+ }
+
+ /**
+ * Returns a parsed Name
+ * @param fullName
+ * @return
+ */
+ public static BotanicalName PARSED_NAME(String fullNameString){
+ return PARSED_NAME(fullNameString, Rank.GENUS());
+ }
+
+ /**
+ * Returns a parsed Name
+ * @param fullName
+ * @return
+ */
+ public static BotanicalName PARSED_NAME(String fullNameString, Rank rank){
+ if (nameParser == null){
+ nameParser = new NonViralNameParserImpl();
+ }
+ return (BotanicalName)nameParser.parseFullName(fullNameString, NomenclaturalCode.ICBN(), rank);
}
/**
* @param fullName
* @return
*/
- public static BotanicalName PARSED_NAME(String fullName){
- return PARSED_NAME(fullName, Rank.GENUS());
+ public static BotanicalName PARSED_REFERENCE(String fullNameAndReferenceString){
+ return PARSED_REFERENCE(fullNameAndReferenceString, Rank.GENUS());
}
/**
* @param fullName
* @return
*/
- public static BotanicalName PARSED_NAME(String fullName, Rank rank){
+ public static BotanicalName PARSED_REFERENCE(String fullNameAndReferenceString, Rank rank){
if (nameParser == null){
- nameParser = new TaxonNameParserBotanicalNameImpl();
+ nameParser = new NonViralNameParserImpl();
}
- return (BotanicalName)nameParser.parseFullName(fullName, rank);
+ return (BotanicalName)nameParser.parseFullReference(fullNameAndReferenceString, NomenclaturalCode.ICBN(), rank);
}
//needed by hibernate
super();
this.cacheStrategy = BotanicNameDefaultCacheStrategy.NewInstance();
}
- public BotanicalName(Rank rank) {
- super(rank);
+ protected BotanicalName(Rank rank, HomotypicalGroup homotypicalGroup) {
+ super(rank, homotypicalGroup);
this.cacheStrategy = BotanicNameDefaultCacheStrategy.NewInstance();
}
- public BotanicalName(Rank rank, String genusOrUninomial, String specificEpithet, String infraSpecificEpithet, Agent combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef) {
- super(rank, genusOrUninomial, specificEpithet, infraSpecificEpithet, combinationAuthorTeam, nomenclaturalReference, nomenclMicroRef);
+ protected BotanicalName(Rank rank, String genusOrUninomial, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
+ super(rank, genusOrUninomial, specificEpithet, infraSpecificEpithet, combinationAuthorTeam, nomenclaturalReference, nomenclMicroRef, homotypicalGroup);
this.cacheStrategy = BotanicNameDefaultCacheStrategy.NewInstance();
}
return hybridRelationships;
}
-
+ public void addRelationship(RelationshipBase relation) {
+ if (relation instanceof HybridRelationship){
+ addHybridRelationship((HybridRelationship)relation);
+ }else {
+ super.addRelationship(relation);
+ }
+ }
public boolean isHybridFormula(){
return this.isHybridFormula;
public void setAnamorphic(boolean isAnamorphic){
this.isAnamorphic = isAnamorphic;
}
+
+
+ @Transient
+ @Override
+ public NomenclaturalCode getNomeclaturalCode(){
+ return NomenclaturalCode.ICBN();
+
+ }
}
\ No newline at end of file