Search in sources :

Example 6 with ListType

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

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

the class ListTypeService method remove.

@Request(RequestType.SESSION)
public void remove(String sessionId, String oid) {
    try {
        ListType listType = ListType.get(oid);
        this.enforceWritePermissions(listType);
        listType.delete();
        ((Session) Session.getCurrentSession()).reloadPermissions();
    } catch (DataNotFoundException e) {
    // Do nothing
    }
}
Also used : DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) ListType(net.geoprism.registry.ListType) Session(com.runwaysdk.session.Session) Request(com.runwaysdk.session.Request)

Example 8 with ListType

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

the class ListTypeInheritedHierarchyTest method testMarkAsInvalidByInheritedParent.

@Test
@Request
public void testMarkAsInvalidByInheritedParent() {
    JsonObject json = ListTypeTest.getJson(USATestData.ORG_NPS.getServerObject(), USATestData.HIER_SCHOOL, USATestData.SCHOOL_ZONE, USATestData.DISTRICT, USATestData.STATE);
    ListType masterlist = ListType.apply(json);
    try {
        masterlist.markAsInvalid(USATestData.HIER_ADMIN.getServerObject(), USATestData.STATE.getServerObject());
        Assert.assertFalse(masterlist.isValid());
    } catch (DuplicateDataDatabaseException e) {
        masterlist.delete();
    }
}
Also used : ListType(net.geoprism.registry.ListType) JsonObject(com.google.gson.JsonObject) DuplicateDataDatabaseException(com.runwaysdk.dataaccess.database.DuplicateDataDatabaseException) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 9 with ListType

use of net.geoprism.registry.ListType 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 10 with ListType

use of net.geoprism.registry.ListType 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)

Aggregations

ListType (net.geoprism.registry.ListType)28 Request (com.runwaysdk.session.Request)21 JsonObject (com.google.gson.JsonObject)19 ListTypeVersion (net.geoprism.registry.ListTypeVersion)11 Test (org.junit.Test)10 IncrementalListType (net.geoprism.registry.IncrementalListType)9 IntervalListType (net.geoprism.registry.IntervalListType)9 SingleListType (net.geoprism.registry.SingleListType)9 DuplicateDataDatabaseException (com.runwaysdk.dataaccess.database.DuplicateDataDatabaseException)8 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)8 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)8 JsonArray (com.google.gson.JsonArray)5 ListTypeEntry (net.geoprism.registry.ListTypeEntry)5 QueryFactory (com.runwaysdk.query.QueryFactory)4 Session (com.runwaysdk.session.Session)4 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)3 InvalidMasterListException (net.geoprism.registry.InvalidMasterListException)3 ListTypeVersionQuery (net.geoprism.registry.ListTypeVersionQuery)3 Geometry (com.vividsolutions.jts.geom.Geometry)2 Organization (net.geoprism.registry.Organization)2