LOG.debug("Attributes to be updated:\n{}", propByRes);
// 5. derived attributes to be removed
for (String derAttrToBeRemoved : attributableMod.getDerivedAttributesToBeRemoved()) {
AbstractDerSchema derSchema = getDerivedSchema(derAttrToBeRemoved, attrUtil.derSchemaClass());
if (derSchema != null) {
AbstractDerAttr derAttr = attributable.getDerivedAttribute(derSchema.getName());
if (derAttr == null) {
LOG.debug("No derived attribute found for schema {}", derSchema.getName());
} else {
derAttrDAO.delete(derAttr);
}
for (ExternalResource resource : resourceDAO.findAll()) {
for (AbstractMappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
if (derSchema.getName().equals(mapItem.getIntAttrName())
&& mapItem.getIntMappingType() == attrUtil.derIntMappingType()
&& attributable.getResources().contains(resource)) {
propByRes.add(ResourceOperation.UPDATE, resource.getName());
if (mapItem.isAccountid() && derAttr != null
&& !derAttr.getValue(attributable.getAttributes()).isEmpty()) {
propByRes.addOldAccountId(resource.getName(),
derAttr.getValue(attributable.getAttributes()));
}
}
}
}
}
}
LOG.debug("Derived attributes to be removed:\n{}", propByRes);
// 6. derived attributes to be added
for (String derAttrToBeAdded : attributableMod.getDerivedAttributesToBeAdded()) {
AbstractDerSchema derSchema = getDerivedSchema(derAttrToBeAdded, attrUtil.derSchemaClass());
if (derSchema != null) {
for (ExternalResource resource : resourceDAO.findAll()) {
for (AbstractMappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
if (derSchema.getName().equals(mapItem.getIntAttrName())
&& mapItem.getIntMappingType() == attrUtil.derIntMappingType()
&& attributable.getResources().contains(resource)) {
propByRes.add(ResourceOperation.UPDATE, resource.getName());
}