Search in sources :

Example 1 with LeftJoinEq

use of com.runwaysdk.query.LeftJoinEq 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);
}
Also used : RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) JsonObject(com.google.gson.JsonObject) RegistryRoleConverter(net.geoprism.registry.conversion.RegistryRoleConverter) Transaction(com.runwaysdk.dataaccess.transaction.Transaction) ValueObject(com.runwaysdk.dataaccess.ValueObject) ConfigurationIF(net.geoprism.ConfigurationIF) Random(java.util.Random) AttributeBooleanIF(com.runwaysdk.dataaccess.AttributeBooleanIF) DefaultConfiguration(net.geoprism.DefaultConfiguration) ServiceFactory(net.geoprism.registry.service.ServiceFactory) AttributeValueException(com.runwaysdk.dataaccess.attributes.AttributeValueException) HashSet(java.util.HashSet) ValueQuery(com.runwaysdk.query.ValueQuery) JSONObject(org.json.JSONObject) GeoprismUserQuery(net.geoprism.GeoprismUserQuery) QueryFactory(com.runwaysdk.query.QueryFactory) ConfigurationService(net.geoprism.ConfigurationService) RoleDAO(com.runwaysdk.business.rbac.RoleDAO) LinkedList(java.util.LinkedList) AttributeBoolean(com.runwaysdk.dataaccess.attributes.entity.AttributeBoolean) RoleDAOIF(com.runwaysdk.business.rbac.RoleDAOIF) Set(java.util.Set) Roles(com.runwaysdk.system.Roles) Collectors(java.util.stream.Collectors) BusinessFacade(com.runwaysdk.business.BusinessFacade) UserDAO(com.runwaysdk.business.rbac.UserDAO) LeftJoinEq(com.runwaysdk.query.LeftJoinEq) OIterator(com.runwaysdk.query.OIterator) List(java.util.List) UserDAOIF(com.runwaysdk.business.rbac.UserDAOIF) GeoprismUser(net.geoprism.GeoprismUser) SingleActorDAOIF(com.runwaysdk.business.rbac.SingleActorDAOIF) ExternalSystem(net.geoprism.registry.graph.ExternalSystem) Session(com.runwaysdk.session.Session) RolePermissionService(net.geoprism.registry.permission.RolePermissionService) JSONArray(org.json.JSONArray) ValueQuery(com.runwaysdk.query.ValueQuery) LeftJoinEq(com.runwaysdk.query.LeftJoinEq) QueryFactory(com.runwaysdk.query.QueryFactory) GeoprismUserQuery(net.geoprism.GeoprismUserQuery) JSONArray(org.json.JSONArray) SingleActorDAOIF(com.runwaysdk.business.rbac.SingleActorDAOIF) RoleDAOIF(com.runwaysdk.business.rbac.RoleDAOIF)

Example 2 with LeftJoinEq

use of com.runwaysdk.query.LeftJoinEq 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;
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) ValueQuery(com.runwaysdk.query.ValueQuery) QueryFactory(com.runwaysdk.query.QueryFactory) ExternalSystem(net.geoprism.registry.graph.ExternalSystem) JSONArray(org.json.JSONArray) LeftJoinEq(com.runwaysdk.query.LeftJoinEq) JSONObject(org.json.JSONObject) GeoprismUserQuery(net.geoprism.GeoprismUserQuery)

Aggregations

LeftJoinEq (com.runwaysdk.query.LeftJoinEq)2 QueryFactory (com.runwaysdk.query.QueryFactory)2 ValueQuery (com.runwaysdk.query.ValueQuery)2 GeoprismUserQuery (net.geoprism.GeoprismUserQuery)2 ExternalSystem (net.geoprism.registry.graph.ExternalSystem)2 RolePermissionService (net.geoprism.registry.permission.RolePermissionService)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 JsonObject (com.google.gson.JsonObject)1 BusinessFacade (com.runwaysdk.business.BusinessFacade)1 RoleDAO (com.runwaysdk.business.rbac.RoleDAO)1 RoleDAOIF (com.runwaysdk.business.rbac.RoleDAOIF)1 SingleActorDAOIF (com.runwaysdk.business.rbac.SingleActorDAOIF)1 UserDAO (com.runwaysdk.business.rbac.UserDAO)1 UserDAOIF (com.runwaysdk.business.rbac.UserDAOIF)1 AttributeBooleanIF (com.runwaysdk.dataaccess.AttributeBooleanIF)1 ValueObject (com.runwaysdk.dataaccess.ValueObject)1 AttributeValueException (com.runwaysdk.dataaccess.attributes.AttributeValueException)1 AttributeBoolean (com.runwaysdk.dataaccess.attributes.entity.AttributeBoolean)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1