use of com.runwaysdk.dataaccess.MdBusinessDAOIF in project geoprism-registry by terraframe.
the class MasterListExcelExporter method createMetadataSheet.
private void createMetadataSheet(Workbook workbook) {
Sheet sheet = workbook.createSheet(this.getSheetName(workbook, "masterlist.metadata"));
Locale locale = Session.getCurrentLocale();
MdBusinessDAOIF metadata = MdBusinessDAO.getMdBusinessDAO(MasterList.CLASS);
int rowNumber = 0;
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.DISPLAYLABEL, this.list.getDisplayLabel().getValue());
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.CODE, this.list.getCode());
this.createRow(sheet, rowNumber++, LocalizationFacade.getFromBundles("masterlist.publishDate"), stripTime(this.version.getPublishDate()));
this.createRow(sheet, rowNumber++, LocalizationFacade.getFromBundles("masterlist.forDate"), stripTime(this.version.getForDate()));
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.DESCRIPTIONLOCAL, this.list.getDescriptionLocal().getValue());
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.PROCESSLOCAL, this.list.getProcessLocal().getValue());
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.PROGRESSLOCAL, this.list.getProgressLocal().getValue());
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.ACCESSCONSTRAINTSLOCAL, this.list.getAccessConstraintsLocal().getValue());
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.USECONSTRAINTSLOCAL, this.list.getUseConstraintsLocal().getValue());
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.ACKNOWLEDGEMENTSLOCAL, this.list.getAcknowledgementsLocal().getValue());
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.DISCLAIMERLOCAL, this.list.getDisclaimerLocal().getValue());
rowNumber++;
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.CONTACTNAME, this.list.getContactName());
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.ORGANIZATION, this.list.getOrganization().getDisplayLabel().getValue());
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.TELEPHONENUMBER, this.list.getTelephoneNumber());
this.createRow(sheet, locale, metadata, rowNumber++, MasterList.EMAIL, this.list.getEmail());
}
use of com.runwaysdk.dataaccess.MdBusinessDAOIF in project geoprism-registry by terraframe.
the class ListTypeShapefileExporter method writeDictionaryFile.
/**
* Writes an additional "data dictionary" / metadata excel spreadsheet to the
* directory, which is intended to be part of the final Shapfile. This is
* useful for downstream developers trying to make sense of the GIS data.
*
* See also: - https://github.com/terraframe/geoprism-registry/issues/628
*/
private void writeDictionaryFile(File directory) {
MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.version.getMdBusinessOid());
List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributesOrdered().stream().filter(mdAttribute -> this.version.isValid(mdAttribute)).collect(Collectors.toList());
mdAttributes = mdAttributes.stream().filter(mdAttribute -> !mdAttribute.definesAttribute().equals("invalid")).collect(Collectors.toList());
try {
File file = new File(directory, "metadata.xlsx");
FileOutputStream fos = new FileOutputStream(file);
ListTypeExcelExporter exporter = new ListTypeExcelExporter(this.version, mdBusiness, mdAttributes, new ListTypeExcelExporterSheet[] { ListTypeExcelExporterSheet.DICTIONARY, ListTypeExcelExporterSheet.METADATA }, criteria);
Workbook wb = exporter.createWorkbook();
wb.write(fos);
} catch (IOException e) {
throw new ProgrammingErrorException(e);
}
}
use of com.runwaysdk.dataaccess.MdBusinessDAOIF in project geoprism-registry by terraframe.
the class VectorTileBuilder method getResultSet.
private ResultSet getResultSet() {
MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.version.getMdBusinessOid());
MdAttributeConcreteDAOIF geomAttribute = mdBusiness.definesAttribute(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME);
MdAttributeConcreteDAOIF labelAttribute = mdBusiness.definesAttribute(DefaultAttribute.DISPLAY_LABEL.getName() + MasterListVersion.DEFAULT_LOCALE);
String column = geomAttribute.getColumnName();
String labelColumn = labelAttribute.getColumnName();
StringBuilder sql = new StringBuilder();
sql.append("SELECT ge.oid");
sql.append(", ge.uid");
sql.append(", ge.code");
sql.append(", ge." + labelColumn + " AS default_locale");
for (Locale locale : locales) {
MdAttributeConcreteDAOIF localeAttribute = mdBusiness.definesAttribute(DefaultAttribute.DISPLAY_LABEL.getName() + locale.toString());
if (localeAttribute != null) {
sql.append(", ge." + localeAttribute.getColumnName() + " AS " + locale.toString());
}
}
sql.append(", ST_Transform(ge." + column + ", 3857) AS " + GeoserverFacade.GEOM_COLUMN + "\n ");
sql.append("FROM " + mdBusiness.getTableName() + " AS ge\n ");
sql.append("WHERE ge." + column + " IS NOT NULL\n ");
sql.append("AND ge.invalid=0");
return Database.query(sql.toString());
}
use of com.runwaysdk.dataaccess.MdBusinessDAOIF 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();
}
});
}
use of com.runwaysdk.dataaccess.MdBusinessDAOIF 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