Revision e1232fbf
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureTreeDropAdapter.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.featuretree.e4; |
10 | 10 |
|
11 |
import java.net.URI; |
|
12 | 11 |
import java.util.Arrays; |
13 | 12 |
import java.util.Collection; |
14 | 13 |
import java.util.Collections; |
... | ... | |
21 | 20 |
import org.eclipse.jface.viewers.ViewerDropAdapter; |
22 | 21 |
import org.eclipse.swt.dnd.TransferData; |
23 | 22 |
|
24 |
import eu.etaxonomy.cdm.api.service.IFeatureNodeService; |
|
25 | 23 |
import eu.etaxonomy.cdm.api.service.ITermService; |
26 | 24 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
27 | 25 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
... | ... | |
34 | 32 |
import eu.etaxonomy.taxeditor.editor.definedterm.e4.DefinedTermDropAdapterE4; |
35 | 33 |
import eu.etaxonomy.taxeditor.featuretree.FeatureNodeTransfer; |
36 | 34 |
import eu.etaxonomy.taxeditor.featuretree.e4.operation.AddFeatureOperation; |
35 |
import eu.etaxonomy.taxeditor.featuretree.e4.operation.AddOntologyTermOperation; |
|
37 | 36 |
import eu.etaxonomy.taxeditor.featuretree.e4.operation.MoveFeatureOperation; |
38 | 37 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
39 | 38 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
... | ... | |
151 | 150 |
return false; |
152 | 151 |
} |
153 | 152 |
else{ |
154 |
Feature feature = Feature.NewInstance(wrapper.getDescription(), wrapper.getLabel(), null); |
|
155 |
feature.setUri(URI.create(wrapper.getUri())); |
|
156 |
vocabulary.addTerm(feature); |
|
157 |
CdmStore.getService(IFeatureNodeService.class).createChildFeatureNode(target, feature); |
|
153 |
AddOntologyTermOperation operation = new AddOntologyTermOperation(wrapper, target, vocabulary, editor, editor); |
|
154 |
AbstractUtility.executeOperation(operation, sync); |
|
158 | 155 |
} |
159 | 156 |
} |
160 | 157 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/operation/AddOntologyTermOperation.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.featuretree.e4.operation; |
|
10 |
|
|
11 |
import java.net.URI; |
|
12 |
|
|
13 |
import org.eclipse.core.commands.ExecutionException; |
|
14 |
import org.eclipse.core.runtime.IAdaptable; |
|
15 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
16 |
import org.eclipse.core.runtime.IStatus; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.api.service.IFeatureNodeService; |
|
19 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
|
20 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
21 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
22 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
|
23 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
24 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
|
25 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; |
|
26 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
27 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
28 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.OntologyTermWrapper; |
|
29 |
|
|
30 |
/** |
|
31 |
* @author pplitzner |
|
32 |
* @since Apr 30, 2018 |
|
33 |
* |
|
34 |
*/ |
|
35 |
public class AddOntologyTermOperation extends AbstractPostOperation<FeatureNode> { |
|
36 |
|
|
37 |
private FeatureNode target; |
|
38 |
private OntologyTermWrapper wrapper; |
|
39 |
private TermVocabulary vocabulary; |
|
40 |
|
|
41 |
public AddOntologyTermOperation(OntologyTermWrapper wrapper, FeatureNode target, TermVocabulary vocabulary, |
|
42 |
IPostOperationEnabled postOperationEnabled, ICdmEntitySessionEnabled cdmEntitySessionEnabled) { |
|
43 |
super("Add ontology term", StoreUtil.getUndoContext(), target, postOperationEnabled, cdmEntitySessionEnabled); |
|
44 |
this.wrapper = wrapper; |
|
45 |
this.target = target; |
|
46 |
this.vocabulary = vocabulary; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { |
|
51 |
Feature feature = Feature.NewInstance(wrapper.getDescription(), wrapper.getLabel(), null); |
|
52 |
feature.setUri(URI.create(wrapper.getUri())); |
|
53 |
vocabulary.addTerm(feature); |
|
54 |
CdmStore.getService(IFeatureNodeService.class).createChildFeatureNode(target, feature); |
|
55 |
|
|
56 |
UpdateResult updateResult = CdmStore.getService(IFeatureNodeService.class).addChildFeatureNode(target.getUuid(), element.getUuid()); |
|
57 |
return postExecute(updateResult.getCdmEntity()); |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { |
|
62 |
return null; |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
|
66 |
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { |
|
67 |
return null; |
|
68 |
} |
|
69 |
|
|
70 |
} |
Also available in: Unified diff
Wrap dropping ontology terms into operation