Search in sources :

Example 1 with ChangeRequestQuery

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

the class ChangeRequestSortingPatch method doIt.

@Transaction
private void doIt() {
    ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
    OIterator<? extends ChangeRequest> it = crq.getIterator();
    for (ChangeRequest cr : it) {
        LocalizedValue goLabel = cr.getGeoObjectDisplayLabel();
        ServerGeoObjectType type = cr.getGeoObjectType();
        cr.appLock();
        cr.getGeoObjectLabel().setLocaleMap(goLabel.getLocaleMap());
        cr.getGeoObjectTypeLabel().setLocaleMap(type.getLabel().getLocaleMap());
        cr.apply();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 2 with ChangeRequestQuery

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

the class ChangeRequestTestDataGenerator method deleteAllChangeRequests.

@Request
public static void deleteAllChangeRequests() {
    ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
    OIterator<? extends ChangeRequest> it = crq.getIterator();
    while (it.hasNext()) {
        it.next().delete();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 3 with ChangeRequestQuery

use of net.geoprism.registry.action.ChangeRequestQuery 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 4 with ChangeRequestQuery

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

the class ChangeRequestServiceTest method testComplexUpdateGeoObjectCR_Verify.

@Request
private void testComplexUpdateGeoObjectCR_Verify(String[] data) throws Exception {
    final String oldOid = data[1];
    final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    sdf.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    final Date newStartDate = sdf.parse(NEW_START_DATE);
    final Date newEndDate = sdf.parse(NEW_END_DATE);
    final Date oldStartDate = sdf.parse(OLD_START_DATE);
    final Date oldEndDate = sdf.parse(OLD_END_DATE);
    ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
    Assert.assertEquals(1, crq.getCount());
    ChangeRequest cr = crq.getIterator().next();
    Assert.assertEquals(AllGovernanceStatus.ACCEPTED.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());
    ServerGeoObjectIF cambodia = FastTestDataset.CAMBODIA.getServerObject();
    ValueOverTimeCollection votc = cambodia.getValuesOverTime(FastTestDataset.AT_National_Anthem.getAttributeName());
    Assert.assertEquals(2, votc.size());
    ValueOverTime vot1 = votc.get(0);
    Assert.assertNotNull(vot1.getOid());
    Assert.assertTrue(!(vot1.getOid().equals(oldOid)));
    Assert.assertEquals(NEW_ANTHEM, vot1.getValue());
    Assert.assertEquals(oldStartDate, vot1.getStartDate());
    Assert.assertEquals(oldEndDate, vot1.getEndDate());
    ValueOverTime vot2 = votc.get(1);
    Assert.assertNotNull(vot2.getOid());
    Assert.assertTrue(!(vot2.getOid().equals(oldOid)));
    Assert.assertEquals(NEW_ANTHEM, vot2.getValue());
    Assert.assertEquals(newStartDate, vot2.getStartDate());
    Assert.assertEquals(newEndDate, vot2.getEndDate());
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) QueryFactory(com.runwaysdk.query.QueryFactory) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) ChangeRequest(net.geoprism.registry.action.ChangeRequest) SimpleDateFormat(java.text.SimpleDateFormat) AbstractAction(net.geoprism.registry.action.AbstractAction) UpdateAttributeAction(net.geoprism.registry.action.geoobject.UpdateAttributeAction) Date(java.util.Date) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 5 with ChangeRequestQuery

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

the class ChangeRequestServiceTest method testUpdateGeoObjectLocalizedValueCR_Verify.

@Request
private void testUpdateGeoObjectLocalizedValueCR_Verify(String[] data) throws Exception {
    final String oldOid = data[1];
    final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    sdf.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    final Date newStartDate = sdf.parse(NEW_START_DATE);
    final Date newEndDate = sdf.parse(NEW_END_DATE);
    ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
    Assert.assertEquals(1, crq.getCount());
    ChangeRequest cr = crq.getIterator().next();
    Assert.assertEquals(AllGovernanceStatus.ACCEPTED.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());
    VertexServerGeoObject cambodia = (VertexServerGeoObject) FastTestDataset.CAMBODIA.getServerObject();
    ValueOverTimeCollection votc = cambodia.getValuesOverTime(DefaultAttribute.DISPLAY_LABEL.getName());
    Assert.assertEquals(1, votc.size());
    ValueOverTime vot1 = votc.get(0);
    Assert.assertNotNull(vot1.getOid());
    Assert.assertEquals(oldOid, vot1.getOid());
    Assert.assertEquals(newStartDate, vot1.getStartDate());
    Assert.assertEquals(newEndDate, vot1.getEndDate());
    Assert.assertEquals("localizeTest", cambodia.getDisplayLabel(newStartDate).getValue());
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) QueryFactory(com.runwaysdk.query.QueryFactory) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest) SimpleDateFormat(java.text.SimpleDateFormat) AbstractAction(net.geoprism.registry.action.AbstractAction) UpdateAttributeAction(net.geoprism.registry.action.geoobject.UpdateAttributeAction) Date(java.util.Date) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Aggregations

QueryFactory (com.runwaysdk.query.QueryFactory)12 ChangeRequest (net.geoprism.registry.action.ChangeRequest)12 ChangeRequestQuery (net.geoprism.registry.action.ChangeRequestQuery)12 Request (com.runwaysdk.session.Request)9 AbstractAction (net.geoprism.registry.action.AbstractAction)8 UpdateAttributeAction (net.geoprism.registry.action.geoobject.UpdateAttributeAction)7 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)5 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Date (java.util.Date)5 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)4 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2 CreateGeoObjectAction (net.geoprism.registry.action.geoobject.CreateGeoObjectAction)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 OIterator (com.runwaysdk.query.OIterator)1 Selectable (com.runwaysdk.query.Selectable)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 Calendar (java.util.Calendar)1 Classifier (net.geoprism.ontology.Classifier)1