@Transactional(readOnly = true) public Object doWork(Session session, ServiceFactory sf) { return sf.getQueryService().findAllByQuery( QUERY, null); } }));
@Transactional(readOnly = true) public List<IObject> doWork(Session session, ServiceFactory sf) { return sf.getQueryService().findAllByQuery( query, params ); } });
@Transactional(readOnly = true) public List<IObject> doWork(Session session, ServiceFactory sf) { return sf.getQueryService().findAllByQuery( query, params ); } });
private List<IObject> loadObjects(String type, IQuery query, Collection<Long> ids) { if (ids != null && ids.size() > 0) { return query.findAllByQuery( "select p from " + type + " p where p.id in (:ids)", new Parameters().addIds(ids)); } return null; }
@Transactional(readOnly = true) public Object doWork(Session session, ServiceFactory sf) { return sf.getQueryService().findAllByQuery( "select fs from Fileset fs where fs.id in (:ids)", new Parameters().addIds(ids)); }})); } catch (Exception e) {
/** * Load all scripts that match the name, hash, and format for script */ protected List<OriginalFile> loadScripts(ServiceFactory sf, Parameters p) { p.addLong("gid", roles.getUserGroupId()); List<OriginalFile> files = sf.getQueryService().findAllByQuery( "select f from OriginalFile f where f.hash = :hash " + "and f.details.group.id = :gid " + "and f.name = :name " + "and f.mimetype = 'text/x-python'", p); return files; }
private void findAttached() { IQuery query = helper.getServiceFactory().getQueryService(); List<IObject> rv = query.findAllByQuery( "select o from Image i join i.pixels p " + "join p.pixelsFileMaps m join m.parent o " + "where i.id = :id", new Parameters().addId(imageId)); rsp.archivedFiles = new ArrayList<Long>(); for (IObject obj : rv) { long id = obj.getId(); rsp.archivedFiles.add(id); File f = new File(pixelsService.getFilesPath(id)); if (f.exists()) { rsp.archivedSize += f.length(); } } }
return sf.getQueryService().findAllByQuery(query, _p);
/** * Retrieves all thumbnail metadata available in the database for a given * Pixels ID. * @param pixelsId Pixels ID to retrieve thumbnail metadata for. * @return See above. */ public List<Thumbnail> loadAllMetadata(long pixelsId) { Parameters params = new Parameters(); params.addId(pixelsId); params.addLong("o_id", userId); StopWatch s1 = new Slf4JStopWatch("omero.loadAllMetadata"); List<Thumbnail> toReturn = queryService.findAllByQuery( "select t from Thumbnail as t " + "join t.pixels p " + "join fetch t.details.updateEvent " + "where t.details.owner.id = :o_id " + "and p.id = :id", params); if (toReturn.isEmpty()) { toReturn = queryService.findAllByQuery( "select t from Thumbnail as t " + "join t.pixels p " + "join fetch t.details.updateEvent " + "where t.details.owner.id = p.details.owner.id " + "and p.id = :id", params); } s1.stop(); return toReturn; }
/** * Loads and prepares missing Pixels sets. * @param pixelsIds Pixels IDs to load missing Pixels objects for. */ private void loadMissingPixels(Set<Long> pixelsIds) { if (pixelsIds.size() > 0) { Parameters parameters = new Parameters(); parameters.addIds(pixelsIds); if (log.isDebugEnabled()) { log.debug("Loading " + pixelsIds.size() + " missing Pixels."); } StopWatch s1 = new Slf4JStopWatch( "omero.loadMissingPixels"); List<Pixels> pixelsWithoutSettings = queryService.findAllByQuery( "select p from Pixels as p where id in (:ids)", parameters); s1.stop(); for (Pixels pixels : pixelsWithoutSettings) { Long pixelsId = pixels.getId(); pixelsIdPixelsMap.put(pixelsId, pixels); pixelsIdOwnerIdMap.put( pixelsId, pixels.getDetails().getOwner().getId()); } } }
params.addIds(pixelsIds); StopWatch s1 = new Slf4JStopWatch("omero.bulkLoadMetadata"); List<Thumbnail> toReturn = queryService.findAllByQuery( "select t from Thumbnail as t " + "join t.pixels p " + "and p.id in (:ids)", params); if (toReturn.isEmpty()) { toReturn = queryService.findAllByQuery( "select t from Thumbnail as t " + "join t.pixels p " +
List<Experimenter> exps = iquery.findAllByQuery(sql.toString(), p);
/** * Bulk loads thumbnail metadata that is owned by the owner of the Pixels * set.. * @param dimensions X-Y dimensions to bulk load metadata for. * @param pixelsIds Pixels IDs to bulk load metadata for. * @return List of thumbnail objects with <code>thumbnail.pixels</code> and * <code>thumbnail.details.updateEvent</code> loaded. */ private List<Thumbnail> bulkLoadOwnerMetadata(Dimension dimensions, Set<Long> pixelsIds) { Parameters params = new Parameters(); params.addInteger("x", (int) dimensions.getWidth()); params.addInteger("y", (int) dimensions.getHeight()); params.addIds(pixelsIds); StopWatch s1 = new Slf4JStopWatch("omero.bulkLoadOwnerMetadata"); // Why is does this not try userId first? List<Thumbnail> toReturn = queryService.findAllByQuery( "select t from Thumbnail as t " + "join t.pixels as p " + "join fetch t.details.updateEvent " + "where t.sizeX = :x and t.sizeY = :y " + "and t.details.owner.id = p.details.owner.id " + "and t.pixels.id in (:ids)", params); s1.stop(); return toReturn; }
List<RenderingDef> toReturn = queryService.findAllByQuery( "select r from RenderingDef as r " + "join fetch r.pixels as p " + new Parameters().addId(userId).addIds(pixelsIds)); if (toReturn.isEmpty()) { toReturn = queryService.findAllByQuery( "select r from RenderingDef as r " + "join fetch r.pixels as p " +
/** * Bulk loads a set of rendering sets for a group of pixels sets. * @param pixelsIds the Pixels sets to retrieve thumbnails for. * @return Loaded rendering settings for <code>pixelsIds</code>. */ private List<RenderingDef> bulkLoadOwnerRenderingSettings( Set<Long> pixelsIds) { StopWatch s1 = new Slf4JStopWatch( "omero.bulkLoadOwnerRenderingSettings"); // Why doesn't this first try by userId? List<RenderingDef> toReturn = queryService.findAllByQuery( "select r from RenderingDef as r " + "join fetch r.pixels as p " + "join fetch r.details.updateEvent " + "join fetch p.details.updateEvent " + "where r.details.owner.id = p.details.owner.id " + "and r.pixels.id in (:ids) " + "order by r.details.updateEvent.time asc", new Parameters().addIds(pixelsIds)); s1.stop(); return toReturn; }
List<RenderingDef> toReturn = queryService.findAllByQuery( "select r from RenderingDef as r " + "join fetch r.pixels as p " + new Parameters().addId(userId).addIds(imageIds)); if (toReturn.isEmpty()) { toReturn = queryService.findAllByQuery( "select r from RenderingDef as r " + "join fetch r.pixels as p " +
sb.append("\n"); for (IObject obj : getQueryService().findAllByQuery(queryString, p)) { if (obj instanceof Experimenter) { addUser(addresses, (Experimenter) obj);
public List<Job> doWork(Session session, ServiceFactory sf) { final List<Job> jobs = sf.getQueryService().findAllByQuery( "select j from Job j where status.id = :id", new Parameters().addId(getSubmittedStatus(sf).getId())); for (Job job : jobs) { startProcess(sf, job.getId()); } return null; }
/** * Use {@link PixelsService} to find pre-FS binary files under * "/OMERO/Files", "/OMERO/Pixels", and "/OMERO/Thumbnails", * and store their size in the response. */ private void findBinary() { IQuery query = helper.getServiceFactory().getQueryService(); Pixels pixels = query.get(Image.class, imageId).getPrimaryPixels(); List<Thumbnail> thumbs = query.findAllByQuery( "select tb from Thumbnail tb where " + "tb.pixels.id = :id", new Parameters().addId(pixels.getId())); String path = pixelsService.getPixelsPath(pixels.getId()); files = new PixelFiles(path); files.update(rsp); for (Thumbnail tb: thumbs) { path = pixelsService.getThumbnailPath(tb.getId()); File thumbnailFile = new File(path); thumbnailFiles.add(thumbnailFile); rsp.thumbnailSize += thumbnailFile.length(); } }
for (final List<Long> idsBatch : Iterables.partition(ids, BATCH_SIZE)) { final Parameters params = new Parameters().addIds(idsBatch); for (final IObject file : q.findAllByQuery(filesById, params)) { files.add((ome.model.core.OriginalFile) file);