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