Project

General

Profile

« Previous | Next » 

Revision 6b3711bc

Added by Patrick Plitzner about 6 years ago

ref #7095 Overhauled categorical data cell editor

  • encapsulated data fetching and storing in RowWrapper
  • simplified data accesion by caching States in RowWrapper

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/RowWrapper.java
8 8
 */
9 9
package eu.etaxonomy.taxeditor.editor.workingSet.matrix;
10 10

  
11
import java.util.ArrayList;
11 12
import java.util.Collection;
12 13
import java.util.HashMap;
14
import java.util.List;
13 15
import java.util.Map;
14 16
import java.util.Set;
15 17

  
......
20 22
import eu.etaxonomy.cdm.model.description.Feature;
21 23
import eu.etaxonomy.cdm.model.description.QuantitativeData;
22 24
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
25
import eu.etaxonomy.cdm.model.description.State;
26
import eu.etaxonomy.cdm.model.description.StateData;
23 27
import eu.etaxonomy.cdm.model.location.NamedArea;
24 28
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
25 29
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
......
111 115
        return country;
112 116
    }
113 117

  
114
    public DescriptionElementBase getDescriptionElementForFeature(Feature feature){
115
        return featureToElementMap.get(feature);
118
    public Object getDataValueForFeature(Feature feature){
119
        DescriptionElementBase descriptionElementBase = featureToElementMap.get(feature);
120
        if(descriptionElementBase!=null && descriptionElementBase.isInstanceOf(CategoricalData.class)){
121
            CategoricalData categoricalData = HibernateProxyHelper.deproxy(descriptionElementBase, CategoricalData.class);
122
            return categoricalData.getStatesOnly();
123
        }
124
        return descriptionElementBase;
125
    }
126

  
127
    public void setDataValueForFeature(Feature feature, Object newValue){
128
        DescriptionElementBase descriptionElementBase = featureToElementMap.get(feature);
129
        //FIXME move this to cdmlib service layer
130
        if(descriptionElementBase!=null && descriptionElementBase.isInstanceOf(CategoricalData.class) && newValue instanceof Collection){
131
            CategoricalData categoricalData = HibernateProxyHelper.deproxy(descriptionElementBase, CategoricalData.class);
132
            List<StateData> stateData = new ArrayList<>(categoricalData.getStateData());
133
            for (StateData stateData2 : stateData) {
134
                categoricalData.removeStateData(stateData2);
135
            }
136
            Collection<State> states = (Collection<State>) newValue;
137
            for (State state : states) {
138
                categoricalData.addStateData(state);
139
            }
140
        }
116 141
    }
117 142

  
118 143
}

Also available in: Unified diff