Project

General

Profile

Download (2.89 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.IVocabularyService;
18
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
19
import eu.etaxonomy.cdm.model.common.OrderedTermBase;
20
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
21
import eu.etaxonomy.cdm.model.common.TermType;
22
import eu.etaxonomy.cdm.model.common.TermVocabulary;
23
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
24
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
25
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
26
import eu.etaxonomy.taxeditor.store.CdmStore;
27

    
28
/**
29
 * @author l.morris
30
 * @date 21 Dec 2011
31
 *
32
 */
33
public class CreateTermVocabularyOperation extends AbstractPostTaxonOperation {
34

    
35
	private final TermEditorInput definedEditorInput;
36

    
37
	public CreateTermVocabularyOperation(String label,
38
			IUndoContext undoContext,
39
			TermEditorInput definedEditorInput,
40
			IPostOperationEnabled postOperationEnabled) {
41
		super(label, undoContext, postOperationEnabled);
42
		this.definedEditorInput = definedEditorInput;
43
	}
44

    
45
	@Override
46
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
47
			throws ExecutionException {
48

    
49
	   TermType type= definedEditorInput.getTermType();
50
	   DefinedTermBase test = type.getEmptyDefinedTermBase();
51
	   TermVocabulary termVocabulary = null;
52
	   if (test instanceof OrderedTermBase){
53
	      termVocabulary = OrderedTermVocabulary.NewInstance(definedEditorInput.getTermType(),
54
                       null,
55
                       "Untitled",
56
                       null,
57
                       null);
58
	   }
59

    
60
	   if (termVocabulary == null){
61
	    termVocabulary =
62
                TermVocabulary.NewInstance(definedEditorInput.getTermType(),
63
                    null,
64
                    "Untitled",
65
                    null,
66
                    null);
67
	   }
68

    
69
		termVocabulary = CdmStore.getService(IVocabularyService.class).save(termVocabulary);
70
		//FIXME: implement creation of term vocabularies
71
//		definedEditorInput.getVocabularies().add(termVocabulary);
72

    
73
		return postExecute(termVocabulary);
74
	}
75

    
76
	@Override
77
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
78
			throws ExecutionException {
79
		return null;
80
	}
81

    
82
	@Override
83
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
84
			throws ExecutionException {
85
		return null;
86
	}
87

    
88
}
(2-2/4)