Search in sources :

Example 26 with VertexServerGeoObject

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());
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) QueryFactory(com.runwaysdk.query.QueryFactory) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest) SimpleDateFormat(java.text.SimpleDateFormat) AbstractAction(net.geoprism.registry.action.AbstractAction) UpdateAttributeAction(net.geoprism.registry.action.geoobject.UpdateAttributeAction) Date(java.util.Date) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 27 with VertexServerGeoObject

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());
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) QueryFactory(com.runwaysdk.query.QueryFactory) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Classifier(net.geoprism.ontology.Classifier) ChangeRequest(net.geoprism.registry.action.ChangeRequest) SimpleDateFormat(java.text.SimpleDateFormat) AbstractAction(net.geoprism.registry.action.AbstractAction) UpdateAttributeAction(net.geoprism.registry.action.geoobject.UpdateAttributeAction) Date(java.util.Date) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 28 with VertexServerGeoObject

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);
    }
}
Also used : VertexGeoObjectStrategy(net.geoprism.registry.conversion.VertexGeoObjectStrategy) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) AbstractUpdateAttributeView(net.geoprism.registry.view.action.AbstractUpdateAttributeView) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 29 with VertexServerGeoObject

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;
}
Also used : JsonObject(com.google.gson.JsonObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject)

Example 30 with VertexServerGeoObject

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());
            }
        }
    }
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Task(net.geoprism.registry.task.Task) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) VertexGeoObjectStrategy(net.geoprism.registry.conversion.VertexGeoObjectStrategy) Date(java.util.Date) GraphQuery(com.runwaysdk.business.graph.GraphQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction) VertexObject(com.runwaysdk.business.graph.VertexObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) HashMap(java.util.HashMap) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) Roles(com.runwaysdk.system.Roles) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Collectors(java.util.stream.Collectors) TaskType(net.geoprism.registry.task.Task.TaskType) MdVertexDAO(com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO) MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) List(java.util.List) LocalizedValueConverter(net.geoprism.registry.conversion.LocalizedValueConverter) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HashMap(java.util.HashMap) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Roles(com.runwaysdk.system.Roles) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) TaskType(net.geoprism.registry.task.Task.TaskType)

Aggregations

VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)51 VertexObject (com.runwaysdk.business.graph.VertexObject)20 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)19 JsonObject (com.google.gson.JsonObject)18 Request (com.runwaysdk.session.Request)13 Date (java.util.Date)12 LinkedList (java.util.LinkedList)11 ChangeRequest (net.geoprism.registry.action.ChangeRequest)11 JsonArray (com.google.gson.JsonArray)10 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)10 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)10 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)9 GraphQuery (com.runwaysdk.business.graph.GraphQuery)8 UpdateAttributeAction (net.geoprism.registry.action.geoobject.UpdateAttributeAction)8 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)8 QueryFactory (com.runwaysdk.query.QueryFactory)6 SimpleDateFormat (java.text.SimpleDateFormat)6 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)6 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)6 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)5