Search in sources :

Example 1 with ValueOverTimeCollection

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

the class VertexServerGeoObject method getParentCollection.

public ValueOverTimeCollection getParentCollection(ServerHierarchyType hierarchyType) {
    ValueOverTimeCollection votc = new ValueOverTimeCollection();
    SortedSet<EdgeObject> edges = this.getEdges(hierarchyType);
    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);
        votc.add(new ValueOverTime(edge.getOid(), startDate, endDate, parent));
    }
    return votc;
}
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) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) Date(java.util.Date) LocalDate(java.time.LocalDate)

Example 2 with ValueOverTimeCollection

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

the class VertexServerGeoObject method buildDefaultExists.

// private void validateCOTAttr(String attrName)
// {
// ValueOverTimeCollection votc = this.vertex.getValuesOverTime(attrName);
// 
// if (votc == null || votc.size() == 0)
// {
// RequiredAttributeException ex = new RequiredAttributeException();
// ex.setAttributeLabel(GeoObjectTypeMetadata.getAttributeDisplayLabel(attrName));
// throw ex;
// }
// else if (votc != null && votc.size() > 0)
// {
// boolean hasValue = false;
// 
// for (int i = 0; i < votc.size(); ++i)
// {
// ValueOverTime vot = votc.get(i);
// 
// if (vot.getValue() != null)
// {
// if (vot.getValue() instanceof String && ((String)vot.getValue()).length() >
// 0)
// {
// hasValue = true;
// break;
// }
// else if (vot.getValue() instanceof Collection)
// {
// Collection<?> val = (Collection<?>) vot.getValue();
// 
// if (val.size() > 0)
// {
// hasValue = true;
// break;
// }
// }
// else
// {
// hasValue = true;
// break;
// }
// }
// }
// 
// if (!hasValue)
// {
// RequiredAttributeException ex = new RequiredAttributeException();
// ex.setAttributeLabel(GeoObjectTypeMetadata.getAttributeDisplayLabel(attrName));
// throw ex;
// }
// }
// }
public ValueOverTime buildDefaultExists() {
    if (this.getValuesOverTime(DefaultAttribute.EXISTS.getName()).size() != 0) {
        return null;
    }
    Collection<AttributeType> attributes = type.getAttributeMap().values();
    String[] shouldNotProcessArray = new String[] { DefaultAttribute.UID.getName(), DefaultAttribute.SEQUENCE.getName(), DefaultAttribute.LAST_UPDATE_DATE.getName(), DefaultAttribute.CREATE_DATE.getName(), DefaultAttribute.TYPE.getName(), DefaultAttribute.EXISTS.getName() };
    Date startDate = null;
    Date endDate = null;
    for (AttributeType attribute : attributes) {
        boolean shouldProcess = !ArrayUtils.contains(shouldNotProcessArray, attribute.getName());
        if (shouldProcess && attribute.isChangeOverTime()) {
            ValueOverTimeCollection votc = this.getValuesOverTime(attribute.getName());
            for (ValueOverTime vot : votc) {
                if (startDate == null || startDate.after(vot.getStartDate())) {
                    startDate = vot.getStartDate();
                }
                if (endDate == null || endDate.before(vot.getEndDate())) {
                    endDate = vot.getEndDate();
                }
            }
        }
    }
    if (startDate != null && endDate != null) {
        return new ValueOverTime(startDate, endDate, Boolean.TRUE);
    } else {
        return null;
    }
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) LineString(com.vividsolutions.jts.geom.LineString) Date(java.util.Date) LocalDate(java.time.LocalDate)

Example 3 with ValueOverTimeCollection

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

the class SearchService method insert.

// @Transaction
public void insert(VertexServerGeoObject object) {
    this.remove(object.getCode());
    String suffix = this.getSuffix();
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
    MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(PACKAGE + "." + EDGE_PREFIX + suffix);
    ValueOverTimeCollection vots = object.getValuesOverTime(DefaultAttribute.DISPLAY_LABEL.getName());
    for (ValueOverTime vot : vots) {
        VertexObjectDAOIF value = (VertexObjectDAOIF) vot.getValue();
        Set<String> attributeNames = LocalizationService.getLocaleNames();
        for (String attributeName : attributeNames) {
            String label = value.getObjectValue(attributeName);
            if (label != null && label.length() > 0) {
                VertexObject vertex = new VertexObject(mdVertex.definesType());
                vertex.setValue(START_DATE, vot.getStartDate());
                vertex.setValue(END_DATE, vot.getEndDate());
                vertex.setValue(CODE, object.getCode());
                vertex.setValue(LABEL, label);
                vertex.setValue(VERTEX_TYPE, object.getType().getCode());
                vertex.apply();
                vertex.addChild(object.getVertex(), mdEdge).apply();
            }
        }
    }
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) VertexObjectDAOIF(com.runwaysdk.dataaccess.graph.VertexObjectDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)

Example 4 with ValueOverTimeCollection

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

the class ChangeRequestServiceTest method testComplexUpdateGeoObjectCR_Verify.

@Request
private void testComplexUpdateGeoObjectCR_Verify(String[] data) throws Exception {
    final String oldOid = data[1];
    final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    sdf.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    final Date newStartDate = sdf.parse(NEW_START_DATE);
    final Date newEndDate = sdf.parse(NEW_END_DATE);
    final Date oldStartDate = sdf.parse(OLD_START_DATE);
    final Date oldEndDate = sdf.parse(OLD_END_DATE);
    ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
    Assert.assertEquals(1, crq.getCount());
    ChangeRequest cr = crq.getIterator().next();
    Assert.assertEquals(AllGovernanceStatus.ACCEPTED.name(), cr.getGovernanceStatus().name());
    AbstractAction action = cr.getAllAction().next();
    Assert.assertTrue(action instanceof UpdateAttributeAction);
    Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), cr.getGeoObjectCode());
    Assert.assertEquals(FastTestDataset.CAMBODIA.getGeoObjectType().getCode(), cr.getGeoObjectTypeCode());
    Assert.assertEquals(FastTestDataset.ORG_CGOV.getCode(), cr.getOrganizationCode());
    ServerGeoObjectIF cambodia = FastTestDataset.CAMBODIA.getServerObject();
    ValueOverTimeCollection votc = cambodia.getValuesOverTime(FastTestDataset.AT_National_Anthem.getAttributeName());
    Assert.assertEquals(2, votc.size());
    ValueOverTime vot1 = votc.get(0);
    Assert.assertNotNull(vot1.getOid());
    Assert.assertTrue(!(vot1.getOid().equals(oldOid)));
    Assert.assertEquals(NEW_ANTHEM, vot1.getValue());
    Assert.assertEquals(oldStartDate, vot1.getStartDate());
    Assert.assertEquals(oldEndDate, vot1.getEndDate());
    ValueOverTime vot2 = votc.get(1);
    Assert.assertNotNull(vot2.getOid());
    Assert.assertTrue(!(vot2.getOid().equals(oldOid)));
    Assert.assertEquals(NEW_ANTHEM, vot2.getValue());
    Assert.assertEquals(newStartDate, vot2.getStartDate());
    Assert.assertEquals(newEndDate, vot2.getEndDate());
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) QueryFactory(com.runwaysdk.query.QueryFactory) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) ChangeRequest(net.geoprism.registry.action.ChangeRequest) SimpleDateFormat(java.text.SimpleDateFormat) AbstractAction(net.geoprism.registry.action.AbstractAction) UpdateAttributeAction(net.geoprism.registry.action.geoobject.UpdateAttributeAction) Date(java.util.Date) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 5 with ValueOverTimeCollection

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

the class ChangeRequestServiceTest method testUpdateGeoObjectLocalizedValueCR_Verify.

@Request
private void testUpdateGeoObjectLocalizedValueCR_Verify(String[] data) throws Exception {
    final String oldOid = data[1];
    final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    sdf.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    final Date newStartDate = sdf.parse(NEW_START_DATE);
    final Date newEndDate = sdf.parse(NEW_END_DATE);
    ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
    Assert.assertEquals(1, crq.getCount());
    ChangeRequest cr = crq.getIterator().next();
    Assert.assertEquals(AllGovernanceStatus.ACCEPTED.name(), cr.getGovernanceStatus().name());
    AbstractAction action = cr.getAllAction().next();
    Assert.assertTrue(action instanceof UpdateAttributeAction);
    Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), cr.getGeoObjectCode());
    Assert.assertEquals(FastTestDataset.CAMBODIA.getGeoObjectType().getCode(), cr.getGeoObjectTypeCode());
    Assert.assertEquals(FastTestDataset.ORG_CGOV.getCode(), cr.getOrganizationCode());
    VertexServerGeoObject cambodia = (VertexServerGeoObject) FastTestDataset.CAMBODIA.getServerObject();
    ValueOverTimeCollection votc = cambodia.getValuesOverTime(DefaultAttribute.DISPLAY_LABEL.getName());
    Assert.assertEquals(1, votc.size());
    ValueOverTime vot1 = votc.get(0);
    Assert.assertNotNull(vot1.getOid());
    Assert.assertEquals(oldOid, vot1.getOid());
    Assert.assertEquals(newStartDate, vot1.getStartDate());
    Assert.assertEquals(newEndDate, vot1.getEndDate());
    Assert.assertEquals("localizeTest", cambodia.getDisplayLabel(newStartDate).getValue());
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) QueryFactory(com.runwaysdk.query.QueryFactory) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest) SimpleDateFormat(java.text.SimpleDateFormat) AbstractAction(net.geoprism.registry.action.AbstractAction) UpdateAttributeAction(net.geoprism.registry.action.geoobject.UpdateAttributeAction) Date(java.util.Date) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Aggregations

ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)30 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)29 Request (com.runwaysdk.session.Request)22 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)18 Test (org.junit.Test)16 Date (java.util.Date)10 ChangeRequest (net.geoprism.registry.action.ChangeRequest)7 SimpleDateFormat (java.text.SimpleDateFormat)6 AbstractAction (net.geoprism.registry.action.AbstractAction)6 QueryFactory (com.runwaysdk.query.QueryFactory)5 ChangeRequestQuery (net.geoprism.registry.action.ChangeRequestQuery)5 UpdateAttributeAction (net.geoprism.registry.action.geoobject.UpdateAttributeAction)5 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)5 VertexObject (com.runwaysdk.business.graph.VertexObject)4 EdgeObject (com.runwaysdk.business.graph.EdgeObject)3 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)3 Calendar (java.util.Calendar)3 LineString (com.vividsolutions.jts.geom.LineString)2 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)2 LocalDate (java.time.LocalDate)2