Search in sources :

Example 1 with VertexGeoObjectStrategy

use of net.geoprism.registry.conversion.VertexGeoObjectStrategy in project geoprism-registry by terraframe.

the class GeoVertexSynonym method createSynonym.

@Transaction
public static JSONObject createSynonym(String typeCode, String code, String label) {
    ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
    VertexGeoObjectStrategy strategy = new VertexGeoObjectStrategy(type);
    VertexServerGeoObject object = strategy.getGeoObjectByCode(code);
    final String oid = object.addSynonym(label);
    JSONObject jObject = new JSONObject();
    jObject.put("synonymId", oid);
    jObject.put("label", object.getDisplayLabel().getValue());
    // jObject.put("ancestors", object.getA new
    // JSONArray(GeoEntityUtil.getAncestorsAsJSON(code)));
    JSONObject response = new JSONObject(jObject);
    response.put("vOid", oid);
    return response;
}
Also used : VertexGeoObjectStrategy(net.geoprism.registry.conversion.VertexGeoObjectStrategy) JSONObject(org.json.JSONObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 2 with VertexGeoObjectStrategy

use of net.geoprism.registry.conversion.VertexGeoObjectStrategy in project geoprism-registry by terraframe.

the class Transition method apply.

public static Transition apply(TransitionEvent event, int order, JsonObject object) {
    Transition transition = (object.has("isNew") && object.get("isNew").getAsBoolean()) ? new Transition() : Transition.get(object.get(OID).getAsString());
    transition.setTransitionType(object.get(Transition.TRANSITIONTYPE).getAsString());
    transition.setImpact(object.get(Transition.IMPACT).getAsString());
    if (transition.isNew()) {
        transition.setValue(Transition.EVENT, event);
    }
    String sourceCode = object.get("sourceCode").getAsString();
    String sourceType = object.get("sourceType").getAsString();
    String targetCode = object.get("targetCode").getAsString();
    String targetType = object.get("targetType").getAsString();
    VertexServerGeoObject source = new VertexGeoObjectStrategy(ServerGeoObjectType.get(sourceType)).getGeoObjectByCode(sourceCode);
    VertexServerGeoObject target = new VertexGeoObjectStrategy(ServerGeoObjectType.get(targetType)).getGeoObjectByCode(targetCode);
    transition.apply(event, order, source, target);
    return transition;
}
Also used : VertexGeoObjectStrategy(net.geoprism.registry.conversion.VertexGeoObjectStrategy) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject)

Example 3 with VertexGeoObjectStrategy

use of net.geoprism.registry.conversion.VertexGeoObjectStrategy in project geoprism-registry by terraframe.

the class UpdateParentValueOverTimeView method getNewValueAsGO.

public VertexServerGeoObject getNewValueAsGO() {
    if (this.newValue != null && !this.newValue.isJsonNull()) {
        String[] newValueSplit = (this.getNewValue().getAsString()).split(VALUE_SPLIT_TOKEN);
        String parentTypeCode = newValueSplit[0];
        String parentCode = newValueSplit[1];
        ServerGeoObjectType parentType = ServerGeoObjectType.get(parentTypeCode);
        final VertexServerGeoObject parent = new VertexGeoObjectStrategy(parentType).getGeoObjectByCode(parentCode);
        return parent;
    }
    return null;
}
Also used : VertexGeoObjectStrategy(net.geoprism.registry.conversion.VertexGeoObjectStrategy) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject)

Example 4 with VertexGeoObjectStrategy

use of net.geoprism.registry.conversion.VertexGeoObjectStrategy in project geoprism-registry by terraframe.

the class UpdateAttributeAction method execute.

@Override
public void execute() {
    ChangeRequest cr = this.getAllRequest().next();
    ServerGeoObjectType type = ServerGeoObjectType.get(cr.getGeoObjectTypeCode());
    VertexServerGeoObject go = new VertexGeoObjectStrategy(type).getGeoObjectByCode(cr.getGeoObjectCode());
    AbstractUpdateAttributeView view = UpdateAttributeViewJsonAdapters.deserialize(this.getJson(), this.getAttributeName(), type);
    view.execute(go);
    if (!this.getAttributeName().equals(UpdateAttributeViewJsonAdapters.PARENT_ATTR_NAME)) {
        String attributeName = this.getAttributeName();
        if (attributeName.equals("geometry")) {
            attributeName = go.getGeometryAttributeName();
        }
        ValueOverTimeCollection votc = go.getValuesOverTime(attributeName);
        votc.reorder();
        go.apply(false);
    }
}
Also used : VertexGeoObjectStrategy(net.geoprism.registry.conversion.VertexGeoObjectStrategy) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) AbstractUpdateAttributeView(net.geoprism.registry.view.action.AbstractUpdateAttributeView) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 5 with VertexGeoObjectStrategy

use of net.geoprism.registry.conversion.VertexGeoObjectStrategy in project geoprism-registry by terraframe.

the class HierarchyChangeTest method testRemoveFromHierarchyWithData.

@Test
@Request
public void testRemoveFromHierarchyWithData() {
    String sessionId = testData.clientSession.getSessionId();
    String hierarchyCode = USATestData.HIER_ADMIN.getCode();
    String countryTypeCode = USATestData.COUNTRY.getCode();
    String stateTypeCode = USATestData.STATE.getCode();
    String cd1TypeCode = USATestData.CO_D_ONE.getCode();
    ServerGeoObjectIF geoobject = new VertexGeoObjectStrategy(USATestData.DISTRICT.getServerObject()).getGeoObjectByCode(cd1TypeCode);
    ServerParentTreeNode parents = geoobject.getParentGeoObjects(null, false, TestDataSet.DEFAULT_OVER_TIME_DATE);
    Assert.assertEquals(1, parents.getParents().size());
    ServiceFactory.getHierarchyService().removeFromHierarchy(sessionId, hierarchyCode, countryTypeCode, stateTypeCode, true);
    ServerGeoObjectIF test = new VertexGeoObjectStrategy(USATestData.DISTRICT.getServerObject()).getGeoObjectByCode(cd1TypeCode);
    ServerParentTreeNode tParents = test.getParentGeoObjects(null, false, TestDataSet.DEFAULT_OVER_TIME_DATE);
    Assert.assertEquals(0, tParents.getParents().size());
}
Also used : VertexGeoObjectStrategy(net.geoprism.registry.conversion.VertexGeoObjectStrategy) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

VertexGeoObjectStrategy (net.geoprism.registry.conversion.VertexGeoObjectStrategy)5 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)4 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)3 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 Request (com.runwaysdk.session.Request)1 ChangeRequest (net.geoprism.registry.action.ChangeRequest)1 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)1 ServerParentTreeNode (net.geoprism.registry.model.ServerParentTreeNode)1 AbstractUpdateAttributeView (net.geoprism.registry.view.action.AbstractUpdateAttributeView)1 JSONObject (org.json.JSONObject)1 Test (org.junit.Test)1