performed javacscript:fix and worked on documentation
[taxeditor.git] / taxeditor-bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / AbstractBulkEditorInput.java
index 56dfe5a894aa08b3ecc3d8f81b6f175a5962d90e..5f9a4870661b1690af47896da9b29d7ad201cc63 100644 (file)
-// $Id$\r
-/**\r
-* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy \r
-* http://www.e-taxonomy.eu\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
-package eu.etaxonomy.taxeditor.bulkeditor.input;\r
-\r
-import java.beans.PropertyChangeSupport;\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
-import java.util.List;\r
-import java.util.UUID;\r
-\r
-import org.apache.log4j.Logger;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.eclipse.ui.IEditorInput;\r
-import org.eclipse.ui.IPersistableElement;\r
-\r
-import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;\r
-import eu.etaxonomy.cdm.model.common.IdentifiableEntity;\r
-import eu.etaxonomy.cdm.model.common.MarkerType;\r
-import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
-import eu.etaxonomy.cdm.strategy.merge.MergeException;\r
-import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService;\r
-import eu.etaxonomy.taxeditor.annotatedlineeditor.IdentifiableEntityComparator;\r
-import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorQuery;\r
-import eu.etaxonomy.taxeditor.bulkeditor.command.BulkEditorInputTypeValues.BulkEditorInputType;\r
-import eu.etaxonomy.taxeditor.store.CdmStore;\r
-\r
-/**\r
- * @author p.ciardelli\r
- * @created 25.06.2009\r
- * @version 1.0\r
- * @param <T>\r
- */\r
-public abstract class AbstractBulkEditorInput<T> extends PropertyChangeSupport implements IEditorInput, IEntityPersistenceService {\r
-       private static final Logger logger = Logger\r
-                       .getLogger(AbstractBulkEditorInput.class);\r
-       /**\r
-        * \r
-        */\r
-       private static final long serialVersionUID = 416414530232743735L;\r
-       private String mode;\r
-       private UUID entityUuid;\r
-\r
-       /**\r
-        * @param sourceBean\r
-        */\r
-       public AbstractBulkEditorInput(Object sourceBean) {\r
-               super(sourceBean);\r
-       }\r
-       \r
-       public static final String QUERY_CHANGED = "query_changed";\r
-       \r
-       static public AbstractBulkEditorInput NewInstance(BulkEditorInputType inputType) {\r
-               return BulkEditorInputType.getInput(inputType);\r
-       }\r
-       \r
-       public static AbstractBulkEditorInput NewInstance(IdentifiableEntity entity) {\r
-               \r
-               \r
-               BulkEditorInputType inputType = BulkEditorInputType.getByType(entity.getClass());\r
-               \r
-               AbstractBulkEditorInput editorInput = NewInstance(inputType);\r
-               \r
-               editorInput.setEntityUuid(entity.getUuid());\r
-               \r
-               return editorInput;\r
-       }\r
-       \r
-       /**\r
-        * Queries the service for entities that match the criterias defined in the given \r
-        * search configurator\r
-        * \r
-        * @param configurator\r
-        * @return\r
-        */\r
-       public List<T> listEntities(){\r
-               if(getEntityUuid() != null){\r
-                       List<T> entityList = new ArrayList<T>();\r
-                       T entity = loadEntity(getEntityUuid());\r
-                       entityList.add(entity);\r
-                       return entityList;\r
-               }\r
-               \r
-               if(query != null){\r
-                       \r
-                       String queryString = query.getSearchString();\r
-                       IIdentifiableEntityServiceConfigurator configurator = query.getSearchConfigurator();\r
-                       Comparator queryComparator = (query.getComparator() != null) ? query.getComparator() : new IdentifiableEntityComparator();\r
-                       \r
-                       List<T> entityList = listEntities(configurator);\r
-                       \r
-                       Collections.sort(entityList, queryComparator);                  \r
-                       \r
-                       // reset query\r
-                       setQuery(null);\r
-                       \r
-                       return entityList;\r
-               }\r
-               return null;\r
-       }\r
-       \r
-       protected abstract List<T> listEntities(IIdentifiableEntityServiceConfigurator configurator);\r
-       \r
-       protected abstract T loadEntity(UUID entityUuid);\r
-\r
-       private void setEntityUuid(UUID entityUuid){\r
-               this.entityUuid = entityUuid;\r
-       }\r
-       \r
-       public UUID getEntityUuid() {\r
-               return entityUuid;\r
-       }\r
-\r
-       private IBulkEditorQuery query;\r
-                       \r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.ui.IEditorInput#exists()\r
-        */\r
-       public boolean exists() {\r
-               // TODO Auto-generated method stub\r
-               return false;\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.ui.IEditorInput#getImageDescriptor()\r
-        */\r
-       public ImageDescriptor getImageDescriptor() {\r
-               // TODO Auto-generated method stub\r
-               return null;\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.ui.IEditorInput#getPersistable()\r
-        */\r
-       public IPersistableElement getPersistable() {\r
-               return null;\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)\r
-        */\r
-       @SuppressWarnings("unchecked")\r
-       public Object getAdapter(Class adapter) {\r
-               return null;\r
-       }\r
-\r
-       /**\r
-        * @param bulkEditorQuery\r
-        */\r
-       public void setQuery(IBulkEditorQuery bulkEditorQuery) {\r
-                               \r
-               this.query = bulkEditorQuery;\r
-               \r
-               if (query != null) {\r
-                       firePropertyChange(QUERY_CHANGED, null, null);\r
-               }\r
-       }\r
-       \r
-       public IBulkEditorQuery getQuery() {\r
-               return query;\r
-       }\r
-       \r
-       public boolean isMergingEnabled() {\r
-               return false;\r
-       }\r
-\r
-       /**\r
-        * @param markerType\r
-        * @return\r
-        */\r
-       public boolean isMarkerTypeEditingEnabled(MarkerType markerType) {\r
-               return false;\r
-       }\r
-       \r
-       public boolean isSingleEntityMode(){\r
-               return getEntityUuid() != null;\r
-       }\r
-       \r
-       /*\r
-        * (non-Javadoc)\r
-        * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#merge(eu.etaxonomy.cdm.model.common.IdentifiableEntity, eu.etaxonomy.cdm.model.common.IdentifiableEntity)\r
-        */\r
-       public boolean merge(Object entity, Object mergeTarget) {\r
-               logger.info("Merge "  + entity + " into " + mergeTarget);\r
-               if (entity instanceof ReferenceBase) {\r
-                       try {\r
-                               CdmStore.getCommonService().merge((ReferenceBase) mergeTarget, (ReferenceBase) entity, null);\r
-                       } catch (MergeException e) {\r
-                               logger.error("Problems merging objects", e);\r
-                       }\r
-               }\r
-               return true;\r
-       };\r
-       \r
-       /*\r
-        * (non-Javadoc)\r
-        * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#create(eu.etaxonomy.cdm.model.common.IdentifiableEntity)\r
-        */\r
-       public boolean create(Object entity) {\r
-               return save(entity);            \r
-       };\r
-}
\ No newline at end of file
+// $Id$
+/**
+* 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.bulkeditor.input;
+
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
+import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
+import eu.etaxonomy.cdm.model.common.MarkerType;
+import eu.etaxonomy.cdm.model.reference.ReferenceBase;
+import eu.etaxonomy.cdm.strategy.merge.MergeException;
+import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService;
+import eu.etaxonomy.taxeditor.annotatedlineeditor.IdentifiableEntityComparator;
+import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorQuery;
+import eu.etaxonomy.taxeditor.bulkeditor.command.BulkEditorInputTypeValues.BulkEditorInputType;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * <p>Abstract AbstractBulkEditorInput class.</p>
+ *
+ * @author p.ciardelli
+ * @created 25.06.2009
+ * @version 1.0
+ * @param <T>
+ */
+public abstract class AbstractBulkEditorInput<T> extends PropertyChangeSupport implements IEditorInput, IEntityPersistenceService {
+       private static final Logger logger = Logger
+                       .getLogger(AbstractBulkEditorInput.class);
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 416414530232743735L;
+       private String mode;
+       private UUID entityUuid;
+
+       /**
+        * <p>Constructor for AbstractBulkEditorInput.</p>
+        *
+        * @param sourceBean a {@link java.lang.Object} object.
+        * @param <T> a T object.
+        */
+       public AbstractBulkEditorInput(Object sourceBean) {
+               super(sourceBean);
+       }
+       
+       /** Constant <code>QUERY_CHANGED="query_changed"</code> */
+       public static final String QUERY_CHANGED = "query_changed";
+       
+       /**
+        * <p>NewInstance</p>
+        *
+        * @param inputType a {@link eu.etaxonomy.taxeditor.bulkeditor.command.BulkEditorInputTypeValues.BulkEditorInputType} object.
+        * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
+        */
+       static public AbstractBulkEditorInput NewInstance(BulkEditorInputType inputType) {
+               return BulkEditorInputType.getInput(inputType);
+       }
+       
+       /**
+        * <p>NewInstance</p>
+        *
+        * @param entity a {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity} object.
+        * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
+        */
+       public static AbstractBulkEditorInput NewInstance(IdentifiableEntity entity) {
+               
+               
+               BulkEditorInputType inputType = BulkEditorInputType.getByType(entity.getClass());
+               
+               AbstractBulkEditorInput editorInput = NewInstance(inputType);
+               
+               editorInput.setEntityUuid(entity.getUuid());
+               
+               return editorInput;
+       }
+       
+       /**
+        * Queries the service for entities that match the criterias defined in the given
+        * search configurator
+        *
+        * @return a {@link java.util.List} object.
+        */
+       public List<T> listEntities(){
+               if(getEntityUuid() != null){
+                       List<T> entityList = new ArrayList<T>();
+                       T entity = loadEntity(getEntityUuid());
+                       entityList.add(entity);
+                       return entityList;
+               }
+               
+               if(query != null){
+                       
+                       String queryString = query.getSearchString();
+                       IIdentifiableEntityServiceConfigurator configurator = query.getSearchConfigurator();
+                       Comparator queryComparator = (query.getComparator() != null) ? query.getComparator() : new IdentifiableEntityComparator();
+                       
+                       List<T> entityList = listEntities(configurator);
+                       
+                       Collections.sort(entityList, queryComparator);                  
+                       
+                       // reset query
+                       setQuery(null);
+                       
+                       return entityList;
+               }
+               return null;
+       }
+       
+       /**
+        * <p>listEntities</p>
+        *
+        * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object.
+        * @return a {@link java.util.List} object.
+        */
+       protected abstract List<T> listEntities(IIdentifiableEntityServiceConfigurator configurator);
+       
+       /**
+        * <p>loadEntity</p>
+        *
+        * @param entityUuid a {@link java.util.UUID} object.
+        * @return a T object.
+        */
+       protected abstract T loadEntity(UUID entityUuid);
+
+       private void setEntityUuid(UUID entityUuid){
+               this.entityUuid = entityUuid;
+       }
+       
+       /**
+        * <p>Getter for the field <code>entityUuid</code>.</p>
+        *
+        * @return a {@link java.util.UUID} object.
+        */
+       public UUID getEntityUuid() {
+               return entityUuid;
+       }
+
+       private IBulkEditorQuery query;
+                       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IEditorInput#exists()
+        */
+       /**
+        * <p>exists</p>
+        *
+        * @return a boolean.
+        */
+       public boolean exists() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+        */
+       /**
+        * <p>getImageDescriptor</p>
+        *
+        * @return a {@link org.eclipse.jface.resource.ImageDescriptor} object.
+        */
+       public ImageDescriptor getImageDescriptor() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IEditorInput#getPersistable()
+        */
+       /**
+        * <p>getPersistable</p>
+        *
+        * @return a {@link org.eclipse.ui.IPersistableElement} object.
+        */
+       public IPersistableElement getPersistable() {
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+        */
+       /** {@inheritDoc} */
+       @SuppressWarnings("unchecked")
+       public Object getAdapter(Class adapter) {
+               return null;
+       }
+
+       /**
+        * <p>Setter for the field <code>query</code>.</p>
+        *
+        * @param bulkEditorQuery a {@link eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorQuery} object.
+        */
+       public void setQuery(IBulkEditorQuery bulkEditorQuery) {
+                               
+               this.query = bulkEditorQuery;
+               
+               if (query != null) {
+                       firePropertyChange(QUERY_CHANGED, null, null);
+               }
+       }
+       
+       /**
+        * <p>Getter for the field <code>query</code>.</p>
+        *
+        * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorQuery} object.
+        */
+       public IBulkEditorQuery getQuery() {
+               return query;
+       }
+       
+       /**
+        * <p>isMergingEnabled</p>
+        *
+        * @return a boolean.
+        */
+       public boolean isMergingEnabled() {
+               return false;
+       }
+
+       /**
+        * <p>isMarkerTypeEditingEnabled</p>
+        *
+        * @param markerType a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
+        * @return a boolean.
+        */
+       public boolean isMarkerTypeEditingEnabled(MarkerType markerType) {
+               return false;
+       }
+       
+       /**
+        * <p>isSingleEntityMode</p>
+        *
+        * @return a boolean.
+        */
+       public boolean isSingleEntityMode(){
+               return getEntityUuid() != null;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#merge(eu.etaxonomy.cdm.model.common.IdentifiableEntity, eu.etaxonomy.cdm.model.common.IdentifiableEntity)
+        */
+       /** {@inheritDoc} */
+       public boolean merge(Object entity, Object mergeTarget) {
+               logger.info("Merge "  + entity + " into " + mergeTarget);
+               if (entity instanceof ReferenceBase) {
+                       try {
+                               CdmStore.getCommonService().merge((ReferenceBase) mergeTarget, (ReferenceBase) entity, null);
+                       } catch (MergeException e) {
+                               logger.error("Problems merging objects", e);
+                       }
+               }
+               return true;
+       };
+       
+       /*
+        * (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#create(eu.etaxonomy.cdm.model.common.IdentifiableEntity)
+        */
+       /** {@inheritDoc} */
+       public boolean create(Object entity) {
+               return save(entity);            
+       };
+}