2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.featuretree
.e4
.operation
;
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
;
18 import eu
.etaxonomy
.cdm
.api
.service
.IFeatureNodeService
;
19 import eu
.etaxonomy
.cdm
.api
.service
.UpdateResult
;
20 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
21 import eu
.etaxonomy
.cdm
.model
.term
.FeatureNode
;
22 import eu
.etaxonomy
.cdm
.model
.term
.TermVocabulary
;
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
;
35 public class AddOntologyTermOperation
extends AbstractPostOperation
<FeatureNode
> {
37 private FeatureNode target
;
38 private OntologyTermWrapper wrapper
;
39 private TermVocabulary vocabulary
;
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
;
46 this.vocabulary
= vocabulary
;
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 CdmStore
.getService(IFeatureNodeService
.class).createChildFeatureNode(target
.getUuid(), feature
, vocabulary
.getUuid());
55 UpdateResult updateResult
= CdmStore
.getService(IFeatureNodeService
.class).addChildFeatureNode(target
.getUuid(), element
.getUuid());
56 return postExecute(updateResult
.getCdmEntity());
60 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
65 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{