Project

General

Profile

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

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

    
36
	private final TermEditorInput definedEditorInput;
37

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

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

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

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

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

    
74
		return postExecute(new TermVocabularyDto(termVocabulary.getUuid(), termVocabulary.getRepresentations(), termVocabulary.getTermType()));
75
	}
76

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

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

    
89
}
(2-2/4)