Search in sources :

Example 1 with UndirectedGraphType

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();
}
Also used : JsonObject(com.google.gson.JsonObject) UndirectedGraphType(net.geoprism.registry.UndirectedGraphType) Session(com.runwaysdk.session.Session) Request(com.runwaysdk.session.Request)

Example 2 with UndirectedGraphType

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();
}
Also used : UndirectedGraphType(net.geoprism.registry.UndirectedGraphType) Request(com.runwaysdk.session.Request)

Example 3 with UndirectedGraphType

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;
}
Also used : JsonArray(com.google.gson.JsonArray) DirectedAcyclicGraphType(net.geoprism.registry.DirectedAcyclicGraphType) GraphType(net.geoprism.registry.model.GraphType) UndirectedGraphType(net.geoprism.registry.UndirectedGraphType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) DirectedAcyclicGraphType(net.geoprism.registry.DirectedAcyclicGraphType) JsonObject(com.google.gson.JsonObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GeoObjectTypePermissionServiceIF(net.geoprism.registry.permission.GeoObjectTypePermissionServiceIF) UndirectedGraphType(net.geoprism.registry.UndirectedGraphType) HashSet(java.util.HashSet) Request(com.runwaysdk.session.Request)

Example 4 with UndirectedGraphType

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();
    }
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) UndirectedGraphType(net.geoprism.registry.UndirectedGraphType) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 5 with UndirectedGraphType

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();
    }
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) UndirectedGraphType(net.geoprism.registry.UndirectedGraphType) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

UndirectedGraphType (net.geoprism.registry.UndirectedGraphType)10 Request (com.runwaysdk.session.Request)9 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)6 Test (org.junit.Test)5 JsonObject (com.google.gson.JsonObject)4 JsonArray (com.google.gson.JsonArray)1 MdEdgeDAO (com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO)1 Session (com.runwaysdk.session.Session)1 MdEdge (com.runwaysdk.system.metadata.MdEdge)1 HashSet (java.util.HashSet)1 DirectedAcyclicGraphType (net.geoprism.registry.DirectedAcyclicGraphType)1 GraphType (net.geoprism.registry.model.GraphType)1 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)1 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)1 GeoObjectTypePermissionServiceIF (net.geoprism.registry.permission.GeoObjectTypePermissionServiceIF)1