cleanup
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / key / polytomous / PolytomousKeyEditorInput.java
index a6555ce7d01e3f5ff8266f33ac90ed98995984f6..e1b8578389013a5883ca5e35792b888957f178e1 100644 (file)
@@ -1,10 +1,18 @@
 /**
- *
- */
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
 package eu.etaxonomy.taxeditor.editor.key.polytomous;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
@@ -15,30 +23,21 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
  * @author n.hoffmann
- *
  */
 public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<PolytomousKey> {
 
-    private final String name;
-    private final UUID keyUuid;
     private PolytomousKey key;
 
 
     protected PolytomousKeyEditorInput(ConversationHolder conversation,
             UUID polytomousKeyUuid) {
         super(conversation);
-        this.keyUuid = polytomousKeyUuid;
-        this.key = CdmStore.getService(IPolytomousKeyService.class).load(polytomousKeyUuid, null);
-        this.name = key.getTitleCache();
+        List<String> propertyPath = new ArrayList<>();
+        propertyPath.add("root");
+        propertyPath.add("root.*");
+        this.key = CdmStore.getService(IPolytomousKeyService.class).load(polytomousKeyUuid, propertyPath);
     }
 
-//    public PolytomousKeyEditorInput(UUID polytomousKeyUuid, String name) {
-//        super(CdmStore.createConversation());
-//        this.keyUuid = polytomousKeyUuid;
-//        this.name = name;
-//    }
-
-
     public static PolytomousKeyEditorInput NewInstance(UUID polytomousKeyUuid) throws Exception{
         try{
             ConversationHolder conversation = CdmStore.createConversation();
@@ -48,23 +47,11 @@ public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<
         }
     }
 
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getName()
-     */
-    @Override
-    public String getName() {
-        return name;
-    }
-
     @Override
     public PolytomousKey getKey() {
         return key;
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
     @Override
     public boolean equals(Object object) {
         if (object instanceof PolytomousKeyEditorInput
@@ -76,20 +63,24 @@ public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<
         return super.equals(object);
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
-     */
     @Override
     public  List<PolytomousKey> getRootEntities() {
         return Arrays.asList(key);
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
-     */
     @Override
     public void merge() {
-        key = CdmStore.getService(IPolytomousKeyService.class).merge(key);
+       key = CdmStore.getService(IPolytomousKeyService.class).merge(key,true).getMergedEntity();
     }
 
-}
+    @Override
+    public Map<Object, List<String>> getPropertyPathsMap() {
+        Map<Object,List<String>> propertyPathsMap = new HashMap<>();
+
+        List<String> polytomousKeyNodePropertyPaths = Arrays.asList(new String[] {
+                "statement" //$NON-NLS-1$
+        });
+         propertyPathsMap.put("children", polytomousKeyNodePropertyPaths); //$NON-NLS-1$
+         return propertyPathsMap;
+    }
+}
\ No newline at end of file