Changeset 2574
- Timestamp:
- 07/01/08 20:02:11 (5 months ago)
- Location:
- trunk/components
- Files:
-
- 2 added
- 3 modified
-
model/src/ome/util/builders/PojoOptions.java (modified) (1 diff)
-
server/src/ome/logic/PojosImpl.java (modified) (4 diffs)
-
server/src/ome/services/query/PojosGetImagesQueryDefinition.java (modified) (3 diffs)
-
server/test/ome/server/itests/scalability (added)
-
server/test/ome/server/itests/scalability/PaginationTest.java (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/model/src/ome/util/builders/PojoOptions.java
r2563 r2574 66 66 protected void copy(Map map) { 67 67 String[] s = new String[] { LEAF, EXPERIMENTER, GROUP, START_TIME, 68 END_TIME };68 END_TIME, OFFSET, LIMIT }; 69 69 for (int i = 0; i < s.length; i++) { 70 70 if (map.containsKey(s[i])) { -
trunk/components/server/src/ome/logic/PojosImpl.java
r2320 r2574 16 16 17 17 // Java imports 18 import java.sql.SQLException; 18 19 import java.util.Collection; 19 20 import java.util.HashMap; … … 60 61 import ome.util.builders.PojoOptions; 61 62 63 import org.hibernate.HibernateException; 64 import org.hibernate.Session; 62 65 import org.jboss.annotation.ejb.LocalBinding; 63 66 import org.jboss.annotation.ejb.RemoteBinding; 64 67 import org.jboss.annotation.ejb.RemoteBindings; 68 import org.springframework.orm.hibernate3.HibernateCallback; 65 69 import org.springframework.transaction.annotation.Transactional; 66 70 … … 346 350 } 347 351 348 @RolesAllowed("user") 349 @Transactional(readOnly = true) 350 public Set getImages(Class rootNodeType, Set rootNodeIds, Map options) { 352 static final Map<Class, String> paginationQueries = new HashMap(); 353 static { 354 paginationQueries.put(Dataset.class, 355 "select link.child.id from DatasetImageLink " 356 + " link where link.parent.id in (:ids)" 357 + "order by link.child.id"); 358 paginationQueries 359 .put( 360 Project.class, 361 "select distinct dil.child.id from ProjectDatasetLink pdl " 362 + "join pdl.child ds join ds.imageLinks as dil " 363 + "where pdl.parent.id in (:ids) order by dil.child.id"); 364 } 365 366 @RolesAllowed("user") 367 @Transactional(readOnly = true) 368 @SuppressWarnings("unchecked") 369 public Set getImages(final Class rootNodeType, final Set rootNodeIds, 370 final Map options) { 351 371 352 372 if (rootNodeIds.size() == 0) { … … 354 374 } 355 375 356 PojoOptions po = new PojoOptions(options); 376 final PojoOptions po = new PojoOptions(options); 377 378 // Effective values 379 Class effType = rootNodeType; 380 Set<Long> effIds = rootNodeIds; 381 382 if (po.isPagination()) { 383 final String query = paginationQueries.get(rootNodeType); 384 if (query == null) { 385 throw new ApiUsageException(rootNodeType.getName() 386 + " does not support pagination yet."); 387 } 388 effType = Image.class; 389 effIds = new HashSet<Long>((List<Long>) iQuery 390 .execute(new HibernateCallback() { 391 public Object doInHibernate(Session s) 392 throws HibernateException, SQLException { 393 return s.createQuery(query).setParameterList("ids", 394 rootNodeIds).setMaxResults(po.getLimit()) 395 .setFirstResult(po.getOffset()).list(); 396 } 397 })); 398 if (effIds == null || effIds.size() == 0) { 399 return new HashSet(); 400 } 401 } 357 402 358 403 Query<List<IObject>> q = getQueryFactory().lookup( 359 404 PojosGetImagesQueryDefinition.class.getName(), 360 new Parameters().addIds( rootNodeIds).addClass(rootNodeType)361 .addOptions(po.map()));405 new Parameters().addIds(effIds).addClass(effType).addOptions( 406 po.map())); 362 407 363 408 List<IObject> l = iQuery.execute(q); -
trunk/components/server/src/ome/services/query/PojosGetImagesQueryDefinition.java
r2052 r2574 41 41 Class klass = (Class) value(CLASS); 42 42 Collection ids = (Collection) value(IDS); 43 PojoOptions po = new PojoOptions((Map) value(OPTIONS)); 43 44 44 45 StringBuilder sb = new StringBuilder(); … … 87 88 88 89 // if PojoOptions sets START_TIME and/or END_TIME 89 if (check(OPTIONS)) { 90 PojoOptions po = new PojoOptions((Map) value(OPTIONS)); 91 if (po.getStartTime() != null) { 92 sb.append("img.details.creationEvent.time > :starttime and "); 93 params.put("starttime", po.getStartTime()); 94 } 95 if (po.getEndTime() != null) { 96 sb.append("img.details.creationEvent.time < :endtime and "); 97 params.put("endtime", po.getEndTime()); 98 } 90 if (po.getStartTime() != null) { 91 sb.append("img.details.creationEvent.time > :starttime and "); 92 params.put("starttime", po.getStartTime()); 93 } 94 if (po.getEndTime() != null) { 95 sb.append("img.details.creationEvent.time < :endtime and "); 96 params.put("endtime", po.getEndTime()); 99 97 } 100 98 … … 118 116 q.setParameter(param, params.get(param)); 119 117 } 118 120 119 q.setParameterList("ids", ids); 121 120 setQuery(q);
