use of net.geoprism.registry.excel.MasterListExcelExporter in project geoprism-registry by terraframe.
the class MasterListShapefileExporter 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());
String excelFilter;
if (filterJson == null) {
excelFilter = "[{attribute:invalid,value:false}]";
} else {
excelFilter = new String(filterJson);
}
try {
File file = new File(directory, "metadata.xlsx");
FileOutputStream fos = new FileOutputStream(file);
MasterListExcelExporter exporter = new MasterListExcelExporter(this.version, mdBusiness, mdAttributes, excelFilter, this.columnNames, new MasterListExcelExporterSheet[] { MasterListExcelExporterSheet.DICTIONARY, MasterListExcelExporterSheet.METADATA });
Workbook wb = exporter.createWorkbook();
wb.write(fos);
} catch (IOException e) {
throw new ProgrammingErrorException(e);
}
}
use of net.geoprism.registry.excel.MasterListExcelExporter in project geoprism-registry by terraframe.
the class GeoRegistryUtil method exportMasterListExcel.
@Transaction
public static InputStream exportMasterListExcel(String oid, String filterJson) {
MasterListVersion version = MasterListVersion.get(oid);
MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(version.getMdBusinessOid());
List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributesOrdered().stream().filter(mdAttribute -> version.isValid(mdAttribute)).collect(Collectors.toList());
if (filterJson.contains("invalid")) {
mdAttributes = mdAttributes.stream().filter(mdAttribute -> !mdAttribute.definesAttribute().equals("invalid")).collect(Collectors.toList());
}
try {
MasterListExcelExporter exporter = new MasterListExcelExporter(version, mdBusiness, mdAttributes, filterJson, null);
return exporter.export();
} catch (IOException e) {
throw new ProgrammingErrorException(e);
}
}
Aggregations