Search in sources :

Example 1 with ListTypeEntry

use of net.geoprism.registry.ListTypeEntry in project geoprism-registry by terraframe.

the class ListTypeService method createVersion.

@Request(RequestType.SESSION)
public JsonObject createVersion(String sessionId, String oid, String metadata) {
    ListTypeEntry entry = ListTypeEntry.get(oid);
    ListType listType = entry.getListType();
    if (!listType.isValid()) {
        throw new InvalidMasterListException();
    }
    this.enforceWritePermissions(listType);
    String version = entry.publish(metadata);
    ((Session) Session.getCurrentSession()).reloadPermissions();
    return JsonParser.parseString(version).getAsJsonObject();
// return entry.toJSON(false);
}
Also used : ListTypeEntry(net.geoprism.registry.ListTypeEntry) ListType(net.geoprism.registry.ListType) InvalidMasterListException(net.geoprism.registry.InvalidMasterListException) Session(com.runwaysdk.session.Session) Request(com.runwaysdk.session.Request)

Example 2 with ListTypeEntry

use of net.geoprism.registry.ListTypeEntry 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 3 with ListTypeEntry

use of net.geoprism.registry.ListTypeEntry in project geoprism-registry by terraframe.

the class ListTypeTest method testPublishInvalidVersion.

@Test(expected = InvalidMasterListException.class)
@Request
public void testPublishInvalidVersion() {
    JsonObject json = getJson(USATestData.ORG_NPS.getServerObject(), USATestData.HIER_ADMIN, USATestData.STATE, USATestData.COUNTRY);
    ListType test = ListType.apply(json);
    try {
        test.appLock();
        test.setValid(false);
        test.apply();
        ListTypeEntry version = test.getOrCreateEntry(TestDataSet.DEFAULT_OVER_TIME_DATE, null);
        version.delete();
    } finally {
        test.delete();
    }
}
Also used : 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) ClassificationTypeTest(net.geoprism.registry.classification.ClassificationTypeTest) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 4 with ListTypeEntry

use of net.geoprism.registry.ListTypeEntry in project geoprism-registry by terraframe.

the class FhirExportTest method classSetupInRequest.

@Request
public static void classSetupInRequest() throws ParseException {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    Date date = format.parse("2020-04-05");
    ListTypeBuilder.Hierarchy admin = new ListTypeBuilder.Hierarchy();
    admin.setType(USATestData.HIER_ADMIN);
    admin.setParents(USATestData.COUNTRY, USATestData.STATE, USATestData.DISTRICT);
    ListTypeBuilder.Hierarchy reportsTo = new ListTypeBuilder.Hierarchy();
    reportsTo.setType(USATestData.HIER_REPORTS_TO);
    reportsTo.setParents(USATestData.HEALTH_POST);
    ListTypeBuilder multiHierarchyBuilder = new ListTypeBuilder();
    multiHierarchyBuilder.setOrg(USATestData.ORG_NPS.getServerObject());
    multiHierarchyBuilder.setInfo(USATestData.HEALTH_STOP);
    multiHierarchyBuilder.setHts(admin, reportsTo);
    multiHierarchyBuilder.setCode("TEST_MULTI");
    multiHierarchyList = multiHierarchyBuilder.build();
    ListTypeEntry multiHierarchyEntry = multiHierarchyList.getOrCreateEntry(date, null);
    multiHierarchyVersion = multiHierarchyEntry.getWorking();
    multiHierarchyVersion.publishNoAuth();
    ListTypeBuilder basicBuilder = new ListTypeBuilder();
    basicBuilder.setOrg(USATestData.ORG_NPS.getServerObject());
    basicBuilder.setInfo(USATestData.HEALTH_STOP);
    basicBuilder.setHts(admin);
    basicBuilder.setCode("TEST_BASIC");
    basicHierarchyList = basicBuilder.build();
    ListTypeEntry basicHierarchyEntry = basicHierarchyList.getOrCreateEntry(date, null);
    basicHierarchyVersion = basicHierarchyEntry.getWorking();
    basicHierarchyVersion.publishNoAuth();
}
Also used : ListTypeEntry(net.geoprism.registry.ListTypeEntry) ListTypeBuilder(net.geoprism.registry.ListTypeBuilder) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Request(com.runwaysdk.session.Request)

Example 5 with ListTypeEntry

use of net.geoprism.registry.ListTypeEntry in project geoprism-registry by terraframe.

the class ListTypeInheritedHierarchyTest method testPublishVersion.

@Test
@Request
public void testPublishVersion() {
    TestDataSet.runAsUser(USATestData.USER_ADMIN, (request, adapter) -> {
        JsonObject json = ListTypeTest.getJson(USATestData.ORG_NPS.getServerObject(), USATestData.HIER_SCHOOL, USATestData.SCHOOL_ZONE, USATestData.COUNTRY, USATestData.STATE, USATestData.DISTRICT);
        ListType test = ListType.apply(json);
        try {
            ListTypeEntry entry = test.getOrCreateEntry(new Date(), null);
            ListTypeVersion version = entry.getWorking();
            try {
                MdBusinessDAOIF mdTable = MdBusinessDAO.get(version.getMdBusinessOid());
                Assert.assertNotNull(mdTable);
                version.publish();
            } finally {
                entry.delete();
            }
        } finally {
            test.delete();
        }
    });
}
Also used : MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) ListTypeEntry(net.geoprism.registry.ListTypeEntry) ListType(net.geoprism.registry.ListType) JsonObject(com.google.gson.JsonObject) ListTypeVersion(net.geoprism.registry.ListTypeVersion) Date(java.util.Date) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

ListTypeEntry (net.geoprism.registry.ListTypeEntry)6 Request (com.runwaysdk.session.Request)5 ListType (net.geoprism.registry.ListType)5 JsonObject (com.google.gson.JsonObject)4 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)3 IncrementalListType (net.geoprism.registry.IncrementalListType)3 IntervalListType (net.geoprism.registry.IntervalListType)3 ListTypeVersion (net.geoprism.registry.ListTypeVersion)3 SingleListType (net.geoprism.registry.SingleListType)3 Test (org.junit.Test)3 Date (java.util.Date)2 InvalidMasterListException (net.geoprism.registry.InvalidMasterListException)2 ListTypeBuilder (net.geoprism.registry.ListTypeBuilder)2 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)2 DuplicateDataDatabaseException (com.runwaysdk.dataaccess.database.DuplicateDataDatabaseException)1 Session (com.runwaysdk.session.Session)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 SimpleDateFormat (java.text.SimpleDateFormat)1 JsonSerializable (net.geoprism.registry.view.JsonSerializable)1 GeoJSONReader (org.wololo.jts2geojson.GeoJSONReader)1