use of net.geoprism.registry.ListTypeVersion in project geoprism-registry by terraframe.
the class CurationTest method createTestInstanceData.
@Request
private void createTestInstanceData() {
list = new SingleListType();
list.setUniversal(FastTestDataset.PROVINCE.getUniversal());
list.getDisplayLabel().setValue("Test List");
list.setCode("TEST_CODE");
list.setOrganization(FastTestDataset.ORG_CGOV.getServerObject());
list.getDescription().setValue("My Overal Description");
list.setValidOn(TestDataSet.DEFAULT_OVER_TIME_DATE);
list.getListDescription().setValue("My Abstract");
list.getListProcess().setValue("Process");
list.getListProgress().setValue("Progress");
list.getListAccessConstraints().setValue("Access Contraints");
list.getListUseConstraints().setValue("User Constraints");
list.getListAcknowledgements().setValue("Acknowledgements");
list.getListDisclaimer().setValue("Disclaimer");
list.setListContactName("Contact Name");
list.setListTelephoneNumber("Telephone Number");
list.setListEmail("Email");
list.apply();
entry = ListTypeEntry.create(list, TestDataSet.DEFAULT_OVER_TIME_DATE, null);
entry.createVersion(ListTypeTest.createVersionMetadata()).publishNoAuth();
List<ListTypeVersion> versions = entry.getVersions();
Assert.assertEquals(2, versions.size());
version = versions.get(0);
job = new ListCurationJob();
job.setRunAsUser(TestDataSet.USER_ADMIN.getGeoprismUser());
job.apply();
history = (ListCurationHistory) job.createNewHistory();
history.appLock();
history.clearStatus();
history.addStatus(AllJobStatus.RUNNING);
history.setVersion(version);
history.apply();
historyId = history.getOid();
jobHistoryRecord = new JobHistoryRecord(job, history);
jobHistoryRecord.apply();
curationProblem = new GeoObjectProblem();
curationProblem.setHistory(history);
curationProblem.setResolution(CurationResolution.UNRESOLVED.name());
curationProblem.setProblemType(GeoObjectProblemType.NO_GEOMETRY.name());
curationProblem.setTypeCode(FastTestDataset.PROVINCE.getCode());
curationProblem.setGoCode(FastTestDataset.PROV_CENTRAL.getCode());
curationProblem.apply();
curationProblemId = curationProblem.getOid();
}
use of net.geoprism.registry.ListTypeVersion in project geoprism-registry by terraframe.
the class ListTypeTest method testPublishVersion.
//
// @Test
// public void testPrivateListByOrgFromOtherOrg()
// {
// JsonObject listJson = getJson(USATestData.ORG_NPS.getServerObject(),
// USATestData.HIER_ADMIN, USATestData.STATE, ListType.PRIVATE, false);
//
// ListTypeService service = new ListTypeService();
// JsonObject result = service.apply(testData.clientRequest.getSessionId(),
// listJson);
//
// try
// {
// USATestData.runAsUser(USATestData.USER_PPP_RA, (request, adapter) -> {
// JsonArray orgs = service.listByOrg(request.getSessionId());
//
// JsonObject org = null;
// for (int i = 0; i < orgs.size(); ++i)
// {
// if
// (orgs.get(i).getAsJsonObject().get("oid").getAsString().equals(USATestData.ORG_NPS.getServerObject().getOid()))
// {
// org = orgs.get(i).getAsJsonObject();
// }
// }
//
// Assert.assertNotNull(org.get("oid").getAsString());
// Assert.assertEquals(USATestData.ORG_NPS.getDisplayLabel(),
// org.get("label").getAsString());
// Assert.assertFalse(org.get("write").getAsBoolean());
// Assert.assertTrue(org.get("lists").getAsJsonArray().size() == 0);
// });
// }
// finally
// {
// String oid = result.get(ComponentInfo.OID).getAsString();
// service.remove(testData.clientRequest.getSessionId(), oid);
// }
// }
//
@Test
@Request
public void testPublishVersion() {
USATestData.runAsUser(USATestData.USER_ADMIN, (request, adapter) -> {
JsonObject json = getJson(USATestData.ORG_NPS.getServerObject(), USATestData.HIER_ADMIN, USATestData.STATE, USATestData.COUNTRY);
ListType test = ListType.apply(json);
try {
ListTypeEntry entry = test.createEntry(TestDataSet.DEFAULT_OVER_TIME_DATE);
try {
entry.publish(createVersionMetadata().toString());
List<ListTypeVersion> versions = entry.getVersions();
Assert.assertEquals(2, versions.size());
ListTypeVersion version = versions.get(0);
MdBusinessDAOIF mdTable = MdBusinessDAO.get(version.getMdBusinessOid());
Assert.assertNotNull(mdTable);
} finally {
entry.delete();
}
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getLocalizedMessage());
} finally {
test.delete();
}
});
}
use of net.geoprism.registry.ListTypeVersion in project geoprism-registry by terraframe.
the class ListCurationJob method execute.
@Override
public void execute(ExecutionContext executionContext) throws Throwable {
try {
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
ListCurationHistory history = (ListCurationHistory) executionContext.getHistory();
ListTypeVersion version = history.getVersion();
deleteOtherHistories(history, version);
new ListCurator(history, version).run();
} finally {
Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
}
}
use of net.geoprism.registry.ListTypeVersion in project geoprism-registry by terraframe.
the class CurationService method details.
@Request(RequestType.SESSION)
public JsonObject details(String sessionId, String historyId, boolean onlyUnresolved, int pageSize, int pageNumber) {
final ListCurationHistory hist = ListCurationHistory.get(historyId);
final ListTypeVersion version = hist.getVersion();
final ListType listType = version.getListType();
final ListCurationJob job = (ListCurationJob) hist.getAllJob().getAll().get(0);
final GeoprismUser user = GeoprismUser.get(job.getRunAsUser().getOid());
final ServerGeoObjectType serverGOT = listType.getGeoObjectType();
final String orgCode = listType.getOrganization().getCode();
this.checkPermissions(orgCode, serverGOT);
JsonObject jo = this.serializeHistory(hist, user, job);
jo.add("page", this.page(sessionId, historyId, onlyUnresolved, pageSize, pageNumber));
return jo;
}
use of net.geoprism.registry.ListTypeVersion in project geoprism-registry by terraframe.
the class CurationService method submitProblemResolution.
@Transaction
private void submitProblemResolution(String json) {
JsonObject config = JsonParser.parseString(json).getAsJsonObject();
ListCurationHistory hist = ListCurationHistory.get(config.get("historyId").getAsString());
ListTypeVersion version = hist.getVersion();
// this.checkPermissions(hist.getOrganization().getCode(),
// hist.getServerGeoObjectType());
// CurationProblem err =
// CurationProblem.get(config.get("problemId").getAsString());
String resolution = config.get("resolution").getAsString();
if (resolution.equals(ErrorResolution.APPLY_GEO_OBJECT.name())) {
String geoObjectCode = config.get("code").getAsString();
String geoObjectTypeCode = config.get("typeCode").getAsString();
String actions = config.get("actions").getAsJsonArray().toString();
ServerGeoObjectService service = new ServerGeoObjectService();
service.updateGeoObjectInTrans(geoObjectCode, geoObjectTypeCode, actions, version.getOid(), null);
// err.appLock();
// err.setResolution(resolution);
// err.apply();
} else {
throw new UnsupportedOperationException("Invalid import resolution [" + resolution + "].");
}
}
Aggregations