Search in sources :

Example 6 with ListTypeVersion

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();
}
Also used : JobHistoryRecord(com.runwaysdk.system.scheduler.JobHistoryRecord) SingleListType(net.geoprism.registry.SingleListType) ListTypeVersion(net.geoprism.registry.ListTypeVersion) Request(com.runwaysdk.session.Request)

Example 7 with ListTypeVersion

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();
        }
    });
}
Also used : MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) ListTypeEntry(net.geoprism.registry.ListTypeEntry) SingleListType(net.geoprism.registry.SingleListType) IntervalListType(net.geoprism.registry.IntervalListType) ListType(net.geoprism.registry.ListType) IncrementalListType(net.geoprism.registry.IncrementalListType) JsonObject(com.google.gson.JsonObject) ListTypeVersion(net.geoprism.registry.ListTypeVersion) DuplicateDataDatabaseException(com.runwaysdk.dataaccess.database.DuplicateDataDatabaseException) InvalidMasterListException(net.geoprism.registry.InvalidMasterListException) ClassificationTypeTest(net.geoprism.registry.classification.ClassificationTypeTest) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 8 with ListTypeVersion

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);
    }
}
Also used : ListTypeVersion(net.geoprism.registry.ListTypeVersion)

Example 9 with ListTypeVersion

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;
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ListType(net.geoprism.registry.ListType) JsonObject(com.google.gson.JsonObject) GeoprismUser(net.geoprism.GeoprismUser) ListTypeVersion(net.geoprism.registry.ListTypeVersion) Request(com.runwaysdk.session.Request)

Example 10 with ListTypeVersion

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 + "].");
    }
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) JsonObject(com.google.gson.JsonObject) ListTypeVersion(net.geoprism.registry.ListTypeVersion) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

ListTypeVersion (net.geoprism.registry.ListTypeVersion)20 Request (com.runwaysdk.session.Request)15 ListType (net.geoprism.registry.ListType)11 JsonObject (com.google.gson.JsonObject)9 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)5 QueryFactory (com.runwaysdk.query.QueryFactory)4 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)3 ListTypeEntry (net.geoprism.registry.ListTypeEntry)3 SingleListType (net.geoprism.registry.SingleListType)3 JsonArray (com.google.gson.JsonArray)2 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)2 Session (com.runwaysdk.session.Session)2 IncrementalListType (net.geoprism.registry.IncrementalListType)2 IntervalListType (net.geoprism.registry.IntervalListType)2 InvalidMasterListException (net.geoprism.registry.InvalidMasterListException)2 ListTypeVersionQuery (net.geoprism.registry.ListTypeVersionQuery)2 FhirSyncLevel (net.geoprism.registry.etl.FhirSyncLevel)2 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)2 JsonSerializable (net.geoprism.registry.view.JsonSerializable)2 GlobalNotificationMessage (net.geoprism.registry.ws.GlobalNotificationMessage)2