use of net.geoprism.registry.model.graph.VertexServerGeoObject 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());
}
use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testUpdateGeoObjectTermCR_Verify.
@Request
private void testUpdateGeoObjectTermCR_Verify(String[] data) throws Exception {
final String attrName = FastTestDataset.AT_RELIGION.getAttributeName();
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(attrName);
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());
String classyId = ((Classifier) cambodia.getValue(attrName, newStartDate)).getOid();
Assert.assertEquals(FastTestDataset.T_Islam.fetchClassifier().getOid(), classyId);
Assert.assertEquals(classyId, vot1.getValue());
}
use of net.geoprism.registry.model.graph.VertexServerGeoObject 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 net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.
the class Transition method toJSON.
public JsonObject toJSON() {
VertexServerGeoObject source = this.getSourceVertex();
VertexServerGeoObject target = this.getTargetVertex();
JsonObject object = new JsonObject();
object.addProperty(OID, this.getOid());
object.addProperty(Transition.ORDER, this.getOrder());
object.addProperty("isNew", this.isNew());
object.addProperty("sourceCode", source.getCode());
object.addProperty("sourceType", source.getType().getCode());
object.addProperty("sourceText", source.getLabel() + " (" + source.getCode() + ")");
object.addProperty("targetCode", target.getCode());
object.addProperty("targetType", target.getType().getCode());
object.addProperty("targetText", target.getLabel() + " (" + target.getCode() + ")");
object.addProperty(Transition.TRANSITIONTYPE, this.getTransitionType());
object.addProperty(Transition.IMPACT, this.getImpact());
return object;
}
use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.
the class Transition method createTask.
public void createTask(VertexServerGeoObject source, VertexServerGeoObject target, Date eventDate) {
LocalizedValue dateValue = LocalizedValueConverter.convert(eventDate);
TransitionType transitionType = this.toTransitionType();
ServerGeoObjectType sourceType = source.getType();
ServerGeoObjectType targetType = target.getType();
List<ServerGeoObjectType> types = Arrays.asList(new ServerGeoObjectType[] { sourceType, targetType }).stream().distinct().collect(Collectors.toList());
for (ServerGeoObjectType type : types) {
List<ServerHierarchyType> hierarchies = type.getHierarchies();
for (ServerHierarchyType hierarchy : hierarchies) {
List<ServerGeoObjectType> children = type.getChildren(hierarchy);
for (ServerGeoObjectType child : children) {
List<Roles> roles = Arrays.asList(new String[] { child.getMaintainerRoleName(), child.getAdminRoleName() }).stream().distinct().map(name -> Roles.findRoleByName(name)).collect(Collectors.toList());
HashMap<String, LocalizedValue> values = new HashMap<String, LocalizedValue>();
values.put("1", source.getDisplayLabel());
values.put("2", sourceType.getLabel());
values.put("3", target.getDisplayLabel());
values.put("4", targetType.getLabel());
values.put("5", child.getLabel());
values.put("6", hierarchy.getLabel());
values.put("7", dateValue);
TaskType taskType = Task.TaskType.SPLIT_EVENT_TASK;
if (transitionType.isMerge()) {
taskType = Task.TaskType.MERGE_EVENT_TASK;
} else if (transitionType.isReassign()) {
taskType = Task.TaskType.REASSIGN_EVENT_TASK;
}
Task.createNewTask(roles, taskType, values, this.getOid());
}
}
}
}
Aggregations