use of net.geoprism.registry.UndirectedGraphType in project geoprism-registry by terraframe.
the class UndirectedGraphTypeService method create.
@Request(RequestType.SESSION)
public JsonObject create(String sessionId, String json) {
JsonObject object = JsonParser.parseString(json).getAsJsonObject();
UndirectedGraphType type = UndirectedGraphType.create(object);
((Session) Session.getCurrentSession()).reloadPermissions();
return type.toJSON();
}
use of net.geoprism.registry.UndirectedGraphType in project geoprism-registry by terraframe.
the class UndirectedGraphTypeService method remove.
@Request(RequestType.SESSION)
public void remove(String sessionId, String code) {
UndirectedGraphType type = UndirectedGraphType.getByCode(code);
type.delete();
}
use of net.geoprism.registry.UndirectedGraphType 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.UndirectedGraphType in project geoprism-registry by terraframe.
the class UndirectedGraphTypeTest method testGetByAll.
@Test
@Request
public void testGetByAll() {
UndirectedGraphType type = UndirectedGraphType.create("TEST", new LocalizedValue("Test Label"), new LocalizedValue("Test Description"));
try {
List<UndirectedGraphType> results = UndirectedGraphType.getAll();
Assert.assertEquals(1, results.size());
UndirectedGraphType result = results.get(0);
Assert.assertEquals(type.getCode(), result.getCode());
} finally {
type.delete();
}
}
use of net.geoprism.registry.UndirectedGraphType in project geoprism-registry by terraframe.
the class UndirectedGraphTypeTest method testGetByCode.
@Test
@Request
public void testGetByCode() {
UndirectedGraphType type = UndirectedGraphType.create("TEST", new LocalizedValue("Test Label"), new LocalizedValue("Test Description"));
try {
UndirectedGraphType result = UndirectedGraphType.getByCode(type.getCode());
Assert.assertNotNull(result);
Assert.assertEquals(type.getCode(), result.getCode());
} finally {
type.delete();
}
}
Aggregations