Search in sources :

Example 11 with RolePermissionService

use of net.geoprism.registry.permission.RolePermissionService in project geoprism-registry by terraframe.

the class CurationService method getListCurationInfo.

public JsonObject getListCurationInfo(ListTypeVersion version) {
    final ListType listType = version.getListType();
    final ServerGeoObjectType serverGOT = listType.getGeoObjectType();
    final String orgCode = listType.getOrganization().getCode();
    this.checkPermissions(orgCode, serverGOT);
    JsonObject json = new JsonObject();
    ListCurationHistory history = ListCurationJob.getMostRecent(version.getOid());
    boolean isRunning = false;
    if (history != null) {
        if (history.getStatus().contains(AllJobStatus.RUNNING)) {
            isRunning = true;
        }
        json.addProperty("lastRun", GeoRegistryUtil.formatDate(history.getCreateDate(), false));
        json.addProperty("curationId", history.getOid());
    }
    final RolePermissionService perms = ServiceFactory.getRolePermissionService();
    boolean hasRunPermission = perms.isSRA() || perms.isRA(orgCode) || perms.isRM(orgCode, serverGOT);
    json.addProperty("canRun", !isRunning && hasRunPermission);
    return json;
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ListType(net.geoprism.registry.ListType) JsonObject(com.google.gson.JsonObject)

Example 12 with RolePermissionService

use of net.geoprism.registry.permission.RolePermissionService in project geoprism-registry by terraframe.

the class ServerGeoObjectService method updateGeoObjectInTrans.

@Transaction
public JsonObject updateGeoObjectInTrans(String geoObjectCode, String geoObjectTypeCode, String actions, String masterListId, String notes) {
    final RolePermissionService perms = ServiceFactory.getRolePermissionService();
    final ServerGeoObjectType type = ServerGeoObjectType.get(geoObjectTypeCode);
    final String orgCode = type.getOrganization().getCode();
    final VertexServerGeoObject go = (VertexServerGeoObject) new ServerGeoObjectService().getGeoObjectByCode(geoObjectCode, geoObjectTypeCode);
    final JsonArray jaActions = JsonParser.parseString(actions).getAsJsonArray();
    if (perms.isSRA() || perms.isRA(orgCode) || perms.isRM(orgCode, type)) {
        this.executeActions(type, go, jaActions);
        if (masterListId != null) {
            ListTypeVersion.get(masterListId).updateRecord(go);
        }
        JsonObject resp = new JsonObject();
        resp.addProperty("isChangeRequest", false);
        resp.add("geoObject", go.toGeoObjectOverTime().toJSON(ServiceFactory.getRegistryService().serializer(Session.getCurrentSession().getOid())));
        return resp;
    } else if (ServiceFactory.getRolePermissionService().isRC(orgCode, type)) {
        ChangeRequest request = createChangeRequest(geoObjectCode, geoObjectTypeCode, notes, orgCode, jaActions);
        JsonObject resp = new JsonObject();
        resp.addProperty("isChangeRequest", true);
        resp.addProperty("changeRequestId", request.getOid());
        return resp;
    } else {
        throw new CGRPermissionException();
    }
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) JsonArray(com.google.gson.JsonArray) CGRPermissionException(net.geoprism.registry.CGRPermissionException) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 13 with RolePermissionService

use of net.geoprism.registry.permission.RolePermissionService in project geoprism-registry by terraframe.

the class SearchService method search.

public List<ServerGeoObjectIF> search(String text, Date date, Long limit) {
    String suffix = this.getSuffix();
    RolePermissionService service = new RolePermissionService();
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
    MdAttributeDAOIF code = mdVertex.definesAttribute(CODE);
    MdAttributeDAOIF startDate = mdVertex.definesAttribute(START_DATE);
    MdAttributeDAOIF endDate = mdVertex.definesAttribute(END_DATE);
    MdAttributeDAOIF label = mdVertex.definesAttribute(LABEL);
    MdAttributeDAOIF vertexType = mdVertex.definesAttribute(VERTEX_TYPE);
    MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(PACKAGE + "." + EDGE_PREFIX + suffix);
    String attributeName = label.getValue(MdAttributeTextInfo.NAME);
    String className = mdVertex.getDBClassName();
    String indexName = className + "." + attributeName;
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT EXPAND(out('" + mdEdge.getDBClassName() + "'))");
    statement.append(" FROM " + mdVertex.getDBClassName());
    if (text != null) {
        String regex = "([+\\-!\\(\\){}\\[\\]^\"~*?:\\\\]|[&\\|]{2})";
        String escapedText = text.replaceAll(regex, "\\\\\\\\$1").trim();
        statement.append(" WHERE (SEARCH_INDEX(\"" + indexName + "\", \"+" + label.getColumnName() + ":" + escapedText + "*\") = true");
        statement.append(" OR :code = " + code.getColumnName() + ")");
    } else {
        statement.append(" WHERE " + code.getColumnName() + " IS NOT NULL");
    }
    if (date != null) {
        statement.append(" AND :date BETWEEN " + startDate.getColumnName() + " AND " + endDate.getColumnName());
    }
    if (!service.isSRA() && service.hasSessionUser()) {
        statement.append(" AND " + vertexType.getColumnName() + " IN ( :vertexTypes )");
    }
    statement.append(" ORDER BY " + label.getColumnName() + " DESC");
    if (limit != null) {
        statement.append(" LIMIT " + limit);
    }
    List<ServerGeoObjectIF> list = new LinkedList<ServerGeoObjectIF>();
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
    if (text != null) {
        query.setParameter("code", text);
    }
    if (date != null) {
        query.setParameter("date", date);
    }
    if (!service.isSRA() && service.hasSessionUser()) {
        List<String> vertexTypes = new GeoObjectPermissionService().getMandateTypes(service.getOrganization());
        query.setParameter("vertexTypes", vertexTypes);
    }
    List<VertexObject> results = query.getResults();
    for (VertexObject result : results) {
        MdVertexDAOIF mdVertexType = (MdVertexDAOIF) result.getMdClass();
        ServerGeoObjectType type = ServerGeoObjectType.get(mdVertexType);
        list.add(new VertexServerGeoObject(type, result, date));
    }
    return list;
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) LinkedList(java.util.LinkedList) GeoObjectPermissionService(net.geoprism.registry.permission.GeoObjectPermissionService) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 14 with RolePermissionService

use of net.geoprism.registry.permission.RolePermissionService in project geoprism-registry by terraframe.

the class ServiceFactory method initialize.

private void initialize() {
    this.registryService = new RegistryService();
    this.cs = new ConversionService();
    this.idService = new RegistryIdService();
    this.adapter = new RegistryAdapterServer(this.idService);
    this.accountService = new AccountService();
    this.goPermissionServ = new GeoObjectPermissionService();
    this.serverGoService = new ServerGeoObjectService(goPermissionServ);
    this.hierarchyService = new HierarchyService();
    this.orgServ = new OrganizationPermissionService();
    this.hierarchyPermServ = new HierarchyTypePermissionService();
    this.goRelPermissionServ = new GeoObjectRelationshipPermissionService();
    this.goTypeRelPermissionServ = new GeoObjectTypeRelationshipPermissionService();
    this.goTypePermissionServ = new GeoObjectTypePermissionService();
    this.rolePermissionServ = new RolePermissionService();
    this.metadataCache = new ServerMetadataCache(this.adapter);
    this.metadataCache.rebuild();
    this.registryService.initialize(this.adapter);
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) HierarchyTypePermissionService(net.geoprism.registry.permission.HierarchyTypePermissionService) HierarchyService(net.geoprism.registry.hierarchy.HierarchyService) ServerMetadataCache(net.geoprism.registry.cache.ServerMetadataCache) OrganizationPermissionService(net.geoprism.registry.permission.OrganizationPermissionService) RegistryAdapterServer(org.commongeoregistry.adapter.RegistryAdapterServer) GeoObjectRelationshipPermissionService(net.geoprism.registry.permission.GeoObjectRelationshipPermissionService) GeoObjectPermissionService(net.geoprism.registry.permission.GeoObjectPermissionService) GeoObjectTypeRelationshipPermissionService(net.geoprism.registry.permission.GeoObjectTypeRelationshipPermissionService) GeoObjectTypePermissionService(net.geoprism.registry.permission.GeoObjectTypePermissionService)

Example 15 with RolePermissionService

use of net.geoprism.registry.permission.RolePermissionService in project geoprism-registry by terraframe.

the class TransitionPermissionService method getPermissions.

public Set<CGRPermissionAction> getPermissions(TransitionEvent event) {
    final RolePermissionService perms = ServiceFactory.getRolePermissionService();
    final String beforeOrgCode = event.getBeforeTypeOrgCode();
    final String beforeGotCode = event.getBeforeTypeCode();
    final String afterOrgCode = event.getAfterTypeOrgCode();
    final String afterGotCode = event.getAfterTypeCode();
    HashSet<CGRPermissionAction> actions = new HashSet<CGRPermissionAction>();
    if (beforeOrgCode == null || beforeGotCode == null) {
        return actions;
    }
    ServerGeoObjectType beforeType = ServerGeoObjectType.get(beforeGotCode, true);
    ServerGeoObjectType afterType = ServerGeoObjectType.get(afterGotCode, true);
    if (perms.isSRA()) {
        actions.addAll(Arrays.asList(CGRPermissionAction.values()));
    } else if (perms.isRA(beforeOrgCode)) {
        actions.addAll(Arrays.asList(CGRPermissionAction.values()));
    } else if (perms.isRM(beforeOrgCode, beforeType)) {
        actions.addAll(Arrays.asList(CGRPermissionAction.values()));
    } else if ((!beforeType.getIsPrivate() && !afterType.getIsPrivate()) || perms.isRA(afterOrgCode) || perms.isRM(afterOrgCode, afterType)) {
        actions.add(CGRPermissionAction.READ);
    }
    return actions;
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) HashSet(java.util.HashSet)

Aggregations

RolePermissionService (net.geoprism.registry.permission.RolePermissionService)15 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)11 JsonObject (com.google.gson.JsonObject)4 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)3 SessionIF (com.runwaysdk.session.SessionIF)3 Organization (net.geoprism.registry.Organization)3 JsonArray (com.google.gson.JsonArray)2 HashSet (java.util.HashSet)2 CGRPermissionException (net.geoprism.registry.CGRPermissionException)2 ListType (net.geoprism.registry.ListType)2 ChangeRequest (net.geoprism.registry.action.ChangeRequest)2 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)2 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)2 GeoObjectPermissionService (net.geoprism.registry.permission.GeoObjectPermissionService)2 GraphQuery (com.runwaysdk.business.graph.GraphQuery)1 VertexObject (com.runwaysdk.business.graph.VertexObject)1 RoleDAOIF (com.runwaysdk.business.rbac.RoleDAOIF)1 SingleActorDAOIF (com.runwaysdk.business.rbac.SingleActorDAOIF)1 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)1 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)1