3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.cdm
.api
.service
;
13 import java
.util
.Collection
;
14 import java
.util
.List
;
18 import org
.hibernate
.Session
;
19 import org
.hibernate
.collection
.spi
.PersistentCollection
;
21 import eu
.etaxonomy
.cdm
.api
.service
.config
.DeleteConfiguratorBase
;
22 import eu
.etaxonomy
.cdm
.database
.DatabaseSchemaMismatchException
;
23 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
24 import eu
.etaxonomy
.cdm
.model
.common
.ISourceable
;
25 import eu
.etaxonomy
.cdm
.model
.common
.OriginalSourceBase
;
26 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmMetaData
;
27 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmMetaData
.MetaDataPropertyName
;
28 import eu
.etaxonomy
.cdm
.model
.reference
.IGeneric
;
29 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.ICdmGenericDao
;
30 import eu
.etaxonomy
.cdm
.strategy
.match
.IMatchStrategy
;
31 import eu
.etaxonomy
.cdm
.strategy
.match
.IMatchable
;
32 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchException
;
33 import eu
.etaxonomy
.cdm
.strategy
.merge
.IMergable
;
34 import eu
.etaxonomy
.cdm
.strategy
.merge
.IMergeStrategy
;
35 import eu
.etaxonomy
.cdm
.strategy
.merge
.MergeException
;
38 public interface ICommonService
extends IService
<OriginalSourceBase
>{
40 // /** find cdmBase by UUID**/
41 // public abstract CdmBase getCdmBaseByUuid(UUID uuid);
43 // /** save a reference and return its UUID**/
44 // public abstract UUID saveCdmBase(CdmBase cdmBase);
50 public void saveAllMetaData(Collection
<CdmMetaData
> metaData
);
53 * Returns all meta data.
56 public Map
<MetaDataPropertyName
, CdmMetaData
> getCdmMetaData();
60 * Returns a map of identifiable entities of class <code>clazz</code> which have an original source of
61 * with namespace <code>idNamespace</code> and with an idInSource in <code>idInSourceSet</code> <BR>
62 * The key of the map is the idInSource. If there are multiple objects that have the same id an arbitrary one is chosen.
64 * @param idInSourceSet
68 public Map
<String
, ?
extends ISourceable
> getSourcedObjectsByIdInSource(Class clazz
, Set
<String
> idInSourceSet
, String idNamespace
);
71 * Returns a list of identifiable entities according to their class, idInSource and idNamespace
77 public ISourceable
getSourcedObjectByIdInSource(Class clazz
, String idInSource
, String idNamespace
);
81 * Returns all CdmBase objects that reference the referencedCdmBase.
82 * For example, if referencedCdmBase is an agent it may return all taxon names
83 * that have this person as an author but also all books, articles, etc. that have
84 * this person as an author
85 * @param referencedCdmBase
88 public Set
<CdmBase
> getReferencingObjects(CdmBase referencedCdmBase
);
91 * Merges mergeSecond into mergeFirst. All references to mergeSecond will be replaced by references
92 * to merge first. If no merge strategy is defined (null), the DefaultMergeStrategy will be taken as default.
96 * @param mergeStrategy
97 * @throws MergeException
99 public <T
extends IMergable
> void merge(T mergeFirst
, T mergeSecond
, IMergeStrategy mergeStrategy
) throws MergeException
;
102 * Returns all objects that match the object to match according to the given match strategy.
103 * If no match strategy is defined the default match strategy is taken.
105 * @param objectToMatch
106 * @param matchStrategy
108 * @throws MatchException
110 public <T
extends IMatchable
> List
<T
> findMatching(T objectToMatch
, IMatchStrategy matchStrategy
) throws MatchException
;
113 * A generic method to retrieve any CdmBase object by its id and class.<BR>
114 * @see ICdmGenericDao#find(Class, int)
115 * @see Session#get(Class, java.io.Serializable)
116 * @param clazz the CdmBase class
117 * @param id the cdmBase identifier
118 * @return the CdmBase object defined by clazz and id
120 public CdmBase
find(Class
<?
extends CdmBase
> clazz
, int id
);
122 public List
getHqlResult(String hqlQuery
);
125 * Initializes a lazy loaded persistent collection.
127 * @param col the persistent collection to initialize
128 * @return the initialized persistent collection
130 public PersistentCollection
initializeCollection(PersistentCollection col
);
133 * Checks if a lazy loaded persistent collection is empty.
135 * @param col the persistent collection
136 * @return the initialized persistent collection
138 public boolean isEmpty(PersistentCollection col
);
141 * Returns the size of a persistent collection.
143 * @param col the persistent collection to initialize
144 * @return the size of the persistent collection
146 public int size(PersistentCollection col
);
149 * Returns the object contained in a persistent collection at the given index.
151 * @param col the persistent collection
152 * @param index the index of the requested element
153 * @return the object at the requested index
155 public Object
get(PersistentCollection col
, int index
);
158 * checks whether an object is contained within a persistent collection.
160 * @param col the persistent collection
161 * @param element the element to check for
162 * @return true if the element exists in the collection, false o/w
164 public boolean contains(PersistentCollection col
, Object element
);
167 * checks whether an index object exists within a persistent collection
170 * @param col the persistent collection
171 * @param key the index object to look for.
172 * @return true if the index object exists in the collection, false o/w
174 public boolean containsKey(PersistentCollection col
, Object key
);
177 * checks whether an value object exists within a persistent collection
180 * @param col the persistent collection
181 * @param key the value object to look for.
182 * @return true if the value object exists in the collection, false o/w
184 public boolean containsValue(PersistentCollection col
, Object element
);