Project

General

Profile

Download (2.48 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 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.editor.definedterm.operation;
10

    
11
import org.eclipse.core.commands.ExecutionException;
12
import org.eclipse.core.commands.operations.IUndoContext;
13
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.core.runtime.IStatus;
16

    
17
import eu.etaxonomy.cdm.api.service.ITermService;
18
import eu.etaxonomy.cdm.api.service.IVocabularyService;
19
import eu.etaxonomy.cdm.persistence.dto.AbstractTermDto;
20
import eu.etaxonomy.cdm.persistence.dto.TermDto;
21
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
22
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
23
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
24
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
25
import eu.etaxonomy.taxeditor.store.CdmStore;
26

    
27
/**
28
 * @author l.morris
29
 * @date 21 Dec 2011
30
 *
31
 */
32
public class CreateDefinedTermOperation extends AbstractPostOperation {
33

    
34
	private final AbstractTermDto parent;
35
	private final TermEditorInput definedTermInput;
36
    private boolean addTermAsKindOf;
37

    
38

    
39
	public CreateDefinedTermOperation(String label,
40
			IUndoContext undoContext,
41
			AbstractTermDto parent,
42
			TermEditorInput definedTermInput,
43
			IPostOperationEnabled postOperationEnabled, boolean addTermAsKindOf) {
44
		super(label, undoContext, null, postOperationEnabled);
45
		this.parent = parent;
46
		this.definedTermInput = definedTermInput;
47
		this.addTermAsKindOf = addTermAsKindOf;
48
	}
49

    
50
	@Override
51
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
52
			throws ExecutionException {
53
	    if(parent instanceof TermDto){
54
	        CdmStore.getService(ITermService.class).addNewTerm(definedTermInput.getTermType(), parent.getUuid(), addTermAsKindOf);
55
	    }
56
	    else if(parent instanceof TermVocabularyDto){
57
	        CdmStore.getService(IVocabularyService.class).addNewTerm(definedTermInput.getTermType(), parent.getUuid());
58
	    }
59
		return postExecute(parent);
60
	}
61

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

    
68
	@Override
69
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
70
			throws ExecutionException {
71
		return null;
72
	}
73

    
74
}
(1-1/4)