use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class ChangeRequestService method deleteDocumentInTransCR.
@Transaction
void deleteDocumentInTransCR(String crOid, String vfOid) {
ChangeRequest request = ChangeRequest.get(crOid);
if (!this.permService.getPermissions(request).contains(ChangeRequestPermissionAction.WRITE_DOCUMENTS)) {
throw new CGRPermissionException();
}
VaultFile vf = VaultFile.get(vfOid);
vf.delete();
}
use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class ChangeRequestDocumentActionServiceTest method createCRTrans.
@Transaction
private void createCRTrans() {
ChangeRequest cr = new ChangeRequest();
cr.addApprovalStatus(AllGovernanceStatus.PENDING);
cr.setGeoObjectCode(FastTestDataset.CAMBODIA.getCode());
cr.setGeoObjectTypeCode(FastTestDataset.COUNTRY.getCode());
cr.setOrganizationCode(FastTestDataset.ORG_CGOV.getCode());
cr.apply();
CreateGeoObjectAction action = new CreateGeoObjectAction();
action.setApiVersion("1.0");
action.setGeoObjectJson(FastTestDataset.CAMBODIA.fetchGeoObjectOverTime().toJSON().toString());
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(new Date());
action.apply();
cr.addAction(action).apply();
this.cr = cr;
this.action = action;
}
use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class ChangeRequestDocumentServiceTest method createCRTrans.
@Transaction
private void createCRTrans() {
ChangeRequest cr = new ChangeRequest();
cr.addApprovalStatus(AllGovernanceStatus.PENDING);
cr.setGeoObjectCode(FastTestDataset.CAMBODIA.getCode());
cr.setGeoObjectTypeCode(FastTestDataset.COUNTRY.getCode());
cr.setOrganizationCode(FastTestDataset.ORG_CGOV.getCode());
cr.apply();
CreateGeoObjectAction action = new CreateGeoObjectAction();
action.setApiVersion("1.0");
action.setGeoObjectJson(FastTestDataset.CAMBODIA.fetchGeoObjectOverTime().toJSON().toString());
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(new Date());
action.apply();
cr.addAction(action).apply();
this.cr = cr;
this.crOid = cr.getOid();
}
use of net.geoprism.registry.action.ChangeRequest 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.ChangeRequest in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testUpdateGeoObjectCR_Verify.
@Request
private void testUpdateGeoObjectCR_Verify() {
ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
Assert.assertEquals(1, crq.getCount());
ChangeRequest cr = crq.getIterator().next();
Assert.assertEquals(AllGovernanceStatus.PENDING.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());
}
Aggregations