minor
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / common / ExtensionType.java
index ce4e44963520f8718be9d8ea7f7f1b24bcc7c8f9..3ad38b0ebd0bf99e6aa95a22527202908d1e0488 100644 (file)
@@ -11,6 +11,7 @@ package eu.etaxonomy.cdm.model.common;
 
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -21,8 +22,9 @@ import javax.xml.bind.annotation.XmlType;
 
 import org.apache.log4j.Logger;
 import org.hibernate.envers.Audited;
+import org.hibernate.search.annotations.Indexed;
 
-import eu.etaxonomy.cdm.model.location.TdwgArea;
+import eu.etaxonomy.cdm.model.description.Feature;
 
 /**
  * Extension types similar to dynamically defined attributes. These are not data
@@ -35,27 +37,69 @@ import eu.etaxonomy.cdm.model.location.TdwgArea;
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "ExtensionType")
 @Entity
+@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
 @Audited
 public class ExtensionType extends DefinedTermBase<ExtensionType> {
        private static final long serialVersionUID = -7761963794004133427L;
+       @SuppressWarnings("unused")
        private static final Logger logger = Logger.getLogger(ExtensionType.class);
 
        private static final UUID uuidXmlFragment = UUID.fromString("ea109c1c-e69b-4e6d-9079-1941b9ee2991");
        private static final UUID uuidRdfFragment = UUID.fromString("f3684e25-dcad-4c1e-a5d8-16cddf1c4f5b");
        private static final UUID uuidDoi = UUID.fromString("f079aacc-ab08-4cc4-90a0-6d3958fb0dbf");
-       private static final UUID uuid2ndNomRef = UUID.fromString("46a98bfa-f11a-47fe-a6c5-50c7e8289b3d");
+//     private static final UUID uuid2ndNomRef = UUID.fromString("46a98bfa-f11a-47fe-a6c5-50c7e8289b3d");
        private static final UUID uuid3rdHybridParent = UUID.fromString("5e552b24-5a2d-498d-a4f4-ccd8e5bc2bae");
        private static final UUID uuidAreaOfInterest = UUID.fromString("cefa478e-604f-4db4-8afc-25e06c28ec69");
        private static final UUID uuidNomStandard = UUID.fromString("4a6cbbe9-8d79-4d15-b316-2ff1adeff526");
        private static final UUID uuidAbbreviation = UUID.fromString("5837e34e-b0f5-4736-8083-ff5eaecd8c43");
-       
+       private static final UUID uuidOrder = UUID.fromString("ecb7770d-a295-49ee-a88f-e9e137a7cabb");
+       private static final UUID uuidInformalCategory = UUID.fromString("11bbc52f-a085-43d3-9f9b-cbe0d1eb9a91");
+       private static final UUID uuidUrl = UUID.fromString("d769fa9f-51ee-4e11-8152-b5ce72b7f413");
        
        protected static Map<UUID, ExtensionType> termMap = null;               
 
+       /** 
+        * Creates a new empty extension type instance.
+        * 
+        * @see #NewInstance(String, String, String)
+        */
+       public static ExtensionType NewInstance() {
+               return new ExtensionType();
+       }
+       
+       /** 
+        * Creates a new extension type instance with a description (in the {@link Language#DEFAULT() default language}),
+        * a label and a label abbreviation.
+        * 
+        * @param       term             the string (in the default language) describing the
+        *                                               new extension type to be created 
+        * @param       label            the string identifying the new extension type to be created
+        * @param       labelAbbrev  the string identifying (in abbreviated form) the
+        *                                               new extension type to be created
+        * @see                                  #readCsvLine(List, Language)
+        * @see                                  #NewInstance()
+        */
+       public static ExtensionType NewInstance(String term, String label, String labelAbbrev){
+               return new ExtensionType(term, label, labelAbbrev);
+       }
+       
+       //public only for Term Loader
+       @Deprecated
        public ExtensionType() {
-               super();
        }
-       public ExtensionType(String term, String label, String labelAbbrev) {
+       
+       /** 
+        * Class constructor: creates a new extension type instance with a description (in the {@link Language#DEFAULT() default language}),
+        * a label and a label abbreviation.
+        * 
+        * @param       term             the string (in the default language) describing the
+        *                                               new extension type to be created 
+        * @param       label            the string identifying the new extension type to be created
+        * @param       labelAbbrev  the string identifying (in abbreviated form) the
+        *                                               new extension type to be created
+        * @see                                  #ExtensionType()
+        */
+       protected ExtensionType(String term, String label, String labelAbbrev) {
                super(term, label, labelAbbrev);
        }
 
@@ -81,9 +125,9 @@ public class ExtensionType extends DefinedTermBase<ExtensionType> {
        }
 
 
-       public static final ExtensionType SECOND_NOM_REF(){
-               return getTermByUuid(uuid2ndNomRef);
-       }
+//     public static final ExtensionType SECOND_NOM_REF(){
+//             return getTermByUuid(uuid2ndNomRef);
+//     }
 
 
        public static final ExtensionType THIRD_HYBRID_PARENT(){
@@ -102,14 +146,24 @@ public class ExtensionType extends DefinedTermBase<ExtensionType> {
                return getTermByUuid(uuidAbbreviation);
        }
        
+       public static final ExtensionType ORDER(){
+               return getTermByUuid(uuidOrder);
+       }
        
+       public static final ExtensionType INFORMAL_CATEGORY(){
+               return getTermByUuid(uuidInformalCategory);
+       }
+
+       public static final ExtensionType URL(){
+               return getTermByUuid(uuidUrl);
+       }
        
        
        @Override
        protected void setDefaultTerms(TermVocabulary<ExtensionType> termVocabulary) {
                termMap = new HashMap<UUID, ExtensionType>();
                for (ExtensionType term : termVocabulary.getTerms()){
-                       termMap.put(term.getUuid(), (ExtensionType)term);
+                       termMap.put(term.getUuid(), term);
                }
        }