(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / location / NamedArea.java
index 2d5580a6d6782a546f82d47911e694b947989043..38b0cbd926dcf080619c8d824c6ef5fd24888830 100644 (file)
@@ -9,6 +9,9 @@
 
 package eu.etaxonomy.cdm.model.location;
 
+import eu.etaxonomy.cdm.model.common.ILoadableTerm;
+import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
 import eu.etaxonomy.cdm.model.common.TimePeriod;
 import eu.etaxonomy.cdm.model.common.OrderedTermBase;
 import eu.etaxonomy.cdm.model.media.Media;
@@ -105,7 +108,7 @@ public class NamedArea extends OrderedTermBase<NamedArea> {
        
        
        @ManyToOne
-       @Cascade({CascadeType.SAVE_UPDATE})
+       //@Cascade({CascadeType.SAVE_UPDATE})  //NamedAreaType is DefinedTerm -> no Cascade
        public NamedAreaType getType(){
                return this.type;
        }
@@ -114,7 +117,7 @@ public class NamedArea extends OrderedTermBase<NamedArea> {
        }
 
        @ManyToOne
-       @Cascade({CascadeType.SAVE_UPDATE})
+       //@Cascade({CascadeType.SAVE_UPDATE})  //NamedAreaLevel is DefinedTerm -> no Cascade
        public NamedAreaLevel getLevel(){
                return this.level;
        }
@@ -138,8 +141,10 @@ public class NamedArea extends OrderedTermBase<NamedArea> {
                this.shape = shape;
        }
 
-
-       @ManyToMany
+    @ManyToMany
+    @JoinTable(
+        name="DefinedTermBase_WaterbodyOrCountry"
+    )
        @Cascade({CascadeType.SAVE_UPDATE})
        public Set<WaterbodyOrCountry> getWaterbodiesOrCountries() {
                return waterbodiesOrCountries;
@@ -163,5 +168,31 @@ public class NamedArea extends OrderedTermBase<NamedArea> {
        public void setPointApproximation(Point pointApproximation) {
                this.pointApproximation = pointApproximation;
        }
+       
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#readCsvLine(java.util.List)
+        */
+       @Override
+       public ILoadableTerm readCsvLine(List csvLine) {
+               Language lang = Language.DEFAULT();
+               super.readCsvLine(csvLine, lang);
+               String abbreviatedLabel = (String)csvLine.get(4);
+               this.getRepresentation(lang).setAbbreviatedLabel(abbreviatedLabel);
+               return this;
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.model.common.OrderedTermBase#setVocabulary(eu.etaxonomy.cdm.model.common.TermVocabulary)
+        */
+       @Override
+       public void setVocabulary(TermVocabulary newVocabulary) {
+               super.setVocabulary(newVocabulary);
+               if (newVocabulary.equals(TermVocabulary.TDWG())){
+                       TdwgArea.addTdwgArea(this);
+               }
+       }
 
+       
+       
 }
\ No newline at end of file