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
.session
.ICdmEntitySessionEnabled
;
31 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
34 * <p>MoveDescriptionToOtherTaxonOperation</p>
36 * @author a.kohlbecker
37 * @created Okt. 11, 2013
39 public class MoveDescriptionToOtherTaxonOperation
extends
40 AbstractPersistentPostOperation
{
42 private final TaxonNode newAcceptedTaxonNode
;
44 private final TaxonDescription description
;
47 * <p>Constructor for ChangeAcceptedTaxonToSynonymOperation.</p>
49 * @param label a {@link java.lang.String} object.
50 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
51 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
52 * @param description a {@link TaxonDescription} object.
53 * @param targetTaxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
54 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
56 public MoveDescriptionToOtherTaxonOperation(String label
,
57 IUndoContext undoContext
,
58 TaxonDescription description
,
59 TaxonNode targetTaxonNode
,
60 IPostOperationEnabled postOperationEnabled
,
61 IConversationEnabled conversationEnabled
,
62 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
63 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
, cdmEntitySessionEnabled
); // FIXME is this the right constructor ???
64 this.description
= description
;
65 this.newAcceptedTaxonNode
= targetTaxonNode
;
70 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
74 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
75 throws ExecutionException
{
80 String moveMessage
= String
.format("Description moved from %s", EditorUtil
.getActiveMultiPageTaxonEditor().getTaxon());
81 if(description
.isProtectedTitleCache()){
82 String separator
= "";
83 if(!StringUtils
.isBlank(description
.getTitleCache())){
86 description
.setTitleCache(description
.getTitleCache() + separator
+ moveMessage
, true);
88 Annotation annotation
= Annotation
.NewInstance(moveMessage
, Language
.getDefaultLanguage());
89 annotation
.setAnnotationType(AnnotationType
.TECHNICAL());
90 description
.addAnnotation(annotation
);
91 newAcceptedTaxonNode
.getTaxon().addDescription(description
);
92 CdmStore
.getService(IDescriptionService
.class).merge(description
);
95 return postExecute(description
);
99 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
103 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
104 throws ExecutionException
{
105 // TODO Auto-generated method stub
110 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
114 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
115 throws ExecutionException
{
116 // TODO Auto-generated method stub