add country to gathering event
authorAndreas Müller <a.mueller@bgbm.org>
Mon, 20 Sep 2010 17:34:29 +0000 (17:34 +0000)
committerAndreas Müller <a.mueller@bgbm.org>
Mon, 20 Sep 2010 17:34:29 +0000 (17:34 +0000)
cdmlib-io/src/test/resources/dbscripts/001_cdm.ddl
cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/dataset.dtd
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/GatheringEvent.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/SchemaUpdater_3_0.java
cdmlib-persistence/src/test/resources/dbscripts/001_cdm.ddl
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/facade/DerivedUnitFacade.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/facade/DerivedUnitFacadeCacheStrategy.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/facade/DerivedUnitFacadeCacheStrategyTest.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/facade/DerivedUnitFacadeTest.java
cdmlib-services/src/test/resources/dbscripts/001_cdm.ddl

index cfc50f3fc9e0a4e90ef363a4e469974e3fc9f850..63856e946760f7ff02eadc02410b17dbb681a99c 100644 (file)
         exactlocation_longitude double,
         createdby_id integer,
         updatedby_id integer,
+        country_id integer,
         actor_id integer,
         exactlocation_referencesystem_id integer,
         locality_id integer,
         exactlocation_longitude double,
         createdby_id integer,
         updatedby_id integer,
+        country_id integer,
         actor_id integer,
         exactlocation_referencesystem_id integer,
         locality_id integer,
index e8090472b2bb61e156296666a54c7356d154e5ea..82a89b5467a8c772d10306e8d754588f1aef3704 100644 (file)
     EXACTLOCATION_LONGITUDE CDATA #IMPLIED
     CREATEDBY_ID CDATA #IMPLIED
     UPDATEDBY_ID CDATA #IMPLIED
+    COUNTRY_ID CDATA #IMPLIED
     ACTOR_ID CDATA #IMPLIED
     EXACTLOCATION_REFERENCESYSTEM_ID CDATA #IMPLIED
     LOCALITY_ID CDATA #IMPLIED
     EXACTLOCATION_LONGITUDE CDATA #IMPLIED
     CREATEDBY_ID CDATA #IMPLIED
     UPDATEDBY_ID CDATA #IMPLIED
+    COUNTRY_ID CDATA #IMPLIED
     ACTOR_ID CDATA #IMPLIED
     EXACTLOCATION_REFERENCESYSTEM_ID CDATA #IMPLIED
     LOCALITY_ID CDATA #IMPLIED
index c33b98c7675c45e3d227c89daf437b5130a0e816..2e09f50735a48feb86d4773c5e9f9ce69d8f36bd 100644 (file)
@@ -16,6 +16,7 @@ import java.util.Set;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
 import javax.persistence.OneToOne;
 import javax.persistence.Transient;
 import javax.validation.constraints.NotNull;
@@ -45,6 +46,8 @@ import eu.etaxonomy.cdm.model.common.LanguageString;
 import eu.etaxonomy.cdm.model.common.TimePeriod;
 import eu.etaxonomy.cdm.model.location.NamedArea;
 import eu.etaxonomy.cdm.model.location.Point;
+import eu.etaxonomy.cdm.model.reference.ReferenceBase;
+import eu.etaxonomy.cdm.strategy.cache.name.CacheUpdate;
 import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty;
 
 /**
@@ -56,6 +59,7 @@ import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty;
 @XmlType(name = "GatheringEvent", propOrder = {
     "locality",
     "exactLocation",
+    "country",
     "collectingAreas",
     "collectingMethod",
     "absoluteElevation",
@@ -80,12 +84,21 @@ public class GatheringEvent extends EventBase implements Cloneable{
        @XmlElement(name = "ExactLocation")
        private Point exactLocation;
        
+       
+       @XmlElement(name = "Country")
+       @XmlIDREF
+       @XmlSchemaType(name = "IDREF")
+       @ManyToOne(fetch = FetchType.LAZY)
+       @Cascade({CascadeType.SAVE_UPDATE})
+       private NamedArea country;
+       
     @XmlElementWrapper(name = "CollectingAreas")
        @XmlElement(name = "CollectingArea")
        @XmlIDREF
        @XmlSchemaType(name = "IDREF")
        @ManyToMany(fetch = FetchType.LAZY)
        @NotNull
+       // further collecting areas. Should not include country
        private Set<NamedArea> collectingAreas = new HashSet<NamedArea>();
        
        @XmlElement(name = "CollectingMethod")
@@ -135,7 +148,20 @@ public class GatheringEvent extends EventBase implements Cloneable{
                this.exactLocation = exactLocation;
        }
 
+       
+
+       public NamedArea getCountry() {
+               return country;
+       }
 
+       public void setCountry(NamedArea country) {
+               this.country = country;
+       }
+
+       /**
+        * Further collecting areas. Should not include #getCountry()
+        * @return
+        */
        public Set<NamedArea> getCollectingAreas(){
                if(collectingAreas == null) {
                        this.collectingAreas = new HashSet<NamedArea>();
@@ -144,6 +170,10 @@ public class GatheringEvent extends EventBase implements Cloneable{
        }
 
        
+        /**
+         * Further collecting areas. Should not include #getCountry()
+         * @param area
+        */
        public void addCollectingArea(NamedArea area){
                if (this.collectingAreas == null)
                        this.collectingAreas = getNewNamedAreaSet();
index cc37fb38b01e9a7a232c4c91fc0cab8ff1d5d65d..59265abc13054e407e3d16f4f26ab6f5073db483 100644 (file)
@@ -92,6 +92,10 @@ public class SchemaUpdater_3_0 extends SchemaUpdaterBase implements ISchemaUpdat
 //             TableNameChanger tableChanger = TableNameChanger.NewInstance(stepName, "TaxonomicTree", "Classification", INCLUDE_AUDIT);\r
 //             stepList.add(tableChanger);\r
                \r
+               //update sortindex on FeatureNode children\r
+               stepName = "Add country column to gathering event";\r
+               step = ColumnAdder.NewIntegerInstance(stepName, "GatheringEvent", "country_id", INCLUDE_AUDIT);\r
+               stepList.add(step);\r
                \r
                return stepList;\r
        }\r
index ab04323fdbff6387a43ac4d80514150eff8859f3..5ce5595b21d05af392d8a34fcf2a2142e54c6175 100644 (file)
         exactlocation_longitude double,
         createdby_id integer,
         updatedby_id integer,
+        country_id integer,
         actor_id integer,
         exactlocation_referencesystem_id integer,
         locality_id integer,
         exactlocation_longitude double,
         createdby_id integer,
         updatedby_id integer,
+        country_id integer,
         actor_id integer,
         exactlocation_referencesystem_id integer,
         locality_id integer,
index b0770f8ae925b6a99c2322cc9c5fd272de9c1ca9..78abb9f316f50df079955cd419baf09306611065 100644 (file)
@@ -25,7 +25,6 @@ import javax.persistence.Transient;
 \r
 \r
 import org.apache.log4j.Logger;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
 \r
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;\r
 import eu.etaxonomy.cdm.model.agent.AgentBase;\r
@@ -763,6 +762,16 @@ public class DerivedUnitFacade {
        \r
 // ****************** Gathering Event *********************************/\r
        \r
+       //country\r
+       public NamedArea getCountry(){\r
+               return  (hasGatheringEvent() ? getGatheringEvent(true).getCountry() : null);\r
+       }\r
+       \r
+       public void setCountry(NamedArea country){\r
+               getGatheringEvent(true).setCountry(country);\r
+       }\r
+       \r
+       \r
        //Collecting area\r
        public void addCollectingArea(NamedArea area) {\r
                getGatheringEvent(true).addCollectingArea(area);\r
index 959283ee007ef07244ba93e4fe2da9e0f7e6660a..6b794f4958d9da62acb6f7b61454a71178f77d09 100644 (file)
@@ -15,7 +15,10 @@ import org.apache.log4j.Logger;
 \r
 import eu.etaxonomy.cdm.common.CdmUtils;\r
 import eu.etaxonomy.cdm.model.agent.Institution;\r
+import eu.etaxonomy.cdm.model.common.Language;\r
+import eu.etaxonomy.cdm.model.common.Representation;\r
 import eu.etaxonomy.cdm.model.common.TimePeriod;\r
+import eu.etaxonomy.cdm.model.location.NamedArea;\r
 import eu.etaxonomy.cdm.model.occurrence.Collection;\r
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;\r
 import eu.etaxonomy.cdm.strategy.StrategyBase;\r
@@ -59,7 +62,13 @@ public class DerivedUnitFacadeCacheStrategy extends StrategyBase implements IIde
                try {\r
                        facade = DerivedUnitFacade.NewInstance(derivedUnit);\r
                        //country\r
-                       //TODO\r
+                       String strCountry = null;\r
+                       NamedArea country = facade.getCountry();\r
+                       Representation repCountry = country == null ? null : country.getRepresentation(Language.DEFAULT());\r
+                       //TODO currently the label is the 3 digit representation of the country and text is the full text.\r
+                       //this is against the common way of handling text, label and labelabbrev in defined terms\r
+                       strCountry = repCountry == null ? null: repCountry.getText();\r
+                       result = CdmUtils.concat(", ", result, strCountry);\r
                        \r
                        // FIXME hasGatheringEvent needed;\r
                        //locality\r
index 23d5b4589e8f6a4c8f7e5d4b7a899fabb3d37929..1199f336846082718c5b0ef96d34f749baf2f6af 100644 (file)
@@ -24,8 +24,10 @@ import eu.etaxonomy.cdm.model.common.LanguageString;
 import eu.etaxonomy.cdm.model.common.TimePeriod;\r
 import eu.etaxonomy.cdm.model.description.Sex;\r
 import eu.etaxonomy.cdm.model.description.Stage;\r
+import eu.etaxonomy.cdm.model.location.NamedArea;\r
 import eu.etaxonomy.cdm.model.location.Point;\r
 import eu.etaxonomy.cdm.model.location.ReferenceSystem;\r
+import eu.etaxonomy.cdm.model.location.WaterbodyOrCountry;\r
 import eu.etaxonomy.cdm.model.media.Media;\r
 import eu.etaxonomy.cdm.model.name.BotanicalName;\r
 import eu.etaxonomy.cdm.model.name.Rank;\r
@@ -70,7 +72,8 @@ public class DerivedUnitFacadeCacheStrategyTest {
        Stage lifeStage = Stage.NewInstance("A wonderful stage", "stage", "st");\r
        Sex sex = Sex.NewInstance("FemaleMale", "FM", "FM");\r
        LanguageString locality = LanguageString.NewInstance("Berlin-Dahlem, E side of Englerallee", Language.DEFAULT());\r
-\r
+       NamedArea country = WaterbodyOrCountry.GERMANY();\r
+       \r
        String accessionNumber = "8909756";\r
        String catalogNumber = "UU879873590";\r
        TaxonNameBase taxonName = BotanicalName.NewInstance(Rank.GENUS(), "Abies", null, null, null, null, null, null, null);\r
@@ -122,6 +125,7 @@ public class DerivedUnitFacadeCacheStrategyTest {
                \r
                gatheringEvent.setTimeperiod(gatheringPeriod);\r
                gatheringEvent.setLocality(locality);\r
+               gatheringEvent.setCountry(country);\r
                \r
                fieldObservation.setFieldNumber(fieldNumber);\r
                fieldObservation.setFieldNotes(fieldNotes);\r
@@ -161,7 +165,7 @@ public class DerivedUnitFacadeCacheStrategyTest {
         */\r
        @Test\r
        public void testGetTitleCache() {\r
-               String correctCache = "Berlin-Dahlem, E side of Englerallee, alt. 40 m, 10°34'1\"N, 12°18'E (WGS84), sand dunes, 05.05.2005 (B 8909756); flowers blue.";\r
+               String correctCache = "Germany, Berlin-Dahlem, E side of Englerallee, alt. 40 m, 10°34'1\"N, 12°18'E (WGS84), sand dunes, 05.05.2005 (B 8909756); flowers blue.";\r
                specimenFacade.setEcology(ecology);\r
                specimenFacade.setPlantDescription(plantDescription);\r
                collection.setCode("B");\r
index 847170e9f92b45866498947e03f83e2a37026f9c..64041596d3d94ac0b5a346e35d7502497b423524 100644 (file)
@@ -34,6 +34,7 @@ import eu.etaxonomy.cdm.model.location.NamedArea;
 import eu.etaxonomy.cdm.model.location.Point;\r
 import eu.etaxonomy.cdm.model.location.ReferenceSystem;\r
 import eu.etaxonomy.cdm.model.location.TdwgArea;\r
+import eu.etaxonomy.cdm.model.location.WaterbodyOrCountry;\r
 import eu.etaxonomy.cdm.model.media.Media;\r
 import eu.etaxonomy.cdm.model.name.BotanicalName;\r
 import eu.etaxonomy.cdm.model.name.Rank;\r
@@ -97,6 +98,8 @@ public class DerivedUnitFacadeTest {
        \r
        DerivedUnitFacade emptyFacade;\r
        \r
+       NamedArea country = WaterbodyOrCountry.GERMANY();\r
+       \r
        \r
 //****************************** SET UP *****************************************/\r
        \r
@@ -129,6 +132,7 @@ public class DerivedUnitFacadeTest {
                gatheringEvent.setDistanceToWaterSurface(distanceToSurface);\r
                gatheringEvent.setExactLocation(exactLocation);\r
                gatheringEvent.setDescription(gatheringEventDescription);\r
+               gatheringEvent.setCountry(country);\r
                \r
                gatheringEvent.setTimeperiod(gatheringPeriod);\r
                gatheringEvent.setLocality(locality);\r
@@ -223,6 +227,10 @@ public class DerivedUnitFacadeTest {
                }\r
        }\r
        \r
+       @Test\r
+       public void testGetSetCountry(){\r
+               \r
+       }\r
        \r
        \r
        /**\r
index bc55f2bb75bb5414a65d0073b89dd8192db292b4..123582f0c6b00f3c8ffd8c963144ef6d400ab613 100644 (file)
         exactlocation_longitude double,
         createdby_id integer,
         updatedby_id integer,
+        country_id integer,
         actor_id integer,
         exactlocation_referencesystem_id integer,
         locality_id integer,
         exactlocation_longitude double,
         createdby_id integer,
         updatedby_id integer,
+        country_id integer,
         actor_id integer,
         exactlocation_referencesystem_id integer,
         locality_id integer,