Search in sources :

Example 16 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class Organization method isRegistryMaintainer.

/**
 * @param org
 * @return If the current user is part of the registry admin role for the
 *         given organization
 */
public static boolean isRegistryMaintainer(Organization org) {
    if (new RolePermissionService().isSRA()) {
        return true;
    }
    final SessionIF session = Session.getCurrentSession();
    if (session != null) {
        Map<String, ServerGeoObjectType> types = org.getGeoObjectTypes();
        Set<Entry<String, ServerGeoObjectType>> entries = types.entrySet();
        for (Entry<String, ServerGeoObjectType> entry : entries) {
            String roleName = RegistryRole.Type.getRM_RoleName(org.getCode(), entry.getKey());
            boolean hasRole = session.userHasRole(roleName);
            if (hasRole) {
                return true;
            }
        }
        return false;
    }
    return true;
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) Entry(java.util.Map.Entry) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) SessionIF(com.runwaysdk.session.SessionIF)

Example 17 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class Organization method getGeoObjectTypes.

/**
 * Return a map of {@link GeoObjectType} codes and labels for this
 * {@link Organization}.
 *
 * @return a map of {@link GeoObjectType} codes and labels for this
 *         {@link Organization}.
 */
public Map<String, ServerGeoObjectType> getGeoObjectTypes() {
    // For performance, get all of the universals defined
    List<? extends EntityDAOIF> universalList = ObjectCache.getCachedEntityDAOs(Universal.CLASS);
    Map<String, ServerGeoObjectType> typeCodeMap = new HashMap<String, ServerGeoObjectType>();
    for (EntityDAOIF entityDAOIF : universalList) {
        Universal universal = (Universal) BusinessFacade.get(entityDAOIF);
        // Check to see if the universal is owned by the organization role.
        String ownerId = universal.getOwnerOid();
        Roles organizationRole = this.getRole();
        if (ownerId.equals(organizationRole.getOid())) {
            ServerGeoObjectType type = ServerGeoObjectType.get(universal);
            typeCodeMap.put(type.getCode(), type);
        }
    }
    return typeCodeMap;
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) HashMap(java.util.HashMap) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) EntityDAOIF(com.runwaysdk.dataaccess.EntityDAOIF) Roles(com.runwaysdk.system.Roles)

Example 18 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class ChangeRequestPermissionService method getPermissions.

public Set<ChangeRequestPermissionAction> getPermissions(ChangeRequest cr) {
    final RolePermissionService perms = ServiceFactory.getRolePermissionService();
    final String orgCode = cr.getOrganizationCode();
    final String gotCode = cr.getGeoObjectTypeCode();
    ServerGeoObjectType type = null;
    if (gotCode != null) {
        type = ServerGeoObjectType.get(gotCode, true);
    }
    HashSet<ChangeRequestPermissionAction> actions = new HashSet<ChangeRequestPermissionAction>();
    final AllGovernanceStatus status = cr.getGovernanceStatus();
    if (perms.isSRA()) {
        actions.addAll(Arrays.asList(ChangeRequestPermissionAction.values()));
        actions.remove(ChangeRequestPermissionAction.DELETE);
        actions.remove(ChangeRequestPermissionAction.WRITE_CONTRIBUTOR_NOTES);
        actions.remove(ChangeRequestPermissionAction.WRITE_DETAILS);
        if (status.equals(AllGovernanceStatus.ACCEPTED)) {
            actions.remove(ChangeRequestPermissionAction.EXECUTE);
            actions.remove(ChangeRequestPermissionAction.WRITE_MAINTAINER_NOTES);
        }
    } else if (perms.isRA(orgCode)) {
        actions.addAll(Arrays.asList(ChangeRequestPermissionAction.values()));
        actions.remove(ChangeRequestPermissionAction.DELETE);
        actions.remove(ChangeRequestPermissionAction.WRITE_CONTRIBUTOR_NOTES);
        actions.remove(ChangeRequestPermissionAction.WRITE_DETAILS);
        if (status.equals(AllGovernanceStatus.ACCEPTED)) {
            actions.remove(ChangeRequestPermissionAction.EXECUTE);
            actions.remove(ChangeRequestPermissionAction.WRITE_MAINTAINER_NOTES);
        }
    } else if (perms.isRM(orgCode, type)) {
        actions.addAll(Arrays.asList(ChangeRequestPermissionAction.values()));
        actions.remove(ChangeRequestPermissionAction.DELETE);
        actions.remove(ChangeRequestPermissionAction.WRITE_CONTRIBUTOR_NOTES);
        actions.remove(ChangeRequestPermissionAction.WRITE_DETAILS);
        if (status.equals(AllGovernanceStatus.ACCEPTED)) {
            actions.remove(ChangeRequestPermissionAction.EXECUTE);
            actions.remove(ChangeRequestPermissionAction.WRITE_MAINTAINER_NOTES);
        }
    } else if (perms.isRC(orgCode, type) || perms.isAC(orgCode, type)) {
        actions.addAll(Arrays.asList(ChangeRequestPermissionAction.READ, ChangeRequestPermissionAction.WRITE, ChangeRequestPermissionAction.READ_APPROVAL_STATUS, ChangeRequestPermissionAction.READ_DETAILS, ChangeRequestPermissionAction.WRITE_DETAILS, ChangeRequestPermissionAction.READ_DOCUMENTS, ChangeRequestPermissionAction.WRITE_DOCUMENTS, ChangeRequestPermissionAction.READ_MAINTAINER_NOTES, ChangeRequestPermissionAction.READ_CONTRIBUTOR_NOTES, ChangeRequestPermissionAction.WRITE_CONTRIBUTOR_NOTES, ChangeRequestPermissionAction.SUBMIT, ChangeRequestPermissionAction.DELETE));
        SessionIF session = Session.getCurrentSession();
        if (session == null || session.getUser() == null || cr.getCreatedBy() == null || !cr.getCreatedBy().getOid().equals(session.getUser().getOid())) {
            actions.remove(ChangeRequestPermissionAction.DELETE);
        }
        if (status.equals(AllGovernanceStatus.ACCEPTED) || status.equals(AllGovernanceStatus.REJECTED) || status.equals(AllGovernanceStatus.INVALID) || status.equals(AllGovernanceStatus.PARTIAL)) {
            actions.remove(ChangeRequestPermissionAction.WRITE_CONTRIBUTOR_NOTES);
            actions.remove(ChangeRequestPermissionAction.WRITE_DETAILS);
            actions.remove(ChangeRequestPermissionAction.DELETE);
        }
    }
    if (orgCode == null || gotCode == null) {
        actions.removeAll(Arrays.asList(ChangeRequestPermissionAction.EXECUTE, ChangeRequestPermissionAction.WRITE_APPROVAL_STATUS, ChangeRequestPermissionAction.WRITE_DETAILS));
        if (gotCode == null) {
            actions.remove(ChangeRequestPermissionAction.READ_DETAILS);
        }
        if (perms.isSRA() || perms.isRA() || perms.isRM()) {
            actions.add(ChangeRequestPermissionAction.DELETE);
        }
    }
    return actions;
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) HashSet(java.util.HashSet) SessionIF(com.runwaysdk.session.SessionIF)

Example 19 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class CreateGeoObjectAction method apply.

@Override
public void apply() {
    String sJson = this.getGeoObjectJson();
    GeoObjectOverTime geoObject = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sJson);
    ServerGeoObjectType type = ServerGeoObjectType.get(geoObject.getType());
    geoObjectPermissionService.enforceCanCreateCR(type.getOrganization().getCode(), type);
    super.apply();
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)

Example 20 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class SetParentAction method apply.

@Override
public void apply() {
    // Important to remember that the child may or may not exist at this point (so we can't fetch it from the DB here)
    ServerGeoObjectType type = ServiceFactory.getMetadataCache().getGeoObjectType(this.getChildTypeCode()).get();
    ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(type, this.getJson());
    ptnOt.enforceUserHasPermissionSetParents(this.getChildTypeCode(), true);
    super.apply();
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime)

Aggregations

ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)201 Request (com.runwaysdk.session.Request)69 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)57 JsonObject (com.google.gson.JsonObject)48 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)32 JsonArray (com.google.gson.JsonArray)30 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)30 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)27 LinkedList (java.util.LinkedList)27 Test (org.junit.Test)27 VertexObject (com.runwaysdk.business.graph.VertexObject)26 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)26 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)23 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)23 Date (java.util.Date)21 GraphQuery (com.runwaysdk.business.graph.GraphQuery)19 List (java.util.List)18 EdgeObject (com.runwaysdk.business.graph.EdgeObject)17 SimpleDateFormat (java.text.SimpleDateFormat)17 Locale (java.util.Locale)17