public QueryConstraints(LocalAdmin iAdmin, LocalQuery iQuery, long id, boolean force) { this.iAdmin = iAdmin; this.iQuery = iQuery; this.id = id; this.force = force; p = new Parameters().addId(id); rv = new UnloadedCollector(iQuery, iAdmin, false); }
@RolesAllowed("user") public Experimenter[] containedExperimenters(long groupId) { List<Experimenter> experimenters = iQuery.findAllByQuery( "select distinct e from Experimenter as e " + "join fetch e.groupExperimenterMap as map " + "join fetch map.parent g " + "where e.id in " + " (select m.child from GroupExperimenterMap m " + " where m.parent.id = :id )", new Parameters() .addId(groupId)); return experimenters.toArray(new Experimenter[experimenters.size()]); }
public String getUserInstitution(long userId, ServiceFactory sf) { final Parameters parameters = new Parameters().addId(userId); final List<Object[]> results = sf.getQueryService().projection(LOAD_USER_INSTITUTION, parameters); if (results instanceof List && results.get(0) instanceof Object[]) { final Object[] firstResult = (Object[]) results.get(0); if (firstResult.length > 0 && firstResult[0] instanceof String) { return (String) firstResult[0]; } } return null; }
@Transactional(readOnly = true) public Object doWork(Session session, ServiceFactory sf) { return sf.getQueryService().findByQuery( LOAD_ORIGINAL_FILE+" f.id = :id", new Parameters().addId(repoId)); } });
@Override public EventLog query() { if (obj == null) { return null; } else { EventLog el = query.findByQuery("select el from EventLog el " + "where el.action = 'INSERT' and " + "el.entityType = :type and " + "el.entityId = :id", new Parameters() .addString("type", obj.getClass().getName()).addId( obj.getId())); obj = null; return el; } }
@Transactional(readOnly = true) public Object doWork(Session session, ServiceFactory sf) { List<Object[]> rv = sf.getQueryService().projection( "select o.id from RenderingDef r join r.details.owner o " + "where r.id = :id", new Parameters().addId(rendDefObj.getId())); Long currentUser = getCurrentEventContext().getCurrentUserId(); Long ownerId = (Long) rv.get(0)[0]; return ownerId.equals(currentUser); }}); }
private void loadFromQuery(Set<String> addresses) { for (Object[] o : getQueryService().projection( "select e.email from Experimenter e " + "join e.groupExperimenterMap m " + "join m.parent g where g.id = :id", new Parameters().addId(getRoles().getSystemGroupId()))) { if (o != null && o.length >= 1 && o[0] != null) { String email = o[0].toString(); if (!email.isEmpty()) { addresses.add(email); } } } }
@Transactional(readOnly = true) public Object doWork(Session session, ServiceFactory sf) { final ExperimenterGroup group = sf.getQueryService().findByQuery( "select p.details.group from Pixels p where p.id = :id", new ome.parameters.Parameters().addId(mpm.pixelsID)); return group.getId(); } });
@Override @RolesAllowed("user") public RenderingDef loadRndSettings(long renderingDefId) { return (RenderingDef) iQuery.findByQuery( RENDERING_DEF_QUERY_PREFIX + "rdef.id = :id", new Parameters().addId(renderingDefId)); }
protected Pixels getPixels(Long id, ServiceFactory sf) { final IQuery iQuery = sf.getQueryService(); final Pixels pixels = iQuery.findByQuery( "select p from Pixels as p " + "left outer join fetch p.channels ch " + // For statsinfo "join fetch p.pixelsType where p.id = :id ", new Parameters().addId(id)); return pixels; }
/** * Use {@link IQuery#projection(String, Parameters)} to load the first * long which matches the given query. This means that the first return * value in the select statement should likely be the id of an object. */ protected omero.RLong firstIdOrNull(String query) { List<Object[]> ids = helper.getServiceFactory().getQueryService() .projection(query, new Parameters().addId(imageId).page(0, 1)); if (ids != null && ids.size() > 0) { Object[] id = ids.get(0); if (id != null && id.length > 0) { return omero.rtypes.rlong((Long) id[0]); } } return null; }
/** * Returns the {@link EventLog} with the next id after the given argument or * null if none exists. This method will only return "true" {@link EventLog} * instances, with a valid id. */ public final EventLog nextEventLog(long id) { if (query == null) { initQueryString(); } Parameters params = new Parameters().page(0, 1).addId(id); return queryService.findByQuery(query, params); }
public void runAsAdmin() { images[0] = iQuery.findByQuery(IMAGE_QUERY, new Parameters() .addId(id)); if (images[0] == null) { throw new ApiUsageException("Cannot find image: " + id); } collect(delete, images[0]); } });
@Transactional(readOnly=true) public Object doWork(org.hibernate.Session session, ServiceFactory sf) { return sf.getQueryService().findByQuery( stdfile_query, new Parameters().addId(job.getId().getValue()) .addString("name", name)); } });
@Override public Session findSessionById(long id, ServiceFactory sf) { final LocalQuery iQuery = (LocalQuery) sf.getQueryService(); final String sessionClass = iQuery.find(Share.class, id) == null ? "Session" : "Share"; return (Session) iQuery.findByQuery( "select s from " + sessionClass + " s " + "left outer join fetch s.sudoer " + "left outer join fetch s.annotationLinks l " + "left outer join fetch l.child a where s.id = :id", new Parameters().addId(id).cache()); }
@RolesAllowed("user") @Transactional(readOnly = false) public void deleteComment(@NotNull Annotation comment) { List<SessionAnnotationLink> links = iQuery.findAllByQuery( "select l from SessionAnnotationLink l " + "where l.child.id = :id", new Parameters() .addId(comment.getId())); for (SessionAnnotationLink sessionAnnotationLink : links) { iUpdate.deleteObject(sessionAnnotationLink); } iUpdate.deleteObject(comment); }
public List<OriginalFile> getMyUserPhotos() { Parameters parameters = new Parameters(); parameters.addId(getEventContext().getCurrentUserId()); parameters.addString("ns", NSEXPERIMENTERPHOTO); List<OriginalFile> photos = iQuery.findAllByQuery( "select f from Experimenter e join e.annotationLinks l " + "join l.child a join a.file f where e.id = :id and a.ns = :ns", parameters); return photos; }
@RolesAllowed("user") public ExperimenterGroup getGroup(long id) { ExperimenterGroup g = iQuery.execute(new GroupQ(new Parameters() .addId(id))); if (g == null) { throw new ApiUsageException("No such group: " + id); } return g; }
@RolesAllowed("user") public Experimenter getExperimenter(final long id) { Experimenter e = iQuery.execute(new UserQ(new Parameters().addId(id))); if (e == null) { throw new ApiUsageException("No such experimenter: " + id); } return e; }
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; }