reverting last commit - will be committed again later
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / ICommonService.java
index 092a279dce6a2ec982ffdbdd55cd9ca0bff9bd1f..4cd11212b320f99a850e222f44ad2e49825b2aa0 100644 (file)
@@ -1,3 +1,4 @@
+// $Id$
 /**
 * Copyright (C) 2007 EDIT
 * European Distributed Institute of Taxonomy 
 
 package eu.etaxonomy.cdm.api.service;
 
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import eu.etaxonomy.cdm.database.DatabaseSchemaMismatchException;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.CdmMetaData;
 import eu.etaxonomy.cdm.model.common.ISourceable;
-import eu.etaxonomy.cdm.model.common.OriginalSource;
+import eu.etaxonomy.cdm.model.common.OriginalSourceBase;
+import eu.etaxonomy.cdm.model.common.CdmMetaData.MetaDataPropertyName;
+import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
+import eu.etaxonomy.cdm.strategy.match.IMatchable;
+import eu.etaxonomy.cdm.strategy.match.MatchException;
+import eu.etaxonomy.cdm.strategy.merge.IMergable;
+import eu.etaxonomy.cdm.strategy.merge.IMergeStrategy;
+import eu.etaxonomy.cdm.strategy.merge.MergeException;
 
 
-public interface ICommonService extends IService<OriginalSource>{
+public interface ICommonService extends IService<OriginalSourceBase>{
 //     
 //     /** find cdmBase by UUID**/
 //     public abstract CdmBase getCdmBaseByUuid(UUID uuid);
@@ -21,6 +37,73 @@ public interface ICommonService extends IService<OriginalSource>{
 //     /** save a reference and return its UUID**/
 //     public abstract UUID saveCdmBase(CdmBase cdmBase);
 
-       /** find cdmBase by UUID**/
-       public abstract ISourceable getSourcedObjectByIdInSource(Class clazz, String idInSource, String idNamespace);
+       /**
+        * Saves all meta data
+        * @param metaData
+        */
+       public void saveAllMetaData(Collection<CdmMetaData> metaData);
+       
+       /**
+        * Returns all meta data.
+        * @return
+        */
+       public Map<MetaDataPropertyName, CdmMetaData> getCdmMetaData();
+       
+       
+       /**
+        * Returns a map of identifiable entities of class <code>clazz</code> which have an original source of 
+        * with namespace <code>idNamespace</code> and with an idInSource in <code>idInSourceSet</code> <BR>
+        * The key of the map is the idInSource. If there are multiple objects that have the same id an arbitrary one is chosen.
+        * @param clazz
+        * @param idInSourceSet
+        * @param idNamespace
+        * @return
+        */
+       public Map<String, ? extends ISourceable> getSourcedObjectsByIdInSource(Class clazz, Set<String> idInSourceSet, String idNamespace);
+       
+       /**
+        * Returns a list of identifiable entities according to their class, idInSource and idNamespace
+        * @param clazz
+        * @param idInSource
+        * @param idNamespace
+        * @return
+        */
+       public ISourceable getSourcedObjectByIdInSource(Class clazz, String idInSource, String idNamespace);
+
+       
+       /**
+        * Returns all CdmBase objects that reference the referencedCdmBase.
+        * For example, if referencedCdmBase is an agent it may return all taxon names
+        * that have this person as an author but also all books, articles, etc. that have 
+        * this person as an author
+        * @param referencedCdmBase
+        * @return
+        */
+       public Set<CdmBase> getReferencingObjects(CdmBase referencedCdmBase);
+       
+       /**
+        * Merges mergeSecond into mergeFirst. All references to mergeSecond will be replaced by references
+        * to merge first. If no merge strategy is defined (null), the DefaultMergeStrategy will be taken as default.
+        * @param <T>
+        * @param mergeFirst
+        * @param mergeSecond
+        * @param mergeStrategy
+        * @throws MergeException
+        */
+       public <T extends IMergable> void   merge(T mergeFirst, T mergeSecond, IMergeStrategy mergeStrategy) throws MergeException;
+       
+       /**
+        * Returns all objects that match the object to match according to the given match strategy.
+        * If no match strategy is defined the default match strategy is taken.
+        * @param <T>
+        * @param objectToMatch
+        * @param matchStrategy
+        * @return
+        * @throws MatchException
+        */
+       public <T extends IMatchable> List<T> findMatching(T objectToMatch, IMatchStrategy matchStrategy) throws MatchException;
+               
+       
+       public List getHqlResult(String hqlQuery);
+
 }