Project

General

Profile

« Previous | Next » 

Revision fe08ca2d

Added by Patrick Plitzner over 5 years ago

ref #7887 Use vocabulary service for term creation directly

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/CreateDefinedTermOperation.java
15 15
import org.eclipse.core.runtime.IStatus;
16 16

  
17 17
import eu.etaxonomy.cdm.api.service.ITermService;
18
import eu.etaxonomy.cdm.api.service.IVocabularyService;
19
import eu.etaxonomy.cdm.persistence.dto.AbstractTermDto;
18 20
import eu.etaxonomy.cdm.persistence.dto.TermDto;
21
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
19 22
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
20 23
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
21 24
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
......
28 31
 */
29 32
public class CreateDefinedTermOperation extends AbstractPostOperation {
30 33

  
31
	private final TermDto parent;
34
	private final AbstractTermDto parent;
32 35
	private final TermEditorInput definedTermInput;
33 36
    private boolean addTermAsKindOf;
34 37

  
35 38

  
36 39
	public CreateDefinedTermOperation(String label,
37 40
			IUndoContext undoContext,
38
			TermDto parent,
41
			AbstractTermDto parent,
39 42
			TermEditorInput definedTermInput,
40 43
			IPostOperationEnabled postOperationEnabled, boolean addTermAsKindOf) {
41 44
		super(label, undoContext, null, postOperationEnabled);
......
47 50
	@Override
48 51
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
49 52
			throws ExecutionException {
50
	    CdmStore.getService(ITermService.class).addNewTerm(definedTermInput.getTermType(), parent.getUuid(), addTermAsKindOf);
51
//
52
//		//FIXME: Implement adding new terms to vocabularies
53
////		if (parentTermBase instanceof TermVocabulary){
54
////			TermVocabulary vocabulary = (TermVocabulary) parentTermBase;
55
////			vocabulary.addTerm(newTerm);
56
////		} else
57
//		DefinedTermBase parentTerm = CdmStore.getService(ITermService.class).load(parent.getUuid());
58
//		TermVocabulary vocabulary = parentTerm.getVocabulary();
59
//		parentTerm.addIncludes(newTerm);
60
////        parent.getIncludes().add(new TermDto(newTerm.getUuid(), null, parentTerm.getUuid(), vocabulary.getUuid(), null));
61
//
62
////			DefinedTermBase parent = (DefinedTermBase) parentTermBase;
63
////			if(addTermAsKindOf){
64
////			    parent.addGeneralizationOf(newTerm);
65
////			}
66
////			else{
67
////			    parent.addIncludes(newTerm);
68
////			}
69
//			vocabulary.addTerm(newTerm);
70
////		}
71

  
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
	    }
72 59
		return postExecute(null);
73 60
	}
74 61

  
75 62
	@Override
76 63
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
77 64
			throws ExecutionException {
78
		// TODO Auto-generated method stub
79 65
		return null;
80 66
	}
81 67

  
82 68
	@Override
83 69
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
84 70
			throws ExecutionException {
85
		// TODO Auto-generated method stub
86 71
		return null;
87 72
	}
88 73

  

Also available in: Unified diff