Project

General

Profile

Revision db7c13f4

IDdb7c13f464ba9d75e857b930f47a7377050f74ae
Parent c13b20b4
Child a82e8663

Added by Katja Luther almost 4 years ago

fix #5828: add abbrevTitleCache and titleCache to uuidAndTitleCache

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/agent/AgentDaoImpl.java
181 181

  
182 182
        Query query = null;
183 183
        if (pattern != null){
184
            query = session.createQuery("select uuid, id, nomenclaturalTitle from " + type.getSimpleName() +" where nomenclaturalTitle like :pattern" + clazzString);
184
            query = session.createQuery("select uuid, id, nomenclaturalTitle, titlecache from " + type.getSimpleName() +" where nomenclaturalTitle like :pattern" + clazzString);
185 185
            pattern = pattern + "%";
186 186
            pattern = pattern.replace("*", "%");
187 187
            pattern = pattern.replace("?", "_");
188 188
            query.setParameter("pattern", pattern);
189 189
        } else {
190 190
            if (clazzString != ""){
191
                query = session.createQuery("select uuid, id, nomenclaturalTitle from " + type.getSimpleName() + " where " + clazzString);
191
                query = session.createQuery("select uuid, id, nomenclaturalTitle, titleCache from " + type.getSimpleName() + " where " + clazzString);
192 192
            } else{
193
                query = session.createQuery("select uuid, id, nomenclaturalTitle from " + type.getSimpleName());
193
                query = session.createQuery("select uuid, id, nomenclaturalTitle, titleCache from " + type.getSimpleName());
194 194
            }
195 195
        }
196 196
        if (limit != null){
197 197
           query.setMaxResults(limit);
198 198
        }
199 199

  
200
        return getUuidAndTitleCache(query);
200
        return getUuidAndAbbrevTitleCache(query);
201 201
    }
202 202

  
203 203

  
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/IdentifiableDaoBase.java
306 306
        return getUuidAndTitleCache(null, null);
307 307
    }
308 308

  
309
    protected <E extends IIdentifiableEntity> List<UuidAndTitleCache<E>> getUuidAndAbbrevTitleCache(Query query){
310
        List<UuidAndTitleCache<E>> list = new ArrayList<UuidAndTitleCache<E>>();
311

  
312
        List<Object[]> result = query.list();
313

  
314
        for(Object[] object : result){
315
            list.add(new UuidAndTitleCache<E>((UUID) object[0],(Integer) object[1], (String) object[3], (String) object[2]));
316
        }
317
        return list;
318
    }
319

  
309 320
    protected <E extends IIdentifiableEntity> List<UuidAndTitleCache<E>> getUuidAndTitleCache(Query query){
310 321
        List<UuidAndTitleCache<E>> list = new ArrayList<UuidAndTitleCache<E>>();
311 322

  
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImpl.java
282 282
                // see FIXME in 'prepareQuery' for more details
283 283
                if (doTaxa && doSynonyms){
284 284
                    if (result[3].equals("synonym")) {
285
                        resultObjects.add( new UuidAndTitleCache(Synonym.class, (UUID) result[0], (Integer) result[1], (String)result[2], new Boolean(result[4].toString())));
285
                        resultObjects.add( new UuidAndTitleCache(Synonym.class, (UUID) result[0], (Integer) result[1], (String)result[2], new Boolean(result[4].toString()), null));
286 286
                    }
287 287
                    else {
288
                        resultObjects.add( new UuidAndTitleCache(Taxon.class, (UUID) result[0], (Integer) result[1], (String)result[2], new Boolean(result[4].toString())));
288
                        resultObjects.add( new UuidAndTitleCache(Taxon.class, (UUID) result[0], (Integer) result[1], (String)result[2], new Boolean(result[4].toString()), null));
289 289
                    }
290 290
                }else if (doTaxa){
291
                        resultObjects.add( new UuidAndTitleCache(Taxon.class, (UUID) result[0], (Integer) result[1], (String)result[2], new Boolean(result[4].toString())));
291
                        resultObjects.add( new UuidAndTitleCache(Taxon.class, (UUID) result[0], (Integer) result[1], (String)result[2], new Boolean(result[4].toString()), null));
292 292
                }else if (doSynonyms){
293
                    resultObjects.add( new UuidAndTitleCache(Synonym.class, (UUID) result[0], (Integer) result[1], (String)result[2], new Boolean(result[4].toString())));
293
                    resultObjects.add( new UuidAndTitleCache(Synonym.class, (UUID) result[0], (Integer) result[1], (String)result[2], new Boolean(result[4].toString()), null));
294 294
                }
295 295
            }
296 296

  
......
2140 2140
            Object[] result;
2141 2141
            for(int i = 0; i<resultArray.size();i++){
2142 2142
            	result = (Object[]) resultArray.get(i);
2143
            	returnResult.add(new UuidAndTitleCache(Taxon.class, (UUID) result[0],(Integer)result[1], (String)result[2], new Boolean(result[4].toString())));
2143
            	returnResult.add(new UuidAndTitleCache(Taxon.class, (UUID) result[0],(Integer)result[1], (String)result[2], new Boolean(result[4].toString()), null));
2144 2144
            }
2145 2145
            return returnResult;
2146 2146
        }
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/UuidAndTitleCache.java
37 37
	private UUID uuid;
38 38
	private Integer id;
39 39
	private String titleCache;
40
	private String abbrevTitleCache;
40 41
	private boolean isOrphaned;
41 42

  
43
    public UuidAndTitleCache(UUID uuid, Integer id, String titleCache, String abbrevTitleCache) {
44
        this.uuid = uuid;
45
        this.titleCache = titleCache;
46
        this.id = id;
47
        this.abbrevTitleCache = abbrevTitleCache;
48
    }
42 49
    public UuidAndTitleCache(UUID uuid, Integer id, String titleCache) {
43 50
        this.uuid = uuid;
44 51
        this.titleCache = titleCache;
45 52
        this.id = id;
53
        this.abbrevTitleCache = null;
46 54
    }
47 55

  
56
    public UuidAndTitleCache(Class<T> type, UUID uuid, Integer id, String titleCache, String abbrevTitleCache) {
57
        this(uuid, id, titleCache, abbrevTitleCache);
58
        this.type = type;
59
        this.isOrphaned = false;
60
    }
48 61
    public UuidAndTitleCache(Class<T> type, UUID uuid, Integer id, String titleCache) {
49
        this(uuid, id, titleCache);
62
        this(uuid, id, titleCache, null);
50 63
        this.type = type;
51 64
        this.isOrphaned = false;
52 65
    }
53 66

  
54
	public UuidAndTitleCache(Class<T> type, UUID uuid, Integer id, String titleCache, Boolean isOrphaned) {
55
		this(type, uuid, id, titleCache);
67
	public UuidAndTitleCache(Class<T> type, UUID uuid, Integer id, String titleCache, Boolean isOrphaned, String abbrevTitleCache) {
68
		this(type, uuid, id, titleCache, abbrevTitleCache);
56 69
		this.isOrphaned = isOrphaned;
57 70
	}
58 71

  
......
64 77
		return titleCache;
65 78
	}
66 79

  
80

  
81
    /**
82
     * @return the titleCache
83
     */
84
    public String getAbbrevTitleCache() {
85
        return abbrevTitleCache;
86
    }
87

  
88

  
67 89
	/**
68 90
	 * @return the uuid
69 91
	 */
......
87 109

  
88 110
    @Override
89 111
    public String toString() {
90
        return "UuidAndTitleCache [type=" + type + ", uuid=" + uuid + ", id=" + id + ", titleCache=" + titleCache
91
                + ", isOrphaned=" + isOrphaned + "]";
112
        return "UuidAndTitleCache [type= " + type + ", uuid= " + uuid + ", id=" + id + ", titleCache= " + titleCache
113
                + ", isOrphaned=" + isOrphaned + ", abbrevTitleCache= " + abbrevTitleCache +"]";
92 114
    }
93 115

  
94 116

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)