use of net.geoprism.registry.action.geoobject.UpdateAttributeActionBase in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method createCRTrans.
@Transaction
private String createCRTrans(String actionType) {
ChangeRequest cr = new ChangeRequest();
cr.addApprovalStatus(AllGovernanceStatus.PENDING);
cr.setOrganizationCode(FastTestDataset.ORG_CGOV.getCode());
if (actionType.equals(UpdateAttributeViewJsonAdapters.PARENT_ATTR_NAME)) {
cr.setGeoObjectCode(FastTestDataset.PROV_CENTRAL.getCode());
cr.setGeoObjectTypeCode(FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode());
} else {
cr.setGeoObjectCode(FastTestDataset.CAMBODIA.getCode());
cr.setGeoObjectTypeCode(FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
}
cr.apply();
AbstractAction action = null;
if (actionType.equals(CreateGeoObjectAction.CLASS)) {
action = new CreateGeoObjectAction();
action.setApiVersion("1.0");
((CreateGeoObjectActionBase) action).setGeoObjectJson(FastTestDataset.CAMBODIA.fetchGeoObjectOverTime().toJSON().toString());
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(new Date());
action.apply();
} else if (actionType.equals(UpdateAttributeAction.CLASS)) {
action = new UpdateAttributeAction();
action.setApiVersion("1.0");
((UpdateAttributeActionBase) action).setAttributeName(FastTestDataset.AT_National_Anthem.getAttributeName());
((UpdateAttributeActionBase) action).setJson(UPDATE_ATTR_JSON);
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(new Date());
action.apply();
} else if (actionType.equals(UpdateAttributeViewJsonAdapters.PARENT_ATTR_NAME)) {
action = new UpdateAttributeAction();
action.setApiVersion("1.0");
((UpdateAttributeActionBase) action).setAttributeName(UpdateAttributeViewJsonAdapters.PARENT_ATTR_NAME);
((UpdateAttributeActionBase) action).setJson(UPDATE_PARENT_ATTR_JSON);
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(new Date());
action.apply();
} else {
throw new UnsupportedOperationException();
}
cr.addAction(action).apply();
return cr.toJSON().toString();
}
use of net.geoprism.registry.action.geoobject.UpdateAttributeActionBase in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testComplexUpdateGeoObjectCR_applyCR.
@Request
private String[] testComplexUpdateGeoObjectCR_applyCR() throws Exception {
ChangeRequest cr = new ChangeRequest();
cr.addApprovalStatus(AllGovernanceStatus.PENDING);
cr.setOrganizationCode(FastTestDataset.ORG_CGOV.getCode());
cr.setGeoObjectCode(FastTestDataset.CAMBODIA.getCode());
cr.setGeoObjectTypeCode(FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
cr.apply();
UpdateAttributeAction action = new UpdateAttributeAction();
action.setApiVersion("1.0");
((UpdateAttributeActionBase) action).setAttributeName(FastTestDataset.AT_National_Anthem.getAttributeName());
JsonObject diff = new JsonObject();
ServerGeoObjectIF cambodia = FastTestDataset.CAMBODIA.getServerObject();
String votOid = cambodia.getValuesOverTime(FastTestDataset.AT_National_Anthem.getAttributeName()).getValueOverTime(FastTestDataset.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE).getOid();
JsonArray valuesOverTime = JsonParser.parseString("[" + "{" + " \"oid\": \"" + votOid + "\"," + " \"action\": \"DELETE\"" + "}," + "{" + " \"action\": \"CREATE\"," + " \"newValue\": \"" + NEW_ANTHEM + "\"," + " \"newStartDate\": \"" + NEW_START_DATE + "\"," + " \"newEndDate\": \"" + NEW_END_DATE + "\"" + "}," + "{" + " \"action\": \"CREATE\"," + " \"newValue\": \"" + NEW_ANTHEM + "\"," + " \"newStartDate\": \"" + OLD_START_DATE + "\"," + " \"newEndDate\": \"" + OLD_END_DATE + "\"" + "}" + "]").getAsJsonArray();
diff.add("valuesOverTime", valuesOverTime);
((UpdateAttributeActionBase) action).setJson(diff.toString());
action.addApprovalStatus(AllGovernanceStatus.ACCEPTED);
action.setCreateActionDate(new Date());
action.apply();
cr.addAction(action).apply();
String serializedCR = cr.toJSON().toString();
return new String[] { serializedCR, votOid };
}
use of net.geoprism.registry.action.geoobject.UpdateAttributeActionBase in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testUpdateGeoObjectLocalizedValueCR_applyCR.
@Request
private String[] testUpdateGeoObjectLocalizedValueCR_applyCR() throws Exception {
ChangeRequest cr = new ChangeRequest();
cr.addApprovalStatus(AllGovernanceStatus.PENDING);
cr.setOrganizationCode(FastTestDataset.ORG_CGOV.getCode());
cr.setGeoObjectCode(FastTestDataset.CAMBODIA.getCode());
cr.setGeoObjectTypeCode(FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
cr.apply();
UpdateAttributeAction action = new UpdateAttributeAction();
action.setApiVersion("1.0");
((UpdateAttributeActionBase) action).setAttributeName(DefaultAttribute.DISPLAY_LABEL.getName());
JsonObject diff = new JsonObject();
VertexServerGeoObject cambodia = (VertexServerGeoObject) FastTestDataset.CAMBODIA.getServerObject();
ValueOverTime vot = cambodia.getValuesOverTime(DefaultAttribute.DISPLAY_LABEL.getName()).getValueOverTime(FastTestDataset.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
JsonArray valuesOverTime = JsonParser.parseString("[" + "{" + " \"oid\": \"" + vot.getOid() + "\"," + " \"action\": \"UPDATE\"," + " \"oldEndDate\": \"" + OLD_END_DATE + "\"," + " \"oldStartDate\": \"" + OLD_START_DATE + "\"," + " \"oldValue\": \"\"," + " \"newValue\": \"\"," + " \"newStartDate\": \"" + NEW_START_DATE + "\"," + " \"newEndDate\": \"" + NEW_END_DATE + "\"" + "}" + "]").getAsJsonArray();
valuesOverTime.get(0).getAsJsonObject().add("oldValue", cambodia.getDisplayLabel(FastTestDataset.DEFAULT_OVER_TIME_DATE).toJSON());
LocalizedValue newValue = new LocalizedValue("localizeTest");
valuesOverTime.get(0).getAsJsonObject().add("newValue", newValue.toJSON());
diff.add("valuesOverTime", valuesOverTime);
((UpdateAttributeActionBase) action).setJson(diff.toString());
action.addApprovalStatus(AllGovernanceStatus.ACCEPTED);
action.setCreateActionDate(new Date());
action.apply();
cr.addAction(action).apply();
String serializedCR = cr.toJSON().toString();
return new String[] { serializedCR, vot.getOid() };
}
use of net.geoprism.registry.action.geoobject.UpdateAttributeActionBase in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testUpdateGeoObjectTermCR_applyCR.
@Request
private String[] testUpdateGeoObjectTermCR_applyCR() throws Exception {
final String attrName = FastTestDataset.AT_RELIGION.getAttributeName();
ChangeRequest cr = new ChangeRequest();
cr.addApprovalStatus(AllGovernanceStatus.PENDING);
cr.setOrganizationCode(FastTestDataset.ORG_CGOV.getCode());
cr.setGeoObjectCode(FastTestDataset.CAMBODIA.getCode());
cr.setGeoObjectTypeCode(FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
cr.apply();
UpdateAttributeAction action = new UpdateAttributeAction();
action.setApiVersion("1.0");
((UpdateAttributeActionBase) action).setAttributeName(attrName);
JsonObject diff = new JsonObject();
VertexServerGeoObject cambodia = (VertexServerGeoObject) FastTestDataset.CAMBODIA.getServerObject();
ValueOverTime vot = cambodia.getValuesOverTime(attrName).getValueOverTime(FastTestDataset.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
JsonArray valuesOverTime = JsonParser.parseString("[" + "{" + " \"oid\": \"" + vot.getOid() + "\"," + " \"action\": \"UPDATE\"," + " \"oldEndDate\": \"" + OLD_END_DATE + "\"," + " \"oldStartDate\": \"" + OLD_START_DATE + "\"," + " \"oldValue\": [\"" + ((Term) FastTestDataset.CAMBODIA.getDefaultValue(attrName)).getCode() + "\"]," + " \"newValue\": [\"" + FastTestDataset.T_Islam.getCode() + "\"]," + " \"newStartDate\": \"" + NEW_START_DATE + "\"," + " \"newEndDate\": \"" + NEW_END_DATE + "\"" + "}" + "]").getAsJsonArray();
diff.add("valuesOverTime", valuesOverTime);
((UpdateAttributeActionBase) action).setJson(diff.toString());
action.addApprovalStatus(AllGovernanceStatus.ACCEPTED);
action.setCreateActionDate(new Date());
action.apply();
cr.addAction(action).apply();
String serializedCR = cr.toJSON().toString();
return new String[] { serializedCR, vot.getOid() };
}
use of net.geoprism.registry.action.geoobject.UpdateAttributeActionBase in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testUpdateGeoObjectDateCR_applyCR.
@Request
private Object[] testUpdateGeoObjectDateCR_applyCR() throws Exception {
final Long newValue = new Date().getTime();
final String attrName = FastTestDataset.AT_DATE_OF_FORMATION.getAttributeName();
ChangeRequest cr = new ChangeRequest();
cr.addApprovalStatus(AllGovernanceStatus.PENDING);
cr.setOrganizationCode(FastTestDataset.ORG_CGOV.getCode());
cr.setGeoObjectCode(FastTestDataset.CAMBODIA.getCode());
cr.setGeoObjectTypeCode(FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
cr.apply();
UpdateAttributeAction action = new UpdateAttributeAction();
action.setApiVersion("1.0");
((UpdateAttributeActionBase) action).setAttributeName(attrName);
JsonObject diff = new JsonObject();
VertexServerGeoObject cambodia = (VertexServerGeoObject) FastTestDataset.CAMBODIA.getServerObject();
ValueOverTime vot = cambodia.getValuesOverTime(attrName).getValueOverTime(FastTestDataset.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
JsonArray valuesOverTime = JsonParser.parseString("[" + "{" + " \"oid\": \"" + vot.getOid() + "\"," + " \"action\": \"UPDATE\"," + " \"oldEndDate\": \"" + OLD_END_DATE + "\"," + " \"oldStartDate\": \"" + OLD_START_DATE + "\"," + " \"oldValue\": \"\"," + " \"newValue\": \"\"," + " \"newStartDate\": \"" + NEW_START_DATE + "\"," + " \"newEndDate\": \"" + NEW_END_DATE + "\"" + "}" + "]").getAsJsonArray();
valuesOverTime.get(0).getAsJsonObject().addProperty("oldValue", ((Date) FastTestDataset.CAMBODIA.getDefaultValue(attrName)).getTime());
valuesOverTime.get(0).getAsJsonObject().addProperty("newValue", newValue);
diff.add("valuesOverTime", valuesOverTime);
((UpdateAttributeActionBase) action).setJson(diff.toString());
action.addApprovalStatus(AllGovernanceStatus.ACCEPTED);
action.setCreateActionDate(new Date());
action.apply();
cr.addAction(action).apply();
String serializedCR = cr.toJSON().toString();
return new Object[] { serializedCR, vot.getOid(), newValue };
}
Aggregations