Project

General

Profile

« Previous | Next » 

Revision c51ef083

Added by Katja Luther almost 8 years ago

add limit and pattern to the uuid and titlecache methods

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/agent/IAgentDao.java
111 111
     * @param pattern
112 112
     * @return
113 113
     */
114
    List<UuidAndTitleCache<AgentBase>> getUuidAndAbbrevTitleCache(Integer limit, String pattern);
114
    List<UuidAndTitleCache<AgentBase>> getUuidAndAbbrevTitleCache(Integer limit, String pattern, Class clazz);
115 115
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/IIdentifiableDao.java
91 91
	 *
92 92
	 * @return a list of <code>UuidAndTitleCache</code> instances
93 93
	 */
94
	public List<UuidAndTitleCache<T>> getUuidAndTitleCache();
94
	public List<UuidAndTitleCache<T>> getUuidAndTitleCache(Integer limit, String pattern);
95
	/**
96
     * Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
97
     * Retrieving this list is considered to be significantly faster than initializing the fully fledged buiseness
98
     * objects. To be used in cases where you want to present large amount of data and provide details after
99
     * a selection has been made.
100
     *
101
     * @return a list of <code>UuidAndTitleCache</code> instances
102
     */
103
    public List<UuidAndTitleCache<T>> getUuidAndTitleCache();
95 104

  
96 105
	 /**
97 106
	 * Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/agent/AgentDaoImpl.java
166 166

  
167 167

  
168 168
	@Override
169
    public List<UuidAndTitleCache<AgentBase>> getUuidAndAbbrevTitleCache(Integer limit, String pattern){
169
    public List<UuidAndTitleCache<AgentBase>> getUuidAndAbbrevTitleCache(Integer limit, String pattern, Class clazz){
170 170
        Session session = getSession();
171
        String clazzString = "";
172
        if (clazz == null){
173
            clazzString = "";
174
        }else if (clazz.equals(Team.class)){
175
            clazzString = "dtype = 'Team'";
176
        } else if (clazz.equals(Person.class)){
177
            clazzString = "dtype = 'Person'";
178
        }  else if (clazz.equals(Institution.class)){
179
            clazzString = "dtype = 'Institution'";
180
        }
181

  
171 182
        Query query = null;
172 183
        if (pattern != null){
173
            query = session.createQuery("select uuid, id, nomenclaturalTitle from " + type.getSimpleName() +" where nomenclaturalTitle like :pattern");
184
            query = session.createQuery("select uuid, id, nomenclaturalTitle from " + type.getSimpleName() +" where nomenclaturalTitle like :pattern" + clazzString);
174 185
            pattern = pattern + "%";
175 186
            query.setParameter("pattern", pattern);
176 187
        } else {
177
            query = session.createQuery("select uuid, id, nomenclaturalTitle from " + type.getSimpleName() );
188
            if (clazzString != ""){
189
                query = session.createQuery("select uuid, id, nomenclaturalTitle from " + type.getSimpleName() + " where " + clazzString);
190
            } else{
191
                query = session.createQuery("select uuid, id, nomenclaturalTitle from " + type.getSimpleName());
192
            }
178 193
        }
179 194
        if (limit != null){
180 195
           query.setMaxResults(limit);
181 196
        }
197

  
182 198
        return getUuidAndTitleCache(query);
183 199
    }
184 200

  
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/IdentifiableDaoBase.java
282 282
    }
283 283

  
284 284
    @Override
285
    public List<UuidAndTitleCache<T>> getUuidAndTitleCache(){
285
    public List<UuidAndTitleCache<T>> getUuidAndTitleCache(Integer limit, String pattern){
286 286
        Session session = getSession();
287
        Query query = session.createQuery("select uuid, id, titleCache from " + type.getSimpleName());
287
        Query query = null;
288
        if (pattern != null){
289
            query = session.createQuery("select uuid, id, titleCache from " + type.getSimpleName() +" where titleCache like :pattern");
290
            pattern = pattern + "%";
291
            query.setParameter("pattern", pattern);
292
        } else {
293
            query = session.createQuery("select uuid, id, titleCache from " + type.getSimpleName() );
294
        }
295
        if (limit != null){
296
           query.setMaxResults(limit);
297
        }
288 298
        return getUuidAndTitleCache(query);
289 299
    }
290 300

  
301

  
302
    @Override
303
    public List<UuidAndTitleCache<T>> getUuidAndTitleCache(){
304
        return getUuidAndTitleCache(null, null);
305
    }
306

  
291 307
    protected <E extends IIdentifiableEntity> List<UuidAndTitleCache<E>> getUuidAndTitleCache(Query query){
292 308
        List<UuidAndTitleCache<E>> list = new ArrayList<UuidAndTitleCache<E>>();
293 309

  
......
296 312
        for(Object[] object : result){
297 313
            list.add(new UuidAndTitleCache<E>((UUID) object[0],(Integer) object[1], (String) object[2]));
298 314
        }
299

  
300 315
        return list;
301 316
    }
302 317

  
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/name/TaxonNameDaoHibernateImpl.java
694 694
    }
695 695

  
696 696
    @Override
697
    public List<UuidAndTitleCache> getUuidAndTitleCacheOfNames() {
698
        String queryString = "SELECT uuid, id, fullTitleCache FROM TaxonNameBase";
697
    public List<UuidAndTitleCache> getUuidAndTitleCacheOfNames(Integer limit, String pattern) {
698
        String queryString = "SELECT uuid, id, fullTitleCache FROM TaxonNameBase LIMIT " + limit;
699 699

  
700 700
        @SuppressWarnings("unchecked")
701 701
        List<Object[]> result = getSession().createSQLQuery(queryString).list();
......
748 748
            taxonDao.delete(taxonBase);
749 749
        }
750 750
        HomotypicalGroup homotypicalGroup = homotypicalGroupDao.load(homotypicalGroupUUID);
751

  
751 752
        if (homotypicalGroup != null){
752
        	if (homotypicalGroup.getTypifiedNames().isEmpty()){
753
            if (homotypicalGroup.getTypifiedNames().contains(persistentObject)){
754
                homotypicalGroup.getTypifiedNames().remove(persistentObject);
755
                homotypicalGroupDao.saveOrUpdate(homotypicalGroup);
756
            }
757
            if (homotypicalGroup.getTypifiedNames().isEmpty()){
753 758
        		homotypicalGroupDao.delete(homotypicalGroup);
754 759
        	}
755 760
        }
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/reference/ReferenceDaoHibernateImpl.java
94 94
	}
95 95

  
96 96
	@Override
97
	public List<UuidAndTitleCache<Reference>> getUuidAndTitleCache() {
97
	public List<UuidAndTitleCache<Reference>> getUuidAndTitleCache(Integer limit, String pattern) {
98 98
		List<UuidAndTitleCache<Reference>> list = new ArrayList<UuidAndTitleCache<Reference>>();
99 99
		Session session = getSession();
100 100

  
101 101
		Query query = session.createQuery("SELECT " +
102 102
				"r.uuid, r.id, r.titleCache, ab.titleCache FROM " + type.getSimpleName() + " AS r LEFT OUTER JOIN r.authorship AS ab ");//"select uuid, titleCache from " + type.getSimpleName());
103
		if (limit != null){
104
		    query.setMaxResults(limit);
105
		}
103 106

  
104 107
		@SuppressWarnings("unchecked")
105 108
        List<Object[]> result = query.list();
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/name/ITaxonNameDao.java
1 1
/**
2 2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy 
3
 * European Distributed Institute of Taxonomy
4 4
 * http://www.e-taxonomy.eu
5
 * 
5
 *
6 6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
 * See LICENSE.TXT at the top of this package for the full license terms.
8 8
 */
......
34 34

  
35 35
/**
36 36
 * @author a.mueller
37
 * 
37
 *
38 38
 */
39 39
public interface ITaxonNameDao extends IIdentifiableDao<TaxonNameBase> {
40 40

  
......
42 42
	 * Return a count of names related to or from this name, optionally filtered
43 43
	 * by relationship type. The direction of the relationships taken in to account is depending on
44 44
	 * the <code>direction</code> parameter.
45
	 * 
45
	 *
46 46
	 * @param name
47 47
	 *            the name
48 48
	 * @param direction
......
58 58
	 * by relationship type. The direction of the relationships taken in to account is depending on
59 59
	 * the <code>direction</code> parameter.
60 60
	 * If both name and direction is null all name relationships will be returned.
61
	 * 
61
	 *
62 62
	 * @param name
63 63
	 *            the name
64 64
	 * @param direction
......
78 78
	public List<NameRelationship> getNameRelationships(TaxonNameBase name, NameRelationship.Direction direction,
79 79
			NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
80 80
			List<String> propertyPaths);
81
	
81

  
82 82
	/**
83 83
	 * Return a count of hybrids related to this name, optionally filtered by
84 84
	 * hybrid relationship type
85
	 * 
85
	 *
86 86
	 * @param name
87 87
	 *            the name
88 88
	 * @param type
......
94 94
	/**
95 95
	 * Return a List of hybrids related to this name, optionally filtered by
96 96
	 * hybrid relationship type
97
	 * 
97
	 *
98 98
	 * @param name
99 99
	 *            the name
100 100
	 * @param type
......
112 112
	/**
113 113
	 * Return a count of types related to this name, optionally filtered by type
114 114
	 * designation status
115
	 * 
115
	 *
116 116
	 * @param name
117 117
	 *            the name
118 118
	 * @param status
......
125 125
	/**
126 126
	 * Return a List of types related to this name, optionally filtered by type
127 127
	 * designation status
128
	 * 
128
	 *
129 129
	 * @param name
130 130
	 *            the name
131 131
	 * @param type
......
141 141
	 * @param propertyPaths
142 142
	 * @return a List of TypeDesignationBase instances
143 143
	 */
144
	public <T extends TypeDesignationBase> List<T> getTypeDesignations(TaxonNameBase name, 
144
	public <T extends TypeDesignationBase> List<T> getTypeDesignations(TaxonNameBase name,
145 145
			Class<T> type,
146 146
			TypeDesignationStatusBase status, Integer pageSize, Integer pageNumber,
147 147
			List<String> propertyPaths);
148
	
148

  
149 149
	/**
150 150
	 * Return a List of types related to this name, optionally filtered by type
151 151
	 * designation status
152
	 * 
152
	 *
153 153
	 * @param name
154 154
	 *            the name
155 155
	 * @param status
......
172 172
	/**
173 173
	 * Returns a List of TaxonNameBase instances that match the properties
174 174
	 * passed
175
	 * 
175
	 *
176 176
	 * @param uninomial
177 177
	 * @param infraGenericEpithet
178 178
	 * @param specificEpithet
......
184 184
	 * @param pageNumber
185 185
	 *            The offset (in pageSize chunks) from the start of the result
186 186
	 *            set (0 - based)
187
	 * @param propertyPaths 
188
	 * @param orderHints 
187
	 * @param propertyPaths
188
	 * @param orderHints
189 189
	 * @return a List of TaxonNameBase instances
190 190
	 */
191 191
	public List<TaxonNameBase> searchNames(String uninomial,
......
196 196
	/**
197 197
	 * Returns a count of TaxonNameBase instances that match the properties
198 198
	 * passed
199
	 * 
199
	 *
200 200
	 * @param uninomial
201 201
	 * @param infraGenericEpithet
202 202
	 * @param specificEpithet
......
209 209

  
210 210
	/**
211 211
	 * Returns a count of TaxonNameBase instances that match the properties passed
212
	 * 
212
	 *
213 213
	 * @param queryString
214 214
	 * @param matchMode
215 215
	 * @param criteria
......
219 219
	/**
220 220
	 * Returns a List of TaxonNameBase instances which nameCache matches the
221 221
	 * query string
222
	 * 
222
	 *
223 223
	 * @param queryString
224 224
	 * @param pageSize
225 225
	 *            The maximum number of names returned (can be null for all
......
231 231
	 */
232 232
	public List<TaxonNameBase<?, ?>> searchNames(String queryString,
233 233
			Integer pageSize, Integer pageNumber);
234
	
235
	
234

  
235

  
236 236

  
237 237
	/**
238 238
	 * Returns a count of TaxonNameBase instances which nameCache matches the
239 239
	 * String queryString
240
	 * 
240
	 *
241 241
	 * @param queryString
242 242
	 * @return a count of TaxonNameBase instances
243 243
	 */
......
255 255
	public List<? extends TaxonNameBase<?, ?>> findByName(String queryString,
256 256
			MatchMode matchmode, Integer pageSize, Integer pageNumber,
257 257
			List<Criterion> criteria, List<String> propertyPaths);
258
	
258

  
259 259
	/**
260 260
	 * @param queryString
261 261
	 * @param matchmode
......
268 268
	public List<? extends TaxonNameBase<?, ?>> findByTitle(String queryString,
269 269
			MatchMode matchmode, Integer pageSize, Integer pageNumber,
270 270
			List<Criterion> criteria, List<String> propertyPaths);
271
	
271

  
272 272
	/**
273 273
	 * Returns a taxon name corresponding to the given uuid
274
	 * 
275
	 * @param uuid 
274
	 *
275
	 * @param uuid
276 276
	 * 			The uuid of the taxon name requested
277 277
	 * @param criteria
278 278
	 * 			Custom criteria to be added to the default list of applied criteria.
279
	 * @param propertyPaths 
280
	 * 			
281
	 * @return 
279
	 * @param propertyPaths
280
	 *
281
	 * @return
282 282
	 */
283 283
	public TaxonNameBase<?, ?> findByUuid(UUID uuid, List<Criterion> criteria, List<String> propertyPaths);
284
	
284

  
285 285
	/**
286 286
	 * @param queryString
287 287
	 * @param matchmode
288 288
	 * @param criteria
289 289
	 * @return
290 290
	 */
291
	public Integer countByName(String queryString, 
291
	public Integer countByName(String queryString,
292 292
			MatchMode matchmode, List<Criterion> criteria);
293
	
294
	public List<RelationshipBase> getAllRelationships(Integer limit, Integer start); 
295
	
296
	public List<UuidAndTitleCache> getUuidAndTitleCacheOfNames();
293

  
294
	public List<RelationshipBase> getAllRelationships(Integer limit, Integer start);
295

  
296
	public List<UuidAndTitleCache> getUuidAndTitleCacheOfNames(Integer limit, String pattern);
297 297

  
298 298
	/**
299 299
	 * @param clazz
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/AgentServiceImpl.java
245 245
     * @see eu.etaxonomy.cdm.api.service.IAgentService#getUuidAndAbbrevTitleCache()
246 246
     */
247 247
    @Override
248
    public List<UuidAndTitleCache<AgentBase>> getUuidAndAbbrevTitleCache() {
249
        return dao.getUuidAndAbbrevTitleCache(null, null);
248
    public List<UuidAndTitleCache<AgentBase>> getUuidAndAbbrevTitleCache(Integer limit, String pattern, Class clazz) {
249
        return dao.getUuidAndAbbrevTitleCache(null, null, clazz);
250 250
    }
251 251

  
252 252
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IAgentService.java
114 114
     *
115 115
     * @return a list of <code>UuidAndTitleCache</code> instances
116 116
     */
117
    public List<UuidAndTitleCache<AgentBase>> getUuidAndAbbrevTitleCache();
117
    public List<UuidAndTitleCache<AgentBase>> getUuidAndAbbrevTitleCache(Integer limit, String pattern, Class clazz);
118 118

  
119 119
    /**
120 120
     * @param teamUuid
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IIdentifiableEntityService.java
105 105
     *
106 106
     * @return a list of <code>UuidAndTitleCache</code> instances
107 107
     */
108
    public List<UuidAndTitleCache<T>> getUuidAndTitleCache();
108
    public List<UuidAndTitleCache<T>> getUuidAndTitleCache(Integer limit, String pattern);
109 109

  
110 110
    /**
111 111
     * Return a Pager of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/INameService.java
452 452
	 * @return
453 453
	 * 			a <code>Map</code> containing uuid and titleCache of names
454 454
	 */
455
	public List<UuidAndTitleCache> getUuidAndTitleCacheOfNames();
455
	public List<UuidAndTitleCache> getUuidAndTitleCacheOfNames(Integer limit, String pattern);
456 456

  
457 457
	/**
458 458
	 * Return a Pager of names matching the given query string, optionally filtered by class, optionally with a particular MatchMode
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITaxonService.java
893 893

  
894 894
    public Synonym findBestMatchingSynonym(String taxonName);
895 895

  
896
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon();
896
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon(Integer limit, String pattern);
897 897

  
898
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym();
898
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym(Integer limit, String pattern);
899 899

  
900 900
    public List<UuidAndTitleCache<IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
901 901

  
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IdentifiableServiceBase.java
137 137

  
138 138
	@Transactional(readOnly = true)
139 139
	@Override
140
	public List<UuidAndTitleCache<T>> getUuidAndTitleCache() {
141
		return dao.getUuidAndTitleCache();
140
	public List<UuidAndTitleCache<T>> getUuidAndTitleCache(Integer limit, String pattern) {
141
		return dao.getUuidAndTitleCache(limit, pattern);
142 142
	}
143 143

  
144 144
	@Transactional(readOnly = true)
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/NameServiceImpl.java
808 808
    }
809 809

  
810 810
    @Override
811
    public List<UuidAndTitleCache> getUuidAndTitleCacheOfNames() {
812
        return dao.getUuidAndTitleCacheOfNames();
811
    public List<UuidAndTitleCache> getUuidAndTitleCacheOfNames(Integer limit, String pattern) {
812
        return dao.getUuidAndTitleCacheOfNames(limit, pattern);
813 813
    }
814 814

  
815 815
    @Override
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
796 796
            (configurator.getPageNumber(), numberOfResults, configurator.getPageSize(), results);
797 797
    }
798 798

  
799
    public List<UuidAndTitleCache<TaxonBase>> getTaxonUuidAndTitleCache(){
800
        return dao.getUuidAndTitleCache();
799
    public List<UuidAndTitleCache<TaxonBase>> getTaxonUuidAndTitleCache(Integer limit, String pattern){
800
        return dao.getUuidAndTitleCache(limit, pattern);
801 801
    }
802 802

  
803 803
    @Override
......
1167 1167
                taxon.setName(null);
1168 1168
            }
1169 1169

  
1170

  
1170 1171
            if ((taxon.getTaxonNodes() == null || taxon.getTaxonNodes().size()== 0)  && result.isOk()){
1171 1172
            	try{
1172 1173
            		UUID uuid = dao.delete(taxon);
......
1586 1587
    }
1587 1588

  
1588 1589
    @Override
1589
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon() {
1590
        return dao.getUuidAndTitleCacheTaxon();
1590
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon(Integer limit, String pattern) {
1591
        return dao.getUuidAndTitleCacheTaxon(limit, pattern);
1591 1592
    }
1592 1593

  
1593 1594
    @Override
1594
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym() {
1595
        return dao.getUuidAndTitleCacheSynonym();
1595
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym(Integer limit, String pattern) {
1596
        return dao.getUuidAndTitleCacheSynonym(limit, pattern);
1596 1597
    }
1597 1598

  
1598 1599
    @Override

Also available in: Unified diff