Revision fd711754
Added by Katja Luther almost 4 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java | ||
---|---|---|
13 | 13 |
import java.util.Collection; |
14 | 14 |
import java.util.Collections; |
15 | 15 |
import java.util.HashMap; |
16 |
import java.util.HashSet; |
|
17 | 16 |
import java.util.LinkedList; |
18 | 17 |
import java.util.List; |
19 | 18 |
import java.util.Map; |
... | ... | |
158 | 157 |
|
159 | 158 |
private NatTable natTable; |
160 | 159 |
|
161 |
private Collection<RowWrapperDTO<?>> rowsToSave = new HashSet<>(); |
|
160 |
// private Collection<RowWrapperDTO<?>> rowsToSave = new HashSet<>(); |
|
161 |
private HashMap<UUID, RowWrapperDTO<?>> rowsToMerge = new HashMap<>(); |
|
162 | 162 |
|
163 | 163 |
private Map<Integer, Feature> indexToFeatureMap = new HashMap<>(); |
164 | 164 |
|
... | ... | |
692 | 692 |
descriptions.clear(); |
693 | 693 |
wrappers.stream().filter(row->row.getTaxonNode()!=null).forEach(wrapper->CharacterMatrix.this.descriptions.add(wrapper)); |
694 | 694 |
loadingDone(isInitialExpandToDeepestTaxonLevel); |
695 |
|
|
695 | 696 |
}); |
696 | 697 |
} |
697 | 698 |
}); |
... | ... | |
712 | 713 |
private void loadingDone(boolean isInitialExpandToDeepestTaxonLevel) { |
713 | 714 |
this.part.loadingDone(); |
714 | 715 |
createTable(isTreeView, freezeLayer.isFrozen(), isInitialExpandToDeepestTaxonLevel); |
716 |
|
|
715 | 717 |
} |
716 | 718 |
|
717 | 719 |
public List<TermDto> getSupportedStatesForCategoricalFeature(Feature feature){ |
... | ... | |
803 | 805 |
} |
804 | 806 |
|
805 | 807 |
public void addRowToSave(RowWrapperDTO<?> row){ |
806 |
rowsToSave.add(row); |
|
808 |
rowsToMerge.put(row.getDescription().getDescription().getUuid(), row); |
|
809 |
} |
|
810 |
|
|
811 |
public HashMap<UUID,RowWrapperDTO<?>> getRowsToSave() { |
|
812 |
return rowsToMerge; |
|
807 | 813 |
} |
808 | 814 |
|
809 |
public Collection<RowWrapperDTO<?>> getRowsToSave() { |
|
810 |
return rowsToSave; |
|
815 |
public HashMap<UUID, RowWrapperDTO<?>> getRowsToMerge() { |
|
816 |
return rowsToMerge; |
|
817 |
} |
|
818 |
|
|
819 |
public void putRowToMerge(RowWrapperDTO rowToMerge) { |
|
820 |
if (this.rowsToMerge == null){ |
|
821 |
this.rowsToMerge = new HashMap<>(); |
|
822 |
} |
|
823 |
this.rowsToMerge.put(rowToMerge.getDescription().getDescription().getUuid(), rowToMerge); |
|
811 | 824 |
} |
812 | 825 |
|
813 | 826 |
public Properties getNatTableState() { |
... | ... | |
915 | 928 |
dataSet = this.getCdmEntitiySession().load(dataSet, true); |
916 | 929 |
// update local dataset |
917 | 930 |
this.setDescriptiveDataSet(dataSet); |
918 |
this.loadDescriptions(getDescriptiveDataSet().getUuid(), false); |
|
931 |
// this.loadDescriptions(getDescriptiveDataSet().getUuid(), false);
|
|
919 | 932 |
|
920 | 933 |
|
921 | 934 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixConfigLabelAccumulator.java | ||
---|---|---|
14 | 14 |
import org.eclipse.nebula.widgets.nattable.layer.LabelStack; |
15 | 15 |
import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator; |
16 | 16 |
|
17 |
import eu.etaxonomy.cdm.api.service.dto.DescriptionBaseDto; |
|
17 | 18 |
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO; |
18 | 19 |
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO; |
19 | 20 |
import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO; |
... | ... | |
87 | 88 |
} |
88 | 89 |
} |
89 | 90 |
//check for supplemental data |
90 |
if(!taxonRowWrapper.getDescription().getSources().isEmpty() && columnPosition==0){ |
|
91 |
if(!taxonRowWrapper.getDescription().getDescription().getSources().isEmpty() && columnPosition==0){
|
|
91 | 92 |
configLabels.addLabel(CharacterMatrix.LABEL_DESCRIPTION_HAS_SUPPLEMENTAL_DATA); |
92 | 93 |
} |
93 | 94 |
configLabels.addLabel(CharacterMatrix.LABEL_TAXON_DESCRIPTION); |
... | ... | |
151 | 152 |
private boolean hasDefaultValue(Feature feature, RowWrapperDTO<?> rowWrapperDTO) { |
152 | 153 |
if(rowWrapperDTO instanceof SpecimenRowWrapperDTO |
153 | 154 |
&& ((SpecimenRowWrapperDTO) rowWrapperDTO).getDefaultDescription()!=null){ |
154 |
return hasDefaultValue(feature, ((SpecimenRowWrapperDTO)rowWrapperDTO).getDefaultDescription().getDescription()); |
|
155 |
TaxonDescription taxDescription = (TaxonDescription)((SpecimenRowWrapperDTO)rowWrapperDTO).getDefaultDescription().getDescription().getDescription(); |
|
156 |
return hasDefaultValue(feature, taxDescription); |
|
155 | 157 |
} |
156 | 158 |
else if(rowWrapperDTO instanceof TaxonRowWrapperDTO){ |
157 | 159 |
TaxonRowWrapperDTO taxonRowWrapper = (TaxonRowWrapperDTO)rowWrapperDTO; |
158 |
Set<TaxonDescription> descriptions = taxonRowWrapper.getDescription().getTaxon().getDescriptions();
|
|
159 |
for (TaxonDescription taxonDescription : descriptions) {
|
|
160 |
Set<DescriptionBaseDto> descriptions = taxonRowWrapper.getTaxonDescriptions();
|
|
161 |
for (DescriptionBaseDto taxonDescription : descriptions) {
|
|
160 | 162 |
if(matrix.getDescriptiveDataSet().getDescriptions().contains(taxonDescription) |
161 |
&& taxonDescription.getTypes().contains(DescriptionType.DEFAULT_VALUES_FOR_AGGREGATION)){ |
|
162 |
return hasDefaultValue(feature, taxonDescription);
|
|
163 |
&& taxonDescription.getDescription().getTypes().contains(DescriptionType.DEFAULT_VALUES_FOR_AGGREGATION)){
|
|
164 |
return hasDefaultValue(feature, (TaxonDescription)taxonDescription.getDescription());
|
|
163 | 165 |
} |
164 | 166 |
} |
165 | 167 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixPart.java | ||
---|---|---|
40 | 40 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
41 | 41 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
42 | 42 |
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService; |
43 |
import eu.etaxonomy.cdm.api.service.dto.DescriptionBaseDto; |
|
44 |
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO; |
|
45 |
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO; |
|
43 | 46 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
44 | 47 |
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet; |
45 | 48 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
46 | 49 |
import eu.etaxonomy.cdm.model.term.TermType; |
50 |
import eu.etaxonomy.cdm.persistence.dto.MergeResult; |
|
47 | 51 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
48 | 52 |
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin; |
49 | 53 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
... | ... | |
186 | 190 |
@Override |
187 | 191 |
public void save(IProgressMonitor monitor) { |
188 | 192 |
// save edited descriptions |
189 |
List<DescriptionBase> descriptions = matrix.getRowsToSave().stream()
|
|
193 |
List<DescriptionBaseDto> descriptions = matrix.getRowsToSave().values().stream()
|
|
190 | 194 |
.map(row->row.getDescription()) |
191 | 195 |
.collect(Collectors.toList()); |
192 | 196 |
matrix.addSpecimensToDescriptiveDataSet(); |
193 |
CdmStore.getService(IDescriptiveDataSetService.class).removeDescriptions(matrix.getDescriptionsToDelete(), matrix.getDescriptiveDataSet().getUuid()); |
|
194 |
|
|
195 |
CdmStore.getService(IDescriptionService.class).merge(descriptions); |
|
197 |
//newly added descriptions should not be saved again. |
|
198 |
descriptions.removeAll(matrix.getRowsToSave().values()); |
|
196 | 199 |
matrix.getRowsToSave().clear(); |
200 |
if (matrix.getDescriptionsToDelete() != null && !matrix.getDescriptionsToDelete().isEmpty()){ |
|
201 |
CdmStore.getService(IDescriptiveDataSetService.class).removeDescriptions(matrix.getDescriptionsToDelete(), matrix.getDescriptiveDataSet().getUuid()); |
|
202 |
} |
|
203 |
List<MergeResult<DescriptionBase>> results = CdmStore.getService(IDescriptionService.class).mergeDescriptions(descriptions, true); |
|
197 | 204 |
conversation.commit(); |
205 |
HashMap<UUID, DescriptionBase> descriptionResults = new HashMap<>(); |
|
206 |
for (MergeResult result: results){ |
|
207 |
if (result.getMergedEntity() != null){ |
|
208 |
descriptionResults.put(result.getMergedEntity().getUuid(), (DescriptionBase)result.getMergedEntity()); |
|
209 |
} |
|
210 |
} |
|
211 |
List<Object> updateRows = matrix.getDescriptions().stream().filter(row->descriptionResults.keySet().contains(((RowWrapperDTO)row).getDescription().getDescription().getUuid())).collect(Collectors.toList()); |
|
212 |
for (Object updateRow: updateRows){ |
|
213 |
if (updateRow instanceof SpecimenRowWrapperDTO){ |
|
214 |
SpecimenRowWrapperDTO dto = (SpecimenRowWrapperDTO)updateRow; |
|
215 |
dto.getDescription().setDescription(descriptionResults.get(((SpecimenRowWrapperDTO) updateRow).getDescription().getDescription().getUuid())); |
|
216 |
} |
|
217 |
} |
|
218 |
// matrix.loadDescriptions(getDescriptiveDataSet().getUuid(), false); |
|
219 |
|
|
198 | 220 |
dirty.setDirty(false); |
199 | 221 |
} |
200 | 222 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/MatrixRowComparator.java | ||
---|---|---|
81 | 81 |
else{ |
82 | 82 |
// same taxon node |
83 | 83 |
} |
84 |
DescriptionBase description1 = rowWrapper1.getDescription(); |
|
85 |
DescriptionBase description2 = rowWrapper2.getDescription(); |
|
84 |
DescriptionBase description1 = rowWrapper1.getDescription().getDescription();
|
|
85 |
DescriptionBase description2 = rowWrapper2.getDescription().getDescription();
|
|
86 | 86 |
//compare by taxon description type |
87 | 87 |
if(description1 instanceof TaxonDescription){ |
88 | 88 |
if(description2 instanceof SpecimenDescription){ |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/MatrixUtility.java | ||
---|---|---|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
private static boolean hasType(TaxonRowWrapperDTO taxonRowWrapperDTO, DescriptionType descriptionType){ |
73 |
return taxonRowWrapperDTO.getDescription().getTypes().stream() |
|
73 |
return taxonRowWrapperDTO.getDescription().getDescription().getTypes().stream()
|
|
74 | 74 |
.anyMatch(type->type.equals(descriptionType)); |
75 | 75 |
} |
76 | 76 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/SpecimenColumnPropertyAccessor.java | ||
---|---|---|
54 | 54 |
return rowWrapper.getTaxonNode(); |
55 | 55 |
} |
56 | 56 |
case 1: |
57 |
return rowWrapper.getFieldUnit().getTitleCache(); |
|
57 |
if (rowWrapper.getFieldUnit() != null){ |
|
58 |
return rowWrapper.getFieldUnit().getTitleCache(); |
|
59 |
}else{ |
|
60 |
return "no information"; |
|
61 |
} |
|
58 | 62 |
case 2: |
59 | 63 |
return rowWrapper.getIdentifier(); |
60 | 64 |
case 3: |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/handler/AddDescriptionHandler.java | ||
---|---|---|
31 | 31 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart; |
32 | 32 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.SpecimenSelectionDialog; |
33 | 33 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
34 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
35 | 34 |
|
36 | 35 |
/** |
37 | 36 |
* @author k.luther |
... | ... | |
43 | 42 |
|
44 | 43 |
// dependent on the selection the specimens are filtered |
45 | 44 |
CharacterMatrixPart matrixPart = (CharacterMatrixPart) activePart.getObject(); |
46 |
if(StoreUtil.promptCheckIsDirty(matrixPart)){ |
|
47 |
return; |
|
48 |
} |
|
45 |
// if(StoreUtil.promptCheckIsDirty(matrixPart)){
|
|
46 |
// return;
|
|
47 |
// }
|
|
49 | 48 |
CharacterMatrix matrix = matrixPart.getMatrix(); |
50 | 49 |
IStructuredSelection selection = matrixPart.getSelection(); |
51 | 50 |
List<String> treeIndexList = null; |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/handler/DeleteDescriptionHandler.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
24 | 24 |
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet; |
25 | 25 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
26 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
26 | 27 |
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper; |
28 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
27 | 29 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart; |
28 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
29 | 30 |
|
30 | 31 |
/** |
31 | 32 |
* @author k.luther |
... | ... | |
37 | 38 |
@Execute |
38 | 39 |
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, UISynchronize sync) { |
39 | 40 |
CharacterMatrixPart matrixPart = (CharacterMatrixPart) activePart.getObject(); |
40 |
if(StoreUtil.promptCheckIsDirty(matrixPart)){ |
|
41 |
return; |
|
42 |
} |
|
41 |
// if(StoreUtil.promptCheckIsDirty(matrixPart)){
|
|
42 |
// return;
|
|
43 |
// }
|
|
43 | 44 |
DescriptiveDataSet descriptiveDataSet = matrixPart.getDescriptiveDataSet(); |
44 | 45 |
RowWrapperDTO wrapper = (RowWrapperDTO) matrixPart.getSelection().getFirstElement(); |
45 |
DescriptionBase description = wrapper.getDescription(); |
|
46 |
DescriptionBase description = wrapper.getDescription().getDescription();
|
|
46 | 47 |
|
47 | 48 |
boolean ok = matrixPart.getMatrix().getDescriptions().remove(wrapper); |
48 | 49 |
matrixPart.getMatrix().addDescriptionToDelete(description.getUuid()); |
49 | 50 |
if (description instanceof SpecimenDescription){ |
50 |
SpecimenNodeWrapper nodeWrapper = new SpecimenNodeWrapper(((SpecimenRowWrapperDTO)wrapper).getSpecimen(), ((SpecimenRowWrapperDTO)wrapper).getType(), wrapper.getTaxonNode()); |
|
51 |
UuidAndTitleCache<SpecimenOrObservationBase> uuidAndTitleCache = new UuidAndTitleCache<>(((SpecimenRowWrapperDTO)wrapper).getSpecimen().getUuid(), ((SpecimenRowWrapperDTO)wrapper).getSpecimen().getId(), ((SpecimenRowWrapperDTO)wrapper).getSpecimen().getTitleCache()); |
|
52 |
SpecimenNodeWrapper nodeWrapper = new SpecimenNodeWrapper(uuidAndTitleCache, |
|
53 |
((SpecimenRowWrapperDTO)wrapper).getType(), |
|
54 |
wrapper.getTaxonNode()); |
|
55 |
|
|
56 |
|
|
51 | 57 |
if (matrixPart.getMatrix().getSpecimenCache()!= null){ |
52 | 58 |
matrixPart.getMatrix().getSpecimenCache().add(nodeWrapper); |
53 | 59 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/StructuredDescriptionAggregationConfigurationWizardPage.java | ||
---|---|---|
95 | 95 |
}); |
96 | 96 |
|
97 | 97 |
checkUseSelectedTaxonNode= new Button(radioComposite, SWT.RADIO); |
98 |
checkUseSelectedTaxonNode.setText("Aggregation only for selected taxon/taxa");
|
|
98 |
checkUseSelectedTaxonNode.setText(Messages.AggregationWizardPage_SINGLE_TAXON);
|
|
99 | 99 |
checkUseSelectedTaxonNode.addListener(SWT.Selection, new Listener() { |
100 | 100 |
@Override |
101 | 101 |
public void handleEvent(Event e) { |
Also available in: Unified diff
ref #8785: update descriptions in description list after merge