Project

General

Profile

Download (3.4 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.editor.workingSet.matrix;
10

    
11
import java.util.ArrayList;
12
import java.util.Collections;
13
import java.util.List;
14

    
15
import eu.etaxonomy.cdm.model.description.CategoricalData;
16
import eu.etaxonomy.cdm.model.description.Feature;
17
import eu.etaxonomy.cdm.model.description.FeatureTree;
18
import eu.etaxonomy.cdm.model.description.QuantitativeData;
19
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
20
import eu.etaxonomy.cdm.model.description.State;
21
import eu.etaxonomy.cdm.model.description.WorkingSet;
22
import eu.etaxonomy.cdm.model.name.Rank;
23
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
24
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
25

    
26
/**
27
 * @author pplitzner
28
 * @since Nov 26, 2017
29
 *
30
 */
31
public class DataSource {
32

    
33
    private static final Feature LEAF_COLOR_FEATURE = Feature.NewInstance("color of the leaf", "leaf color", "leaf color");
34
    private static final Feature LEAF_LENGTH_FEATURE = Feature.NewInstance("length of the leaf", "Leaf length", "leaf length");
35

    
36
    public static WorkingSet getWorkingSet(){
37
        FeatureTree tree = FeatureTree.NewInstance(getFeatures());
38

    
39
        WorkingSet workingSet = WorkingSet.NewInstance();
40
        workingSet.setDescriptiveSystem(tree);
41
        workingSet.setMaxRank(Rank.GENUS());
42
        workingSet.setMinRank(Rank.SUBSPECIES());
43
        getDescriptions().forEach(description -> workingSet.addDescription(description));
44
        workingSet.setLabel("PP-Wset");
45
        return workingSet;
46

    
47
    }
48

    
49
    public static List<SpecimenDescription> getDescriptions(){
50
        List<SpecimenDescription> descriptions = new ArrayList<>();
51

    
52
        SpecimenDescription description = createDescription(0.3f, 2.4f, "blue");
53
        DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
54
        derivedUnit.setAccessionNumber("B 10 35489");
55
        description.setDescribedSpecimenOrObservation(derivedUnit);
56

    
57
        SpecimenDescription description2 = createDescription(1.6f, 6.4f, "red");
58
        DerivedUnit derivedUnit2 = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
59
        derivedUnit2.setAccessionNumber("B 10 44556");
60
        description2.setDescribedSpecimenOrObservation(derivedUnit2);
61

    
62
        descriptions.add(description);
63
        descriptions.add(description2);
64
        return descriptions;
65
    }
66

    
67
    private static List<Feature> getFeatures(){
68
        List<Feature> features = new ArrayList<>();
69
        features.add(LEAF_LENGTH_FEATURE);
70
        features.add(LEAF_COLOR_FEATURE);
71

    
72
        return features;
73
    }
74

    
75
    private static SpecimenDescription createDescription(Float min, Float max, String colorLabel) {
76
        SpecimenDescription desc = SpecimenDescription.NewInstance();
77

    
78
        QuantitativeData length = QuantitativeData.NewInstance(LEAF_LENGTH_FEATURE);
79
        length.setMinimum(min, Collections.emptySet());
80
        length.setMaximum(max, Collections.emptySet());
81
        desc.addElement(length);
82

    
83
        CategoricalData color = CategoricalData.NewInstance(LEAF_COLOR_FEATURE);
84
        color.addStateData(State.NewInstance(colorLabel, colorLabel, colorLabel));
85
        desc.addElement(color);
86

    
87

    
88
        return desc;
89
    }
90

    
91
}
(3-3/8)