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) -> {
});
}
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;
}
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);
}
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();
}
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);
}
Aggregations