Search in sources :

Example 6 with ChangeRequest

use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.

the class ChangeRequestService method markAllAsInvalid.

@Transaction
public void markAllAsInvalid(ServerGeoObjectType type) {
    String reason = LocalizationFacade.localize("changeRequest.invalidate.deleteReferencedGeoObjectType");
    ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
    crq.WHERE(crq.getApprovalStatus().containsExactly(AllGovernanceStatus.PENDING));
    try (OIterator<? extends ChangeRequest> it = crq.getIterator()) {
        for (ChangeRequest cr : it) {
            if (cr.getGeoObjectTypeCode().equals(type.getCode())) {
                cr.invalidate(reason);
            }
        }
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 7 with ChangeRequest

use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.

the class ChangeRequestService method uploadFileInTransactionCR.

@Transaction
String uploadFileInTransactionCR(String requestId, String fileName, InputStream fileStream) {
    ChangeRequest request = ChangeRequest.get(requestId);
    if (!this.permService.getPermissions(request).contains(ChangeRequestPermissionAction.WRITE_DOCUMENTS)) {
        throw new CGRPermissionException();
    }
    VaultFile vf = VaultFile.createAndApply(fileName, fileStream);
    request.addDocument(vf).apply();
    JsonObject jo = new JsonObject();
    jo.addProperty("fileName", vf.getName());
    jo.addProperty("oid", vf.getOid());
    jo.addProperty("requestId", requestId);
    return jo.toString();
}
Also used : CGRPermissionException(net.geoprism.registry.CGRPermissionException) VaultFile(com.runwaysdk.system.VaultFile) JsonObject(com.google.gson.JsonObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 8 with ChangeRequest

use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.

the class ChangeRequestService method deleteChangeRequest.

@Request(RequestType.SESSION)
public String deleteChangeRequest(String sessionId, String requestId) {
    ChangeRequest request = ChangeRequest.get(requestId);
    if (!this.permService.getPermissions(request).containsAll(Arrays.asList(ChangeRequestPermissionAction.DELETE))) {
        throw new CGRPermissionException();
    }
    request.delete();
    return requestId;
}
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 9 with ChangeRequest

use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.

the class ChangeRequestService method listDocumentsCR.

String listDocumentsCR(String requestId) {
    JsonArray ja = new JsonArray();
    ChangeRequest request = ChangeRequest.get(requestId);
    if (!this.permService.getPermissions(request).contains(ChangeRequestPermissionAction.READ_DOCUMENTS)) {
        throw new CGRPermissionException();
    }
    OIterator<? extends VaultFile> it = request.getAllDocument();
    try {
        for (VaultFile vf : it) {
            JsonObject jo = new JsonObject();
            jo.addProperty("fileName", vf.getName());
            jo.addProperty("oid", vf.getOid());
            jo.addProperty("requestId", requestId);
            ja.add(jo);
        }
    } finally {
        it.close();
    }
    return ja.toString();
}
Also used : JsonArray(com.google.gson.JsonArray) CGRPermissionException(net.geoprism.registry.CGRPermissionException) VaultFile(com.runwaysdk.system.VaultFile) JsonObject(com.google.gson.JsonObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 10 with ChangeRequest

use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.

the class ChangeRequestService method update.

@Request(RequestType.SESSION)
public JsonObject update(String sessionId, String cr) {
    JsonObject obj = JsonParser.parseString(cr).getAsJsonObject();
    String oid = obj.get("oid").getAsString();
    JsonArray actions = obj.get("actions").getAsJsonArray();
    String notes = obj.get("contributorNotes").getAsString();
    ChangeRequest current = ChangeRequest.get(oid);
    ServerGeoObjectService service = new ServerGeoObjectService();
    service.updateChangeRequest(current, notes, actions);
    return current.getDetails();
}
Also used : JsonArray(com.google.gson.JsonArray) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) JsonObject(com.google.gson.JsonObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Request(com.runwaysdk.session.Request) 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