use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF in project geoprism-registry by terraframe.
the class BusinessType method deleteMdAttributeFromAttributeType.
/**
* Delete the {@link MdAttributeConcreteDAOIF} from the given {
*
* @param type
* TODO
* @param mdBusiness
* @param attributeName
*/
@Transaction
public void deleteMdAttributeFromAttributeType(String attributeName) {
MdAttributeConcreteDAOIF mdAttributeConcreteDAOIF = ServerGeoObjectType.getMdAttribute(this.getMdVertex(), attributeName);
if (mdAttributeConcreteDAOIF != null) {
if (mdAttributeConcreteDAOIF instanceof MdAttributeTermDAOIF || mdAttributeConcreteDAOIF instanceof MdAttributeMultiTermDAOIF) {
String attributeTermKey = TermConverter.buildtAtttributeKey(this.getMdVertex().getTypeName(), mdAttributeConcreteDAOIF.definesAttribute());
try {
Classifier attributeTerm = Classifier.getByKey(attributeTermKey);
attributeTerm.delete();
} catch (DataNotFoundException e) {
}
}
mdAttributeConcreteDAOIF.getBusinessDAO().delete();
}
}
use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF in project geoprism-registry by terraframe.
the class GeoRegistryUtil method exportMasterListShapefile.
@Transaction
public static InputStream exportMasterListShapefile(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 {
MasterListShapefileExporter exporter = new MasterListShapefileExporter(version, mdBusiness, mdAttributes, filterJson);
return exporter.export();
} catch (IOException e) {
throw new ProgrammingErrorException(e);
}
}
use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF in project geoprism-registry by terraframe.
the class GeoRegistryUtil method exportListTypeExcel.
@Transaction
public static InputStream exportListTypeExcel(String oid, String json) {
ListTypeVersion version = ListTypeVersion.get(oid);
MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(version.getMdBusinessOid());
JsonObject criteria = (json != null) ? JsonParser.parseString(json).getAsJsonObject() : new JsonObject();
List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributesOrdered().stream().filter(mdAttribute -> version.isValid(mdAttribute)).collect(Collectors.toList());
if (json.contains("invalid")) {
mdAttributes = mdAttributes.stream().filter(mdAttribute -> !mdAttribute.definesAttribute().equals("invalid")).collect(Collectors.toList());
}
try {
ListTypeExcelExporter exporter = new ListTypeExcelExporter(version, mdBusiness, mdAttributes, null, criteria);
return exporter.export();
} catch (IOException e) {
throw new ProgrammingErrorException(e);
}
}
use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF in project geoprism-registry by terraframe.
the class ListTypeVersion method record.
public JsonObject record(String uid) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
NumberFormat numberFormat = NumberFormat.getInstance(Session.getCurrentLocale());
MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid());
List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributes();
BusinessQuery query = new QueryFactory().businessQuery(mdBusiness.definesType());
query.WHERE(query.get(DefaultAttribute.UID.getName()).EQ(uid));
JsonObject record = new JsonObject();
record.addProperty("recordType", "LIST");
record.addProperty("version", this.getOid());
record.add("typeLabel", LocalizedValueConverter.convert(this.getListType().getDisplayLabel()).toJSON());
record.add("attributes", this.getAttributesAsJson());
try (OIterator<Business> iterator = query.getIterator()) {
if (iterator.hasNext()) {
Business row = iterator.next();
JsonObject object = new JsonObject();
object.addProperty(ORIGINAL_OID, row.getValue(ORIGINAL_OID));
for (MdAttributeConcreteDAOIF mdAttribute : mdAttributes) {
if (this.isValid(mdAttribute)) {
String attributeName = mdAttribute.definesAttribute();
Object value = row.getObjectValue(attributeName);
if (value != null) {
if (value instanceof Double) {
object.addProperty(mdAttribute.definesAttribute(), numberFormat.format((Double) value));
} else if (value instanceof Number) {
object.addProperty(mdAttribute.definesAttribute(), (Number) value);
} else if (value instanceof Boolean) {
object.addProperty(mdAttribute.definesAttribute(), (Boolean) value);
} else if (value instanceof String) {
object.addProperty(mdAttribute.definesAttribute(), (String) value);
} else if (value instanceof Character) {
object.addProperty(mdAttribute.definesAttribute(), (Character) value);
} else if (value instanceof Date) {
object.addProperty(mdAttribute.definesAttribute(), format.format((Date) value));
}
}
}
}
record.add("data", object);
}
}
JsonArray bbox = this.bbox(uid);
if (bbox == null || bbox.size() == 0) {
bbox = this.bbox(null);
}
record.add("bbox", bbox);
return record;
}
use of com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF in project geoprism-registry by terraframe.
the class ListTypeVersion method removeAttribute.
private void removeAttribute(MdBusinessDAOIF mdBusiness, String name) {
MdAttributeConcreteDAOIF mdAttribute = mdBusiness.definesAttribute(name);
if (mdAttribute != null) {
ListTypeAttributeGroup.remove(mdAttribute);
mdAttribute.getBusinessDAO().delete();
}
}
Aggregations