Revision 90f49fe4
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionElementsHandlerE4.java | ||
---|---|---|
87 | 87 |
Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(factualDataPart.getSelectionProvidingPart()); |
88 | 88 |
if(e4WrappedPart instanceof TaxonNameEditorE4){ |
89 | 89 |
editor = (TaxonNameEditorE4) e4WrappedPart; |
90 |
|
|
91 |
|
|
92 |
|
|
93 | 90 |
} |
94 | 91 |
Taxon actualTaxon= null; |
95 | 92 |
|
96 | 93 |
List<DescriptionElementBase> elements = new ArrayList<DescriptionElementBase>(); |
97 |
|
|
94 |
DescriptionBase description = null; |
|
98 | 95 |
for (Iterator iter = viewselection.iterator(); iter.hasNext();) { |
99 | 96 |
Object object = iter.next(); |
100 | 97 |
if (object instanceof DescriptionElementBase) { |
101 | 98 |
UUID uuid = ((DescriptionElementBase) object).getUuid(); |
99 |
description = ((DescriptionElementBase) object).getInDescription(); |
|
100 |
DescriptionElementBase element ; |
|
101 |
if (((DescriptionElementBase) object).getId() > 0){ |
|
102 |
element = CdmStore.getService(IDescriptionService.class).loadDescriptionElement(uuid, null); |
|
103 |
}else{ |
|
104 |
element = ((DescriptionElementBase) object); |
|
105 |
} |
|
102 | 106 |
|
103 |
elements.add(CdmStore.getService(IDescriptionService.class).loadDescriptionElement(uuid, null));
|
|
107 |
elements.add(element);
|
|
104 | 108 |
} else if (object instanceof FeatureNodeContainer) { |
105 | 109 |
for (DescriptionElementBase de : ((FeatureNodeContainer) object).getDescriptionElements()) { |
106 |
elements.add( |
|
107 |
CdmStore.getService(IDescriptionService.class).loadDescriptionElement(de.getUuid(), null)); |
|
110 |
DescriptionElementBase element ; |
|
111 |
if (de.getId() > 0){ |
|
112 |
element = CdmStore.getService(IDescriptionService.class).loadDescriptionElement(de.getUuid(), null); |
|
113 |
}else{ |
|
114 |
element = (de); |
|
115 |
} |
|
116 |
description = de.getInDescription(); |
|
117 |
elements.add(element); |
|
108 | 118 |
} |
109 | 119 |
} |
110 | 120 |
} |
111 | 121 |
|
112 |
if(elements.size() == 0){ |
|
122 |
if(elements.size() == 0 ){
|
|
113 | 123 |
return; |
114 | 124 |
} |
115 | 125 |
|
116 |
DescriptionBase description = elements.get(0).getInDescription(); |
|
126 |
if (elements.get(0) != null){ |
|
127 |
description = elements.get(0).getInDescription(); |
|
128 |
} |
|
117 | 129 |
Set<UUID> excludeTaxa = new HashSet<>(); |
118 | 130 |
if (description!=null && description.isInstanceOf(TaxonDescription.class)){ |
119 | 131 |
TaxonDescription taxonDescription = HibernateProxyHelper.deproxy(description, TaxonDescription.class); |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionToOtherTaxonOperation.java | ||
---|---|---|
16 | 16 |
import org.eclipse.core.runtime.IProgressMonitor; |
17 | 17 |
import org.eclipse.core.runtime.IStatus; |
18 | 18 |
|
19 |
import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController; |
|
20 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
|
21 | 19 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
22 | 20 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
23 | 21 |
import eu.etaxonomy.cdm.model.common.Annotation; |
... | ... | |
89 | 87 |
Annotation annotation = Annotation.NewInstance(moveMessage, Language.getDefaultLanguage()); |
90 | 88 |
annotation.setAnnotationType(AnnotationType.TECHNICAL()); |
91 | 89 |
description.addAnnotation(annotation); |
92 |
newAcceptedTaxonNode.getTaxon().addDescription(description); |
|
93 |
if (CdmApplicationState.getCurrentAppConfig() instanceof CdmApplicationRemoteController) { |
|
94 |
CdmStore.getService(IDescriptionService.class).merge(description, true); |
|
95 |
} else { |
|
96 |
CdmStore.getService(IDescriptionService.class).saveOrUpdate(description); |
|
97 |
} |
|
98 |
|
|
99 | 90 |
CdmStore.getService(IDescriptionService.class).moveTaxonDescription(description.getUuid(), newAcceptedTaxonNode.getTaxon().getUuid()); |
100 | 91 |
monitor.worked(40); |
101 | 92 |
|
Also available in: Unified diff
fix #3276: avoid exception when moving unpersisted facts