Added listByTitle as an alternative to findByTitle
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / IIdentifiableEntityService.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.cdm.api.service;
12
13 import java.util.List;
14
15 import org.hibernate.criterion.Criterion;
16
17 import eu.etaxonomy.cdm.api.service.pager.Pager;
18 import eu.etaxonomy.cdm.model.common.ISourceable;
19 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
20 import eu.etaxonomy.cdm.model.common.IdentifiableSource;
21 import eu.etaxonomy.cdm.model.common.LSID;
22 import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
23 import eu.etaxonomy.cdm.model.media.Rights;
24 import eu.etaxonomy.cdm.persistence.dao.BeanInitializer;
25 import eu.etaxonomy.cdm.persistence.query.MatchMode;
26 import eu.etaxonomy.cdm.persistence.query.OrderHint;
27 import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
28
29 public interface IIdentifiableEntityService<T extends IdentifiableEntity> extends IAnnotatableService<T> {
30
31 /**
32 * (Re-)generate the title caches for all objects of this concrete IdentifiableEntity class
33 */
34 public void updateTitleCache();
35
36 public void updateTitleCache(Class<? extends T> clazz);
37
38 public void updateTitleCache(Class<? extends T> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<T> cacheStrategy);
39
40 /**
41 * Finds an object with a given LSID. If the object does not currently exist in the current view, then
42 * the most recent prior version of the object will be returned, or null if an object with this identifier
43 * has never existed
44 *
45 * @param lsid
46 * @return an object of type T or null of the object has never existed
47 */
48 public T find(LSID lsid);
49
50 /**
51 * Replaces all *ToMany and *ToOne references to an object (x) with another object of the same type (y)
52 *
53 * Ignores ManyToAny and OneToAny relationships as these are typically involved with bidirectional
54 * parent-child relations
55 *
56 * @param x
57 * @param y
58 * @return the replacing object (y)
59 */
60 public T replace(T x, T y);
61
62 /**
63 * Return a Pager of sources belonging to this object
64 *
65 * @param t The identifiable entity
66 * @param pageSize The maximum number of sources returned (can be null for all sources)
67 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
68 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
69 * @return a Pager of OriginalSource entities
70 */
71 public Pager<IdentifiableSource> getSources(T t, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
72
73 /**
74 * Return a Pager of rights belonging to this object
75 *
76 * @param t The identifiable entity
77 * @param pageSize The maximum number of rights returned (can be null for all rights)
78 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
79 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
80 * @return a Pager of Rights entities
81 */
82 public Pager<Rights> getRights(T t, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
83
84 public ISourceable getSourcedObjectByIdInSource(Class clazz, String idInSource, String idNamespace);
85
86 /**
87 * Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
88 * Retrieving this list is considered to be significantly faster than initializing the fully fledged buiseness
89 * objects. To be used in cases where you want to present large amount of data and provide details after
90 * a selection has been made.
91 *
92 * @return a list of <code>UuidAndTitleCache</code> instances
93 */
94 public List<UuidAndTitleCache<T>> getUuidAndTitleCache();
95
96 /**
97 * Return a Pager of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
98 *
99 * @param clazz filter by class - can be null to include all instances of type T
100 * @param queryString the query string to filter by
101 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
102 * @param criteria additional criteria to filter by
103 * @param pageSize The maximum number of objects returned (can be null for all objects)
104 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
105 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
106 * @param orderHints
107 * Supports path like <code>orderHints.propertyNames</code> which
108 * include *-to-one properties like createdBy.username or
109 * authorTeam.persistentTitleCache
110 * @return a paged list of instances of type T matching the queryString
111 */
112 public Pager<T> findByTitle(Class<? extends T> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
113
114 /**
115 * Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
116 *
117 * @param clazz filter by class - can be null to include all instances of type T
118 * @param queryString the query string to filter by
119 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
120 * @param criteria additional criteria to filter by
121 * @param pageSize The maximum number of objects returned (can be null for all objects)
122 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
123 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
124 * @param orderHints
125 * Supports path like <code>orderHints.propertyNames</code> which
126 * include *-to-one properties like createdBy.username or
127 * authorTeam.persistentTitleCache
128 * @return a paged list of instances of type T matching the queryString
129 */
130 public List<T> listByTitle(Class<? extends T> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
131
132 /**
133 * Returns a Paged List of IdentifiableEntity instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
134 *
135 * @param clazz filter the results by class (or pass null to return all IdentifiableEntity instances)
136 * @param queryString
137 * @param pageSize The maximum number of identifiable entities returned (can be null for all matching identifiable entities)
138 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
139 * @param orderHints
140 * Supports path like <code>orderHints.propertyNames</code> which
141 * include *-to-one properties like createdBy.username or
142 * authorTeam.persistentTitleCache
143 * @param propertyPaths properties to be initialized
144 * @return a Pager IdentifiableEntity instances
145 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
146 */
147 public Pager<T> search(Class<? extends T> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
148 }