use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.
the class UndirectedGraphStrategy method addParent.
@SuppressWarnings("unchecked")
@Override
public <T extends ServerGraphNode> T addParent(VertexServerGeoObject geoObject, VertexServerGeoObject parent, Date startDate, Date endDate) {
if (this.isCycle(geoObject, parent, startDate, endDate)) {
throw new UnsupportedOperationException("Cyclic graph is not supported");
}
if (this.getEdges(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 (T) node;
}
use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.
the class VertexServerGeoObject method addParent.
@Override
public ServerParentTreeNode addParent(ServerGeoObjectIF parent, ServerHierarchyType hierarchyType, Date startDate, Date endDate) {
if (!hierarchyType.getUniversalType().equals(AllowedIn.CLASS)) {
hierarchyType.validateUniversalRelationship(this.getType(), parent.getType());
}
ValueOverTimeCollection votc = this.getParentCollection(hierarchyType);
votc.add(new ValueOverTime(startDate, endDate, parent));
SortedSet<EdgeObject> newEdges = this.setParentCollection(hierarchyType, votc);
ServerParentTreeNode node = new ServerParentTreeNode(this, hierarchyType, startDate, null, null);
node.addParent(new ServerParentTreeNode(parent, hierarchyType, startDate, null, newEdges.first().getOid()));
return node;
}
use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.
the class VertexServerGeoObject method toGeoObjectOverTime.
public GeoObjectOverTime toGeoObjectOverTime(boolean generateUid) {
Map<String, ValueOverTimeCollectionDTO> votAttributeMap = GeoObjectOverTime.buildVotAttributeMap(type.getType());
Map<String, Attribute> attributeMap = GeoObjectOverTime.buildAttributeMap(type.getType());
GeoObjectOverTime geoObj = new GeoObjectOverTime(type.getType(), votAttributeMap, attributeMap);
Map<String, AttributeType> attributes = type.getAttributeMap();
attributes.forEach((attributeName, attribute) -> {
if (attributeName.equals(DefaultAttribute.DISPLAY_LABEL.getName())) {
ValueOverTimeCollection votc = this.getValuesOverTime(attributeName);
ValueOverTimeCollectionDTO votcDTO = new ValueOverTimeCollectionDTO(attribute);
for (ValueOverTime vot : votc) {
Object value = this.getDisplayLabel(vot.getStartDate());
ValueOverTimeDTO votDTO = new ValueOverTimeDTO(vot.getOid(), vot.getStartDate(), vot.getEndDate(), votcDTO);
votDTO.setValue(value);
votcDTO.add(votDTO);
}
geoObj.setValueCollection(attributeName, votcDTO);
} else // }
if (vertex.hasAttribute(attributeName)) {
if (attribute.isChangeOverTime()) {
ValueOverTimeCollection votc = this.getValuesOverTime(attributeName);
ValueOverTimeCollectionDTO votcDTO = new ValueOverTimeCollectionDTO(attribute);
for (ValueOverTime vot : votc) {
// if (attributeName.equals(DefaultAttribute.STATUS.getName()))
// {
// Term statusTerm =
// ServiceFactory.getConversionService().geoObjectStatusToTerm(this.getStatus(vot.getStartDate()));
//
// ValueOverTimeDTO votDTO = new ValueOverTimeDTO(vot.getOid(),
// vot.getStartDate(), vot.getEndDate(), votcDTO);
// votDTO.setValue(statusTerm.getCode());
// votcDTO.add(votDTO);
// }
// else
// {
Object value = vot.getValue();
if (value != null) {
if (attribute instanceof AttributeTermType) {
Classifier classifier = Classifier.get((String) value);
try {
ValueOverTimeDTO votDTO = new ValueOverTimeDTO(vot.getOid(), vot.getStartDate(), vot.getEndDate(), votcDTO);
votDTO.setValue(classifier.getClassifierId());
votcDTO.add(votDTO);
} catch (UnknownTermException e) {
TermValueException ex = new TermValueException();
ex.setAttributeLabel(e.getAttribute().getLabel().getValue());
ex.setCode(e.getCode());
throw e;
}
} else if (attribute instanceof AttributeClassificationType) {
String classificationTypeCode = ((AttributeClassificationType) attribute).getClassificationType();
ClassificationType classificationType = ClassificationType.getByCode(classificationTypeCode);
Classification classification = Classification.getByOid(classificationType, (String) value);
try {
ValueOverTimeDTO votDTO = new ValueOverTimeDTO(vot.getOid(), vot.getStartDate(), vot.getEndDate(), votcDTO);
votDTO.setValue(classification.toTerm());
votcDTO.add(votDTO);
} catch (UnknownTermException e) {
TermValueException ex = new TermValueException();
ex.setAttributeLabel(e.getAttribute().getLabel().getValue());
ex.setCode(e.getCode());
throw e;
}
} else {
ValueOverTimeDTO votDTO = new ValueOverTimeDTO(vot.getOid(), vot.getStartDate(), vot.getEndDate(), votcDTO);
votDTO.setValue(value);
votcDTO.add(votDTO);
}
}
// }
}
geoObj.setValueCollection(attributeName, votcDTO);
} else {
Object value = this.getValue(attributeName);
if (value != null) {
if (attribute instanceof AttributeTermType) {
Classifier classifier = Classifier.get((String) value);
try {
geoObj.setValue(attributeName, classifier.getClassifierId());
} catch (UnknownTermException e) {
TermValueException ex = new TermValueException();
ex.setAttributeLabel(e.getAttribute().getLabel().getValue());
ex.setCode(e.getCode());
throw e;
}
} else if (attribute instanceof AttributeClassificationType) {
String classificationType = ((AttributeClassificationType) attribute).getClassificationType();
MdClassificationDAOIF mdClassificationDAO = MdClassificationDAO.getMdClassificationDAO(classificationType);
MdVertexDAOIF mdVertexDAO = mdClassificationDAO.getReferenceMdVertexDAO();
VertexObject classification = VertexObject.get(mdVertexDAO, (String) value);
try {
geoObj.setValue(attributeName, classification.getObjectValue(AbstractClassification.CODE));
} catch (UnknownTermException e) {
TermValueException ex = new TermValueException();
ex.setAttributeLabel(e.getAttribute().getLabel().getValue());
ex.setCode(e.getCode());
throw e;
}
} else {
geoObj.setValue(attributeName, value);
}
}
}
}
});
if (// && !vertex.isAppliedToDB())
generateUid && vertex.isNew()) {
geoObj.setUid(RegistryIdService.getInstance().next());
// geoObj.setStatus(ServiceFactory.getAdapter().getMetadataCache().getTerm(DefaultTerms.GeoObjectStatusTerm.NEW.code).get(),
// this.date, this.date);
} else {
geoObj.setUid(vertex.getObjectValue(RegistryConstants.UUID));
}
ValueOverTimeCollection votc = this.getValuesOverTime(this.getGeometryAttributeName());
ValueOverTimeCollectionDTO votcDTO = new ValueOverTimeCollectionDTO(geoObj.getGeometryAttributeType());
for (ValueOverTime vot : votc) {
Object value = vot.getValue();
ValueOverTimeDTO votDTO = new ValueOverTimeDTO(vot.getOid(), vot.getStartDate(), vot.getEndDate(), votcDTO);
votDTO.setValue(value);
votcDTO.add(votDTO);
}
geoObj.setValueCollection(DefaultAttribute.GEOMETRY.getName(), votcDTO);
geoObj.setCode(vertex.getObjectValue(DefaultAttribute.CODE.getName()));
return geoObj;
}
use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTime in project geoprism-registry by terraframe.
the class VertexServerGeoObject method setParentCollection.
public SortedSet<EdgeObject> setParentCollection(ServerHierarchyType hierarchyType, ValueOverTimeCollection votc) {
SortedSet<EdgeObject> newEdges = new TreeSet<EdgeObject>(new EdgeComparator());
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);
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 = this.getVertex().addParent(inGo.getVertex(), hierarchyType.getMdEdge());
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 = this.getVertex().addParent(((VertexServerGeoObject) vot.getValue()).getVertex(), hierarchyType.getMdEdge());
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 UpdateChangeOverTimeAttributeView method execute.
@Override
public void execute(VertexServerGeoObject go) {
String attributeName = this.getAttributeNameGeomAccounting(go);
// This list is intentionally NOT a ValueOverTimeCollection. The reason for this is because we
// DON'T want any of the reordering or splitting logic to happen until AFTER we have applied
// all of the actions. The logic we want to avoid is ValueOverTimeCollection.calculateStartDates
List<ValueOverTime> looseVotc = new ArrayList<ValueOverTime>(go.getValuesOverTime(attributeName));
for (UpdateValueOverTimeView vot : this.valuesOverTime) {
vot.execute(this, go, looseVotc);
}
ValueOverTimeCollection newVotc = new ValueOverTimeCollection();
newVotc.addAll(looseVotc);
this.validateValuesOverTime(newVotc);
go.getVertex().getGraphObjectDAO().getAttribute(attributeName).setValuesOverTime(newVotc);
}
Aggregations