Implement FormatKeys for all currently used occurrences parameters
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 1 Dec 2015 13:30:10 +0000 (14:30 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 2 Dec 2015 10:08:50 +0000 (11:08 +0100)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/ICdmFormatter.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/DerivedUnitFormatter.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/FieldUnitFormatter.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/IdentifiableEntityFormatter.java [new file with mode: 0644]
cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/MediaSpecimenFormatter.java [new file with mode: 0644]
cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/SequenceFormatter.java [new file with mode: 0644]
cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/SingleReadFormatter.java [new file with mode: 0644]
cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/SpecimenOrObservationBaseFormatter.java [new file with mode: 0644]

index a51c3d28fdc7a0457079c525b28221e462873fcd..60e3d2b33aa2064a487d00f92f84fdf4413fb756 100644 (file)
@@ -24,9 +24,33 @@ public interface ICdmFormatter {
         OPEN_BRACKET,
         CLOSE_BRACKET,
         SPACE,
-        /*occurrences*/
-        LOCALITY_TEXT,
-        ACCESSION_NUMBER
+        /*identifiable entity*/
+        SAMPLE_DESIGNATION,
+        /*specimenOrObservationBase*/
+        RECORD_BASIS,
+        KIND_OF_UNIT,
+        /*field unit*/
+        FIELD_NUMBER,
+        /*gathering event*/
+        GATHERING_COUNTRY,
+        GATHERING_LOCALITY_TEXT,
+        GATHERING_DATE,
+        GATHERING_COLLECTOR,
+        /*derived unit*/
+        COLLECTION_CODE,
+        COLLECTION_NAME,
+        MOST_SIGNIFICANT_IDENTIFIER,
+        ACCESSION_NUMBER,
+        BARCODE,
+        CATALOG_NUMBER,
+        /*media specimen*/
+        MEDIA_TITLE,
+        MEDIA_ARTIST,
+        /*sequence*/
+        SEQUENCE_DNA_MARKER,
+        /*single read*/
+        SINGLE_READ_PRIMER,
+        AMPLIFICATION_LABEL,
     }
 
     public String format(Object object, FormatKey... formatKeys);
index 17fc89f096fc6adb1955b0b321892defc97ac574..eec79b2747cb93b3d964769852d0e9aefe572d89 100644 (file)
@@ -17,7 +17,7 @@ import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
  * @date Nov 30, 2015
  *
  */
-public class DerivedUnitFormatter extends AbstractCdmFormatter{
+public class DerivedUnitFormatter extends SpecimenOrObservationBaseFormatter{
 
     public DerivedUnitFormatter(Object object, FormatKey[] formatKeys) {
         super(object, formatKeys);
@@ -32,6 +32,25 @@ public class DerivedUnitFormatter extends AbstractCdmFormatter{
             case ACCESSION_NUMBER:
                 formatKeyMap.put(FormatKey.ACCESSION_NUMBER, derivedUnit.getAccessionNumber());
                 break;
+            case BARCODE:
+                formatKeyMap.put(FormatKey.BARCODE, derivedUnit.getBarcode());
+                break;
+            case CATALOG_NUMBER:
+                formatKeyMap.put(FormatKey.CATALOG_NUMBER, derivedUnit.getCatalogNumber());
+                break;
+            case MOST_SIGNIFICANT_IDENTIFIER:
+                formatKeyMap.put(FormatKey.MOST_SIGNIFICANT_IDENTIFIER, derivedUnit.getMostSignificantIdentifier());
+                break;
+            case COLLECTION_CODE:
+                if(derivedUnit.getCollection()!=null){
+                    formatKeyMap.put(FormatKey.COLLECTION_CODE, derivedUnit.getCollection().getCode());
+                }
+                break;
+            case COLLECTION_NAME:
+                if(derivedUnit.getCollection()!=null){
+                    formatKeyMap.put(FormatKey.COLLECTION_NAME, derivedUnit.getCollection().getName());
+                }
+                break;
 
             default:
                 break;
index d23e7d2d56c25d85a4d4b6f85e8401387b4fb2b3..7bef4dd71704f4b2703fa53429640db35f628a1b 100644 (file)
@@ -16,7 +16,7 @@ import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
  * @date Nov 30, 2015
  *
  */
-public class FieldUnitFormatter extends AbstractCdmFormatter {
+public class FieldUnitFormatter extends SpecimenOrObservationBaseFormatter {
 
     public FieldUnitFormatter(Object object, FormatKey[] formatKeys) {
         super(object, formatKeys);
@@ -27,8 +27,12 @@ public class FieldUnitFormatter extends AbstractCdmFormatter {
         super.initFormatKeys(object);
         FieldUnit fieldUnit = (FieldUnit)object;
         if(fieldUnit.getGatheringEvent()!=null){
-            formatKeyMap.put(FormatKey.LOCALITY_TEXT, fieldUnit.getGatheringEvent().getLocality().getText());
+            formatKeyMap.put(FormatKey.GATHERING_LOCALITY_TEXT, fieldUnit.getGatheringEvent().getLocality().getText());
+            formatKeyMap.put(FormatKey.GATHERING_COLLECTOR, fieldUnit.getGatheringEvent().getCollector().toString());
+            formatKeyMap.put(FormatKey.GATHERING_COUNTRY, fieldUnit.getGatheringEvent().getCountry().getLabel());
+            formatKeyMap.put(FormatKey.GATHERING_DATE, fieldUnit.getGatheringEvent().getGatheringDate().toString());
         }
+        formatKeyMap.put(FormatKey.FIELD_NUMBER, fieldUnit.getFieldNumber());
     }
 
 }
diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/IdentifiableEntityFormatter.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/IdentifiableEntityFormatter.java
new file mode 100644 (file)
index 0000000..134c8f3
--- /dev/null
@@ -0,0 +1,41 @@
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.format.occurrences;
+
+
+/**
+ * @author pplitzner
+ * @date Nov 30, 2015
+ *
+ */
+public class IdentifiableEntityFormatter extends AbstractCdmFormatter {
+
+    public IdentifiableEntityFormatter(Object object, FormatKey[] formatKeys) {
+        super(object, formatKeys);
+    }
+
+    @Override
+    protected void initFormatKeys(Object object, FormatKey... formatKeys) {
+        super.initFormatKeys(object);
+//        IdentifiableEntity identifiableEntity = (IdentifiableEntity)object;
+//        List<Identifier> identifiers = identifiableEntity.getIdentifiers();
+//        String identifierString = null;
+//        for (Identifier identifier : identifiers) {
+//            if(identifier.getType()!=null && identifier.getType().equals(DerivateLabelProvider.getSampleDesignationTerm())){
+//                //first sample designation is the current
+//                identifierString = identifier.toString();
+//            }
+//        }
+//        if(identifierString!=null){
+//            formatKeyMap.put(FormatKey.FIELD_NUMBER, identifierString);
+//        }
+    }
+
+}
diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/MediaSpecimenFormatter.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/MediaSpecimenFormatter.java
new file mode 100644 (file)
index 0000000..06a1d20
--- /dev/null
@@ -0,0 +1,41 @@
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.format.occurrences;
+
+import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
+
+/**
+ * @author pplitzner
+ * @date Nov 30, 2015
+ *
+ */
+public class MediaSpecimenFormatter extends DerivedUnitFormatter {
+
+    public MediaSpecimenFormatter(Object object, FormatKey[] formatKeys) {
+        super(object, formatKeys);
+    }
+
+    @Override
+    protected void initFormatKeys(Object object, FormatKey... formatKeys) {
+        super.initFormatKeys(object);
+        MediaSpecimen mediaSpecimen = (MediaSpecimen)object;
+        Media media = mediaSpecimen.getMediaSpecimen();
+        if(media!=null){
+            if(media.getArtist()!=null){
+                formatKeyMap.put(FormatKey.MEDIA_ARTIST, media.getArtist().toString());
+            }
+            if(media.getTitle()!=null){
+                formatKeyMap.put(FormatKey.MEDIA_TITLE, media.getTitle().getText());
+            }
+        }
+    }
+
+}
diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/SequenceFormatter.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/SequenceFormatter.java
new file mode 100644 (file)
index 0000000..4235d3b
--- /dev/null
@@ -0,0 +1,34 @@
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.format.occurrences;
+
+import eu.etaxonomy.cdm.model.molecular.Sequence;
+
+/**
+ * @author pplitzner
+ * @date Nov 30, 2015
+ *
+ */
+public class SequenceFormatter extends AbstractCdmFormatter {
+
+    public SequenceFormatter(Object object, FormatKey[] formatKeys) {
+        super(object, formatKeys);
+    }
+
+    @Override
+    protected void initFormatKeys(Object object, FormatKey... formatKeys) {
+        super.initFormatKeys(object);
+        Sequence sequence = (Sequence)object;
+        if(sequence.getDnaMarker()!=null){
+            formatKeyMap.put(FormatKey.SEQUENCE_DNA_MARKER, sequence.getDnaMarker().getLabel());
+        }
+    }
+
+}
diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/SingleReadFormatter.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/SingleReadFormatter.java
new file mode 100644 (file)
index 0000000..9a60bdf
--- /dev/null
@@ -0,0 +1,38 @@
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.format.occurrences;
+
+import eu.etaxonomy.cdm.model.molecular.SingleRead;
+
+/**
+ * @author pplitzner
+ * @date Nov 30, 2015
+ *
+ */
+public class SingleReadFormatter extends AbstractCdmFormatter {
+
+    public SingleReadFormatter(Object object, FormatKey[] formatKeys) {
+        super(object, formatKeys);
+    }
+
+    @Override
+    protected void initFormatKeys(Object object, FormatKey... formatKeys) {
+        super.initFormatKeys(object);
+        SingleRead singleRead = (SingleRead)object;
+        if(singleRead.getPrimer()!=null){
+            formatKeyMap.put(FormatKey.SINGLE_READ_PRIMER, singleRead.getPrimer().getLabel());
+        }
+        if(singleRead.getAmplificationResult()!=null &&
+                singleRead.getAmplificationResult().getAmplification()!=null){
+            formatKeyMap.put(FormatKey.AMPLIFICATION_LABEL, singleRead.getAmplificationResult().getAmplification().getLabelCache());
+        }
+    }
+
+}
diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/SpecimenOrObservationBaseFormatter.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/occurrences/SpecimenOrObservationBaseFormatter.java
new file mode 100644 (file)
index 0000000..d1409ef
--- /dev/null
@@ -0,0 +1,33 @@
+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.format.occurrences;
+
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+
+/**
+ * @author pplitzner
+ * @date Nov 30, 2015
+ *
+ */
+public class SpecimenOrObservationBaseFormatter extends IdentifiableEntityFormatter {
+
+    public SpecimenOrObservationBaseFormatter(Object object, FormatKey[] formatKeys) {
+        super(object, formatKeys);
+    }
+
+    @Override
+    protected void initFormatKeys(Object object, FormatKey... formatKeys) {
+        super.initFormatKeys(object);
+        SpecimenOrObservationBase specimenOrObservationBase = (SpecimenOrObservationBase)object;
+        formatKeyMap.put(FormatKey.RECORD_BASIS, specimenOrObservationBase.getRecordBasis().toString());
+        formatKeyMap.put(FormatKey.KIND_OF_UNIT, specimenOrObservationBase.getKindOfUnit().toString());
+    }
+
+}