use of org.hisp.dhis.attribute.Attribute in project dhis2-core by dhis2.
the class IdentifiableObjectBundleHook method handleAttributeValues.
private void handleAttributeValues(IdentifiableObject identifiableObject, ObjectBundle bundle, Schema schema) {
Session session = sessionFactory.getCurrentSession();
if (!schema.havePersistedProperty("attributeValues"))
return;
Iterator<AttributeValue> iterator = identifiableObject.getAttributeValues().iterator();
while (iterator.hasNext()) {
AttributeValue attributeValue = iterator.next();
// if value null or empty, just skip it
if (StringUtils.isEmpty(attributeValue.getValue())) {
iterator.remove();
continue;
}
Attribute attribute = bundle.getPreheat().get(bundle.getPreheatIdentifier(), attributeValue.getAttribute());
if (attribute == null) {
iterator.remove();
continue;
}
attributeValue.setAttribute(attribute);
session.save(attributeValue);
session.flush();
}
}
Aggregations