77f0373462feb490517dfda4af1a25c4ee2170cf
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / key / polytomous / operation / RemotingCreatePolytomousKeyNodeOperation.java
1 // $Id$
2 /**
3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10 package eu.etaxonomy.taxeditor.editor.key.polytomous.operation;
11
12 import org.eclipse.core.runtime.IAdaptable;
13 import org.eclipse.core.runtime.IProgressMonitor;
14
15 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
16 import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
17 import eu.etaxonomy.cdm.model.common.CdmBase;
18 import eu.etaxonomy.cdm.model.common.LanguageString;
19 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
20 import eu.etaxonomy.taxeditor.operation.RemotingCdmMergeOperation;
21 import eu.etaxonomy.taxeditor.store.CdmStore;
22
23 /**
24 * @author cmathew
25 * @date 21 Jul 2015
26 *
27 */
28 public class RemotingCreatePolytomousKeyNodeOperation extends RemotingCdmMergeOperation {
29
30 private final PolytomousKeyNode parentNode;
31
32 private final static String LABEL = "Create new polytomous key node";
33
34 public RemotingCreatePolytomousKeyNodeOperation(Object source,
35 boolean async,
36 PolytomousKeyNode parentNode){
37 super(LABEL, Action.Create, source, async);
38 this.parentNode = parentNode;
39 }
40 /* (non-Javadoc)
41 * @see eu.etaxonomy.taxeditor.operation.RemotingCdmMergeOperation#doMergeExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
42 */
43 @Override
44 protected CdmBase doMergeExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
45 PolytomousKeyNode childNode = PolytomousKeyNode.NewInstance();
46 parentNode.addChild(childNode);
47 childNode.getModifyingText().put(CdmStore.getDefaultLanguage(),LanguageString.NewInstance("",CdmStore.getDefaultLanguage()));
48 return CdmApplicationState.getCurrentAppConfig().getPolytomousKeyNodeService().merge(childNode);
49 }
50
51 }