Search in sources :

Example 26 with ChangeRequest

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

Example 27 with ChangeRequest

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;
}
Also used : CreateGeoObjectAction(net.geoprism.registry.action.geoobject.CreateGeoObjectAction) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Date(java.util.Date) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 28 with ChangeRequest

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();
}
Also used : CreateGeoObjectAction(net.geoprism.registry.action.geoobject.CreateGeoObjectAction) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Date(java.util.Date) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 29 with ChangeRequest

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() };
}
Also used : JsonArray(com.google.gson.JsonArray) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) UpdateAttributeActionBase(net.geoprism.registry.action.geoobject.UpdateAttributeActionBase) JsonObject(com.google.gson.JsonObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest) UpdateAttributeAction(net.geoprism.registry.action.geoobject.UpdateAttributeAction) Date(java.util.Date) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 30 with ChangeRequest

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());
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ChangeRequest(net.geoprism.registry.action.ChangeRequest) AbstractAction(net.geoprism.registry.action.AbstractAction) UpdateAttributeAction(net.geoprism.registry.action.geoobject.UpdateAttributeAction) 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