use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection 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.ValueOverTimeCollection in project geoprism-registry by terraframe.
the class UpdateAttributeAction method execute.
@Override
public void execute() {
ChangeRequest cr = this.getAllRequest().next();
ServerGeoObjectType type = ServerGeoObjectType.get(cr.getGeoObjectTypeCode());
VertexServerGeoObject go = new VertexGeoObjectStrategy(type).getGeoObjectByCode(cr.getGeoObjectCode());
AbstractUpdateAttributeView view = UpdateAttributeViewJsonAdapters.deserialize(this.getJson(), this.getAttributeName(), type);
view.execute(go);
if (!this.getAttributeName().equals(UpdateAttributeViewJsonAdapters.PARENT_ATTR_NAME)) {
String attributeName = this.getAttributeName();
if (attributeName.equals("geometry")) {
attributeName = go.getGeometryAttributeName();
}
ValueOverTimeCollection votc = go.getValuesOverTime(attributeName);
votc.reorder();
go.apply(false);
}
}
use of com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection 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.ValueOverTimeCollection 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.ValueOverTimeCollection 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;
}
Aggregations