Search in sources :

Example 16 with Roles

use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.

the class Transition method createTask.

public void createTask(VertexServerGeoObject source, VertexServerGeoObject target, Date eventDate) {
    LocalizedValue dateValue = LocalizedValueConverter.convert(eventDate);
    TransitionType transitionType = this.toTransitionType();
    ServerGeoObjectType sourceType = source.getType();
    ServerGeoObjectType targetType = target.getType();
    List<ServerGeoObjectType> types = Arrays.asList(new ServerGeoObjectType[] { sourceType, targetType }).stream().distinct().collect(Collectors.toList());
    for (ServerGeoObjectType type : types) {
        List<ServerHierarchyType> hierarchies = type.getHierarchies();
        for (ServerHierarchyType hierarchy : hierarchies) {
            List<ServerGeoObjectType> children = type.getChildren(hierarchy);
            for (ServerGeoObjectType child : children) {
                List<Roles> roles = Arrays.asList(new String[] { child.getMaintainerRoleName(), child.getAdminRoleName() }).stream().distinct().map(name -> Roles.findRoleByName(name)).collect(Collectors.toList());
                HashMap<String, LocalizedValue> values = new HashMap<String, LocalizedValue>();
                values.put("1", source.getDisplayLabel());
                values.put("2", sourceType.getLabel());
                values.put("3", target.getDisplayLabel());
                values.put("4", targetType.getLabel());
                values.put("5", child.getLabel());
                values.put("6", hierarchy.getLabel());
                values.put("7", dateValue);
                TaskType taskType = Task.TaskType.SPLIT_EVENT_TASK;
                if (transitionType.isMerge()) {
                    taskType = Task.TaskType.MERGE_EVENT_TASK;
                } else if (transitionType.isReassign()) {
                    taskType = Task.TaskType.REASSIGN_EVENT_TASK;
                }
                Task.createNewTask(roles, taskType, values, this.getOid());
            }
        }
    }
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Task(net.geoprism.registry.task.Task) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) VertexGeoObjectStrategy(net.geoprism.registry.conversion.VertexGeoObjectStrategy) Date(java.util.Date) GraphQuery(com.runwaysdk.business.graph.GraphQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction) VertexObject(com.runwaysdk.business.graph.VertexObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) HashMap(java.util.HashMap) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) Roles(com.runwaysdk.system.Roles) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Collectors(java.util.stream.Collectors) TaskType(net.geoprism.registry.task.Task.TaskType) MdVertexDAO(com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO) MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) List(java.util.List) LocalizedValueConverter(net.geoprism.registry.conversion.LocalizedValueConverter) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HashMap(java.util.HashMap) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Roles(com.runwaysdk.system.Roles) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) TaskType(net.geoprism.registry.task.Task.TaskType)

Example 17 with Roles

use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.

the class LocalizedValueConverter method setOwner.

/**
 * Set the owner to the corresponding {@link Organization} role for the given
 * code, or if code is null then the owner field is not set.
 *
 * @param business
 * @param organizationCode
 */
protected static void setOwner(Business business, String organizationCode) {
    Organization organization = null;
    Roles orgRole = null;
    if (organizationCode != null && !organizationCode.equals("")) {
        organization = Organization.getByKey(organizationCode);
        orgRole = organization.getRole();
        business.setOwner(orgRole);
    }
}
Also used : Organization(net.geoprism.registry.Organization) Roles(com.runwaysdk.system.Roles)

Example 18 with Roles

use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.

the class ServerGeoObjectTypeConverter method create_RC_GeoObjectTypeRole.

private void create_RC_GeoObjectTypeRole(MdGeoVertexDAO mdGeoVertexDAO, String organizationCode, String geoObjectTypeCode) {
    if (organizationCode != null && !organizationCode.trim().equals("")) {
        String rcRoleName = RegistryRole.Type.getRC_RoleName(organizationCode, geoObjectTypeCode);
        Locale locale = Session.getCurrentLocale();
        String defaultDisplayLabel = mdGeoVertexDAO.getLocalValue(MdGeoVertexInfo.DISPLAY_LABEL, locale) + " Registry Contributor";
        Roles rcOrgRole = new Roles();
        rcOrgRole.setRoleName(rcRoleName);
        rcOrgRole.getDisplayLabel().setDefaultValue(defaultDisplayLabel);
        rcOrgRole.apply();
        String orgRoleName = RegistryRole.Type.getRootOrgRoleName(organizationCode);
        Roles orgRole = Roles.findRoleByName(orgRoleName);
        RoleDAO orgRoleDAO = (RoleDAO) BusinessFacade.getEntityDAO(orgRole);
        RoleDAO rcOrgRoleDAO = (RoleDAO) BusinessFacade.getEntityDAO(rcOrgRole);
        orgRoleDAO.addInheritance(rcOrgRoleDAO);
        // Inherit the permissions from the root RC role
        RoleDAO rootRC_DAO = (RoleDAO) BusinessFacade.getEntityDAO(Roles.findRoleByName(RegistryConstants.REGISTRY_CONTRIBUTOR_ROLE));
        rootRC_DAO.addInheritance(rcOrgRoleDAO);
    }
}
Also used : Locale(java.util.Locale) RoleDAO(com.runwaysdk.business.rbac.RoleDAO) Roles(com.runwaysdk.system.Roles)

Example 19 with Roles

use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.

the class ServerGeoObjectTypeConverter method assignSRAPermissions.

public void assignSRAPermissions(MdGeoVertexDAO mdGeoVertexDAO, MdBusiness mdBusiness) {
    Roles sraRole = Roles.findRoleByName(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE);
    this.assignAllPermissions(mdBusiness, sraRole);
    this.assignAllPermissions(mdGeoVertexDAO, sraRole);
}
Also used : Roles(com.runwaysdk.system.Roles)

Example 20 with Roles

use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.

the class ServerGeoObjectTypeConverter method create_AC_GeoObjectTypeRole.

private void create_AC_GeoObjectTypeRole(MdGeoVertexDAO mdGeoVertexDAO, String organizationCode, String geoObjectTypeCode) {
    if (organizationCode != null && !organizationCode.trim().equals("")) {
        String acRoleName = RegistryRole.Type.getAC_RoleName(organizationCode, geoObjectTypeCode);
        Locale locale = Session.getCurrentLocale();
        String defaultDisplayLabel = mdGeoVertexDAO.getLocalValue(MdGeoVertexInfo.DISPLAY_LABEL, locale) + " API Consumer";
        Roles acOrgRole = new Roles();
        acOrgRole.setRoleName(acRoleName);
        acOrgRole.getDisplayLabel().setDefaultValue(defaultDisplayLabel);
        acOrgRole.apply();
        String orgRoleName = RegistryRole.Type.getRootOrgRoleName(organizationCode);
        Roles orgRole = Roles.findRoleByName(orgRoleName);
        RoleDAO orgRoleDAO = (RoleDAO) BusinessFacade.getEntityDAO(orgRole);
        RoleDAO acOrgRoleDAO = (RoleDAO) BusinessFacade.getEntityDAO(acOrgRole);
        orgRoleDAO.addInheritance(acOrgRoleDAO);
        // Inherit the permissions from the root RC role
        RoleDAO rootAC_DAO = (RoleDAO) BusinessFacade.getEntityDAO(Roles.findRoleByName(RegistryConstants.API_CONSUMER_ROLE));
        rootAC_DAO.addInheritance(acOrgRoleDAO);
    }
}
Also used : Locale(java.util.Locale) RoleDAO(com.runwaysdk.business.rbac.RoleDAO) Roles(com.runwaysdk.system.Roles)

Aggregations

Roles (com.runwaysdk.system.Roles)25 RegistryRoleConverter (net.geoprism.registry.conversion.RegistryRoleConverter)7 RegistryRole (org.commongeoregistry.adapter.metadata.RegistryRole)7 RoleDAO (com.runwaysdk.business.rbac.RoleDAO)6 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)4 Request (com.runwaysdk.session.Request)4 Locale (java.util.Locale)4 Organization (net.geoprism.registry.Organization)4 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)4 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)3 Actor (com.runwaysdk.system.Actor)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 LinkedList (java.util.LinkedList)3 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)3 MdVertexDAO (com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO)2 LocalizedValueStore (com.runwaysdk.localization.LocalizedValueStore)2 GeoprismUser (net.geoprism.GeoprismUser)2 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)2 JsonArray (com.google.gson.JsonArray)1