use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.
the class PatchExistsAndInvalidInstanceData method patchInstanceData.
private void patchInstanceData() {
List<Universal> unis = PatchExistsAndInvalid.getUniversals();
int applied = 0;
for (Universal uni : unis) {
ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
MdGraphClassDAOIF mdClass = type.getMdVertex();
List<VertexServerGeoObject> data = getInstanceData(type, mdClass);
int current = 0;
final int size = data.size();
logger.info("Starting to patch instance data for type [" + mdClass.getDBClassName() + "] with count [" + size + "] ");
for (VertexServerGeoObject go : data) {
ValueOverTime defaultExists = go.buildDefaultExists();
if (defaultExists != null) {
go.setValue(DefaultAttribute.EXISTS.getName(), Boolean.TRUE, defaultExists.getStartDate(), defaultExists.getEndDate());
go.setValue(DefaultAttribute.INVALID.getName(), false);
// This apply method is mega slow due to the SearchService so we're going to just bypass it
// go.apply(false);
go.getVertex().setValue(GeoVertex.LASTUPDATEDATE, new Date());
go.getVertex().apply();
applied++;
}
if (current % 100 == 0) {
logger.info("Finished record " + current + " of " + size);
}
current++;
}
}
logger.info("Applied " + applied + " records across " + unis.size() + " types.");
}
use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.
the class DirectedAcyclicGraphStrategy 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;
}
use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.
the class UndirectedGraphStrategy 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 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.ValueOverTime 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;
}
}
Aggregations