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