use of net.geoprism.registry.io.ImportAttributeSerializer in project geoprism-registry by terraframe.
the class GeoObjectExcelExporter method createWorkbook.
public Workbook createWorkbook() throws IOException {
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet(WorkbookUtil.createSafeSheetName(this.type.getLabel().getValue()));
CreationHelper createHelper = workbook.getCreationHelper();
Font font = workbook.createFont();
font.setBold(true);
CellStyle boldStyle = workbook.createCellStyle();
boldStyle.setFont(font);
CellStyle dateStyle = workbook.createCellStyle();
dateStyle.setDataFormat(createHelper.createDataFormat().getFormat(BuiltinFormats.getBuiltinFormat(14)));
Row header = sheet.createRow(0);
boolean includeCoordinates = this.type.getGeometryType().equals(GeometryType.POINT) || this.type.getGeometryType().equals(GeometryType.MIXED);
Collection<AttributeType> attributes = new ImportAttributeSerializer(Session.getCurrentLocale(), includeCoordinates, true, locales).attributes(this.type.getType());
// Get the ancestors of the type
List<GeoObjectType> dtoAncestors = this.type.getTypeAncestors(this.hierarchy, true);
List<ServerGeoObjectType> ancestors = new LinkedList<ServerGeoObjectType>();
for (GeoObjectType ancestor : dtoAncestors) {
ancestors.add(ServerGeoObjectType.get(ancestor));
}
this.writeHeader(boldStyle, header, attributes, ancestors);
for (int i = 0; i < this.objects.size(); i++) {
ServerGeoObjectIF object = this.objects.get(i);
Row row = sheet.createRow(i + 1);
this.writeRow(row, object, attributes, ancestors, dateStyle);
}
return workbook;
}
use of net.geoprism.registry.io.ImportAttributeSerializer in project geoprism-registry by terraframe.
the class ExcelService method getType.
private JSONObject getType(ServerGeoObjectType geoObjectType) {
final boolean includeCoordinates = geoObjectType.getGeometryType().equals(GeometryType.POINT) || geoObjectType.getGeometryType().equals(GeometryType.MULTIPOINT) || geoObjectType.getGeometryType().equals(GeometryType.MIXED);
final ImportAttributeSerializer serializer = new ImportAttributeSerializer(Session.getCurrentLocale(), includeCoordinates, false, LocalizationFacade.getInstalledLocales());
JSONObject type = new JSONObject(geoObjectType.toJSON(serializer).toString());
JSONArray attributes = type.getJSONArray(GeoObjectType.JSON_ATTRIBUTES);
for (int i = 0; i < attributes.length(); i++) {
JSONObject attribute = attributes.getJSONObject(i);
String attributeType = attribute.getString(AttributeType.JSON_TYPE);
attribute.put(GeoObjectImportConfiguration.BASE_TYPE, GeoObjectImportConfiguration.getBaseType(attributeType));
}
return type;
}
use of net.geoprism.registry.io.ImportAttributeSerializer in project geoprism-registry by terraframe.
the class ShapefileService method getType.
private JSONObject getType(ServerGeoObjectType geoObjectType) {
JSONObject type = new JSONObject(geoObjectType.toJSON(new ImportAttributeSerializer(Session.getCurrentLocale(), false, false, LocalizationFacade.getInstalledLocales())).toString());
JSONArray attributes = type.getJSONArray(GeoObjectType.JSON_ATTRIBUTES);
for (int i = 0; i < attributes.length(); i++) {
JSONObject attribute = attributes.getJSONObject(i);
String attributeType = attribute.getString(AttributeType.JSON_TYPE);
attribute.put(GeoObjectImportConfiguration.BASE_TYPE, GeoObjectImportConfiguration.getBaseType(attributeType));
}
return type;
}
Aggregations