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
.application
.CdmApplicationRemoteController
;
21 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationState
;
22 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
23 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
24 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
25 import eu
.etaxonomy
.cdm
.model
.common
.AnnotationType
;
26 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
27 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
29 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
30 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
31 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
32 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
33 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
36 * <p>MoveDescriptionToOtherTaxonOperation</p>
38 * @author a.kohlbecker
39 * @created Okt. 11, 2013
41 public class MoveDescriptionToOtherTaxonOperation
extends
42 AbstractPersistentPostOperation
{
44 private final TaxonNode newAcceptedTaxonNode
;
46 private final TaxonDescription description
;
49 * <p>Constructor for ChangeAcceptedTaxonToSynonymOperation.</p>
51 * @param label a {@link java.lang.String} object.
52 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
53 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
54 * @param description a {@link TaxonDescription} object.
55 * @param targetTaxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
56 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
58 public MoveDescriptionToOtherTaxonOperation(String label
,
59 IUndoContext undoContext
,
60 TaxonDescription description
,
61 TaxonNode targetTaxonNode
,
62 IPostOperationEnabled postOperationEnabled
,
63 IConversationEnabled conversationEnabled
,
64 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
65 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
, cdmEntitySessionEnabled
); // FIXME is this the right constructor ???
66 this.description
= description
;
67 this.newAcceptedTaxonNode
= targetTaxonNode
;
72 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
76 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
77 throws ExecutionException
{
82 String moveMessage
= String
.format("Description moved from %s", EditorUtil
.getActiveMultiPageTaxonEditor().getTaxon());
83 if(description
.isProtectedTitleCache()){
84 String separator
= "";
85 if(!StringUtils
.isBlank(description
.getTitleCache())){
88 description
.setTitleCache(description
.getTitleCache() + separator
+ moveMessage
, true);
90 Annotation annotation
= Annotation
.NewInstance(moveMessage
, Language
.getDefaultLanguage());
91 annotation
.setAnnotationType(AnnotationType
.TECHNICAL());
92 description
.addAnnotation(annotation
);
93 newAcceptedTaxonNode
.getTaxon().addDescription(description
);
94 if (CdmApplicationState
.getCurrentAppConfig() instanceof CdmApplicationRemoteController
) {
95 CdmStore
.getService(IDescriptionService
.class).merge(description
);
97 CdmStore
.getService(IDescriptionService
.class).saveOrUpdate(description
);
100 // CdmStore.getService(IDescriptionService.class).moveTaxonDescription(description.getUuid(), newAcceptedTaxonNode.getTaxon().getUuid());
103 return postExecute(description
);
107 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
111 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
112 throws ExecutionException
{
113 // TODO Auto-generated method stub
118 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
122 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
123 throws ExecutionException
{
124 // TODO Auto-generated method stub