use of net.geoprism.registry.permission.GeoObjectTypePermissionServiceIF in project geoprism-registry by terraframe.
the class HierarchyService method getHierarchyGroupedTypes.
@Request(RequestType.SESSION)
public JsonArray getHierarchyGroupedTypes(String sessionId) {
final HierarchyTypePermissionServiceIF hierarchyPermissions = ServiceFactory.getHierarchyPermissionService();
final GeoObjectTypePermissionServiceIF typePermissions = ServiceFactory.getGeoObjectTypePermissionService();
final RolePermissionService rps = ServiceFactory.getRolePermissionService();
final boolean isSRA = rps.isSRA();
JsonArray allHiers = new JsonArray();
List<ServerHierarchyType> shts = ServiceFactory.getMetadataCache().getAllHierarchyTypes();
for (ServerHierarchyType sht : shts) {
final String htOrgCode = sht.getOrganizationCode();
if (hierarchyPermissions.canRead(htOrgCode) && (isSRA || rps.isRA(htOrgCode) || rps.isRM(htOrgCode))) {
JsonObject hierView = new JsonObject();
hierView.addProperty("code", sht.getCode());
hierView.addProperty("label", sht.getDisplayLabel().getValue());
hierView.addProperty("orgCode", sht.getOrganizationCode());
JsonArray allHierTypes = new JsonArray();
List<ServerGeoObjectType> types = sht.getAllTypes();
for (ServerGeoObjectType type : types) {
final String gotOrgCode = type.getOrganizationCode();
if (typePermissions.canRead(gotOrgCode, type, type.getIsPrivate()) && (isSRA || rps.isRA(gotOrgCode) || rps.isRM(gotOrgCode, type))) {
if (type.getIsAbstract()) {
JsonObject superView = new JsonObject();
superView.addProperty("code", type.getCode());
superView.addProperty("label", type.getLabel().getValue());
superView.addProperty("orgCode", type.getOrganizationCode());
superView.addProperty("isAbstract", true);
List<ServerGeoObjectType> subtypes = type.getSubtypes();
for (ServerGeoObjectType subtype : subtypes) {
JsonObject typeView = new JsonObject();
typeView.addProperty("code", subtype.getCode());
typeView.addProperty("label", subtype.getLabel().getValue());
typeView.addProperty("orgCode", subtype.getOrganization().getCode());
typeView.add("super", superView);
allHierTypes.add(typeView);
}
} else {
JsonObject typeView = new JsonObject();
typeView.addProperty("code", type.getCode());
typeView.addProperty("label", type.getLabel().getValue());
typeView.addProperty("orgCode", type.getOrganizationCode());
allHierTypes.add(typeView);
}
}
}
hierView.add("types", allHierTypes);
allHiers.add(hierView);
}
}
return allHiers;
}
use of net.geoprism.registry.permission.GeoObjectTypePermissionServiceIF in project geoprism-registry by terraframe.
the class RelationshipVisualizationService method tree.
@Request(RequestType.SESSION)
public JsonElement tree(String sessionId, Date date, String relationshipType, String graphTypeCode, String geoObjectCode, String geoObjectTypeCode) {
final GeoObjectTypePermissionServiceIF typePermissions = ServiceFactory.getGeoObjectTypePermissionService();
final ServerGeoObjectType type = ServiceFactory.getMetadataCache().getGeoObjectType(geoObjectTypeCode).get();
JsonObject view = new JsonObject();
JsonArray jaEdges = new JsonArray();
view.add("edges", jaEdges);
JsonArray jaVerticies = new JsonArray();
view.add("verticies", jaVerticies);
if (typePermissions.canRead(type.getOrganization().getCode(), type, type.getIsPrivate())) {
VertexServerGeoObject rootGo = (VertexServerGeoObject) ServiceFactory.getGeoObjectService().getGeoObjectByCode(geoObjectCode, type);
final GraphType graphType = GraphType.getByCode(relationshipType, graphTypeCode);
jaVerticies.add(serializeVertex(rootGo, (graphType instanceof UndirectedGraphType) ? "PARENT" : "SELECTED"));
Set<String> setEdges = new HashSet<String>();
Set<String> setVerticies = new HashSet<String>();
if (graphType instanceof UndirectedGraphType) {
// get parent and get children return the same thing for an undirected
// graph
fetchChildrenData(false, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
} else if (graphType instanceof DirectedAcyclicGraphType) {
// Out is children
fetchParentsData(false, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
// In is parents
fetchChildrenData(false, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
} else {
// Out is children
fetchParentsData(true, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
// In is parents
fetchChildrenData(false, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
}
}
return view;
}
use of net.geoprism.registry.permission.GeoObjectTypePermissionServiceIF in project geoprism-registry by terraframe.
the class TermConverter method enforceTermPermissions.
public static void enforceTermPermissions(Classifier parent, CGRPermissionActionIF action) {
GeoObjectTypePermissionServiceIF service = ServiceFactory.getGeoObjectTypePermissionService();
// Is this a root term for an {@link MdAttributeTerm}
try (OIterator<? extends MdAttributeTerm> attrTerm = parent.getAllClassifierTermAttributeRoots()) {
for (MdAttributeTerm mdAttributeTerm : attrTerm) {
MdClassDAOIF mdEntityDAOIF = MdClassDAO.get(mdAttributeTerm.getDefiningMdClassId());
ServerGeoObjectType geoObjectType = ServerGeoObjectType.get(mdEntityDAOIF.getTypeName(), true);
if (geoObjectType != null) {
Organization organization = geoObjectType.getOrganization();
service.enforceActorHasPermission(organization.getCode(), geoObjectType, geoObjectType.getIsPrivate(), action);
}
}
}
}
use of net.geoprism.registry.permission.GeoObjectTypePermissionServiceIF in project geoprism-registry by terraframe.
the class ServerHierarchyType method filterOutPrivateNodes.
private void filterOutPrivateNodes(HierarchyNode parent) {
final GeoObjectTypePermissionServiceIF typePermServ = ServiceFactory.getGeoObjectTypePermissionService();
List<HierarchyNode> list = parent.getChildren();
Iterator<HierarchyNode> it = list.iterator();
while (it.hasNext()) {
HierarchyNode child = it.next();
GeoObjectType got = child.getGeoObjectType();
if (!typePermServ.canRead(got.getOrganizationCode(), ServerGeoObjectType.get(got), got.getIsPrivate())) {
it.remove();
} else {
this.filterOutPrivateNodes(child);
}
}
}
Aggregations