Trim code
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 24 Aug 2015 05:10:32 +0000 (07:10 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 24 Aug 2015 08:39:19 +0000 (10:39 +0200)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorQuery.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorSearch.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/SearchManager.java

index 96b0cbed6fcb4ac6c33077779f453099abea96ce..e65805b9d516c14d23c75b36652cfe13cca4dfff 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* 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.
 */
@@ -24,10 +24,10 @@ import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
  * @version 1.0
  */
 public class BulkEditorQuery {
-               
-       private String searchString;
-       private Comparator<?> comparator;
-       private IIdentifiableEntityServiceConfigurator searchConfigurator;
+
+       private final String searchString;
+       private final Comparator<?> comparator;
+       private final IIdentifiableEntityServiceConfigurator searchConfigurator;
 
        public BulkEditorQuery (String searchString, Comparator comparator) {
                this.searchString = searchString;
@@ -38,30 +38,21 @@ public class BulkEditorQuery {
                searchConfigurator.setTitleSearchString(searchString);
                searchConfigurator.setMatchMode(null);
                searchConfigurator.setPropertyPaths(propertyPath);
-               
+
                if(searchString != null && searchString.trim().equals("*")){
                        searchConfigurator.setPageSize(1000);
                }
-               
+
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorQuery#getComparator()
-        */
        public Comparator getComparator() {
                return comparator;
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorQuery#getSearchString()
-        */
        public String getSearchString() {
                return searchString;
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorQuery#getSearchConfigurator()
-        */
        public IIdentifiableEntityServiceConfigurator getSearchConfigurator() {
                return searchConfigurator;
        }
index 238df83c828bdc028c24938e5f24a4889d8d44aa..552a9d0dfa46af09e0ff38a26280854d3fd59c8e 100644 (file)
@@ -148,18 +148,18 @@ public class BulkEditorSearch {
        }
 
 
-       /*
+       /**
         * Shows the results of the search.
         */
        private void updateEditorInput() {
 
                String searchString = getSearchString().trim();
 
-               if(DEFAULT_TEXT.equals(searchString) || CdmUtils.isEmpty(searchString)){
+               if(DEFAULT_TEXT.equals(searchString) || CdmUtils.isBlank(searchString)){
                        return;
                }
 
-               BulkEditorQuery query = new BulkEditorQuery(getSearchString(), getComparator());
+               BulkEditorQuery query = new BulkEditorQuery(searchString, getComparator());
                editor.performSearch(query);
        }
 
index 2a739544f0deeab50984dc606b4db9d09ca8d4d0..bae14730a3e804fb7ad11e1ade91c9520d45ba64 100644 (file)
@@ -1,23 +1,18 @@
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* 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.bulkeditor.input;
 
-import java.util.Arrays;
 import java.util.List;
-import java.util.UUID;
-
-import org.eclipse.core.commands.ExecutionException;
 
 import eu.etaxonomy.cdm.api.service.IAgentService;
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
-import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
 import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
 import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.cdm.model.agent.Person;
@@ -29,7 +24,6 @@ import eu.etaxonomy.cdm.strategy.merge.MergeException;
 import eu.etaxonomy.cdm.strategy.merge.MergeMode;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
 import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
-import eu.etaxonomy.taxeditor.bulkeditor.handler.MergeGroupHandler;
 import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.AgentCreator;
 import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.IdentifiableEntitySortProvider;
 import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
@@ -38,62 +32,32 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
 
 
 /**
- * <p>AgentEditorInput class.</p>
- *
  * @author p.ciardelli
  * @created 25.06.2009
  * @version 1.0
  */
 public class AgentEditorInput extends AbstractBulkEditorInput<TeamOrPersonBase> {
 
-       /**
-        * 
-        */
        private static final long serialVersionUID = 3387950621617078479L;
 
-       /** Constant <code>ID="bulkeditor.input.author"</code> */
        public static final String ID = "bulkeditor.input.author";
-       
+
        private static AgentEditorInput instance;
 
-       /**
-        * <p>getID</p>
-        *
-        * @return the iD
-        */
        public static String getID() {
                return ID;
        }
-       
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IEditorInput#getName()
-        */
-       /**
-        * <p>getName</p>
-        *
-        * @return a {@link java.lang.String} object.
-        */
-       public String getName() {
+
+       @Override
+    public String getName() {
                return BulkEditorInputType.AGENT.label;
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IEditorInput#getToolTipText()
-        */
-       /**
-        * <p>getToolTipText</p>
-        *
-        * @return a {@link java.lang.String} object.
-        */
-       public String getToolTipText() {
+       @Override
+    public String getToolTipText() {
                return getName();
        }
 
-       /**
-        * <p>Getter for the field <code>instance</code>.</p>
-        *
-        * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
-        */
        public static AbstractBulkEditorInput getInstance() {
                if (instance == null) {
                        instance = new AgentEditorInput();
@@ -101,24 +65,18 @@ public class AgentEditorInput extends AbstractBulkEditorInput<TeamOrPersonBase>
                return instance;
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled()
-        */
        /** {@inheritDoc} */
        @Override
        public boolean isMergingEnabled() {
                return true;
        }
-       
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled()
-        */
+
        /** {@inheritDoc} */
        @Override
        public boolean isConvertingEnabled() {
                return true;
        }
-       
+
        /** {@inheritDoc} */
        @Override
     public boolean merge(TeamOrPersonBase entity, TeamOrPersonBase mergeTarget) {
@@ -126,7 +84,7 @@ public class AgentEditorInput extends AbstractBulkEditorInput<TeamOrPersonBase>
                        try {
                                IMergeStrategy strategy = DefaultMergeStrategy.NewInstance(Person.class);
                                strategy.setMergeMode("institutionalMemberships", MergeMode.FIRST);
-                               CdmStore.getCommonService().merge((IMergable)mergeTarget, (IMergable)entity, strategy);                         
+                               CdmStore.getCommonService().merge((IMergable)mergeTarget, (IMergable)entity, strategy);
                        } catch (MergeException e) {
                                MessagingUtils.errorDialog("Bulk Editor Merge Error",
                                                this,
@@ -144,42 +102,36 @@ public class AgentEditorInput extends AbstractBulkEditorInput<TeamOrPersonBase>
        public List<TeamOrPersonBase> listEntities(IIdentifiableEntityServiceConfigurator configurator) {
                return CdmStore.getSearchManager().findTeamOrPersons(configurator);
        }
-       
-       /** {@inheritDoc} 
+
+       /** {@inheritDoc}
        @Override
        public AgentBase loadEntity(UUID uuid) {
-               List<String> propertyPaths = Arrays.asList(new String[]{}); 
+               List<String> propertyPaths = Arrays.asList(new String[]{});
                return CdmStore.getService(IAgentService.class).load(uuid, propertyPaths);
        }*/
 
-       
+
        public boolean delete(AgentBase entity) throws ReferencedObjectUndeletableException  {
-               
-                       return CdmStore.getService(IAgentService.class).delete(entity) != null;                 
-               
+
+                       return CdmStore.getService(IAgentService.class).delete(entity) != null;
+
        }
 
        /** {@inheritDoc} */
        public boolean save(AgentBase entity) {
-               
+
                return CdmStore.getService(IAgentService.class).saveOrUpdate(entity) != null;
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
-        */
        @Override
        public List<IBulkEditorSortProvider<TeamOrPersonBase>> getSortProviders() {
                List<IBulkEditorSortProvider<TeamOrPersonBase>> sortProviders = super.getSortProviders();
-               
+
                sortProviders.add(0, new IdentifiableEntitySortProvider<TeamOrPersonBase>());
-               
+
                return sortProviders;
        }
-       
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
-        */
+
        @Override
        protected IEntityCreator<TeamOrPersonBase> createEntityCreator() {
                return new AgentCreator();
index 0eb45b3dd42c8ea7d90f6e83f83c7f773928d010..cf673e87a62843ae6156c4fdc7f116cb8e987362 100644 (file)
@@ -59,12 +59,6 @@ public class SearchManager {
        // TODO make this configurable via preferences
        private static final int MAX_RESULTS_BEFORE_WARNING = 500;
 
-       /**
-        * <p>findNames</p>
-        *
-        * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object.
-        * @return a {@link java.util.List} object.
-        */
        public List<TaxonNameBase> findNames(IIdentifiableEntityServiceConfigurator configurator){
                if(checkLargeResult(CdmStore.getService(INameService.class).countByTitle(configurator))){
                        return CdmStore.getService(INameService.class).findByTitle(configurator).getRecords();
@@ -86,31 +80,13 @@ public class SearchManager {
                                relationships.add((NameRelationship) relationship);
                        }
                }
-
-
                return relationships;
-
        }
 
-       /**
-        * <p>findTaxaAndNames</p>
-        *
-        * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator} object.
-        * @return a {@link java.util.List} object.
-        */
        public List<UuidAndTitleCache<IdentifiableEntity>> findTaxaAndNames(IFindTaxaAndNamesConfigurator<TaxonBase> configurator){
                return CdmStore.getService(ITaxonService.class).findTaxaAndNamesForEditor(configurator);
        }
 
-
-
-
-       /**
-        * <p>findReferences</p>
-        *
-        * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object.
-        * @return a {@link java.util.List} object.
-        */
        public List<Reference> findReferences(IIdentifiableEntityServiceConfigurator configurator){
                if(checkLargeResult(CdmStore.getService(IReferenceService.class).countByTitle(configurator))){
                        return  CdmStore.getService(IReferenceService.class).findByTitle(configurator).getRecords();
@@ -118,13 +94,6 @@ public class SearchManager {
                return NO_RESULTS;
        }
 
-
-       /**
-        * <p>findAgents</p>
-        *
-        * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object.
-        * @return a {@link java.util.List} object.
-        */
        public List<AgentBase> findAgents(IIdentifiableEntityServiceConfigurator configurator){
                if(checkLargeResult(CdmStore.getService(IAgentService.class).countByTitle(configurator))){
                        return CdmStore.getService(IAgentService.class).findByTitle(configurator).getRecords();
@@ -132,12 +101,6 @@ public class SearchManager {
                return NO_RESULTS;
        }
 
-       /**
-        * <p>findTeamOrPersons</p>
-        *
-        * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object.
-        * @return a {@link java.util.List} object.
-        */
        @SuppressWarnings("unchecked")
        public List<TeamOrPersonBase> findTeamOrPersons(IIdentifiableEntityServiceConfigurator configurator){
                configurator.setClazz(TeamOrPersonBase.class);
@@ -214,10 +177,6 @@ public class SearchManager {
        }
 
 
-       /**
-        * @param count
-        * @return
-        */
        private boolean checkLargeResult(int count) {
                if(count > MAX_RESULTS_BEFORE_WARNING){
                        return MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Large result expected",
@@ -228,11 +187,6 @@ public class SearchManager {
                }
        }
 
-       /**
-        *
-        * @param configurator
-        * @return
-        */
        private String sqlizeTitleSearchString(IIdentifiableEntityServiceConfigurator configurator){
                return configurator.getTitleSearchString().replace(WILDCARD, "%");
        }