use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF in project geoprism-registry by terraframe.
the class ServerGeoObjectTypeConverter method convertAttributeTypes.
public GeoObjectType convertAttributeTypes(Universal uni, GeoObjectType gt, MdBusiness mdBusiness) {
if (mdBusiness != null) {
MdBusinessDAOIF mdBusinessDAOIF = (MdBusinessDAOIF) BusinessFacade.getEntityDAO(mdBusiness);
// Standard attributes are defined by default on the GeoObjectType
AttributeTypeConverter builder = new AttributeTypeConverter();
List<? extends MdAttributeConcreteDAOIF> definedMdAttributeList = mdBusinessDAOIF.getAllDefinedMdAttributes();
for (MdAttributeConcreteDAOIF mdAttribute : definedMdAttributeList) {
if (this.convertMdAttributeToAttributeType(mdAttribute)) {
AttributeType attributeType = builder.build(mdAttribute);
if (attributeType != null) {
gt.addAttribute(attributeType);
}
}
}
}
return gt;
}
use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF in project geoprism-registry by terraframe.
the class ListTypeExcelExporter method createDataDictionarySheet.
private void createDataDictionarySheet(Workbook workbook) {
Sheet sheet = workbook.createSheet(getSheetName(workbook, "masterlist.data.dictionary"));
Locale locale = Session.getCurrentLocale();
int rowNumber = 0;
for (MdAttributeConcreteDAOIF mdAttribute : mdAttributes) {
this.createRow(sheet, locale, rowNumber++, mdAttribute, mdAttribute.getDescription(locale));
}
}
use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF in project geoprism-registry by terraframe.
the class ServerGeoObjectType method updateMdAttributeFromAttributeType.
/**
* Creates an {@link MdAttributeConcrete} for the given {@link MdBusiness}
* from the given {@link AttributeType}
*
* @pre assumes no attribute has been defined on the type with the given name.
*
* @param mdBusiness
* Type to receive attribute definition
* @param attributeType
* newly defined attribute
*
* @return {@link AttributeType}
*/
@Transaction
public static MdAttributeConcrete updateMdAttributeFromAttributeType(MdClass mdClass, AttributeType attributeType) {
MdAttributeConcreteDAOIF mdAttributeConcreteDAOIF = getMdAttribute(mdClass, attributeType.getName());
if (mdAttributeConcreteDAOIF != null) {
// Get the type safe version
MdAttributeConcrete mdAttribute = (MdAttributeConcrete) BusinessFacade.get(mdAttributeConcreteDAOIF);
mdAttribute.lock();
try {
// The name cannot be updated
// mdAttribute.setAttributeName(attributeType.getName());
LocalizedValueConverter.populate(mdAttribute.getDisplayLabel(), attributeType.getLabel());
LocalizedValueConverter.populate(mdAttribute.getDescription(), attributeType.getDescription());
if (attributeType instanceof AttributeFloatType) {
// Refresh the terms
AttributeFloatType attributeFloatType = (AttributeFloatType) attributeType;
mdAttribute.setValue(MdAttributeDoubleInfo.LENGTH, Integer.toString(attributeFloatType.getPrecision()));
mdAttribute.setValue(MdAttributeDoubleInfo.DECIMAL, Integer.toString(attributeFloatType.getScale()));
} else if (attributeType instanceof AttributeClassificationType) {
MdAttributeClassification mdAttributeTerm = (MdAttributeClassification) mdAttribute;
AttributeClassificationType attributeClassificationType = (AttributeClassificationType) attributeType;
String classificationTypeCode = attributeClassificationType.getClassificationType();
ClassificationType classificationType = ClassificationType.getByCode(classificationTypeCode);
Term root = attributeClassificationType.getRootTerm();
if (root != null) {
Classification classification = Classification.get(classificationType, root.getCode());
mdAttributeTerm.setValue(MdAttributeClassification.ROOT, classification.getOid());
}
}
mdAttribute.apply();
} finally {
mdAttribute.unlock();
}
if (attributeType instanceof AttributeTermType) {
// Refresh the terms
AttributeTermType attributeTermType = (AttributeTermType) attributeType;
org.commongeoregistry.adapter.Term getRootTerm = attributeTermType.getRootTerm();
String classifierKey = TermConverter.buildClassifierKeyFromTermCode(getRootTerm.getCode());
TermConverter termBuilder = new TermConverter(classifierKey);
attributeTermType.setRootTerm(termBuilder.build());
}
return mdAttribute;
}
return null;
}
use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF in project geoprism-registry by terraframe.
the class ListTypeShapefileExporter method features.
public FeatureCollection<SimpleFeatureType, SimpleFeature> features(SimpleFeatureType featureType) {
List<SimpleFeature> features = new ArrayList<SimpleFeature>();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
BusinessQuery query = this.version.buildQuery(this.criteria);
query.ORDER_BY_DESC(query.aCharacter(DefaultAttribute.CODE.getName()));
OIterator<Business> objects = query.getIterator();
try {
while (objects.hasNext()) {
Business row = objects.next();
builder.set(GEOM, row.getObjectValue(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME));
for (MdAttributeConcreteDAOIF mdAttribute : mdAttributes) {
String attributeName = mdAttribute.definesAttribute();
Object value = row.getObjectValue(attributeName);
if (value != null) {
builder.set(this.getColumnName(attributeName), value);
}
}
SimpleFeature feature = builder.buildFeature(row.getValue(DefaultAttribute.CODE.getName()));
features.add(feature);
}
} finally {
objects.close();
}
return new ListFeatureCollection(featureType, features);
}
use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF 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);
}
}
Aggregations