Skip to content

Commit

Permalink
MID-8746:fix for choices for singlevalue attribute path element in ma…
Browse files Browse the repository at this point in the history
…ppings
  • Loading branch information
skublik committed Apr 6, 2023
1 parent c79d70b commit 4ddbbde
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.evolveum.midpoint.gui.impl.component.input.AutoCompleteDisplayableValueConverter;
import com.evolveum.midpoint.gui.impl.page.admin.resource.ResourceDetailsModel;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.processor.*;
Expand Down Expand Up @@ -203,15 +204,28 @@ protected List<DisplayableValue<ItemPathType>> load() {
List<DisplayableValue<ItemPathType>> choices = getAllAttributes(propertyWrapper, pageBase);
if (!choices.isEmpty()) {
PrismValueWrapper<ItemPathType> wrapper = propertyWrapper.getObject();
if (wrapper.getParent().getParent().getParent().isSingleValue()) {
ItemWrapper parent = wrapper.getParent().getParent().getParent();
if (parent.isSingleValue()) {
ResourceObjectTypeDefinitionType objectType = getResourceObjectType(propertyWrapper.getObject());
if (objectType != null) {
List<ItemPathType> existingPaths = new ArrayList<>();
objectType.getAttribute().forEach(attributeMapping -> {
if (attributeMapping.getRef() != null
&& !attributeMapping.getRef().equivalent(wrapper.getRealValue())) {
existingPaths.add(attributeMapping.getRef());

if (attributeMapping.getRef() == null
|| attributeMapping.getRef().equivalent(wrapper.getRealValue())) {
return;
}

PrismContainer container =
attributeMapping.asPrismContainerValue().findContainer(parent.getItemName());
container = container != null ? container.clone() : null;
WebPrismUtil.cleanupEmptyContainers(container);

if (container != null && container.isEmpty()) {
return;
}

existingPaths.add(attributeMapping.getRef());
});
choices.removeIf(value -> {
for (ItemPathType existingPath : existingPaths) {
Expand Down Expand Up @@ -244,7 +258,6 @@ private List<DisplayableValue<ItemPathType>> getAllAttributes(
LOGGER.debug("Couldn't get complete resource schema", e);
}


if (schema == null) {
schema = ResourceDetailsModel.getResourceSchema(
propertyWrapper.getParent().findObjectWrapper(), pageBase);
Expand Down

0 comments on commit 4ddbbde

Please sign in to comment.