public void runAsAdmin() { iQuery.execute(new HibernateCallback<Object>() { public Object doInHibernate(org.hibernate.Session s) throws HibernateException, SQLException { Query q = qb.query(s); List<Object[]> results = q.list(); if (results.size() != shareIds.size()) { throw new ValidationException( "Missing or protected shares specified"); } for (Object[] values : results) { Long shareId = (Long) values[0]; Long count = (Long) values[1]; rv.put(shareId, count); } return null; }}); }}); return rv;
@SuppressWarnings("rawtypes") private List getGroupField(final Experimenter e, final String name) { Assert.notNull(e); Assert.notNull(e.getId()); List<String> groupNames = iQuery.execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { org.hibernate.Query q = session .createQuery("select m.parent." + name + " " + "from Experimenter e " + "join e.groupExperimenterMap m " + "where e.id = :id order by index(m)"); q.setParameter("id", e.getId()); return q.list(); } }); return groupNames; }
protected Share shareToSession(final ShareData data) { Share share = iQuery.execute(new HibernateCallback<Object>() { public Object doInHibernate(org.hibernate.Session arg0) throws HibernateException, SQLException { BasicSecuritySystem bss = (BasicSecuritySystem) sec; try { bss.disableReadFilter(arg0); return arg0 .createQuery( "select sh from Share sh " + "join fetch sh.owner " + "where sh.id = :id") .setParameter("id", data.id).uniqueResult(); } finally { bss.enableReadFilter(arg0); } } }); if (share != null) { share.putAt("#2733", "ALLOW"); } return share; }
List<Session> list = iQuery.execute(new HibernateCallback<Object>() { public Object doInHibernate(org.hibernate.Session arg0) throws HibernateException, SQLException {
query.execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException {
@Override @RolesAllowed("user") @Transactional(readOnly = true) public Map getCollectionCount(String type, String property, Set ids, Parameters options) { String parsedProperty = LsidUtils.parseField(property); checkType(type); checkProperty(type, parsedProperty); Map<Long, Integer> results = new HashMap<Long, Integer>(); String query = "select size(table." + parsedProperty + ") from " + type + " table where table.id = :id"; // FIXME: optimize by doing new list(id,size(table.property)) ... group // by id for (Iterator iter = ids.iterator(); iter.hasNext();) { Long id = (Long) iter.next(); Query<List<Integer>> q = getQueryFactory().lookup(query, new Parameters().addId(id)); Integer count = iQuery.execute(q).get(0); results.put(id, count); } return results; }
String repo = (String) iQuery.execute(new HibernateCallback<String>(){ public String doInHibernate(Session arg0) throws HibernateException, SQLException {
@Override @RolesAllowed("user") @Transactional(readOnly = true) @SuppressWarnings("unchecked") public Set getUserImages(Parameters options) { options = new Parameters(options); // Checks for null if (!options.isExperimenter() && !options.isGroup()) { throw new ApiUsageException("experimenter or group option " + "is required for getUserImages()."); } Query<List<Image>> q = getQueryFactory().lookup( PojosGetUserImagesQueryDefinition.class.getName(), options); List<Image> l = iQuery.execute(q); return new HashSet<Image>(l); }
@Override @RolesAllowed("user") @Transactional(readOnly = true) @SuppressWarnings("unchecked") public Set getImagesByOptions(Parameters options) { options = new Parameters(options); // Checks for null if (options.getStartTime() == null && options.getEndTime() == null) { throw new ApiUsageException("start or end time option " + "is required for getImagesByOptions()."); } Query<List<IObject>> q = getQueryFactory().lookup( PojosGetImagesByOptionsQueryDefinition.class.getName(), options); List<IObject> l = iQuery.execute(q); return new HashSet<IObject>(l); }
.addSet("annotatorIds", annotatorIds)); List<IAnnotated> l = iQuery.execute(q); iQuery.clear();
PojosFindHierarchiesQueryDefinition.class.getName(), options.addClass(rootNodeType).addIds(imageIds)); List<Image> l = iQuery.execute(q);
@RolesAllowed("user") public Experimenter lookupExperimenter(final String omeName) { Experimenter e = iQuery.execute(new UserQ(new Parameters().addString( "name", roleProvider.isIgnoreCaseLookup() ? omeName.toLowerCase() : omeName))); if (e == null) { throw new ApiUsageException("No such experimenter: " + omeName); } return e; }
try { List<SessionAnnotationLink> links = (List<SessionAnnotationLink>) iQuery.execute(new HibernateCallback<Object>(){ public Object doInHibernate(org.hibernate.Session arg0) throws HibernateException, SQLException {
@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; }
PojosLoadHierarchyQueryDefinition.class.getName(), options.addClass(rootNodeType).addIds(rootNodeIds)); List<IObject> l = iQuery.execute(q); PojosLoadHierarchyQueryDefinition.class.getName(), options.addClass(Dataset.class).addIds(rootNodeIds)); List<IObject> list = iQuery.execute(q); Iterator<IObject> j = list.iterator(); Long id; PojosLoadHierarchyQueryDefinition.class.getName(), options.addClass(Plate.class).addIds(rootNodeIds)); List<IObject> list = iQuery.execute(q); Iterator<IObject> j = list.iterator(); Long id;
@RolesAllowed("user") public ExperimenterGroup lookupGroup(final String groupName) { ExperimenterGroup g = iQuery.execute(new GroupQ(new Parameters() .addString("name", groupName))); if (g == null) { throw new ApiUsageException("No such group: " + groupName); } 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; }
@RolesAllowed("user") public List<Long> getLeaderOfGroupIds(final Experimenter e) { Assert.notNull(e); Assert.notNull(e.getId()); final QueryBuilder qb = new QueryBuilder(); qb.select("g.id").from("ExperimenterGroup", "g"); qb.join("g.groupExperimenterMap", "m", false, false); qb.where(); qb.and("m.owner = true"); qb.and("m.parent.id = g.id"); qb.and("m.child.id = :id"); qb.param("id", e.getId()); List<Long> groupIds = iQuery.execute(new HibernateCallback<List<Long>>() { public List<Long> doInHibernate(Session session) throws HibernateException, SQLException { org.hibernate.Query q = qb.query(session); return (List<Long>) q.list(); } }); return groupIds; }
iQuery.execute(new HibernateCallback<Object>() { public Object doInHibernate(org.hibernate.Session s) throws HibernateException, SQLException {