(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / BotanicalName.java
index 0d76df7e02d1d81e2bbd50282d353e91b775ed48..7dedb4f25c71a0186ffcaab9901c6d2b70b52865 100644 (file)
@@ -15,12 +15,15 @@ import org.hibernate.annotations.Cascade;
 import org.hibernate.annotations.CascadeType;
 
 import eu.etaxonomy.cdm.model.agent.Agent;
+import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor;
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
-import eu.etaxonomy.cdm.strategy.BotanicNameCacheStrategy;
-import eu.etaxonomy.cdm.strategy.ZooNameCacheStrategy;
+import eu.etaxonomy.cdm.strategy.cache.BotanicNameDefaultCacheStrategy;
+import eu.etaxonomy.cdm.strategy.parser.TaxonNameParserBotanicalNameImpl;
 
 import java.util.*;
 
+import javax.naming.NameParser;
 import javax.persistence.*;
 
 /**
@@ -42,18 +45,82 @@ public class BotanicalName extends NonViralName {
        private boolean isAnamorphic;
        private Set<HybridRelationship> hybridRelationships = new HashSet();
 
+       /**
+        * @param rank
+        * @return
+        */
+       public static BotanicalName NewInstance(Rank 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 TaxonNameParserBotanicalNameImpl();
+               }
+               return (BotanicalName)nameParser.parseFullName(fullNameString, rank);
+       }
+       
+       /**
+        * Returns a parsed Name
+        * @param fullName
+        * @return
+        */
+       public static BotanicalName PARSED_REFERENCE(String fullNameAndReferenceString){
+               return PARSED_REFERENCE(fullNameAndReferenceString, Rank.GENUS());
+       }
+       
+       /**
+        * Returns a parsed Name
+        * @param fullName
+        * @return
+        */
+       public static BotanicalName PARSED_REFERENCE(String fullNameAndReferenceString, Rank rank){
+               if (nameParser == null){
+                       nameParser = new TaxonNameParserBotanicalNameImpl();
+               }
+               return (BotanicalName)nameParser.parseFullReference(fullNameAndReferenceString, rank);
+       }
+       
        //needed by hibernate
        protected BotanicalName(){
                super();
-               this.cacheStrategy = BotanicNameCacheStrategy.NewInstance();
+               this.cacheStrategy = BotanicNameDefaultCacheStrategy.NewInstance();
        }
-       public BotanicalName(Rank rank) {
-               super(rank);
-               this.cacheStrategy = BotanicNameCacheStrategy.NewInstance();
+       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);
-               this.cacheStrategy = BotanicNameCacheStrategy.NewInstance();
+       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();
        }