Search in sources :

Example 21 with Roles

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

the class ClassificationType method assignPermissions.

public void assignPermissions() {
    MdVertexDAOIF mdVertex = this.mdClassification.getReferenceMdVertexDAO();
    MdEdgeDAOIF mdEdge = this.mdClassification.getReferenceMdEdgeDAO();
    Roles sraRole = Roles.findRoleByName(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE);
    this.assignPermissions(mdVertex, sraRole, true);
    this.assignPermissions(mdEdge, sraRole, true);
    Roles raRole = Roles.findRoleByName(RegistryConstants.REGISTRY_ADMIN_ROLE);
    this.assignPermissions(mdVertex, raRole, false);
    this.assignPermissions(mdEdge, raRole, false);
    Roles rmRole = Roles.findRoleByName(RegistryConstants.REGISTRY_MAINTAINER_ROLE);
    this.assignPermissions(mdVertex, rmRole, false);
    this.assignPermissions(mdEdge, rmRole, false);
    Roles rcRole = Roles.findRoleByName(RegistryConstants.REGISTRY_CONTRIBUTOR_ROLE);
    this.assignPermissions(mdVertex, rcRole, false);
    this.assignPermissions(mdEdge, rcRole, false);
    Roles acRole = Roles.findRoleByName(RegistryConstants.API_CONSUMER_ROLE);
    this.assignPermissions(mdVertex, acRole, false);
    this.assignPermissions(mdEdge, acRole, false);
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) Roles(com.runwaysdk.system.Roles)

Example 22 with Roles

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

the class ServerGeoObjectType method deleteInTransaction.

@Transaction
private void deleteInTransaction() {
    List<ServerHierarchyType> hierarchies = this.getHierarchies(true);
    if (hierarchies.size() > 0) {
        StringBuilder codes = hierarchies.stream().collect(StringBuilder::new, (x, y) -> x.append(y.getCode()), (a, b) -> a.append(",").append(b));
        throw new TypeInUseException("Cannot delete a GeoObjectType used in the hierarchies: " + codes);
    }
    // for (String hierarchy : hierarchies)
    // {
    // OIterator<com.runwaysdk.business.ontology.Term> it =
    // this.universal.getDirectDescendants(hierarchy);
    // 
    // try
    // {
    // if (it.hasNext())
    // {
    // }
    // }
    // finally
    // {
    // it.close();
    // }
    // }
    /*
     * Delete all subtypes
     */
    List<ServerGeoObjectType> subtypes = this.getSubtypes();
    for (ServerGeoObjectType subtype : subtypes) {
        subtype.deleteInTransaction();
    }
    /*
     * Delete all inherited hierarchies
     */
    List<? extends InheritedHierarchyAnnotation> annotations = InheritedHierarchyAnnotation.getByUniversal(getUniversal());
    for (InheritedHierarchyAnnotation annotation : annotations) {
        annotation.delete();
    }
    GeoVertexType.remove(this.universal.getUniversalId());
    /*
     * Delete all Attribute references
     */
    // AttributeHierarchy.deleteByUniversal(this.universal);
    this.getMetadata().delete();
    // This deletes the {@link MdBusiness} as well
    this.universal.delete(false);
    // Delete the term root
    Classifier classRootTerm = TermConverter.buildIfNotExistdMdBusinessClassifier(this.mdBusiness);
    classRootTerm.delete();
    // roles specified on the super type.
    if (this.getSuperType() == null) {
        Actor ownerActor = this.universal.getOwner();
        if (ownerActor instanceof Roles) {
            Roles ownerRole = (Roles) ownerActor;
            String roleName = ownerRole.getRoleName();
            if (RegistryRole.Type.isOrgRole(roleName)) {
                String organizationCode = RegistryRole.Type.parseOrgCode(roleName);
                String geoObjectTypeCode = this.type.getCode();
                String rmRoleName = RegistryRole.Type.getRM_RoleName(organizationCode, geoObjectTypeCode);
                Roles role = Roles.findRoleByName(rmRoleName);
                role.delete();
                String rcRoleName = RegistryRole.Type.getRC_RoleName(organizationCode, geoObjectTypeCode);
                role = Roles.findRoleByName(rcRoleName);
                role.delete();
                String acRoleName = RegistryRole.Type.getAC_RoleName(organizationCode, geoObjectTypeCode);
                role = Roles.findRoleByName(acRoleName);
                role.delete();
            }
        }
    }
    ListType.markAllAsInvalid(null, this);
    new SearchService().clear(this.getCode());
    new ChangeRequestService().markAllAsInvalid(this);
    // Delete the transition and transition events
    TransitionEvent.removeAll(this);
    Transition.removeAll(this);
}
Also used : InheritedHierarchyAnnotation(net.geoprism.registry.InheritedHierarchyAnnotation) Roles(com.runwaysdk.system.Roles) Classifier(net.geoprism.ontology.Classifier) TypeInUseException(net.geoprism.registry.TypeInUseException) ChangeRequestService(net.geoprism.registry.service.ChangeRequestService) Actor(com.runwaysdk.system.Actor) SearchService(net.geoprism.registry.service.SearchService) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 23 with Roles

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

the class ServerGeoObjectType method getOrganization.

/**
 * @return The organization associated with this GeoObjectType.
 */
public Organization getOrganization() {
    Actor owner = this.universal.getOwner();
    if (!(owner instanceof Roles)) {
        // If we get here, then the GeoObjectType was not created
        return null;
    // correctly.
    } else {
        Roles uniRole = (Roles) owner;
        String myOrgCode = RegistryRole.Type.parseOrgCode(uniRole.getRoleName());
        return Organization.getByCode(myOrgCode);
    }
}
Also used : Actor(com.runwaysdk.system.Actor) Roles(com.runwaysdk.system.Roles)

Example 24 with Roles

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

the class OrganizationAndRoleTest method rm_RoleToRegistryRoleRequest.

@Request
public void rm_RoleToRegistryRoleRequest() {
    String rmRoleName = RegistryRole.Type.getRM_RoleName(FastTestDataset.ORG_CGOV.getCode(), FastTestDataset.PROVINCE.getCode());
    Roles rmRole = Roles.findRoleByName(rmRoleName);
    RegistryRole registryRole = new RegistryRoleConverter().build(rmRole);
    Assert.assertEquals(rmRoleName, registryRole.getName());
    Assert.assertEquals(FastTestDataset.ORG_CGOV.getCode(), registryRole.getOrganizationCode());
    Assert.assertEquals(FastTestDataset.PROVINCE.getCode(), registryRole.getGeoObjectTypeCode());
}
Also used : RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) RegistryRoleConverter(net.geoprism.registry.conversion.RegistryRoleConverter) Roles(com.runwaysdk.system.Roles) Request(com.runwaysdk.session.Request)

Example 25 with Roles

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

the class TaskTest method createInstanceData.

@Request(RequestType.SESSION)
private static void createInstanceData(String sessionId) {
    final List<Roles> roles = new ArrayList<Roles>();
    roles.add(Roles.findRoleByName(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE));
    LocalizedValueStore lv = new LocalizedValueStore();
    lv.setStoreKey(TestTaskType.TestGeoObjectSplitOrphanedChildren.getTitleKey());
    lv.setStoreTag("UIText");
    lv.setStructValue(LocalizedValueStore.STOREVALUE, MdAttributeLocalInfo.DEFAULT_LOCALE, "Split Has Orphaned Children");
    lv.setStructValue(LocalizedValueStore.STOREVALUE, Locale.CHINESE.toString(), "斯普利特有孤儿");
    lv.setStructValue(LocalizedValueStore.STOREVALUE, Locale.KOREAN.toString(), "스 플리트는 고아를 낳았다");
    lv.setStructValue(LocalizedValueStore.STOREVALUE, Locale.CANADA.toString(), "Oh no! Split Has Orphaned Children eh.");
    lv.apply();
    LocalizedValueStore lv2 = new LocalizedValueStore();
    lv2.setStoreKey(TestTaskType.TestGeoObjectSplitOrphanedChildren.getTemplateKey());
    lv2.setStoreTag("UIText");
    lv2.setStructValue(LocalizedValueStore.STOREVALUE, MdAttributeLocalInfo.DEFAULT_LOCALE, "The {typeName} {oldParentName} has split. You must reassign the children with new parents.");
    lv2.setStructValue(LocalizedValueStore.STOREVALUE, Locale.CHINESE.toString(), "{typeName} {oldParentName}已拆分。 您必须将孩子重新分配给新父母。");
    lv2.setStructValue(LocalizedValueStore.STOREVALUE, Locale.KOREAN.toString(), "{typeName} {oldParentName}이 (가) 분할되었습니다. 새 부모에게 자녀를 재 할당해야합니다.");
    lv2.setStructValue(LocalizedValueStore.STOREVALUE, Locale.CANADA.toString(), "Oh no! The {typeName} {oldParentName} has split. You must reassign the children with new parents eh.");
    lv2.apply();
    Map<String, LocalizedValue> values = new HashMap<String, LocalizedValue>();
    LocalizedValue lvTypeName = new LocalizedValue(null);
    lvTypeName.setValue(MdAttributeLocalInfo.DEFAULT_LOCALE, "district");
    lvTypeName.setValue(Locale.CHINESE, "区");
    lvTypeName.setValue(Locale.KOREAN, "지구");
    lvTypeName.setValue(Locale.CANADA, "district eh");
    values.put("typeName", lvTypeName);
    LocalizedValue lvOldParentName = new LocalizedValue(null);
    lvOldParentName.setValue(MdAttributeLocalInfo.DEFAULT_LOCALE, "D1");
    lvOldParentName.setValue(Locale.CHINESE, "D1 Chinese");
    lvOldParentName.setValue(Locale.KOREAN, "D1 Korean");
    lvOldParentName.setValue(Locale.CANADA, "D1 Canada");
    values.put("oldParentName", lvOldParentName);
    Task.createNewTask(roles, TestTaskType.TestGeoObjectSplitOrphanedChildren, values, null);
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Roles(com.runwaysdk.system.Roles) LocalizedValueStore(com.runwaysdk.localization.LocalizedValueStore) Request(com.runwaysdk.session.Request)

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