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();
}
}
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();
}
}
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);
}
}
}
}
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());
}
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());
}
Aggregations