fix #8480 Use DescriptionTypes for matrix descriptions
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 19 Aug 2019 14:13:50 +0000 (16:13 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 19 Aug 2019 14:13:50 +0000 (16:13 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/MatrixRowComparator.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/MatrixUtility.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/handler/CreateDefaultTaxonDescriptionHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/handler/CreateLiteratureTaxonDescriptionHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/handler/CreateTaxonDescriptionHandler.java

index 5478942932ffa92a4d50bd3e918a534670bc33a2..7cb400a6ab44ffd84d0cba0cebbe8675799dea02 100644 (file)
@@ -12,8 +12,8 @@ import java.util.Comparator;
 
 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
-import eu.etaxonomy.cdm.model.common.MarkerType;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.description.DescriptionType;
 import eu.etaxonomy.cdm.model.description.SpecimenDescription;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
@@ -100,10 +100,10 @@ public class MatrixRowComparator implements Comparator<Object>{
                     //description2 has to also be a TaxonDescription
                     TaxonDescription taxonDescription1 = (TaxonDescription)description1;
                     TaxonDescription taxonDescription2 = (TaxonDescription)description2;
-                    boolean isComputed1 = taxonDescription1.getMarkers().stream()
-                            .anyMatch(marker -> marker.getMarkerType().equals(MarkerType.COMPUTED()));
-                    boolean isComputed2 = taxonDescription2.getMarkers().stream()
-                            .anyMatch(marker -> marker.getMarkerType().equals(MarkerType.COMPUTED()));
+                    boolean isComputed1 = taxonDescription1.getTypes().stream()
+                            .anyMatch(type -> type.equals(DescriptionType.AGGREGATED));
+                    boolean isComputed2 = taxonDescription2.getTypes().stream()
+                            .anyMatch(type -> type.equals(DescriptionType.AGGREGATED));
                     if(isComputed1){
                         if(!isComputed2){
                             return -1;
index c876f7c4971301cb9c00b6a48e6b98c882c7169e..2c1c9f00f9803f9bf57b4113ad5c8c3b91db316a 100644 (file)
@@ -12,7 +12,7 @@ import java.util.Set;
 import java.util.stream.Collectors;
 
 import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
-import eu.etaxonomy.cdm.model.common.MarkerType;
+import eu.etaxonomy.cdm.model.description.DescriptionType;
 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
 import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.description.QuantitativeData;
@@ -78,20 +78,20 @@ public class MatrixUtility {
     }
 
     public static boolean isDefaultTaxonDescription(TaxonRowWrapperDTO taxonRowWrapperDTO){
-        return hasMarker(taxonRowWrapperDTO, MarkerType.TO_BE_CHECKED());
+        return hasType(taxonRowWrapperDTO, DescriptionType.DEFAULT_VALUES_FOR_AGGREGATION);
     }
 
     public static boolean isAggregatedTaxonDescription(TaxonRowWrapperDTO taxonRowWrapperDTO){
-        return hasMarker(taxonRowWrapperDTO, MarkerType.COMPUTED());
+        return hasType(taxonRowWrapperDTO, DescriptionType.AGGREGATED);
     }
 
     public static boolean isLiteratureTaxonDescription(TaxonRowWrapperDTO taxonRowWrapperDTO){
-        return hasMarker(taxonRowWrapperDTO, MarkerType.IN_BIBLIOGRAPHY());
+        return hasType(taxonRowWrapperDTO, DescriptionType.SECONDARY_DATA);
     }
 
-    private static boolean hasMarker(TaxonRowWrapperDTO taxonRowWrapperDTO, MarkerType markerType){
-        return taxonRowWrapperDTO.getDescription().getMarkers().stream()
-        .anyMatch(marker->marker.getMarkerType().equals(markerType));
+    private static boolean hasType(TaxonRowWrapperDTO taxonRowWrapperDTO, DescriptionType descriptionType){
+        return taxonRowWrapperDTO.getDescription().getTypes().stream()
+        .anyMatch(type->type.equals(descriptionType));
     }
 }
 
index 186db99dd658b65ac4963214e54d4fbe36abb7b8..124dfb101d66812dbeb14e65dbd3558517d35fc7 100644 (file)
@@ -16,7 +16,7 @@ import org.eclipse.e4.ui.services.IServiceConstants;
 import org.eclipse.jface.viewers.IStructuredSelection;
 
 import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
-import eu.etaxonomy.cdm.model.common.MarkerType;
+import eu.etaxonomy.cdm.model.description.DescriptionType;
 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
@@ -31,14 +31,8 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
 public class CreateDefaultTaxonDescriptionHandler extends CreateTaxonDescriptionHandler{
 
     @Override
-    protected boolean getMarkerFlag() {
-        return true;
-    }
-
-    @Override
-    protected MarkerType getMarkerType() {
-        //FIXME #7957 Use actual marker type when implemented
-        return MarkerType.TO_BE_CHECKED();
+    protected DescriptionType getDescriptionType() {
+        return DescriptionType.DEFAULT_VALUES_FOR_AGGREGATION;
     }
 
     @Override
@@ -52,7 +46,7 @@ public class CreateDefaultTaxonDescriptionHandler extends CreateTaxonDescription
             TaxonNodeDto taxonNodeDto = (TaxonNodeDto) selection.getFirstElement();
 
             TaxonDescription defaultTaxonDescription = CdmStore.getService(IDescriptiveDataSetService.class)
-                    .findTaxonDescriptionByMarkerType(descriptiveDataSet.getUuid(), taxonNodeDto.getUuid(), getMarkerType());
+                    .findTaxonDescriptionByDescriptionType(descriptiveDataSet.getUuid(), taxonNodeDto.getUuid(), getDescriptionType());
             canExecute = defaultTaxonDescription==null;
             menuItem.setVisible(canExecute);
         }
index 4daa92fe11c99354e99568754b19ec9026e7e0a9..350c29960184917ad3554a0f7826882729f29f8b 100644 (file)
@@ -8,7 +8,7 @@
 */
 package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.handler;
 
-import eu.etaxonomy.cdm.model.common.MarkerType;
+import eu.etaxonomy.cdm.model.description.DescriptionType;
 
 /**
  * @author pplitzner
@@ -18,12 +18,7 @@ import eu.etaxonomy.cdm.model.common.MarkerType;
 public class CreateLiteratureTaxonDescriptionHandler extends CreateTaxonDescriptionHandler{
 
     @Override
-    protected boolean getMarkerFlag() {
-        return true;
-    }
-
-    @Override
-    protected MarkerType getMarkerType() {
-        return MarkerType.IN_BIBLIOGRAPHY();
+    protected DescriptionType getDescriptionType() {
+        return DescriptionType.SECONDARY_DATA;
     }
 }
index 7f4a2eff1efcad235d2c277e52af4c7129e0ad19..d500e81911d08c45f76ee48d7c1f8ad4ff180e78 100644 (file)
@@ -20,7 +20,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 
 import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
 import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
-import eu.etaxonomy.cdm.model.common.MarkerType;
+import eu.etaxonomy.cdm.model.description.DescriptionType;
 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
 import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart;
@@ -43,15 +43,12 @@ public abstract class CreateTaxonDescriptionHandler {
         DescriptiveDataSet descriptiveDataSet = matrixPart.getDescriptiveDataSet();
         TaxonNodeDto node = (TaxonNodeDto) matrixPart.getSelection().getFirstElement();
         TaxonRowWrapperDTO taxonRowWrapperDTO = CdmStore.getService(IDescriptiveDataSetService.class)
-                .createTaxonDescription(descriptiveDataSet.getUuid(), node.getUuid(), getMarkerType(), getMarkerFlag());
+                .createTaxonDescription(descriptiveDataSet.getUuid(), node.getUuid(), getDescriptionType());
         matrixPart.getMatrix().getCdmEntitiySession().load(taxonRowWrapperDTO.getDescription(), true);
         matrixPart.getMatrix().getDescriptions().add(taxonRowWrapperDTO);
     }
 
-    protected abstract boolean getMarkerFlag();
-
-
-    protected abstract MarkerType getMarkerType();
+    protected abstract DescriptionType getDescriptionType();
 
     @CanExecute
     public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,