Revision 1acb2d39
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java | ||
---|---|---|
77 | 77 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
78 | 78 |
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService; |
79 | 79 |
import eu.etaxonomy.cdm.api.service.IProgressMonitorService; |
80 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
|
80 | 81 |
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO; |
81 | 82 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
82 | 83 |
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet; |
... | ... | |
581 | 582 |
return features; |
582 | 583 |
} |
583 | 584 |
|
585 |
public void addUpdateResult(UpdateResult result){ |
|
586 |
part.addUpdateResult(result); |
|
587 |
} |
|
588 |
|
|
584 | 589 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java | ||
---|---|---|
15 | 15 |
import java.util.List; |
16 | 16 |
import java.util.Map; |
17 | 17 |
import java.util.Set; |
18 |
import java.util.UUID; |
|
18 | 19 |
import java.util.stream.Collectors; |
19 | 20 |
|
20 | 21 |
import org.eclipse.jface.layout.GridDataFactory; |
... | ... | |
30 | 31 |
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService; |
31 | 32 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
32 | 33 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
34 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
|
33 | 35 |
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO; |
34 | 36 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
35 | 37 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
... | ... | |
37 | 39 |
import eu.etaxonomy.cdm.model.description.QuantitativeData; |
38 | 40 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
39 | 41 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
42 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
40 | 43 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
41 | 44 |
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper; |
42 | 45 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
43 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
44 | 46 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
45 | 47 |
import eu.etaxonomy.taxeditor.model.DescriptionHelper; |
46 | 48 |
import eu.etaxonomy.taxeditor.model.ImageResources; |
47 | 49 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
48 | 50 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
49 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
|
|
51 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonSelectionDialog; |
|
50 | 52 |
|
51 | 53 |
/** |
52 | 54 |
* @author pplitzner |
... | ... | |
126 | 128 |
* Aggregate button |
127 | 129 |
*/ |
128 | 130 |
Button btnAggregate = new Button(this, SWT.PUSH); |
129 |
// btnAggregate.setImage(ImageResources.getImage(ImageResources.ACTIVE_DELETE_ICON)); |
|
130 | 131 |
btnAggregate.setText("Aggregate"); |
131 | 132 |
btnAggregate.addSelectionListener(new SelectionAdapter() { |
132 | 133 |
@Override |
... | ... | |
135 | 136 |
List<TaxonNodeDto> nodeDtos = taxonSubtreeFilter.stream() |
136 | 137 |
.map(node -> new TaxonNodeDto(node)).collect(Collectors.toList()); |
137 | 138 |
TaxonNodeDto parentDto = CdmStore.getService(ITaxonNodeService.class).findCommonParentDto(nodeDtos); |
138 |
UuidAndTitleCache<TaxonNode> parentNodeUuidAndTitleCache = TaxonNodeSelectionDialog.selectUuidAndTitleCache( |
|
139 |
getShell(), |
|
140 |
"Select taxon node for aggregated description", |
|
141 |
null, |
|
142 |
null, |
|
143 |
parentDto.getClassificationUUID()); |
|
144 |
CdmStore.getService(IDescriptionService.class).aggregateDescription(parentDto.getTaxonUuid(), null, matrix.getDescriptiveDataSet().getUuid()); |
|
139 |
UUID taxonUuid = parentDto.getTaxonUuid(); |
|
140 |
if(MessagingUtils.confirmDialog( |
|
141 |
"Choose taxon node", |
|
142 |
String.format("Do you want to choose a different taxon for" |
|
143 |
+ "the aggregated description than thecommon parent node %s?" |
|
144 |
, parentDto.getTaxonTitleCache()))){ |
|
145 |
Taxon taxon = TaxonSelectionDialog.selectTaxon(getShell(), null); |
|
146 |
taxonUuid = taxon.getUuid(); |
|
147 |
} |
|
148 |
UpdateResult result = CdmStore.getService(IDescriptionService.class).aggregateDescription(taxonUuid, null, matrix.getDescriptiveDataSet().getUuid()); |
|
149 |
matrix.addUpdateResult(result); |
|
145 | 150 |
matrix.setDirty(); |
146 | 151 |
|
147 | 152 |
} |
148 | 153 |
}); |
149 |
btnAggregate.setVisible(false); |
|
150 |
btnAggregate.setEnabled(false); |
|
151 | 154 |
|
152 | 155 |
} |
153 | 156 |
private SpecimenDescription getDescriptionForDescriptiveDataSet(SpecimenOrObservationBase specimen){ |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixPart.java | ||
---|---|---|
36 | 36 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
37 | 37 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
38 | 38 |
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService; |
39 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
|
39 | 40 |
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO; |
40 | 41 |
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet; |
41 | 42 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
... | ... | |
86 | 87 |
|
87 | 88 |
private DescriptiveDataSet descriptiveDataSet; |
88 | 89 |
|
90 |
private Collection<UpdateResult> updateResults; |
|
91 |
|
|
89 | 92 |
private ConversationHolder conversation; |
90 | 93 |
|
91 | 94 |
private ICdmEntitySession cdmEntitySession; |
... | ... | |
156 | 159 |
.filter(o->o instanceof RowWrapperDTO) |
157 | 160 |
.forEach(wrapper->save((RowWrapperDTO)wrapper)); |
158 | 161 |
CdmStore.getService(IDescriptiveDataSetService.class).merge(descriptiveDataSet, true); |
162 |
updateResults.forEach(result-> |
|
163 |
CdmStore.getService(result.getCdmEntity()).merge(result.getCdmEntity(), true)); |
|
159 | 164 |
conversation.commit(); |
165 |
updateResults = null; |
|
160 | 166 |
dirty.setDirty(false); |
161 | 167 |
} |
162 | 168 |
|
... | ... | |
232 | 238 |
return propertyMap; |
233 | 239 |
} |
234 | 240 |
|
241 |
public void addUpdateResult(UpdateResult result){ |
|
242 |
updateResults.add(result); |
|
243 |
} |
|
244 |
|
|
235 | 245 |
} |
Also available in: Unified diff
ref #7509 Add "Aggregate" button to character matrix