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;
}
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;
}
}
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();
}
}
}
}
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());
}
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());
}
Aggregations