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