Search in sources :

Example 1 with GeoObjectPermissionService

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

the class LocationService method search.

@Request(RequestType.SESSION)
public List<GeoObject> search(String sessionId, String text, Date date) {
    final GeoObjectPermissionService pService = new GeoObjectPermissionService();
    List<ServerGeoObjectIF> results = new SearchService().search(text, date, 20L);
    return results.stream().collect(() -> new LinkedList<GeoObject>(), (list, element) -> {
        ServerGeoObjectType type = element.getType();
        GeoObject geoObject = element.toGeoObject(date);
        geoObject.setWritable(pService.canCreateCR(type.getOrganization().getCode(), type));
        list.add(geoObject);
    }, (listA, listB) -> {
    });
}
Also used : GeoObjectPermissionService(net.geoprism.registry.permission.GeoObjectPermissionService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) Request(com.runwaysdk.session.Request)

Example 2 with GeoObjectPermissionService

use of net.geoprism.registry.permission.GeoObjectPermissionService 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 3 with GeoObjectPermissionService

use of net.geoprism.registry.permission.GeoObjectPermissionService 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 4 with GeoObjectPermissionService

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

the class TransitionEventService method getHistoricalReport.

@Request(RequestType.SESSION)
public JsonObject getHistoricalReport(String sessionId, String typeCode, Date startDate, Date endDate, Integer pageSize, Integer pageNumber) {
    ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
    new GeoObjectPermissionService().enforceCanRead(type.getOrganization().getCode(), type);
    return HistoricalRow.getHistoricalReport(type, startDate, endDate, pageSize, pageNumber).toJSON();
}
Also used : GeoObjectPermissionService(net.geoprism.registry.permission.GeoObjectPermissionService) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request)

Example 5 with GeoObjectPermissionService

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

the class TransitionEventService method exportExcel.

@Request(RequestType.SESSION)
public InputStream exportExcel(String sessionId, String typeCode, Date startDate, Date endDate) throws IOException {
    ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
    new GeoObjectPermissionService().enforceCanRead(type.getOrganization().getCode(), type);
    return HistoricalRow.exportToExcel(type, startDate, endDate);
}
Also used : GeoObjectPermissionService(net.geoprism.registry.permission.GeoObjectPermissionService) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request)

Aggregations

GeoObjectPermissionService (net.geoprism.registry.permission.GeoObjectPermissionService)5 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)4 Request (com.runwaysdk.session.Request)3 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)2 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)2 RolePermissionService (net.geoprism.registry.permission.RolePermissionService)2 GraphQuery (com.runwaysdk.business.graph.GraphQuery)1 VertexObject (com.runwaysdk.business.graph.VertexObject)1 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)1 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)1 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)1 LinkedList (java.util.LinkedList)1 ServerMetadataCache (net.geoprism.registry.cache.ServerMetadataCache)1 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)1 HierarchyService (net.geoprism.registry.hierarchy.HierarchyService)1 GeoObjectRelationshipPermissionService (net.geoprism.registry.permission.GeoObjectRelationshipPermissionService)1 GeoObjectTypePermissionService (net.geoprism.registry.permission.GeoObjectTypePermissionService)1 GeoObjectTypeRelationshipPermissionService (net.geoprism.registry.permission.GeoObjectTypeRelationshipPermissionService)1 HierarchyTypePermissionService (net.geoprism.registry.permission.HierarchyTypePermissionService)1 OrganizationPermissionService (net.geoprism.registry.permission.OrganizationPermissionService)1