View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.r2.lum.lu.dao.impl;
17  
18  import java.util.*;
19  
20  import javax.persistence.EntityManager;
21  import javax.persistence.PersistenceContext;
22  import javax.persistence.Query;
23  
24  import org.kuali.student.r1.common.dao.impl.AbstractCrudDaoImpl;
25  import org.kuali.student.r2.core.versionmanagement.dto.VersionDisplayInfo;
26  import org.kuali.student.r2.lum.lu.dao.LuDao;
27  import org.kuali.student.r2.lum.lu.entity.Clu;
28  import org.kuali.student.r2.lum.lu.entity.CluCluRelation;
29  import org.kuali.student.r2.lum.lu.entity.CluLoRelation;
30  import org.kuali.student.r2.lum.lu.entity.CluPublication;
31  import org.kuali.student.r2.lum.lu.entity.CluResult;
32  import org.kuali.student.r2.lum.lu.entity.CluResultType;
33  import org.kuali.student.r2.lum.lu.entity.CluSet;
34  //import org.kuali.student.r2.lum.lu.entity.Lui;
35  //import org.kuali.student.r2.lum.lu.entity.LuiLuiRelation;
36  
37  public class LuDaoImpl extends AbstractCrudDaoImpl implements LuDao {
38  
39  	@PersistenceContext(unitName = "Lu")
40  	@Override
41  	public void setEm(EntityManager em) {
42  		super.setEm(em);
43  	}
44  
45  	@Override
46  	public List<Clu> getClusByIdList(List<String> cluIdList) {
47  		Query query = em.createNamedQuery("Clu.findClusByIdList");
48  		query.setParameter("idList", cluIdList);
49  		@SuppressWarnings("unchecked")
50  		List<Clu> resultList = query.getResultList();
51  		return resultList;
52  	}
53  
54  	@Override
55  	public List<Clu> getClusByLuType(String luTypeKey, String luState) {
56  		Query query = em.createNamedQuery("Clu.getClusByLuType");
57  		query.setParameter("luTypeKey", luTypeKey);
58  		query.setParameter("luState", luState);
59  		@SuppressWarnings("unchecked")
60  		List<Clu> resultList = query.getResultList();
61  		return resultList;
62  	}
63  
64  	@Override
65  	public List<CluSet> getCluSetInfoByIdList(List<String> cluSetIdList) {
66  		Query query = em.createNamedQuery("CluSet.getCluSetInfoByIdList");
67  		query.setParameter("cluSetIdList", cluSetIdList);
68          @SuppressWarnings("unchecked")
69  		List<CluSet> resultList = query.getResultList();
70  		return resultList;
71  	}
72            /*
73  	@Override
74  	public List<Lui> getLuisByIdList(List<String> luiIds) {
75  		Query query = em.createNamedQuery("Lui.getLuisByIdList");
76  		query.setParameter("luiIdList", luiIds);
77  		@SuppressWarnings("unchecked")
78  		List<Lui> luis = query.getResultList();
79  		return luis;
80  	}
81                     */
82  	@Override
83  	public List<String> getLuiIdsByCluId(String cluId) {
84  		Query query = em.createNamedQuery("Lui.getLuiIdsByCluId");
85  		query.setParameter("cluId", cluId);
86  		@SuppressWarnings("unchecked")
87  		List<String> luiIds = query.getResultList();
88  		return luiIds;
89  	}
90                       /*
91  	@Override
92  	public List<Lui> getLuisByRelationType(String luiId,
93  			String luLuRelationTypeId) {
94  		Query query = em
95  				.createNamedQuery("LuiLuiRelation.getLuisByRelationType");
96  		query.setParameter("luiId", luiId);
97  		query.setParameter("luLuRelationTypeId", luLuRelationTypeId);
98  
99  		@SuppressWarnings("unchecked")
100 		List<Lui> luis = query.getResultList();
101 		return luis;
102 	}
103                             */
104 	@Override
105 	public List<String> getLuiIdsByRelationType(String relatedLuiId,
106 			String luLuRelationTypeId) {
107 		Query query = em
108 				.createNamedQuery("LuiLuiRelation.getLuiIdsByRelationType");
109 		query.setParameter("luiId", relatedLuiId);
110 		query.setParameter("luLuRelationTypeId", luLuRelationTypeId);
111 
112 		@SuppressWarnings("unchecked")
113 		List<String> luiIds = query.getResultList();
114 		return luiIds;
115 	}
116 
117 	@Override
118 	public List<String> getLuiIdsInAtpByCluId(String cluId, String atpKey) {
119 		Query query = em.createNamedQuery("Lui.getLuiIdsInAtpByCluId");
120 		query.setParameter("cluId", cluId);
121 		query.setParameter("atpKey", atpKey);
122 		@SuppressWarnings("unchecked")
123 		List<String> luiIds = query.getResultList();
124 		return luiIds;
125 	}
126 
127 	@Override
128 	public Boolean isCluInCluSet(String cluId, String cluSetId) {
129 		Query query = em.createNamedQuery("CluSet.isCluInCluSet");
130 		query.setParameter("cluId", cluId);
131 		query.setParameter("cluSetId", cluSetId);
132 		Long valid = (Long) query.getSingleResult();
133 		return valid.intValue() > 0;
134 	}
135                               /*
136 	@Override
137 	public List<LuiLuiRelation> getLuiLuiRelations(String luiId) {
138 		Query query = em
139 				.createNamedQuery("LuiLuiRelation.getLuiLuiRelationsByLuiId");
140 		query.setParameter("luiId", luiId);
141 		@SuppressWarnings("unchecked")
142 		List<LuiLuiRelation> luiLuiRelations = query.getResultList();
143 		return luiLuiRelations;
144 	}
145                                      */
146 	@Override
147 	public List<CluCluRelation> getCluCluRelationsByClu(String cluId) {
148 		Query query = em.createNamedQuery("CluCluRelation.getCluCluRelation");
149 		query.setParameter("cluId", cluId);
150 		@SuppressWarnings("unchecked")
151 		List<CluCluRelation> cluCluRelations = query.getResultList();
152 		return cluCluRelations;
153 	}
154 
155 	@Override
156 	public List<String> getCluIdsByLoId(String loId) {
157 		Query query = em.createNamedQuery("Clu.getCluIdsByLoId");
158 		query.setParameter("loId", loId);
159 		@SuppressWarnings("unchecked")
160 		List<String> cluIds = query.getResultList();
161 		return cluIds;
162 	}
163 
164 	@Override
165 	public List<String> getRelatedCluIdsByCluId(String cluId,
166 			String luLuRelationTypeId) {
167 		Query query = em
168 				.createNamedQuery("CluCluRelation.getRelatedCluIdsByCluId");
169 		query.setParameter("cluId", cluId);
170 		query.setParameter("luLuRelationTypeId", luLuRelationTypeId);
171 		@SuppressWarnings("unchecked")
172 		List<String> relatedCluIds = query.getResultList();
173 		return relatedCluIds;
174 	}
175 
176 	@Override
177     public List<String> getCluIdsByRelatedCluId(String relatedCluId, String luLuRelationTypeId) {
178         Query query = em.createNamedQuery("CluCluRelation.getCluIdsByRelatedCluId");
179         query.setParameter("relatedCluId", relatedCluId);
180         query.setParameter("luLuRelationTypeId", luLuRelationTypeId);
181         @SuppressWarnings("unchecked")
182         List<String> relatedCluIds = query.getResultList();
183         return relatedCluIds;
184     }
185 
186     @Override
187 	public List<Clu> getRelatedClusByCluId(String cluId,
188 			String luLuRelationTypeId) {
189 		Query query = em
190 				.createNamedQuery("CluCluRelation.getRelatedClusByCluId");
191 		query.setParameter("cluId", cluId);
192 		query.setParameter("luLuRelationTypeId", luLuRelationTypeId);
193 		@SuppressWarnings("unchecked")
194 		List<Clu> relatedClus = query.getResultList();
195 		return relatedClus;
196 	}
197 
198     @Override
199 	public List<Clu> getClusByRelatedCluId(String relatedCluId,
200 			String luLuRelationTypeId) {
201 		Query query = em
202 				.createNamedQuery("CluCluRelation.getClusByRelatedCluId");
203 		query.setParameter("relatedCluId", relatedCluId);
204 		query.setParameter("luLuRelationTypeId", luLuRelationTypeId);
205 		@SuppressWarnings("unchecked")
206 		List<Clu> relatedClus = query.getResultList();
207 		return relatedClus;
208 	}
209     
210     
211 
212 	@Override
213 	public List<String> getRelatedLuiIdsByLuiId(String luiId,
214 			String luLuRelationTypeId) {
215 		Query query = em
216 				.createNamedQuery("LuiLuiRelation.getRelatedLuiIdsByLuiId");
217 		query.setParameter("luiId", luiId);
218 		query.setParameter("luLuRelationTypeId", luLuRelationTypeId);
219 		@SuppressWarnings("unchecked")
220 		List<String> relatedLuiIds = query.getResultList();
221 		return relatedLuiIds;
222 	}
223                      /*
224 	@Override
225 	public List<Lui> getRelatedLuisByLuiId(String luiId,
226 			String luLuRelationTypeId) {
227 		Query query = em
228 				.createNamedQuery("LuiLuiRelation.getRelatedLuisByLuiId");
229 		query.setParameter("luiId", luiId);
230 		query.setParameter("luLuRelationTypeId", luLuRelationTypeId);
231 		@SuppressWarnings("unchecked")
232 		List<Lui> relatedLuis = query.getResultList();
233 		return relatedLuis;
234 	}                    */
235 
236 	@Override
237 	public List<Clu> getClusByRelation(String parentCluId,
238 			String luLuRelationTypeKey) {
239 		Query query = em.createNamedQuery("Clu.getClusByRelation");
240 		query.setParameter("parentCluId", parentCluId);
241 		query.setParameter("luLuRelationTypeKey", luLuRelationTypeKey);
242 		@SuppressWarnings("unchecked")
243 		List<Clu> resultList = query.getResultList();
244 		return resultList;
245 	}
246 
247 	@Override
248 	public List<Clu> getClusByRelationSt(String cluId, String luLuRelationTypeId, List<String> luStateList) {
249 		Query query = em.createNamedQuery("CluCluRelation.getRelatedClusByCluIdSt");
250 		query.setParameter("cluId", cluId);
251 		query.setParameter("luLuRelationTypeId", luLuRelationTypeId);
252 		query.setParameter("luStateList", luStateList);
253 		@SuppressWarnings("unchecked")
254 		List<Clu> resultList = query.getResultList();
255 		
256 		query = em.createNamedQuery("CluCluRelation.getClusByRelatedCluIdSt");
257 		query.setParameter("relatedCluId", cluId);
258 		query.setParameter("luLuRelationTypeId", luLuRelationTypeId);
259 		query.setParameter("luStateList", luStateList);		
260 		List<Clu> resultListRel = query.getResultList();
261 		if(resultListRel != null)
262 			for(Clu clu:resultListRel) {
263 				if (!resultList.contains(clu))
264 					resultList.add(clu);
265 			}
266 		
267 		return resultList;
268 	}
269 	
270 	@Override
271 	public List<CluLoRelation> getCluLoRelationsByClu(String cluId) {
272 		Query query = em
273 				.createNamedQuery("CluLoRelation.getCluLoRelationByClu");
274 		query.setParameter("cluId", cluId);
275 		@SuppressWarnings("unchecked")
276 		List<CluLoRelation> cluLoRelations = query.getResultList();
277 		return cluLoRelations;
278 	}
279 
280 	@Override
281 	public List<CluLoRelation> getCluLoRelationsByLo(String loId) {
282 		Query query = em
283 				.createNamedQuery("CluLoRelation.getCluLoRelationByLo");
284 		query.setParameter("loId", loId);
285 		@SuppressWarnings("unchecked")
286 		List<CluLoRelation> cluLoRelations = query.getResultList();
287 		return cluLoRelations;
288 	}
289 
290 	@Override
291 	public List<CluLoRelation> getCluLoRelationsByCludIdAndLoId(String cluId,
292 			String loId) {
293 		Query query = em.createNamedQuery("CluLoRelation.getCluLoRelation");
294 		query.setParameter("cluId", cluId);
295 		query.setParameter("loId", loId);
296 
297 		@SuppressWarnings("unchecked")
298 		List<CluLoRelation> rels = query.getResultList();
299 		return rels;
300 	}
301 
302 	@Override
303 	public List<String> getAllowedLuLuRelationTypesForLuType(String luTypeId,
304 			String relatedLuTypeId) {
305 		Query query = em
306 				.createNamedQuery("AllowedLuLuRelationType.getAllowedTypesByLuTypes");
307 		query.setParameter("luTypeId", luTypeId);
308 		query.setParameter("relatedLuTypeId", relatedLuTypeId);
309 		@SuppressWarnings("unchecked")
310 		List<String> resultList = query.getResultList();
311 		return resultList;
312 	}
313 
314 	@Override
315 	public List<String> getAllowedCluLoRelationTypesForLuType(String luTypeId) {
316 		Query query = em
317 				.createNamedQuery("AllowedCluLoRealtionType.getAllowedTypesByLuType");
318 		query.setParameter("luTypeId", luTypeId);
319 		@SuppressWarnings("unchecked")
320 		List<String> resultList = query.getResultList();
321 		return resultList;
322 	}
323 
324 	@Override
325 	public List<String> getAllowedResultUsageTypesForLuType(String luTypeId) {
326 		Query query = em
327 				.createNamedQuery("AllowedResultUsageLuType.getAllowedTypesByLuType");
328 		query.setParameter("luTypeId", luTypeId);
329 		@SuppressWarnings("unchecked")
330 		List<String> resultList = query.getResultList();
331 		return resultList;
332 	}
333 
334 	@Override
335 	public List<String> getAllowedResultComponentTypesForResultUsageType(
336 			String resultUsageType) {
337 		Query query = em
338 				.createNamedQuery("AllowedResultComponentUsageType.getAllowedComponentsByUsageType");
339 		query.setParameter("resultUsageType", resultUsageType);
340 		@SuppressWarnings("unchecked")
341 		List<String> resultList = query.getResultList();
342 		return resultList;
343 	}
344 
345 	@Override
346 	public List<CluResultType> getAllowedCluResultTypesForLuType(String luTypeId) {
347 		Query query = em
348 				.createNamedQuery("AllowedCluResultLuType.getAllowedTypesByLuType");
349 		query.setParameter("luTypeId", luTypeId);
350 		@SuppressWarnings("unchecked")
351 		List<CluResultType> resultList = query.getResultList();
352 		return resultList;
353 	}
354 
355 	@Override
356 	public List<String> getCluIdsByResultUsageType(String resultUsageTypeKey) {
357 		Query query = em
358 				.createNamedQuery("CluResult.getCluIdByResultUsageType");
359 		query.setParameter("resultUsageType", resultUsageTypeKey);
360 		@SuppressWarnings("unchecked")
361 		List<String> resultList = query.getResultList();
362 		return resultList;
363 	}
364 
365 	@Override
366 	public List<String> getCluIdsByResultComponentId(String resultComponentId) {
367 		Query query = em
368 				.createNamedQuery("CluResult.getCluIdByResultComponentId");
369 		query.setParameter("resultComponentId", resultComponentId);
370 		@SuppressWarnings("unchecked")
371 		List<String> resultList = query.getResultList();
372 		return resultList;
373 	}
374 
375 	@Override
376 	public List<String> getAllowedLuLuRelationTypesByLuiId(String luiId,
377 			String relatedLuiId) {
378 		Query query = em
379 				.createNamedQuery("LuiLuiRelation.getRelationTypeByLuiId");
380 		query.setParameter("luiId", luiId);
381 		query.setParameter("relatedLuiId", relatedLuiId);
382 		@SuppressWarnings("unchecked")
383 		List<String> resultList = query.getResultList();
384 		return resultList;
385 	}
386 
387 	@Override
388 	public List<String> getAllowedLuLuRelationTypesByCluId(String cluId,
389 			String relatedCluId) {
390 		Query query = em
391 				.createNamedQuery("CluCluRelation.getRelationTypeByCluId");
392 		query.setParameter("cluId", cluId);
393 		query.setParameter("relatedCluId", relatedCluId);
394 		@SuppressWarnings("unchecked")
395 		List<String> resultList = query.getResultList();
396 		return resultList;
397 	}
398 
399 	@Override
400 	public List<CluResult> getCluResultByClu(String cluId) {
401 		Query query = em
402 				.createNamedQuery("CluResult.getCluResultByCluId");
403 		query.setParameter("cluId", cluId);
404 		@SuppressWarnings("unchecked")
405 		List<CluResult> resultList = query.getResultList();
406 		return resultList;
407 	}
408 
409     @Override
410     public List<CluResult> getCluResultsByClus(List<String> cluIds) {
411         Set<String> cluIdSet = new HashSet<String>(cluIds.size());
412         // remove duplicates from the key list
413         cluIdSet.addAll(cluIds);
414         return (List<CluResult>) em.createNamedQuery("CluResult.getCluResultsByCluIds").setParameter("cluIds", cluIdSet).getResultList();
415     }
416 
417     @Override
418     public Clu getLatestCluVersion(String cluVersionIndId) {
419         Query query = em.createNamedQuery("Clu.findLatestClu");
420         query.setParameter("versionIndId", cluVersionIndId);
421         Clu clu = (Clu)query.getSingleResult();
422         return clu;
423     }
424 
425 	@Override
426 	public Clu getCurrentCluVersion(String cluVersionIndId) {
427         Query query = em.createNamedQuery("Clu.findCurrentClu");
428         query.setParameter("versionIndId", cluVersionIndId);
429         query.setParameter("currentTime", new Date());
430         Clu clu = (Clu)query.getSingleResult();
431         return clu;
432 	}
433 
434 	@Override
435 	public VersionDisplayInfo getCurrentCluVersionInfo(String cluVersionIndId, String objectTypeURI) {
436         Query query = em.createNamedQuery("Clu.findCurrentVersionInfo");
437         query.setParameter("versionIndId", cluVersionIndId);
438         query.setParameter("currentTime", new Date());
439         VersionDisplayInfo versionDisplayInfo = (VersionDisplayInfo)query.getSingleResult();
440         versionDisplayInfo.setRefObjectUri(objectTypeURI);
441         return versionDisplayInfo;
442 	}
443 
444 	@Override
445 	public VersionDisplayInfo getCurrentVersionOnDate(String versionIndId,
446 			String objectTypeURI, Date date) {
447         Query query = em.createNamedQuery("Clu.findCurrentVersionOnDate");
448         query.setParameter("versionIndId", versionIndId);
449         query.setParameter("date", date);
450         VersionDisplayInfo versionDisplayInfo = (VersionDisplayInfo)query.getSingleResult();
451         versionDisplayInfo.setRefObjectUri(objectTypeURI);
452         return versionDisplayInfo;
453 	}
454 
455 	@Override
456 	public VersionDisplayInfo getFirstVersion(String versionIndId,
457 			String objectTypeURI) {
458         Query query = em.createNamedQuery("Clu.findFirstVersion");
459         query.setParameter("versionIndId", versionIndId);
460         VersionDisplayInfo versionDisplayInfo = (VersionDisplayInfo)query.getSingleResult();
461         versionDisplayInfo.setRefObjectUri(objectTypeURI);
462         return versionDisplayInfo;
463 	}
464 
465 	@Override
466 	public VersionDisplayInfo getLatestVersion(String versionIndId,
467 			String objectTypeURI) {
468         Query query = em.createNamedQuery("Clu.findLatestVersion");
469         query.setParameter("versionIndId", versionIndId);
470         VersionDisplayInfo versionDisplayInfo = (VersionDisplayInfo)query.getSingleResult();
471         versionDisplayInfo.setRefObjectUri(objectTypeURI);
472         return versionDisplayInfo;
473 	}
474 
475 	@Override
476 	public VersionDisplayInfo getVersionBySequenceNumber(String versionIndId,
477 			String objectTypeURI, Long sequenceNumber) {
478         Query query = em.createNamedQuery("Clu.findVersionBySequence");
479         query.setParameter("versionIndId", versionIndId);
480         query.setParameter("sequenceNumber", sequenceNumber);
481         VersionDisplayInfo versionDisplayInfo = (VersionDisplayInfo)query.getSingleResult();
482         versionDisplayInfo.setRefObjectUri(objectTypeURI);
483         return versionDisplayInfo;
484 	}
485 
486 	@Override
487 	public List<VersionDisplayInfo> getVersions(String versionIndId,
488 			String objectTypeURI) {
489         Query query = em.createNamedQuery("Clu.findVersions");
490         query.setParameter("versionIndId", versionIndId);
491         List<VersionDisplayInfo> versionDisplayInfos = (List<VersionDisplayInfo>)query.getResultList();
492         if(versionDisplayInfos==null){
493         	versionDisplayInfos = Collections.emptyList();
494         }
495         for(VersionDisplayInfo versionDisplayInfo:versionDisplayInfos){
496         	versionDisplayInfo.setRefObjectUri(objectTypeURI);
497         }
498         return versionDisplayInfos;
499 	}
500 
501 	@Override
502 	public List<VersionDisplayInfo> getVersionsInDateRange(String versionIndId,
503 			String objectTypeURI, Date from, Date to) {
504 		if(from==null&&to==null){
505 			throw new IllegalArgumentException("from and to dates can not both be null");
506 		}
507 		Query query;
508 		if(from==null){
509 			query = em.createNamedQuery("Clu.findVersionsBeforeDate");
510 	        query.setParameter("versionIndId", versionIndId);
511 	        query.setParameter("date", to);			
512 		}else if(to==null){
513 			query = em.createNamedQuery("Clu.findVersionsAfterDate");
514 	        query.setParameter("versionIndId", versionIndId);
515 	        query.setParameter("date", from);
516 		}else{
517 			query = em.createNamedQuery("Clu.findVersionsInDateRange");
518 	        query.setParameter("versionIndId", versionIndId);
519 	        query.setParameter("from", from);
520 	        query.setParameter("to", to);
521 		}
522 		
523         List<VersionDisplayInfo> versionDisplayInfos = (List<VersionDisplayInfo>)query.getResultList();
524         if(versionDisplayInfos==null){
525         	versionDisplayInfos = Collections.emptyList();
526         }
527         for(VersionDisplayInfo versionDisplayInfo:versionDisplayInfos){
528         	versionDisplayInfo.setRefObjectUri(objectTypeURI);
529         }
530         return versionDisplayInfos;
531 	}
532 
533 	@Override
534 	public List<CluPublication> getCluPublicationsByType(
535 			String luPublicationTypeKey) {
536         Query query = em.createNamedQuery("CluPublication.findCluPublicationsByType");
537         query.setParameter("luPublicationTypeKey", luPublicationTypeKey);
538         List<CluPublication> cluPublications = query.getResultList();
539         return cluPublications;
540 	}
541 
542 	@Override
543 	public List<CluPublication> getCluPublicationsByCluId(String cluId) {
544         Query query = em.createNamedQuery("CluPublication.findPublicationsByCluId");
545         query.setParameter("cluId", cluId);
546         List<CluPublication> cluPublications = query.getResultList();
547         return cluPublications;
548 	}
549 
550 	@Override
551 	public List<CluSet> getCluSetsByCluVersionIndId(List<String> cluVersionIndIds) {
552         Query query = em.createNamedQuery("CluSet.findCluSetsByCluVersionIndIds");
553         query.setParameter("cluVersionIndIds", cluVersionIndIds);
554         List<CluSet> cluSetIds = query.getResultList();
555         return cluSetIds;
556 	}
557 
558 	@Override
559 	public List<CluSet> getAllDynamicCluSets() {
560         Query query = em.createNamedQuery("CluSet.findAllDynamicCluSets");
561         List<CluSet> cluSetIds = query.getResultList();
562         return cluSetIds;
563 	}
564 
565 	@Override
566 	public List<Clu> getCrossListedClusByCodes(List<String> crossListedCodes) {
567 		if(crossListedCodes!=null && crossListedCodes.isEmpty()){
568 			crossListedCodes.add(""); //Add a blank param value because jpql IN(:var) has problems with empty lists
569 		}
570         Query query = em.createNamedQuery("Clu.getCrossListedClusByCodes");
571         query.setParameter("crossListedCodes", crossListedCodes);
572         List<Clu> clus = query.getResultList();
573         return clus;
574 	}
575 	
576 }