use of net.geoprism.registry.model.GraphType 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.model.GraphType in project geoprism-registry by terraframe.
the class RelationshipVisualizationService method getRelationshipTypes.
@Request(RequestType.SESSION)
public JsonElement getRelationshipTypes(String sessionId, String geoObjectTypeCode) {
JsonArray view = new JsonArray();
// Hierarchy relationships
final HierarchyTypePermissionServiceIF htpService = ServiceFactory.getHierarchyPermissionService();
ServerGeoObjectType type = ServerGeoObjectType.get(geoObjectTypeCode);
type.getHierarchies().stream().filter(htp -> {
return htpService.canRead(htp.getOrganizationCode());
}).forEach(graphType -> {
JsonObject jo = new JsonObject();
jo.addProperty("oid", graphType.getCode());
jo.addProperty("code", graphType.getCode());
jo.add("label", graphType.getLabel().toJSON());
jo.addProperty("isHierarchy", true);
view.add(jo);
});
// Non-hierarchy relationships
UndirectedGraphType.getAll().forEach(graphType -> {
JsonObject jo = graphType.toJSON();
jo.addProperty("isHierarchy", false);
view.add(jo);
});
DirectedAcyclicGraphType.getAll().forEach(graphType -> {
JsonObject jo = graphType.toJSON();
jo.addProperty("isHierarchy", false);
view.add(jo);
});
return view;
}
Aggregations