use of net.geoprism.registry.ListTypeBuilder in project geoprism-registry by terraframe.
the class ListTypeTest method getJson.
@Request
public static JsonObject getJson(Organization org, TestHierarchyTypeInfo ht, TestGeoObjectTypeInfo info, TestGeoObjectTypeInfo... parents) {
ListTypeBuilder.Hierarchy hierarchy = new ListTypeBuilder.Hierarchy();
hierarchy.setType(ht);
hierarchy.setParents(parents);
ListTypeBuilder builder = new ListTypeBuilder();
builder.setOrg(org);
builder.setInfo(info);
builder.setHts(hierarchy);
return builder.buildJSON();
}
use of net.geoprism.registry.ListTypeBuilder 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.ListTypeBuilder in project geoprism-registry by terraframe.
the class ListTypeTest method dataTest.
private void dataTest(Boolean includeGeometries) {
GeoJSONReader reader = new GeoJSONReader();
TestDataSet.runAsUser(USATestData.USER_ADMIN, (request, adapter) -> {
ListTypeBuilder.Hierarchy hierarchy = new ListTypeBuilder.Hierarchy();
hierarchy.setType(USATestData.HIER_ADMIN);
hierarchy.setParents(USATestData.COUNTRY, USATestData.STATE, USATestData.DISTRICT);
hierarchy.setSubtypeHierarchies(USATestData.HIER_REPORTS_TO);
ListTypeBuilder builder = new ListTypeBuilder();
builder.setOrg(USATestData.ORG_NPS.getServerObject());
builder.setInfo(USATestData.HEALTH_FACILITY);
builder.setHts(hierarchy);
ListType test = builder.build();
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);
Page<JsonSerializable> data = version.data(new JsonObject(), true, includeGeometries);
// Entries should be HP_1, HP_2, HS_1, HS_2
Assert.assertEquals(new Long(4), data.getCount());
List<JsonSerializable> results = data.getResults();
for (int i = 0; i < results.size(); i++) {
JsonObject result = results.get(i).toJSON().getAsJsonObject();
String code = result.get("code").getAsString();
if (code.equals(USATestData.HS_ONE.getCode())) {
String reportsTo = result.get("usatestdatareportstocode").getAsString();
Assert.assertEquals(USATestData.HP_ONE.getCode(), reportsTo);
} else if (code.equals(USATestData.HS_TWO.getCode())) {
String reportsTo = result.get("usatestdatareportstocode").getAsString();
Assert.assertEquals(USATestData.HP_TWO.getCode(), reportsTo);
}
if (includeGeometries != null && includeGeometries.equals(Boolean.TRUE)) {
Assert.assertEquals(true, result.has("geometry"));
JsonObject geometries = result.get("geometry").getAsJsonObject();
Geometry jtsGeom = reader.read(geometries.toString());
Assert.assertTrue(jtsGeom.isValid());
} else {
Assert.assertEquals(false, result.has("geometry"));
}
}
} finally {
entry.delete();
}
} catch (Throwable t) {
t.printStackTrace();
throw new RuntimeException(t);
} finally {
test.delete();
}
});
}
Aggregations