- UUID monitorUuid = CdmApplicationState.getLongRunningTasksService().addRowWrapperToDataset(specimenToAdd, getDescriptiveDataSet().getUuid());
- specimenToAdd = null;
- String jobLabel = "Add specimens to matrix";
- Job job = Job.create(jobLabel, (ICoreRunnable) monitor -> {
- SubMonitor subMonitor = SubMonitor.convert(monitor);
- subMonitor.beginTask(jobLabel, IProgressMonitor.UNKNOWN);
- IRemotingProgressMonitor remotingMonitor;
- try {
- remotingMonitor = CdmStore.getProgressMonitorClientManager()
- .pollMonitor(jobLabel,
- monitorUuid,
- 50,
- null,
- (List)null,
- subMonitor);
- Object resultObject = remotingMonitor.getResult();
- if(resultObject instanceof Exception){
- MessagingUtils.errorDialog("Adding specimens failed", this, "Adding specimens was not successfull", TaxeditorEditorPlugin.PLUGIN_ID, (Exception)resultObject, true, true);
- }
- else if(resultObject instanceof UpdateResult){
- UpdateResult result = (UpdateResult)resultObject;
- if(!result.getExceptions().isEmpty()){
- MessagingUtils.warningDialog(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_TITLE, this,
- String.format(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_MESSAGE, result.getExceptions()
- .stream().map(ex->ex.toString())
- .collect(Collectors.joining("\n"))));
- }
- DescriptiveDataSet dataSet = (DescriptiveDataSet) result.getCdmEntity();
- dataSet = this.getCdmEntitiySession().load(dataSet, true);
- // update local dataset
- this.setDescriptiveDataSet(dataSet);
- this.loadDescriptions(getDescriptiveDataSet().getUuid(), false);
+ UpdateResult result = CdmStore.getService(IDescriptiveDataSetService.class).addRowWrapperToDataset(specimenToAdd, getDescriptiveDataSet().getUuid());
+ if(!result.getExceptions().isEmpty()){
+ MessagingUtils.warningDialog(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_TITLE, this,
+ String.format(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_MESSAGE, result.getExceptions()
+ .stream().map(ex->ex.toString())
+ .collect(Collectors.joining("\n"))));
+ }
+ DescriptiveDataSet dataSet = (DescriptiveDataSet) result.getCdmEntity();
+ HashMap<UUID, DescriptionBase> resultMap = new HashMap<>();
+ for (CdmBase updated: result.getUpdatedObjects()){
+ if (updated instanceof SpecimenDescription){
+ resultMap.put(updated.getUuid(), (DescriptionBase)updated);
+ }