2 * Copyright (C) 2009 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
.editor
.definedterm
.operation
;
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
;
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
;
34 public class CreateTermVocabularyOperation
extends AbstractPostTaxonOperation
{
36 private final TermEditorInput definedEditorInput
;
38 public CreateTermVocabularyOperation(String label
,
39 IUndoContext undoContext
,
40 TermEditorInput definedEditorInput
,
41 IPostOperationEnabled postOperationEnabled
) {
42 super(label
, undoContext
, postOperationEnabled
);
43 this.definedEditorInput
= definedEditorInput
;
47 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
48 throws ExecutionException
{
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(),
61 if (termVocabulary
== null){
63 TermVocabulary
.NewInstance(definedEditorInput
.getTermType(),
70 termVocabulary
= CdmStore
.getService(IVocabularyService
.class).save(termVocabulary
);
71 //FIXME: implement creation of term vocabularies
72 // definedEditorInput.getVocabularies().add(termVocabulary);
74 return postExecute(new TermVocabularyDto(termVocabulary
.getUuid(), termVocabulary
.getRepresentations(), termVocabulary
.getTermType(), termVocabulary
.getTitleCache(), termVocabulary
.isAllowDuplicates(), termVocabulary
.isOrderRelevant(), termVocabulary
.isFlat()));
78 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
79 throws ExecutionException
{
84 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
85 throws ExecutionException
{