2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.persistence
.dao
.common
;
12 import java
.util
.List
;
15 import java
.util
.UUID
;
17 import org
.hibernate
.Query
;
18 import org
.hibernate
.Session
;
19 import org
.springframework
.dao
.DataAccessException
;
21 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
22 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmMetaData
;
23 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmMetaData
.MetaDataPropertyName
;
24 import eu
.etaxonomy
.cdm
.strategy
.match
.IMatchStrategy
;
25 import eu
.etaxonomy
.cdm
.strategy
.match
.IMatchable
;
26 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchException
;
27 import eu
.etaxonomy
.cdm
.strategy
.merge
.IMergeStrategy
;
28 import eu
.etaxonomy
.cdm
.strategy
.merge
.MergeException
;
30 public interface ICdmGenericDao
{
32 public UUID
saveOrUpdate(CdmBase transientObject
) throws DataAccessException
;
34 public UUID
save(CdmBase newOrManagedObject
) throws DataAccessException
;
36 public UUID
update(CdmBase transientObject
) throws DataAccessException
;
38 public UUID
delete(CdmBase persistentObject
) throws DataAccessException
;
40 public void saveMetaData(CdmMetaData cdmMetaData
);
42 public List
<CdmMetaData
> getMetaData();
45 * Returns a CdmBase object of class <code>clazz</code> that has a property with name
46 * <code>propertyName</code> that references the CdmBase object <code>referencedCdmBase</code>.
52 public List
<CdmBase
> getCdmBasesByFieldAndClass(Class clazz
, String propertyName
, CdmBase referencedCdmBase
);
59 * @param referencedCdmBase
62 public List
<CdmBase
> getCdmBasesWithItemInCollection(Class itemClass
, Class clazz
, String propertyName
, CdmBase item
);
65 * Returns all CDM classes. If includeAbstractClasses is false the abstract classes
66 * will not be in the resultset.
67 * @param includeAbstractClasses
70 public Set
<Class
<?
extends CdmBase
>> getAllCdmClasses(boolean includeAbstractClasses
);
73 * Returns all CdmBase objects that reference the referencedCdmBase.
74 * For example, if referencedCdmBase is an agent it may return all taxon names
75 * that have this person as an author but also all books, articles, etc. that have
76 * this person as an author
77 * @param referencedCdmBase
80 public Set
<CdmBase
> getReferencingObjects(CdmBase referencedCdmBase
);
83 * Merges cdmBase2 into cdmBase2 and rearranges all reference to cdmBase2 by letting them point to
84 * cdmBase1. If the merge strategy is not defined (<code>null</code>) the default merge strategy is taken instead.
88 * @param mergeStrategy
89 * @throws IllegalArgumentException
90 * @throws NullPointerException
91 * @throws MergeException
93 public <T
extends CdmBase
> void merge(T cdmBase1
, T cdmBase2
, IMergeStrategy mergeStrategy
) throws MergeException
;
96 * Returns a List of matching persistent objects according to the match strategy
98 * @param objectToMatch
99 * @param matchStrategy
101 * @throws MatchException
103 public <T
extends IMatchable
> List
<T
> findMatching(T objectToMatch
, IMatchStrategy matchStrategy
) throws MatchException
;
107 * A generic method to retrieve any CdmBase object by its id and class.<BR>
108 * Return the persistent instance of the given entity class with the given identifier,
109 * or null if there is no such persistent instance. (If the instance is already
110 * associated with the session, return that instance. This method never returns
111 * an uninitialized instance.)
112 * TODO: the behaviour for abstract high level classes (such as CdmBase itself)
114 * @see Session#get(Class, java.io.Serializable)
115 * @param clazz the CdmBase class
116 * @param id the identifier
117 * @return the CdmBase instance
119 public <T
extends CdmBase
> T
find(Class
<T
> clazz
, int id
);
122 * Returns the result of an hql query
123 * TODO implement parameters
124 * @deprecated this is not clean implemantation as it is hibernate related.
129 public List
getHqlResult(String hqlQuery
);
132 * TODO remove as this is Hibernate specific.
134 * @deprecated this is not clean implemantation as it is hibernate related.
135 * Will be replaced in future
140 public Query
getHqlQuery(String hqlQuery
);