Search in sources :

Example 16 with ValueOverTime

use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.

the class ValueOverTimeTest method testStoreSameLocalizedValue.

@Test
@Request
public void testStoreSameLocalizedValue() {
    final String defaultValue = "default store";
    LocalizedValue original = new LocalizedValue(defaultValue);
    original.setValue(LocalizedValue.DEFAULT_LOCALE, defaultValue);
    ServerGeoObjectIF go = TEST_GO.getServerObject();
    go.setDisplayLabel(original, TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
    go.apply(false);
    final String newValue = defaultValue;
    LocalizedValue lvNew = new LocalizedValue(newValue);
    lvNew.setValue(LocalizedValue.DEFAULT_LOCALE, newValue);
    ServerGeoObjectIF go2 = TEST_GO.getServerObject();
    go2.setDisplayLabel(lvNew, addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, 5), addDay(TestDataSet.DEFAULT_END_TIME_DATE, -5));
    go2.apply(false);
    ServerGeoObjectIF go3 = TEST_GO.getServerObject();
    ValueOverTimeCollection votc = go3.getValuesOverTime(DefaultAttribute.DISPLAY_LABEL.getName());
    Assert.assertEquals(1, votc.size());
    ValueOverTime vot = votc.get(0);
    Assert.assertEquals(defaultValue, ((VertexObjectDAO) vot.getValue()).getObjectValue(com.runwaysdk.constants.MdAttributeLocalInfo.DEFAULT_LOCALE));
    Assert.assertEquals(TestDataSet.DEFAULT_OVER_TIME_DATE, vot.getStartDate());
    Assert.assertEquals(TestDataSet.DEFAULT_END_TIME_DATE, vot.getEndDate());
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 17 with ValueOverTime

use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.

the class CRAttributePatch method patchAllGos.

private void patchAllGos() {
    for (Universal uni : getUniversals()) {
        MdGeoVertexDAO mdVertex = GeoVertexType.getMdGeoVertex(uni.getUniversalId());
        List<? extends MdAttributeDAOIF> attributes = mdVertex.getAllDefinedMdAttributes();
        String[] skipAttrs = new String[] { DefaultAttribute.UID.getName(), "uuid", DefaultAttribute.CODE.getName(), DefaultAttribute.CREATE_DATE.getName(), DefaultAttribute.LAST_UPDATE_DATE.getName(), DefaultAttribute.SEQUENCE.getName(), DefaultAttribute.TYPE.getName(), MdAttributeConcreteInfo.OID, MdAttributeConcreteInfo.SEQUENCE };
        StringBuilder statement = new StringBuilder();
        statement.append("SELECT FROM " + mdVertex.getDBClassName());
        GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
        List<VertexObject> results = query.getResults();
        logger.info("Updating [" + results.size() + "] objects on table [" + mdVertex.getDBClassName() + "].");
        for (VertexObject vo : query.getResults()) {
            for (MdAttributeDAOIF attr : attributes) {
                if (!ArrayUtils.contains(skipAttrs, attr.definesAttribute())) {
                    ValueOverTimeCollection col = vo.getValuesOverTime(attr.definesAttribute());
                    for (ValueOverTime vot : col) {
                        vot.setOid(UUID.randomUUID().toString());
                    }
                }
            }
            vo.apply();
        }
    }
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) VertexObject(com.runwaysdk.business.graph.VertexObject) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) MdGeoVertexDAO(com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 18 with ValueOverTime

use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.

the class DirectedAcyclicGraphStrategy method addParent.

@SuppressWarnings("unchecked")
@Override
public ServerParentGraphNode addParent(VertexServerGeoObject geoObject, VertexServerGeoObject parent, Date startDate, Date endDate) {
    GraphValidationService.validate(type, parent, parent);
    if (this.isCycle(geoObject, parent, startDate, endDate)) {
        throw new UnsupportedOperationException("Cannot add a cycle");
    }
    if (this.getParentEdges(geoObject, parent, startDate, endDate).size() > 0) {
        throw new UnsupportedOperationException("Duplicate edge");
    }
    Set<ValueOverTime> votc = this.getParentCollection(geoObject);
    votc.add(new ValueOverTime(startDate, endDate, parent));
    SortedSet<EdgeObject> newEdges = this.setParentCollection(geoObject, votc);
    ServerParentGraphNode node = new ServerParentGraphNode(geoObject, this.type, startDate, endDate, null);
    node.addParent(new ServerParentGraphNode(parent, this.type, startDate, endDate, newEdges.first().getOid()));
    return node;
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerParentGraphNode(net.geoprism.registry.model.ServerParentGraphNode)

Example 19 with ValueOverTime

use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.

the class DirectedAcyclicGraphStrategy method setParentCollection.

private SortedSet<EdgeObject> setParentCollection(VertexServerGeoObject geoObject, Set<ValueOverTime> votc) {
    SortedSet<EdgeObject> newEdges = new TreeSet<EdgeObject>(new EdgeComparator());
    SortedSet<EdgeObject> edges = this.getParentEdges(geoObject);
    for (EdgeObject edge : edges) {
        final Date startDate = edge.getObjectValue(GeoVertex.START_DATE);
        final Date endDate = edge.getObjectValue(GeoVertex.END_DATE);
        VertexObject parentVertex = edge.getParent();
        MdVertexDAOIF mdVertex = (MdVertexDAOIF) parentVertex.getMdClass();
        ServerGeoObjectType parentType = ServerGeoObjectType.get(mdVertex);
        final VertexServerGeoObject edgeGo = new VertexServerGeoObject(parentType, parentVertex, startDate);
        ValueOverTime inVot = null;
        for (ValueOverTime vot : votc) {
            if (vot.getOid() == edge.getOid()) {
                inVot = vot;
                break;
            }
        }
        if (inVot == null) {
            edge.delete();
        } else {
            VertexServerGeoObject inGo = (VertexServerGeoObject) inVot.getValue();
            boolean hasValueChange = false;
            if ((inGo == null && edgeGo != null) || (inGo != null && edgeGo == null)) {
                hasValueChange = true;
            } else if ((inGo != null && edgeGo != null) && !inGo.equals(edgeGo)) {
                hasValueChange = true;
            }
            if (hasValueChange) {
                edge.delete();
                EdgeObject newEdge = geoObject.getVertex().addParent(inGo.getVertex(), this.type.getMdEdgeDAO());
                newEdge.setValue(GeoVertex.START_DATE, startDate);
                newEdge.setValue(GeoVertex.END_DATE, endDate);
                newEdge.apply();
                newEdges.add(newEdge);
            } else {
                boolean hasChanges = false;
                if (startDate != inVot.getStartDate()) {
                    hasChanges = true;
                    edge.setValue(GeoVertex.START_DATE, startDate);
                }
                if (endDate != inVot.getEndDate()) {
                    hasChanges = true;
                    edge.setValue(GeoVertex.END_DATE, endDate);
                }
                if (hasChanges) {
                    edge.apply();
                }
            }
        }
    }
    for (ValueOverTime vot : votc) {
        boolean isNew = true;
        for (EdgeObject edge : edges) {
            if (vot.getOid() == edge.getOid()) {
                isNew = false;
            }
        }
        if (isNew) {
            EdgeObject newEdge = geoObject.getVertex().addParent(((VertexServerGeoObject) vot.getValue()).getVertex(), this.type.getMdEdgeDAO());
            newEdge.setValue(GeoVertex.START_DATE, vot.getStartDate());
            newEdge.setValue(GeoVertex.END_DATE, vot.getEndDate());
            newEdge.apply();
            newEdges.add(newEdge);
        }
    }
    return newEdges;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) TreeSet(java.util.TreeSet) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Date(java.util.Date)

Example 20 with ValueOverTime

use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.

the class UndirectedGraphStrategy method getParentCollection.

private Set<ValueOverTime> getParentCollection(VertexServerGeoObject geoObject) {
    Set<ValueOverTime> set = new TreeSet<ValueOverTime>(new Comparator<ValueOverTime>() {

        @Override
        public int compare(ValueOverTime o1, ValueOverTime o2) {
            return o1.getOid().compareTo(o2.getOid());
        }
    });
    SortedSet<EdgeObject> edges = this.getParentEdges(geoObject);
    for (EdgeObject edge : edges) {
        final Date startDate = edge.getObjectValue(GeoVertex.START_DATE);
        final Date endDate = edge.getObjectValue(GeoVertex.END_DATE);
        VertexObject parentVertex = edge.getParent();
        MdVertexDAOIF mdVertex = (MdVertexDAOIF) parentVertex.getMdClass();
        ServerGeoObjectType parentType = ServerGeoObjectType.get(mdVertex);
        VertexServerGeoObject parent = new VertexServerGeoObject(parentType, parentVertex, startDate);
        set.add(new ValueOverTime(edge.getOid(), startDate, endDate, parent));
    }
    return set;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) VertexObject(com.runwaysdk.business.graph.VertexObject) TreeSet(java.util.TreeSet) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Date(java.util.Date)

Aggregations

ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)44 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)29 Request (com.runwaysdk.session.Request)26 Date (java.util.Date)22 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)18 Test (org.junit.Test)16 EdgeObject (com.runwaysdk.business.graph.EdgeObject)10 ChangeRequest (net.geoprism.registry.action.ChangeRequest)10 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)10 VertexObject (com.runwaysdk.business.graph.VertexObject)9 UpdateAttributeAction (net.geoprism.registry.action.geoobject.UpdateAttributeAction)9 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)8 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)8 SimpleDateFormat (java.text.SimpleDateFormat)6 AbstractAction (net.geoprism.registry.action.AbstractAction)6 JsonArray (com.google.gson.JsonArray)5 JsonObject (com.google.gson.JsonObject)5 QueryFactory (com.runwaysdk.query.QueryFactory)5 TreeSet (java.util.TreeSet)5 ChangeRequestQuery (net.geoprism.registry.action.ChangeRequestQuery)5