Search in sources :

Example 11 with ChangeRequest

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();
}
Also used : CGRPermissionException(net.geoprism.registry.CGRPermissionException) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 12 with ChangeRequest

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());
}
Also used : CGRPermissionException(net.geoprism.registry.CGRPermissionException) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 13 with ChangeRequest

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;
}
Also used : CGRPermissionException(net.geoprism.registry.CGRPermissionException) VaultFile(com.runwaysdk.system.VaultFile) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 14 with ChangeRequest

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());
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) ChangeRequest(net.geoprism.registry.action.ChangeRequest) AbstractAction(net.geoprism.registry.action.AbstractAction) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 15 with ChangeRequest

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());
    }
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Aggregations

ChangeRequest (net.geoprism.registry.action.ChangeRequest)38 Request (com.runwaysdk.session.Request)21 Date (java.util.Date)16 UpdateAttributeAction (net.geoprism.registry.action.geoobject.UpdateAttributeAction)14 JsonObject (com.google.gson.JsonObject)13 AbstractAction (net.geoprism.registry.action.AbstractAction)13 QueryFactory (com.runwaysdk.query.QueryFactory)12 ChangeRequestQuery (net.geoprism.registry.action.ChangeRequestQuery)12 JsonArray (com.google.gson.JsonArray)10 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)10 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)10 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)10 CGRPermissionException (net.geoprism.registry.CGRPermissionException)9 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)7 SimpleDateFormat (java.text.SimpleDateFormat)7 CreateGeoObjectAction (net.geoprism.registry.action.geoobject.CreateGeoObjectAction)7 UpdateAttributeActionBase (net.geoprism.registry.action.geoobject.UpdateAttributeActionBase)6 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)6 VaultFile (com.runwaysdk.system.VaultFile)4 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)4