use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class RegistryService method updateGeoObjectOverTime.
@Request(RequestType.SESSION)
public GeoObjectOverTime updateGeoObjectOverTime(String sessionId, String jGeoObj) {
GeoObjectOverTime goTime = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), jGeoObj);
ServerGeoObjectType type = ServerGeoObjectType.get(goTime.getType().getCode());
ServiceFactory.getGeoObjectPermissionService().enforceCanWrite(goTime.getType().getOrganizationCode(), type);
ServerGeoObjectIF object = service.apply(goTime, false, false);
return object.toGeoObjectOverTime();
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class RegistryService method createGeoObjectOverTime.
@Request(RequestType.SESSION)
public GeoObjectOverTime createGeoObjectOverTime(String sessionId, String jGeoObj) {
GeoObjectOverTime goTime = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), jGeoObj);
ServerGeoObjectType type = ServerGeoObjectType.get(goTime.getType().getCode());
ServiceFactory.getGeoObjectPermissionService().enforceCanCreate(goTime.getType().getOrganizationCode(), type);
ServerGeoObjectIF object = service.apply(goTime, true, false);
return object.toGeoObjectOverTime();
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class RegistryService method getGeoObject.
@Request(RequestType.SESSION)
public GeoObject getGeoObject(String sessionId, String uid, String geoObjectTypeCode, Date date) {
ServerGeoObjectIF object = this.service.getGeoObject(uid, geoObjectTypeCode);
if (object == null) {
net.geoprism.registry.DataNotFoundException ex = new net.geoprism.registry.DataNotFoundException();
ex.setTypeLabel(GeoObjectMetadata.get().getClassDisplayLabel());
ex.setDataIdentifier(uid);
ex.setAttributeLabel(GeoObjectMetadata.get().getAttributeDisplayLabel(DefaultAttribute.UID.getName()));
throw ex;
}
final GeoObjectPermissionServiceIF pService = ServiceFactory.getGeoObjectPermissionService();
pService.enforceCanRead(object.getType().getOrganization().getCode(), object.getType());
ServerGeoObjectType type = object.getType();
GeoObject geoObject = object.toGeoObject(date);
geoObject.setWritable(pService.canCreateCR(type.getOrganization().getCode(), type));
return geoObject;
}
use of net.geoprism.registry.model.ServerGeoObjectIF 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.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class ServerParentTreeNodeOverTime method enforceUserHasPermissionSetParents.
public void enforceUserHasPermissionSetParents(String childCode, boolean asCR) {
final Collection<ServerHierarchyType> hierarchyTypes = this.getHierarchies();
ServerGeoObjectType childType = ServerGeoObjectType.get(childCode);
for (ServerHierarchyType hierarchyType : hierarchyTypes) {
final List<ServerParentTreeNode> entries = this.getEntries(hierarchyType);
for (ServerParentTreeNode entry : entries) {
final ServerGeoObjectIF parent = entry.getGeoObject();
if (asCR) {
ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanAddChildCR(hierarchyType.getOrganization().getCode(), parent.getType(), childType);
} else {
ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanAddChild(hierarchyType.getOrganization().getCode(), parent.getType(), childType);
}
}
}
}
Aggregations