use of net.geoprism.GeoprismUserQuery in project geoprism-registry by terraframe.
the class UserInfo method getSRAs.
public static JSONObject getSRAs(Integer pageSize, Integer pageNumber) {
RoleDAOIF role = RoleDAO.findRole(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE);
Set<SingleActorDAOIF> actors = role.assignedActors();
Set<String> oids = actors.parallelStream().map(actor -> actor.getOid()).collect(Collectors.toSet());
ValueQuery vQuery = new ValueQuery(new QueryFactory());
GeoprismUserQuery uQuery = new GeoprismUserQuery(vQuery);
UserInfoQuery iQuery = new UserInfoQuery(vQuery);
vQuery.SELECT(uQuery.getOid(), uQuery.getUsername(), uQuery.getFirstName(), uQuery.getLastName(), uQuery.getPhoneNumber(), uQuery.getEmail(), uQuery.getInactive());
vQuery.SELECT(iQuery.getAltFirstName(), iQuery.getAltLastName(), iQuery.getAltPhoneNumber(), iQuery.getPosition());
vQuery.SELECT(iQuery.getExternalSystemOid());
vQuery.WHERE(new LeftJoinEq(uQuery.getOid(), iQuery.getGeoprismUser()));
vQuery.AND(uQuery.getOid().IN(oids.toArray(new String[oids.size()])));
vQuery.ORDER_BY_ASC(uQuery.getUsername());
return serializePage(pageSize, pageNumber, new JSONArray(), vQuery);
}
use of net.geoprism.GeoprismUserQuery in project geoprism-registry by terraframe.
the class UserInfoPatch method doIt.
@Transaction
private void doIt() {
UserInfoQuery query = new UserInfoQuery(new QueryFactory());
try (OIterator<? extends UserInfo> it = query.getIterator()) {
while (it.hasNext()) {
UserInfo info = it.next();
info.appLock();
info.apply();
}
}
// Ensure all geoprism users have a user info
GeoprismUserQuery gQuery = new GeoprismUserQuery(new QueryFactory());
try (OIterator<? extends GeoprismUser> it = gQuery.getIterator()) {
while (it.hasNext()) {
GeoprismUser user = it.next();
UserInfo info = UserInfo.getByUser(user);
if (info == null) {
info = new UserInfo();
info.setGeoprismUser(user);
info.apply();
}
}
}
}
use of net.geoprism.GeoprismUserQuery in project geoprism-registry by terraframe.
the class TestUserInfo method getGeoprismUser.
public GeoprismUser getGeoprismUser() {
GeoprismUserQuery query = new GeoprismUserQuery(new QueryFactory());
query.WHERE(query.getUsername().EQ(this.username));
OIterator<? extends GeoprismUser> it = query.getIterator();
try {
if (it.hasNext()) {
return it.next();
} else {
return null;
}
} finally {
it.close();
}
}
use of net.geoprism.GeoprismUserQuery in project geoprism-registry by terraframe.
the class UserInfo method page.
public static JSONObject page(Integer pageSize, Integer pageNumber) {
final RolePermissionService perms = ServiceFactory.getRolePermissionService();
List<Organization> organizations = Organization.getUserOrganizations();
boolean isSRA = perms.isSRA();
boolean isRMorRCorAC = (!isSRA && !perms.isRA()) && (perms.isRM() || perms.isRC() || perms.isAC());
List<ExternalSystem> externalSystemList = ExternalSystem.getExternalSystemsForOrg(1, 100);
JSONArray externalSystems = new JSONArray();
for (ExternalSystem externalSystem : externalSystemList) {
externalSystems.put(new JSONObject(externalSystem.toJSON().toString()));
}
if (organizations.size() > 0 || isSRA) {
ValueQuery vQuery = new ValueQuery(new QueryFactory());
GeoprismUserQuery uQuery = new GeoprismUserQuery(vQuery);
UserInfoQuery iQuery = new UserInfoQuery(vQuery);
vQuery.SELECT(uQuery.getOid(), uQuery.getUsername(), uQuery.getFirstName(), uQuery.getLastName(), uQuery.getPhoneNumber(), uQuery.getEmail(), uQuery.getInactive());
vQuery.SELECT(iQuery.getAltFirstName(), iQuery.getAltLastName(), iQuery.getAltPhoneNumber(), iQuery.getPosition());
vQuery.SELECT(iQuery.getExternalSystemOid());
vQuery.WHERE(new LeftJoinEq(uQuery.getOid(), iQuery.getGeoprismUser()));
if (organizations.size() > 0) {
// restrict by org code
OrganizationQuery orgQuery = new OrganizationQuery(vQuery);
OrganizationUserQuery relQuery = new OrganizationUserQuery(vQuery);
for (Organization org : organizations) {
orgQuery.OR(orgQuery.getCode().EQ(org.getCode()));
}
vQuery.WHERE(relQuery.parentOid().EQ(orgQuery.getOid()));
vQuery.WHERE(uQuery.getOid().EQ(relQuery.childOid()));
}
if (isRMorRCorAC) {
vQuery.WHERE(uQuery.getInactive().EQ(false));
}
vQuery.ORDER_BY_ASC(uQuery.getUsername());
return serializePage(pageSize, pageNumber, externalSystems, vQuery);
}
JSONObject page = new JSONObject();
page.put("resultSet", new JSONArray());
page.put("count", 0);
page.put("pageNumber", pageNumber);
page.put("pageSize", pageSize);
page.put("externalSystems", externalSystems);
return page;
}
use of net.geoprism.GeoprismUserQuery in project geoprism-registry by terraframe.
the class UserInfo method getAdminUser.
private static GeoprismUser getAdminUser() {
GeoprismUserQuery guq = new GeoprismUserQuery(new QueryFactory());
guq.WHERE(guq.getUsername().EQ(RegistryConstants.ADMIN_USER_NAME));
OIterator<? extends GeoprismUser> it = guq.getIterator();
try {
if (it.hasNext()) {
return it.next();
} else {
return null;
}
} finally {
it.close();
}
}
Aggregations