Implemented new methods required for CATE in ITaxonDao and implementation, including...
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / persistence / dao / common / ICdmEntityDao.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.cdm.persistence.dao.common;
11
12 import java.util.Collection;
13 import java.util.List;
14 import java.util.Map;
15 import java.util.UUID;
16
17 import org.springframework.dao.DataAccessException;
18
19 import eu.etaxonomy.cdm.model.common.CdmBase;
20
21 /**
22 * an data access interface that all data access classes implement
23 * @author m.doering
24 * @version 1.0
25 * @created 02-Nov-2007 19:36:10
26 */
27 public interface ICdmEntityDao<T extends CdmBase> {
28
29 /**
30 * @param transientObject
31 * @return
32 * @throws DataAccessException
33 */
34 public UUID saveOrUpdate(T transientObject) throws DataAccessException;
35
36 //public UUID saveOrUpdateAll(Collection<T> transientObjects) throws DataAccessException;
37
38 /**
39 * @param newOrManagedObject
40 * @return
41 * @throws DataAccessException
42 */
43 public UUID save(T newOrManagedObject) throws DataAccessException;
44
45 public Map<UUID, T> saveAll(Collection<T> cdmObjCollection) throws DataAccessException;
46
47 /**
48 * @param transientObject
49 * @return
50 * @throws DataAccessException
51 */
52 public UUID update(T transientObject) throws DataAccessException;
53
54 /**
55 * @param persistentObject
56 * @return
57 * @throws DataAccessException
58 */
59 public UUID delete(T persistentObject) throws DataAccessException;
60
61 /**
62 * Returns a sublist of CdmBase instances stored in the database.
63 * A maximum of 'limit' objects are returned, starting at object with index 'start'.
64 * @param limit
65 * @param start
66 * @return
67 * @throws DataAccessException
68 */
69 public List<T> list(int limit, int start) throws DataAccessException;
70
71 /**
72 * Returns a sublist of CdmBase instances of type <TYPE> stored in the database.
73 * A maximum of 'limit' objects are returned, starting at object with index 'start'.
74 * @param limit
75 * @param start
76 * @return
77 * @throws DataAccessException
78 */
79 public <TYPE extends T> List<TYPE> list(Class<TYPE> type, int limit, int start) throws DataAccessException;
80
81 public List<T> rows(String tableName, int limit, int start) throws DataAccessException;
82
83 /**
84 * @param id
85 * @return
86 * @throws DataAccessException
87 */
88 public T findById(int id) throws DataAccessException;
89
90 /**
91 * @param Uuid
92 * @return
93 * @throws DataAccessException
94 */
95 public T findByUuid(UUID Uuid) throws DataAccessException;
96
97 /**
98 * @param uuid
99 * @return
100 * @throws DataAccessException
101 */
102 public Boolean exists(UUID uuid) throws DataAccessException;
103
104 public int count();
105
106 /**
107 * Returns the number of objects of type <TYPE> - which must extend T
108 * @param <TYPE>
109 * @param clazz
110 * @return
111 */
112 public <TYPE extends T> int count(Class<TYPE> clazz);
113
114 /**
115 *
116 */
117 public void flush();
118
119
120
121 }