use of net.geoprism.registry.permission.GeoObjectRelationshipPermissionServiceIF in project geoprism-registry by terraframe.
the class HierarchyService method getHierarchiesForType.
@Request(RequestType.SESSION)
public JsonArray getHierarchiesForType(String sessionId, String code, Boolean includeTypes) {
ServerGeoObjectType geoObjectType = ServerGeoObjectType.get(code);
List<ServerHierarchyType> hierarchyTypes = ServerHierarchyType.getAll();
JsonArray hierarchies = new JsonArray();
HierarchyTypePermissionServiceIF htpService = ServiceFactory.getHierarchyPermissionService();
GeoObjectRelationshipPermissionServiceIF grpService = ServiceFactory.getGeoObjectRelationshipPermissionService();
for (ServerHierarchyType sHT : hierarchyTypes) {
if (htpService.canRead(sHT.getOrganizationCode())) {
List<GeoObjectType> parents = geoObjectType.getTypeAncestors(sHT, true);
if (parents.size() > 0 || geoObjectType.isRoot(sHT)) {
JsonObject object = new JsonObject();
object.addProperty("code", sHT.getCode());
object.addProperty("label", sHT.getDisplayLabel().getValue());
if (includeTypes) {
JsonArray pArray = new JsonArray();
for (GeoObjectType parent : parents) {
ServerGeoObjectType pType = ServerGeoObjectType.get(parent);
if (!pType.getCode().equals(geoObjectType.getCode()) && grpService.canViewChild(sHT.getOrganizationCode(), null, pType)) {
JsonObject pObject = new JsonObject();
pObject.addProperty("code", pType.getCode());
pObject.addProperty("label", pType.getLabel().getValue());
pArray.add(pObject);
}
}
object.add("parents", pArray);
}
hierarchies.add(object);
}
}
}
if (hierarchies.size() == 0) {
for (ServerHierarchyType sHT : hierarchyTypes) {
if (htpService.canWrite(sHT.getOrganizationCode())) {
if (geoObjectType.isRoot(sHT)) {
JsonObject object = new JsonObject();
object.addProperty("code", sHT.getCode());
object.addProperty("label", sHT.getDisplayLabel().getValue());
object.add("parents", new JsonArray());
hierarchies.add(object);
}
}
}
}
return hierarchies;
}
use of net.geoprism.registry.permission.GeoObjectRelationshipPermissionServiceIF in project geoprism-registry by terraframe.
the class ServerChildTreeNode method toNode.
public ChildTreeNode toNode(boolean enforcePermissions) {
final GeoObjectRelationshipPermissionServiceIF relPermServ = ServiceFactory.getGeoObjectRelationshipPermissionService();
final GeoObjectPermissionServiceIF goPermServ = ServiceFactory.getGeoObjectPermissionService();
GeoObject go = this.getGeoObject().toGeoObject(this.getStartDate());
HierarchyType ht = this.getHierarchyType() != null ? this.getHierarchyType().toHierarchyType() : null;
ChildTreeNode node = new ChildTreeNode(go, ht);
String orgCode = go.getType().getOrganizationCode();
ServerGeoObjectType type = ServerGeoObjectType.get(go.getType());
for (ServerChildTreeNode child : this.children) {
if (!enforcePermissions || (relPermServ.canViewChild(orgCode, type, child.getGeoObject().getType()) && goPermServ.canRead(orgCode, type))) {
node.addChild(child.toNode(enforcePermissions));
}
}
return node;
}
use of net.geoprism.registry.permission.GeoObjectRelationshipPermissionServiceIF in project geoprism-registry by terraframe.
the class HierarchyService method filterHierarchiesFromPermissions.
public static void filterHierarchiesFromPermissions(ServerGeoObjectType type, ServerParentTreeNodeOverTime pot) {
GeoObjectRelationshipPermissionServiceIF service = ServiceFactory.getGeoObjectRelationshipPermissionService();
Collection<ServerHierarchyType> hierarchies = pot.getHierarchies();
for (ServerHierarchyType hierarchy : hierarchies) {
Organization organization = hierarchy.getOrganization();
// null, type) ))
if (!service.canViewChild(organization.getCode(), null, type)) {
pot.remove(hierarchy);
}
}
}
Aggregations