Project

General

Profile

Download (2.65 KB) Statistics
| Branch: | Tag: | Revision:
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.description.Feature;
21
import eu.etaxonomy.cdm.model.term.TermNode;
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;
29

    
30
/**
31
 * @author pplitzner
32
 * @since Apr 30, 2018
33
 *
34
 */
35
public class AddOntologyTermOperation extends AbstractPostOperation<TermNode> {
36

    
37
    private TermNode target;
38
    private OntologyTermWrapper wrapper;
39
    private TermVocabulary vocabulary;
40

    
41
    public AddOntologyTermOperation(OntologyTermWrapper wrapper, TermNode 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
        CdmStore.getService(IFeatureNodeService.class).createChildFeatureNode(target.getUuid(), feature, vocabulary.getUuid());
54

    
55
        UpdateResult updateResult = CdmStore.getService(IFeatureNodeService.class).addChildFeatureNode(target.getUuid(), element.getUuid());
56
        return postExecute(updateResult.getCdmEntity());
57
    }
58

    
59
    @Override
60
    public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
61
        return null;
62
    }
63

    
64
    @Override
65
    public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
66
        return null;
67
    }
68

    
69
}
(2-2/6)