commit bfda4dd3ceed23c103826de8cf93ae447e625f2b
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Mon Jan 15 07:19:04 2018 +0100

    ref #7095 Implement specimen generator to test for huge data sets

diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/SpecimenGenerator.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/SpecimenGenerator.java
new file mode 100644
index 000000000..a9fd92f7d
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/SpecimenGenerator.java
@@ -0,0 +1,103 @@
+/**
+* Copyright (C) 2018 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.taxeditor.editor.workingSet.matrix;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+
+import eu.etaxonomy.cdm.api.service.ITermService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.description.CategoricalData;
+import eu.etaxonomy.cdm.model.description.Character;
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.FeatureNode;
+import eu.etaxonomy.cdm.model.description.QuantitativeData;
+import eu.etaxonomy.cdm.model.description.SpecimenDescription;
+import eu.etaxonomy.cdm.model.description.State;
+import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author pplitzner
+ * @since Jan 11, 2018
+ *
+ */
+public class SpecimenGenerator {
+
+    private static final int SPECIMEN_COUNT = 1000;
+
+    public Collection<SpecimenOrObservationBase> generate(){
+        Collection<SpecimenOrObservationBase> specimens = new HashSet<>();
+        List<DescriptionElementBase> descriptionElements = new ArrayList<>();
+
+        descriptionElements.add(generateQuantitativeData("leaf", "length"));
+        descriptionElements.add(generateCategoricalData("leaf", "color"));
+
+        for(int i=0;i<SPECIMEN_COUNT;i++){
+            specimens.add(generateSpecimen(descriptionElements));
+        }
+        return specimens;
+    }
+
+    private SpecimenOrObservationBase generateSpecimen(List<DescriptionElementBase> descriptionElements){
+        DerivedUnit specimen = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
+        SpecimenDescription description = SpecimenDescription.NewInstance(specimen);
+        descriptionElements.forEach(descriptionElement->{
+            initQuantitativeData(descriptionElement);
+            description.addElement(descriptionElement);
+        });
+        specimen.setAccessionNumber("GEN");
+        return specimen;
+    }
+
+    private QuantitativeData generateQuantitativeData(String structure, String property){
+//        Character character = Character.NewInstance(generateFeatureNode(structure), generateFeatureNode(property));
+        Character character = (Character) CdmStore.getService(ITermService.class).load(UUID.fromString("4e3b8ff8-87fc-4919-b390-fb13a22540ab"));
+        QuantitativeData data = QuantitativeData.NewInstance(character);
+        return data;
+    }
+
+    private CategoricalData generateCategoricalData(String structure, String property){
+//        Character character = Character.NewInstance(generateFeatureNode(structure), generateFeatureNode(property));
+        Character character = (Character) CdmStore.getService(ITermService.class).load(UUID.fromString("43e3a556-5619-4d20-99d8-aaccab84a914"));
+        CategoricalData data = CategoricalData.NewInstance(character);
+        return data;
+    }
+
+    private void initQuantitativeData(DescriptionElementBase descriptionElement){
+        if(descriptionElement.isInstanceOf(QuantitativeData.class)){
+            QuantitativeData data = HibernateProxyHelper.deproxy(descriptionElement, QuantitativeData.class);
+            Random random = new Random();
+            data.setMinimum(random.nextFloat()*10, null);
+            data.setMaximum(random.nextFloat()*10, null);
+        }
+        else if(descriptionElement.isInstanceOf(CategoricalData.class)){
+            CategoricalData data = HibernateProxyHelper.deproxy(descriptionElement, CategoricalData.class);
+            Random random = new Random();
+            String nextInt = "State: "+random.nextInt();
+
+            State state = State.NewInstance(nextInt, nextInt, nextInt);
+            data.addStateData(state);
+        }
+    }
+
+    private FeatureNode generateFeatureNode(String label){
+        Feature feature = Feature.NewInstance(label, label, label);
+        FeatureNode featureNode = FeatureNode.NewInstance(feature);
+        return featureNode;
+    }
+
+}
