Revision f9e1b92e
Added by Katja Luther almost 3 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java | ||
---|---|---|
107 | 107 |
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO; |
108 | 108 |
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO; |
109 | 109 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
110 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
110 | 111 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
111 | 112 |
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet; |
112 | 113 |
import eu.etaxonomy.cdm.model.description.Feature; |
113 | 114 |
import eu.etaxonomy.cdm.model.description.MeasurementUnit; |
115 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
|
114 | 116 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
115 | 117 |
import eu.etaxonomy.cdm.model.term.TermNode; |
116 | 118 |
import eu.etaxonomy.cdm.model.term.TermTree; |
... | ... | |
269 | 271 |
//grab all space |
270 | 272 |
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable); |
271 | 273 |
|
272 |
//update label to current data set
|
|
274 |
//update label to current dataset |
|
273 | 275 |
toolbar.getWsLabel().setText(getDescriptiveDataSet().getLabel()); |
274 | 276 |
toolbar.getWsLabel().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
275 | 277 |
toolbar.getWsLabel().getParent().layout(); |
... | ... | |
312 | 314 |
} |
313 | 315 |
|
314 | 316 |
public void initDescriptiveDataSet(){ |
315 |
//get features/columns stored in descriptive data set
|
|
317 |
//get features/columns stored in descriptive dataset |
|
316 | 318 |
TermTree<Feature> tree = getDescriptiveDataSet().getDescriptiveSystem(); |
317 | 319 |
features = initFeatureList(tree.getRoot()); |
318 | 320 |
|
... | ... | |
848 | 850 |
//map descriptions on a list of uuids of the described specimen |
849 | 851 |
!this.descriptions.stream() |
850 | 852 |
.filter(rowWrapper->rowWrapper instanceof SpecimenRowWrapperDTO) |
851 |
.map(specimenRowWrapper->((SpecimenRowWrapperDTO) specimenRowWrapper).getSpecimen().getUuid()) |
|
853 |
.map(specimenRowWrapper->((SpecimenRowWrapperDTO) specimenRowWrapper).getSpecimenDto().getUuid())
|
|
852 | 854 |
.collect(Collectors.toList()) |
853 | 855 |
//and check if the specimen to add is already contained |
854 | 856 |
.contains(wrapper.getUuidAndTitleCache().getUuid()) |
... | ... | |
944 | 946 |
setDirty(); |
945 | 947 |
} |
946 | 948 |
|
947 |
public void addSpecimensToDescriptiveDataSet(){
|
|
949 |
public HashMap<UUID, DescriptionBase> addSpecimensToDescriptiveDataSet(){
|
|
948 | 950 |
if (specimenToAdd == null || specimenToAdd.isEmpty()){ |
949 |
return; |
|
951 |
return new HashMap<>();
|
|
950 | 952 |
} |
951 | 953 |
UpdateResult result = CdmStore.getService(IDescriptiveDataSetService.class).addRowWrapperToDataset(specimenToAdd, getDescriptiveDataSet().getUuid()); |
952 | 954 |
if(!result.getExceptions().isEmpty()){ |
... | ... | |
956 | 958 |
.collect(Collectors.joining("\n")))); |
957 | 959 |
} |
958 | 960 |
DescriptiveDataSet dataSet = (DescriptiveDataSet) result.getCdmEntity(); |
961 |
HashMap<UUID, DescriptionBase> resultMap = new HashMap<>(); |
|
962 |
for (CdmBase updated: result.getUpdatedObjects()){ |
|
963 |
if (updated instanceof SpecimenDescription){ |
|
964 |
resultMap.put(updated.getUuid(), (SpecimenDescription)updated); |
|
965 |
} |
|
966 |
|
|
967 |
|
|
968 |
} |
|
959 | 969 |
dataSet = this.getCdmEntitiySession().load(dataSet, true); |
960 | 970 |
// update local dataset |
961 | 971 |
this.setDescriptiveDataSet(dataSet); |
... | ... | |
965 | 975 |
this.rowsToMerge.remove(row.getDescription().getDescription().getUuid()); |
966 | 976 |
} |
967 | 977 |
specimenToAdd.clear(); |
968 |
// UUID monitorUuid = CdmApplicationState.getLongRunningTasksService().addRowWrapperToDataset(specimenToAdd, getDescriptiveDataSet().getUuid()); |
|
969 |
// specimenToAdd = null; |
|
970 |
// String jobLabel = "Add specimens to matrix"; |
|
971 |
// Job job = Job.create(jobLabel, (ICoreRunnable) monitor -> { |
|
972 |
// SubMonitor subMonitor = SubMonitor.convert(monitor); |
|
973 |
// subMonitor.beginTask(jobLabel, IProgressMonitor.UNKNOWN); |
|
974 |
// IRemotingProgressMonitor remotingMonitor; |
|
975 |
// try { |
|
976 |
// remotingMonitor = CdmStore.getProgressMonitorClientManager() |
|
977 |
// .pollMonitor(jobLabel, |
|
978 |
// monitorUuid, |
|
979 |
// 50, |
|
980 |
// null, |
|
981 |
// (List)null, |
|
982 |
// subMonitor); |
|
983 |
// Object resultObject = remotingMonitor.getResult(); |
|
984 |
// if(resultObject instanceof Exception){ |
|
985 |
// MessagingUtils.errorDialog("Adding specimens failed", this, "Adding specimens was not successfull", TaxeditorEditorPlugin.PLUGIN_ID, (Exception)resultObject, true, true); |
|
986 |
// } |
|
987 |
// else if(resultObject instanceof UpdateResult){ |
|
988 |
// UpdateResult result = (UpdateResult)resultObject; |
|
989 |
// if(!result.getExceptions().isEmpty()){ |
|
990 |
// MessagingUtils.warningDialog(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_TITLE, this, |
|
991 |
// String.format(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_MESSAGE, result.getExceptions() |
|
992 |
// .stream().map(ex->ex.toString()) |
|
993 |
// .collect(Collectors.joining("\n")))); |
|
994 |
// } |
|
995 |
// DescriptiveDataSet dataSet = (DescriptiveDataSet) result.getCdmEntity(); |
|
996 |
// dataSet = this.getCdmEntitiySession().load(dataSet, true); |
|
997 |
// // update local dataset |
|
998 |
// this.setDescriptiveDataSet(dataSet); |
|
999 |
// |
|
1000 |
//// this.loadDescriptions(getDescriptiveDataSet().getUuid(), false); |
|
1001 |
// |
|
1002 |
// |
|
1003 |
// } |
|
1004 |
// } catch (InterruptedException e) { |
|
1005 |
// return; |
|
1006 |
// } |
|
1007 |
// monitor.done(); |
|
1008 |
// }); |
|
1009 |
// |
|
1010 |
// job.schedule(); |
|
978 |
return resultMap; |
|
979 |
|
|
1011 | 980 |
} |
1012 | 981 |
|
1013 | 982 |
@Inject |
Also available in: Unified diff
ref #9710: update descriptions of matrix after save