#5054 Add save to make sure term is refreshed
authorCherian Mathew <c.mathew@bgbm.org>
Tue, 7 Jul 2015 10:55:31 +0000 (12:55 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Tue, 7 Jul 2015 10:55:31 +0000 (12:55 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/CreateDefinedTermOperation.java

index b96cacdc0e3799702e0e3e5a416485751b8a5873..7d0439b6dd08e978d02f40e4a0ed4a3ce26ac404 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$\r
 /**\r
 * Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
 * http://www.e-taxonomy.eu\r
-* \r
+*\r
 * The contents of this file are subject to the Mozilla Public License Version 1.1\r
 * See LICENSE.TXT at the top of this package for the full license terms.\r
 */\r
@@ -23,6 +23,7 @@ import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;\r
 import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;\r
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
+import eu.etaxonomy.taxeditor.store.CdmStore;\r
 import eu.etaxonomy.taxeditor.store.StoreUtil;\r
 \r
 /**\r
@@ -32,10 +33,10 @@ import eu.etaxonomy.taxeditor.store.StoreUtil;
  */\r
 public class CreateDefinedTermOperation extends AbstractPostTaxonOperation {\r
 \r
-       \r
 \r
-       private TermBase parentTermBase;\r
-       private TermEditorInput definedTermInput;\r
+\r
+       private final TermBase parentTermBase;\r
+       private final TermEditorInput definedTermInput;\r
 \r
        /**\r
         * @param label\r
@@ -43,7 +44,7 @@ public class CreateDefinedTermOperation extends AbstractPostTaxonOperation {
         * @param postOperationEnabled\r
         */\r
        public CreateDefinedTermOperation(String label,\r
-                       IUndoContext undoContext, \r
+                       IUndoContext undoContext,\r
                        TermBase termBase,\r
                        TermEditorInput definedTermInput,\r
                        IPostOperationEnabled postOperationEnabled) {\r
@@ -58,27 +59,28 @@ public class CreateDefinedTermOperation extends AbstractPostTaxonOperation {
        @Override\r
        public IStatus execute(IProgressMonitor monitor, IAdaptable info)\r
                        throws ExecutionException {\r
-               \r
+\r
                DefinedTermBase newTerm = definedTermInput.getTermType().getEmptyDefinedTermBase();\r
                if (newTerm == null) {\r
-                       IStatus status = \r
-                                       new Status(IStatus.CANCEL, \r
-                                                       StoreUtil.getPluginId(), \r
+                       IStatus status =\r
+                                       new Status(IStatus.CANCEL,\r
+                                                       StoreUtil.getPluginId(),\r
                                                        "Creation of term corresponding to type '" + definedTermInput.getTermType().getMessage() + "' is not yet supported");\r
                        MessagingUtils.warningDialog("Cannot create term", newTerm, status);\r
                        return status;\r
                }\r
-               \r
+               newTerm = CdmStore.getCurrentApplicationConfiguration().getTermService().save(newTerm);\r
+\r
                if (parentTermBase instanceof TermVocabulary){\r
                        TermVocabulary vocabulary = (TermVocabulary) parentTermBase;\r
                        vocabulary.addTerm(newTerm);\r
                } else if (parentTermBase instanceof DefinedTermBase) {\r
-                       DefinedTermBase parent = (DefinedTermBase) parentTermBase;                      \r
-                       parent.addIncludes(newTerm);                    \r
+                       DefinedTermBase parent = (DefinedTermBase) parentTermBase;\r
+                       parent.addIncludes(newTerm);\r
                        TermVocabulary vocabulary = parent.getVocabulary();\r
                        vocabulary.addTerm(newTerm);\r
                }\r
-               \r
+\r
                return postExecute(newTerm);\r
        }\r
 \r