Project

General

Profile

« Previous | Next » 

Revision 027a0208

Added by Katja Luther 8 months ago

ref #9861: check applicability of feature

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
173 173
    private HashMap<UUID, RowWrapperDTO<?>> rowsToMerge = new HashMap<>();
174 174

  
175 175
    private Map<Integer, FeatureDto> indexToFeatureMap = new HashMap<>();
176
    private Map<UUID, Integer> featureToIndexMap = new HashMap<>();
176 177

  
177 178
    private Map<UUID, List<TermDto>> categoricalFeatureToStateMap = new HashMap<>();
178 179

  
......
680 681

  
681 682
    private void initLabels(int index, FeatureDto feature) {
682 683
        indexToFeatureMap.put(index+LEADING_COLUMN_COUNT, feature);
683

  
684
        featureToIndexMap.put(feature.getUuid(), index+LEADING_COLUMN_COUNT);
684 685
        String label = feature.getTitleCache();
685 686
        String property = feature.getUuid().toString();
686 687
        //show unit for quantitative data
......
794 795
        return indexToFeatureMap;
795 796
    }
796 797

  
797
    public LinkedMap<String, String> getPropertyToLabelMap() {
798
    public Map<UUID, Integer> getFeatureToIndexMap() {
799
		return featureToIndexMap;
800
	}
801

  
802
	public void setFeatureToIndexMap(Map<UUID, Integer> featureToIndexMap) {
803
		this.featureToIndexMap = featureToIndexMap;
804
	}
805

  
806
	public LinkedMap<String, String> getPropertyToLabelMap() {
798 807
        return propertyToLabelMap;
799 808
    }
800 809

  
......
937 946

  
938 947
        }
939 948
    }
949
    
950
    @Inject
951
    @Optional
952
    private void updateMatrix(@UIEventTopic(WorkbenchEventConstants.REFRESH_MATRIX)UUID uuid){
953
        if(uuid!= null && uuid.equals(part.getDescriptiveDataSet().getUuid())){
954
           this.specimenCache = null;
955

  
956
        }
957
    }
940 958

  
941 959
    public void addRowsToMatrix(Collection<SpecimenNodeWrapper> wrappers){
942 960

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

  
11
import java.util.Map.Entry;
11 12
import java.util.Optional;
12 13
import java.util.Set;
13 14

  
......
20 21
import eu.etaxonomy.cdm.api.service.dto.QuantitativeDataDto;
21 22
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
22 23
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
24
import eu.etaxonomy.cdm.api.service.dto.StateDataDto;
23 25
import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
24 26
import eu.etaxonomy.cdm.persistence.dto.FeatureDto;
27
import eu.etaxonomy.cdm.persistence.dto.FeatureStateDto;
25 28
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
29
import eu.etaxonomy.cdm.persistence.dto.TermDto;
30
import eu.etaxonomy.cdm.persistence.dto.TermTreeDto;
26 31

  
27 32
/**
28 33
 * @author pplitzner
......
124 129
	            if (hasMoreThanOneValue(feature, (RowWrapperDTO)rowObject)){
125 130
	            	isEditable = false;
126 131
	            }
132
	            if (!isApplicableCheck(feature, (RowWrapperDTO)rowObject)){
133
	            	isEditable = false;
134
	            }
127 135
            }
128 136

  
129 137
            if(feature.isSupportsCategoricalData()){
......
188 196
        
189 197
       
190 198
    }
199
    
200
    private boolean isApplicableCheck(FeatureDto feature, RowWrapperDTO<?> rowWrapperDTO) {
201
        TermTreeDto tree = matrix.getDescriptiveDataSet().getDescriptiveSystem();
202
        boolean isApplicableCheck = true;
203
        if (tree.getOnlyApplicable().containsKey(feature.getUuid())){
204
        	
205
        	for (FeatureStateDto featureStateDto:tree.getOnlyApplicable().get(feature.getUuid())){
206
        		FeatureDto dto = featureStateDto.getFeature();
207
        		TermDto stateDto = featureStateDto.getState();
208
        		Set<DescriptionElementDto> descEls = rowWrapperDTO.getDataValueForFeature(dto.getUuid());
209
        		if (descEls != null){
210
	        		for (DescriptionElementDto el:descEls){
211
	        			if (el instanceof CategoricalDataDto){
212
	        				for (StateDataDto stateData:((CategoricalDataDto) el).getStates()){
213
	        					isApplicableCheck &= stateData.getState().getUuid().equals(stateDto.getUuid());
214
	        				}
215
	        			}
216
	        		}
217
        		}
218
        	}
219
        	
220
        }
221
        if (tree.getInapplicableMap().containsKey(feature.getUuid())){
222
        	
223
        	for (FeatureStateDto featureStateDto:tree.getInapplicableMap().get(feature.getUuid())){
224
        		FeatureDto dto = featureStateDto.getFeature();
225
        		TermDto stateDto = featureStateDto.getState();
226
        		Set<DescriptionElementDto> descEls = rowWrapperDTO.getDataValueForFeature(dto.getUuid());
227
        		if (descEls != null){
228
	        		for (DescriptionElementDto el:descEls){
229
	        			if (el instanceof CategoricalDataDto){
230
	        				for (StateDataDto stateData:((CategoricalDataDto) el).getStates()){
231
	        					isApplicableCheck &= !stateData.getState().getUuid().equals(stateDto.getUuid());
232
	        				}
233
	        			}
234
	        		}
235
        		}
236
        	}
237
        	
238
        }
239
        return isApplicableCheck;
240
   
241
}
191 242

  
192 243

  
193 244
    private boolean hasDefaultValue(FeatureDto feature, DescriptionBaseDto defaultDescription) {
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/categorical/CategoricalDataCellEditor.java
76 76

  
77 77
    @Override
78 78
    protected Control activateCell(Composite parent, Object originalCanonicalValue) {
79
    	
79 80
        if(matrix.getBodyDataProvider().getRowObject(this.getRowIndex()) instanceof RowWrapperDTO){
80 81
            NatCombo natCombo = (NatCombo) super.activateCell(parent, originalCanonicalValue);
81 82
            natCombo.addSelectionListener(new SelectionListener() {

Also available in: Unified diff