use of net.geoprism.registry.model.graph.VertexServerGeoObject 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();
}
}
use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.
the class BasicVertexQuery method getResults.
public List<ServerGeoObjectIF> getResults() {
List<ServerGeoObjectIF> list = new LinkedList<ServerGeoObjectIF>();
GraphQuery<VertexObject> query = this.getQuery();
List<VertexObject> results = query.getResults();
for (VertexObject result : results) {
list.add(new VertexServerGeoObject(type, result, this.date));
}
return list;
}
use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.
the class BasicVertexQuery method getSingleResult.
public ServerGeoObjectIF getSingleResult() {
GraphQuery<VertexObject> query = this.getQuery();
VertexObject vertex = query.getSingleResult();
if (vertex != null) {
return new VertexServerGeoObject(type, vertex, this.date);
}
return null;
}
use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.
the class VertexGeoObjectQuery method getSingleResult.
public ServerGeoObjectIF getSingleResult() {
GraphQuery<VertexObject> query = this.getQuery();
VertexObject vertex = query.getSingleResult();
if (vertex != null) {
return new VertexServerGeoObject(type, vertex, this.date);
}
return null;
}
use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.
the class LocationService method getLocationInformation.
@Request(RequestType.SESSION)
public LocationInformation getLocationInformation(String sessionId, Date date, String typeCode, String hierarchyCode) {
LocationInformation information = new LocationInformation();
HierarchyService hService = ServiceFactory.getHierarchyService();
HierarchyType[] hierarchies = hService.getHierarchyTypes(sessionId, null, PermissionContext.READ);
ServerHierarchyType hierarchy = null;
if (hierarchyCode == null || hierarchyCode.length() == 0) {
hierarchy = ServerHierarchyType.get(hierarchies[0]);
} else {
hierarchy = ServerHierarchyType.get(hierarchyCode);
}
List<ServerGeoObjectType> nodes = hierarchy.getDirectRootNodes();
if (nodes.size() > 0) {
/*
* If a typeCode is given and it is an option based on the hierarchy than
* use that type otherwise use the first type code
*/
ServerGeoObjectType type = nodes.get(0);
if (typeCode != null && typeCode.length() > 0) {
for (ServerGeoObjectType node : nodes) {
if (node.getCode().equals(typeCode)) {
type = ServerGeoObjectType.get(typeCode);
}
}
}
if (type != null) {
ServiceFactory.getGeoObjectPermissionService().enforceCanRead(type.getOrganization().getCode(), type);
information.setChildType(type.getType());
List<VertexServerGeoObject> children = this.getGeoObjects(type.getCode(), date);
for (VertexServerGeoObject child : children) {
information.addChild(child.toGeoObject(date));
}
}
}
information.setHierarchies(hierarchies);
information.setHierarchy(hierarchy.getCode());
information.setChildTypes(nodes);
return information;
}
Aggregations