use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class ChangeRequestService method implementDecisions.
@Request(RequestType.SESSION)
public JsonObject implementDecisions(String sessionId, String request) {
ChangeRequest input = ChangeRequest.fromJSON(request);
ChangeRequest current = ChangeRequest.get(JsonParser.parseString(request).getAsJsonObject().get("oid").getAsString());
if (!this.permService.getPermissions(current).containsAll(Arrays.asList(ChangeRequestPermissionAction.EXECUTE, ChangeRequestPermissionAction.WRITE_APPROVAL_STATUS, ChangeRequestPermissionAction.WRITE))) {
throw new CGRPermissionException();
}
current.execute(input.getMaintainerNotes(), input.getAdditionalNotes());
return current.getDetails();
}
use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class ChangeRequestService method reject.
@Request(RequestType.SESSION)
public void reject(String sessionId, String request) {
ChangeRequest input = ChangeRequest.fromJSON(request);
ChangeRequest current = ChangeRequest.get(JsonParser.parseString(request).getAsJsonObject().get("oid").getAsString());
if (!this.permService.getPermissions(current).containsAll(Arrays.asList(ChangeRequestPermissionAction.WRITE, ChangeRequestPermissionAction.WRITE_APPROVAL_STATUS, ChangeRequestPermissionAction.READ, ChangeRequestPermissionAction.READ_DETAILS))) {
throw new CGRPermissionException();
}
current.reject(input.getMaintainerNotes(), input.getAdditionalNotes());
}
use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class ChangeRequestService method downloadDocumentCR.
ApplicationResource downloadDocumentCR(String crOid, String vfOid) {
ChangeRequest request = ChangeRequest.get(crOid);
if (!this.permService.getPermissions(request).contains(ChangeRequestPermissionAction.READ_DOCUMENTS)) {
throw new CGRPermissionException();
}
VaultFile vf = VaultFile.get(vfOid);
return vf;
}
use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testImplementParentDecisionsVerify.
@Request
private void testImplementParentDecisionsVerify(String crOid) throws Exception {
ChangeRequest cr = ChangeRequest.get(crOid);
Assert.assertEquals(AllGovernanceStatus.ACCEPTED.name(), cr.getApprovalStatus().get(0).name());
AbstractAction action = cr.getAllAction().next();
Assert.assertEquals(AllGovernanceStatus.ACCEPTED.name(), action.getApprovalStatus().get(0).name());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
Date newStartDate = sdf.parse(NEW_START_DATE);
Date newEndDate = sdf.parse(NEW_END_DATE);
ServerGeoObjectIF serverGo = FastTestDataset.PROV_CENTRAL.getServerObject();
List<ServerParentTreeNode> ptns = serverGo.getParentsOverTime(new String[] { FastTestDataset.COUNTRY.getCode() }, false).getEntries(FastTestDataset.HIER_ADMIN.getServerObject());
Assert.assertEquals(1, ptns.size());
ServerParentTreeNode ptn = ptns.get(0);
List<ServerParentTreeNode> parents = ptn.getParents();
Assert.assertEquals(1, parents.size());
ServerParentTreeNode parent = parents.get(0);
Assert.assertEquals(newStartDate, ptn.getStartDate());
Assert.assertEquals(newEndDate, ptn.getEndDate());
Assert.assertEquals(BELIZE.getCode(), parent.getGeoObject().getCode());
}
use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testGetAllCR.
private void testGetAllCR(ClientRequestIF request, boolean hasPermission) {
ChangeRequestService service = new ChangeRequestService();
Page<ChangeRequest> page = service.getAllRequests(request.getSessionId(), 10, 1, "", "", null);
JsonObject joPage = toJson(request.getSessionId(), page);
JsonArray jaResults = joPage.get("resultSet").getAsJsonArray();
final int count = joPage.get("count").getAsInt();
final int pageNumber = joPage.get("pageNumber").getAsInt();
if (hasPermission) {
Assert.assertEquals(2, count);
Assert.assertEquals(1, pageNumber);
Assert.assertEquals(2, jaResults.size());
for (int i = 0; i < jaResults.size(); ++i) {
JsonObject joRequest = jaResults.get(i).getAsJsonObject();
JsonObject current = joRequest.get("current").getAsJsonObject();
// JsonObject geoObject = current.get("geoObject").getAsJsonObject();
// JsonObject geoObjectType = current.get("geoObjectType").getAsJsonObject();
//
// Assert.assertNotNull(geoObject);
// Assert.assertNotNull(geoObjectType);
// Assert.assertEquals(FastTestDataset.CAMBODIA.getDisplayLabel(), geoObject.get("label").getAsString());
// Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), geoObject.get("code").getAsString());
}
} else {
Assert.assertEquals(0, count);
Assert.assertEquals(0, jaResults.size());
}
}
Aggregations