Search in sources :

Example 1 with DirectedAcyclicGraphType

use of net.geoprism.registry.DirectedAcyclicGraphType in project geoprism-registry by terraframe.

the class DirectedAcyclicGraphTypeService method update.

@Request(RequestType.SESSION)
public JsonObject update(String sessionId, String json) {
    JsonObject object = JsonParser.parseString(json).getAsJsonObject();
    String code = object.get(DirectedAcyclicGraphType.CODE).getAsString();
    DirectedAcyclicGraphType type = DirectedAcyclicGraphType.getByCode(code);
    type.update(object);
    return type.toJSON();
}
Also used : DirectedAcyclicGraphType(net.geoprism.registry.DirectedAcyclicGraphType) JsonObject(com.google.gson.JsonObject) Request(com.runwaysdk.session.Request)

Example 2 with DirectedAcyclicGraphType

use of net.geoprism.registry.DirectedAcyclicGraphType in project geoprism-registry by terraframe.

the class DirectedAcyclicGraphTypeService method remove.

@Request(RequestType.SESSION)
public void remove(String sessionId, String code) {
    DirectedAcyclicGraphType type = DirectedAcyclicGraphType.getByCode(code);
    type.delete();
}
Also used : DirectedAcyclicGraphType(net.geoprism.registry.DirectedAcyclicGraphType) Request(com.runwaysdk.session.Request)

Example 3 with DirectedAcyclicGraphType

use of net.geoprism.registry.DirectedAcyclicGraphType 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 DirectedAcyclicGraphType

use of net.geoprism.registry.DirectedAcyclicGraphType in project geoprism-registry by terraframe.

the class XMLImporter method createDirectedAcyclicGraphType.

private DirectedAcyclicGraphType createDirectedAcyclicGraphType(Element elem) {
    String code = elem.getAttribute("code");
    LocalizedValue label = this.getLabel(elem);
    LocalizedValue description = this.getDescription(elem);
    DirectedAcyclicGraphType type = DirectedAcyclicGraphType.create(code, label, description);
    return type;
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) DirectedAcyclicGraphType(net.geoprism.registry.DirectedAcyclicGraphType)

Example 5 with DirectedAcyclicGraphType

use of net.geoprism.registry.DirectedAcyclicGraphType in project geoprism-registry by terraframe.

the class DirectedAcyclicGraphTypeTest method testUpdate.

@Test
@Request
public void testUpdate() {
    DirectedAcyclicGraphType type = DirectedAcyclicGraphType.create("TEST", new LocalizedValue("Test Label"), new LocalizedValue("Test Description"));
    try {
        JsonObject object = new JsonObject();
        object.add(DirectedAcyclicGraphType.DISPLAYLABEL, new LocalizedValue("Updated Label").toJSON());
        object.add(DirectedAcyclicGraphType.DESCRIPTION, new LocalizedValue("Updated Description").toJSON());
        type.update(object);
        Assert.assertEquals("Updated Label", type.getDisplayLabel().getValue());
        Assert.assertEquals("Updated Description", type.getDescription().getValue());
    } finally {
        type.delete();
    }
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) DirectedAcyclicGraphType(net.geoprism.registry.DirectedAcyclicGraphType) JsonObject(com.google.gson.JsonObject) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

DirectedAcyclicGraphType (net.geoprism.registry.DirectedAcyclicGraphType)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 UndirectedGraphType (net.geoprism.registry.UndirectedGraphType)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