ref #7502 Refactor column generation
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / GroupEditorInput.java
index 1ec68333958a42b6fe3c518f45d7e3b0ffe25a85..6f00ff03a0973ee19e9fdaa8af463247e0669ce2 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
 * Copyright (C) 2007 EDIT
 * European Distributed Institute of Taxonomy
 
 package eu.etaxonomy.taxeditor.bulkeditor.input;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
 import java.util.List;
+import java.util.UUID;
 
+import eu.etaxonomy.cdm.api.service.IAgentService;
 import eu.etaxonomy.cdm.api.service.IGroupService;
+import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
 import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.Group;
+import eu.etaxonomy.cdm.persistence.query.OrderHint;
+import eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
 import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.GroupCreator;
+import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.GroupNameComparator;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
@@ -41,41 +50,38 @@ public class GroupEditorInput extends AbstractBulkEditorInput<Group> {
                return instance;
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IEditorInput#getName()
-        */
-       @Override
+    @Override
+    protected List<String> getPropertyKeys_internal() {
+        List<String> propertyKeysInternal = new ArrayList<>();
+        return propertyKeysInternal;
+    }
+
+    @Override
        public String getName() {
                return BulkEditorInputType.GROUP.label;
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IEditorInput#getToolTipText()
-        */
-       @Override
-       public String getToolTipText() {
-               return getName();
-       }
-
        /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
         */
        @Override
        public Group save(Group entity) {
-           if(CdmStore.getCurrentSessionManager().isRemoting()) {
-               return CdmStore.getService(IGroupService.class).merge(entity) ;
-           } else {
-               CdmStore.getService(IGroupService.class).saveOrUpdate(entity);
-               return entity;
-           }
+           return CdmStore.getService(IGroupService.class).merge(entity, true).getMergedEntity();
+
        }
 
        /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
         */
        @Override
-       public boolean delete(Group entity) throws ReferencedObjectUndeletableException {
-               return CdmStore.getService(IGroupService.class).delete(entity) != null;
+       public boolean delete(Group entity, DeleteConfiguratorBase config) throws ReferencedObjectUndeletableException {
+               return CdmStore.getService(IGroupService.class).delete(entity.getUuid()) != null;
+       }
+
+       @Override
+       protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) {
+           //TODO there is no count method for groups
+           return CdmStore.getService(IGroupService.class).count(Group.class);
        }
 
        /* (non-Javadoc)
@@ -84,6 +90,7 @@ public class GroupEditorInput extends AbstractBulkEditorInput<Group> {
        @Override
        protected List<Group> listEntities(
                        IIdentifiableEntityServiceConfigurator configurator) {
+           configurator.setOrderHints(new OrderHint("name", SortOrder.ASCENDING).asList());
                return CdmStore.getSearchManager().findGroups(configurator);
        }
 
@@ -120,6 +127,18 @@ public class GroupEditorInput extends AbstractBulkEditorInput<Group> {
 
     }
 
+       @Override
+       protected Group loadEntity(UUID entityUuid) {
+               List<String> propertyPaths = Arrays.asList(new String[]{});
+               return HibernateProxyHelper.deproxy(CdmStore.getService(IAgentService.class).load(entityUuid, propertyPaths), Group.class);
+       }
+
+       @Override
+       public Comparator<Group> getTitleComparator(){
+        return new GroupNameComparator();
+    }
+
+
 
 
 }