Skip to content

Commit

Permalink
induced entitlement panel fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Sep 2, 2019
1 parent 0d49aea commit f052877
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
Expand Up @@ -42,6 +42,7 @@
import com.evolveum.midpoint.web.util.ExpressionUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
import org.apache.commons.collections.CollectionUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.list.ListItem;
Expand Down Expand Up @@ -283,23 +284,19 @@ protected void onSelectPerformed(AjaxRequestTarget target, ShadowType object) {
try {
PrismContainerWrapper<ConstructionType> constructionContainerWrapper = ConstructionAssociationPanel.this.getModelObject();
PrismContainerWrapper<ResourceObjectAssociationType> associationWrapper = constructionContainerWrapper.findContainer(ConstructionType.F_ASSOCIATION);
PrismContainerValue newAssociation = associationWrapper.getItem().createNewValue();
List<PrismContainerValue<ResourceObjectAssociationType>> associationValueList = associationWrapper.getItem().getValues();
PrismContainerValue<ResourceObjectAssociationType> associationValue = null;
if (CollectionUtils.isEmpty(associationValueList)){
associationValue = associationWrapper.getItem().createNewValue();
} else {
associationValue = associationValueList.get(0);
}
ItemName associationRefPath = def.getName();
((ResourceObjectAssociationType) newAssociation.asContainerable())
((ResourceObjectAssociationType) associationValue.asContainerable())
.setRef(new ItemPathType(associationRefPath));
ExpressionType newAssociationExpression = ((ResourceObjectAssociationType) newAssociation.asContainerable()).beginOutbound().beginExpression();
ExpressionType newAssociationExpression = ((ResourceObjectAssociationType) associationValue.asContainerable()).beginOutbound().beginExpression();
ExpressionUtil.addShadowRefEvaluatorValue(newAssociationExpression, object.getOid(),
getPageBase().getPrismContext());
// ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
// Task task = getPageBase().createAnonymousTask("Adding new shadow");
// getPageBase().createValueWrapper(associationWrapper, newAssociation, ValueStatus.ADDED, null);
// ContainerValueWrapper<ResourceObjectAssociationType> valueWrapper =
// factory.createContainerValueWrapper(associationWrapper, newAssociation,
// associationWrapper.getObjectStatus(), ValueStatus.ADDED, associationWrapper.getPath(), task);

Task task = ConstructionAssociationPanel.this.getPageBase().createSimpleTask("Create new association value wrapper");
WrapperContext context = new WrapperContext(task, task.getResult());
associationWrapper.getValues().add(getPageBase().createValueWrapper(associationWrapper, newAssociation, ValueStatus.ADDED, context));
} catch (SchemaException ex){
LOGGER.error("Couldn't find association container, ", ex.getLocalizedMessage());
}
Expand Down
Expand Up @@ -19,6 +19,10 @@
import java.util.Arrays;
import java.util.List;

import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
Expand Down Expand Up @@ -49,11 +53,6 @@
import com.evolveum.midpoint.web.model.PrismContainerWrapperModel;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.web.util.ExpressionUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectAssociationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;

/**
* Created by honchar.
Expand Down Expand Up @@ -107,10 +106,24 @@ protected List<IColumn<PrismContainerValueWrapper<AssignmentType>, String>> init
@Override
public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<AssignmentType>>> item, String componentId,
final IModel<PrismContainerValueWrapper<AssignmentType>> rowModel) {



PrismContainerValueWrapper<AssignmentType> assignment = rowModel.getObject();
ExpressionType expressionType = null;
try {
PrismContainerWrapper<ResourceObjectAssociationType> associationWrapper = assignment.findContainer(ItemPath.create(AssignmentType.F_CONSTRUCTION, ConstructionType.F_ASSOCIATION));
List<PrismContainerValue<ResourceObjectAssociationType>> associationValueList = associationWrapper.getItem().getValues();
if (!CollectionUtils.isEmpty(associationValueList)){
PrismContainerValue<ResourceObjectAssociationType> associationValue = associationValueList.get(0);
ResourceObjectAssociationType association = associationValue.getRealValue();
MappingType outbound = association != null ? association.getOutbound() : null;
expressionType = outbound != null ? outbound.getExpression() : null;
}
} catch (SchemaException ex){
LOGGER.error("Unable to find association container in the construction, ", ex.getLocalizedMessage());
}

List<ShadowType> shadowsList = WebComponentUtil.loadReferencedObjectList(ExpressionUtil.getShadowRefValue(WebComponentUtil.getAssociationExpression(rowModel.getObject(), getPageBase()),
List<ShadowType> shadowsList = WebComponentUtil.loadReferencedObjectList(ExpressionUtil.getShadowRefValue(
expressionType,
InducedEntitlementsPanel.this.getPageBase().getPrismContext()),
OPERATION_LOAD_SHADOW_OBJECT, InducedEntitlementsPanel.this.getPageBase());

Expand Down

0 comments on commit f052877

Please sign in to comment.