Revision 6fcdf7cc
Added by Katja Luther almost 4 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java | ||
---|---|---|
897 | 897 |
if (specimenToAdd == null || specimenToAdd.isEmpty()){ |
898 | 898 |
return; |
899 | 899 |
} |
900 |
UUID monitorUuid = CdmApplicationState.getLongRunningTasksService().addRowWrapperToDataset(specimenToAdd, getDescriptiveDataSet().getUuid()); |
|
901 |
specimenToAdd = null; |
|
902 |
String jobLabel = "Add specimens to matrix"; |
|
903 |
Job job = Job.create(jobLabel, (ICoreRunnable) monitor -> { |
|
904 |
SubMonitor subMonitor = SubMonitor.convert(monitor); |
|
905 |
subMonitor.beginTask(jobLabel, IProgressMonitor.UNKNOWN); |
|
906 |
IRemotingProgressMonitor remotingMonitor; |
|
907 |
try { |
|
908 |
remotingMonitor = CdmStore.getProgressMonitorClientManager() |
|
909 |
.pollMonitor(jobLabel, |
|
910 |
monitorUuid, |
|
911 |
50, |
|
912 |
null, |
|
913 |
(List)null, |
|
914 |
subMonitor); |
|
915 |
Object resultObject = remotingMonitor.getResult(); |
|
916 |
if(resultObject instanceof Exception){ |
|
917 |
MessagingUtils.errorDialog("Adding specimens failed", this, "Adding specimens was not successfull", TaxeditorEditorPlugin.PLUGIN_ID, (Exception)resultObject, true, true); |
|
918 |
} |
|
919 |
else if(resultObject instanceof UpdateResult){ |
|
920 |
UpdateResult result = (UpdateResult)resultObject; |
|
921 |
if(!result.getExceptions().isEmpty()){ |
|
922 |
MessagingUtils.warningDialog(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_TITLE, this, |
|
923 |
String.format(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_MESSAGE, result.getExceptions() |
|
924 |
.stream().map(ex->ex.toString()) |
|
925 |
.collect(Collectors.joining("\n")))); |
|
926 |
} |
|
927 |
DescriptiveDataSet dataSet = (DescriptiveDataSet) result.getCdmEntity(); |
|
928 |
dataSet = this.getCdmEntitiySession().load(dataSet, true); |
|
929 |
// update local dataset |
|
930 |
this.setDescriptiveDataSet(dataSet); |
|
931 |
|
|
932 |
// this.loadDescriptions(getDescriptiveDataSet().getUuid(), false); |
|
933 |
|
|
934 |
|
|
935 |
} |
|
936 |
} catch (InterruptedException e) { |
|
937 |
return; |
|
938 |
} |
|
939 |
monitor.done(); |
|
940 |
}); |
|
941 |
|
|
942 |
job.schedule(); |
|
900 |
UpdateResult result = CdmStore.getService(IDescriptiveDataSetService.class).addRowWrapperToDataset(specimenToAdd, getDescriptiveDataSet().getUuid()); |
|
901 |
if(!result.getExceptions().isEmpty()){ |
|
902 |
MessagingUtils.warningDialog(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_TITLE, this, |
|
903 |
String.format(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_MESSAGE, result.getExceptions() |
|
904 |
.stream().map(ex->ex.toString()) |
|
905 |
.collect(Collectors.joining("\n")))); |
|
906 |
} |
|
907 |
DescriptiveDataSet dataSet = (DescriptiveDataSet) result.getCdmEntity(); |
|
908 |
dataSet = this.getCdmEntitiySession().load(dataSet, true); |
|
909 |
// update local dataset |
|
910 |
this.setDescriptiveDataSet(dataSet); |
|
911 |
|
|
912 |
// UUID monitorUuid = CdmApplicationState.getLongRunningTasksService().addRowWrapperToDataset(specimenToAdd, getDescriptiveDataSet().getUuid()); |
|
913 |
// specimenToAdd = null; |
|
914 |
// String jobLabel = "Add specimens to matrix"; |
|
915 |
// Job job = Job.create(jobLabel, (ICoreRunnable) monitor -> { |
|
916 |
// SubMonitor subMonitor = SubMonitor.convert(monitor); |
|
917 |
// subMonitor.beginTask(jobLabel, IProgressMonitor.UNKNOWN); |
|
918 |
// IRemotingProgressMonitor remotingMonitor; |
|
919 |
// try { |
|
920 |
// remotingMonitor = CdmStore.getProgressMonitorClientManager() |
|
921 |
// .pollMonitor(jobLabel, |
|
922 |
// monitorUuid, |
|
923 |
// 50, |
|
924 |
// null, |
|
925 |
// (List)null, |
|
926 |
// subMonitor); |
|
927 |
// Object resultObject = remotingMonitor.getResult(); |
|
928 |
// if(resultObject instanceof Exception){ |
|
929 |
// MessagingUtils.errorDialog("Adding specimens failed", this, "Adding specimens was not successfull", TaxeditorEditorPlugin.PLUGIN_ID, (Exception)resultObject, true, true); |
|
930 |
// } |
|
931 |
// else if(resultObject instanceof UpdateResult){ |
|
932 |
// UpdateResult result = (UpdateResult)resultObject; |
|
933 |
// if(!result.getExceptions().isEmpty()){ |
|
934 |
// MessagingUtils.warningDialog(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_TITLE, this, |
|
935 |
// String.format(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_MESSAGE, result.getExceptions() |
|
936 |
// .stream().map(ex->ex.toString()) |
|
937 |
// .collect(Collectors.joining("\n")))); |
|
938 |
// } |
|
939 |
// DescriptiveDataSet dataSet = (DescriptiveDataSet) result.getCdmEntity(); |
|
940 |
// dataSet = this.getCdmEntitiySession().load(dataSet, true); |
|
941 |
// // update local dataset |
|
942 |
// this.setDescriptiveDataSet(dataSet); |
|
943 |
// |
|
944 |
//// this.loadDescriptions(getDescriptiveDataSet().getUuid(), false); |
|
945 |
// |
|
946 |
// |
|
947 |
// } |
|
948 |
// } catch (InterruptedException e) { |
|
949 |
// return; |
|
950 |
// } |
|
951 |
// monitor.done(); |
|
952 |
// }); |
|
953 |
// |
|
954 |
// job.schedule(); |
|
943 | 955 |
} |
944 | 956 |
|
945 | 957 |
} |
Also available in: Unified diff
ref #9029: do not add specimen in long running task to avoid description duplicate - continue