3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.editor
.view
.descriptive
.operation
;
13 import org
.apache
.commons
.lang
.StringUtils
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
16 import org
.eclipse
.core
.runtime
.IAdaptable
;
17 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
18 import org
.eclipse
.core
.runtime
.IStatus
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
21 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
22 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
23 import eu
.etaxonomy
.cdm
.model
.common
.AnnotationType
;
24 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
25 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
27 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
28 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
29 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
30 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
33 * <p>MoveDescriptionToOtherTaxonOperation</p>
35 * @author a.kohlbecker
36 * @created Okt. 11, 2013
38 public class MoveDescriptionToOtherTaxonOperation
extends
39 AbstractPersistentPostOperation
{
41 private TaxonNode newAcceptedTaxonNode
;
43 private TaxonDescription description
;
46 * <p>Constructor for ChangeAcceptedTaxonToSynonymOperation.</p>
48 * @param label a {@link java.lang.String} object.
49 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
50 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
51 * @param description a {@link TaxonDescription} object.
52 * @param targetTaxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
53 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
55 public MoveDescriptionToOtherTaxonOperation(String label
,
56 IUndoContext undoContext
, TaxonDescription description
, TaxonNode targetTaxonNode
,
57 IPostOperationEnabled postOperationEnabled
, IConversationEnabled conversationEnabled
) {
58 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
); // FIXME is this the right constructor ???
59 this.description
= description
;
60 this.newAcceptedTaxonNode
= targetTaxonNode
;
65 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
69 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
70 throws ExecutionException
{
75 String moveMessage
= String
.format("Description moved from %s", EditorUtil
.getActiveMultiPageTaxonEditor().getTaxon());
76 if(description
.isProtectedTitleCache()){
77 String separator
= "";
78 if(!StringUtils
.isBlank(description
.getTitleCache())){
81 description
.setTitleCache(description
.getTitleCache() + separator
+ moveMessage
, true);
83 Annotation annotation
= Annotation
.NewInstance(moveMessage
, Language
.getDefaultLanguage());
84 annotation
.setAnnotationType(AnnotationType
.TECHNICAL());
85 description
.addAnnotation(annotation
);
86 newAcceptedTaxonNode
.getTaxon().addDescription(description
);
87 CdmStore
.getService(IDescriptionService
.class).saveOrUpdate(description
);
90 return postExecute(description
);
94 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
98 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
99 throws ExecutionException
{
100 // TODO Auto-generated method stub
105 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
109 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
110 throws ExecutionException
{
111 // TODO Auto-generated method stub