/** * Returns the experimenters contained in this group. * * @return See above. */ public Set getExperimenters() { if (experimenters == null && asGroup().sizeOfGroupExperimenterMap() >= 0) { experimenters = new HashSet<ExperimenterData>(); List<GroupExperimenterMap> links = asGroup().copyGroupExperimenterMap(); for (GroupExperimenterMap link : links) { experimenters.add(new ExperimenterData(link.getChild())); } } return experimenters == null ? null : new HashSet(experimenters); }
/** * Returns the experimenters contained in this group. * * @return See above. */ public Set getLeaders() { if (leaders == null && asGroup().sizeOfGroupExperimenterMap() >= 0) { leaders = new HashSet<ExperimenterData>(); List<GroupExperimenterMap> links = asGroup().copyGroupExperimenterMap(); for (GroupExperimenterMap link : links) { if (link.getOwner().getValue()) leaders.add(new ExperimenterData(link.getChild())); } } return leaders == null ? null : new HashSet(leaders); }
/** * Tests the creation of a user using the <code>createUser</code> method. * * @throws Exception Thrown if an error occurred. */ @Test public void testCreateUser() throws Exception { String uuid = UUID.randomUUID().toString(); Experimenter e = new ExperimenterI(); e.setOmeName(omero.rtypes.rstring(uuid)); e.setFirstName(omero.rtypes.rstring("user")); e.setLastName(omero.rtypes.rstring("user")); IAdminPrx svc = root.getSession().getAdminService(); // already tested ExperimenterGroup g = new ExperimenterGroupI(); g.setName(omero.rtypes.rstring(uuid)); g.getDetails().setPermissions(new PermissionsI("rw----")); long groupId = svc.createGroup(g); long id = svc.createUser(e, uuid); IQueryPrx query = root.getSession().getQueryService(); // Check if we have a user ParametersI p = new ParametersI(); p.addId(id); e = (Experimenter) query.findByQuery("select distinct e from Experimenter e where e.id = :id", p); assertNotNull(e); assertTrue(e.getOmeName().getValue().equals(uuid)); // check if we are in the correct group i.e. user and uuid // now check if the user is in correct groups. ExperimenterGroup userGroup = svc.lookupGroup(USER_GROUP); List<Long> ids = new ArrayList<Long>(); ids.add(groupId); ids.add(userGroup.getId().getValue()); p = new ParametersI(); p.addLongs("gids", ids); List list = (List) query.findAllByQuery( "select m " + "from GroupExperimenterMap as m " + "left outer join fetch m.child " + "left outer join fetch m.parent" + " where m.parent.id in (:gids)", p); assertNotNull(list); Iterator i = list.iterator(); GroupExperimenterMap geMap; int count = 0; while (i.hasNext()) { geMap = (GroupExperimenterMap) i.next(); if (geMap.getChild().getId().getValue() == id) count++; } assertTrue(count == 2); }