Skip to content

Commit

Permalink
fixes for policy rules tab panel
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Oct 4, 2017
1 parent e124438 commit d818a79
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
Expand Up @@ -153,22 +153,15 @@ protected <T extends ObjectType> void addSelectedAssignmentsPerformed(AjaxReques
}
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
for (T object : assignmentsList){
// ContainerWrapper<AssignmentType> newAssignmentContainer = factory.createContainerWrapper(object.asPrismContainerValue().getContainer(),
// ContainerStatus.ADDING, new ItemPath(FocusType.F_ASSIGNMENT));

ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(object.getOid());
ort.setRelation(SchemaConstants.ORG_DEFAULT);
ort.setType(WebComponentUtil.classToQName(getPageBase().getPrismContext(), object.getClass()));


PrismContainerValue<AssignmentType> newAssignment = getModelObject().getItem().createNewValue();
newAssignment.asContainerable().setTargetRef(ort);

PrismContainerValue<AssignmentType> newAssignment = getModelObject().getItem().createNewValue();
newAssignment.asContainerable().setTargetRef(ort);

// AssignmentType assignment = new AssignmentType();
// assignment.setTargetRef(ort);
// assignment.asPrismContainerValue().setParent(getModelObject().getItem());

ContainerValueWrapper<AssignmentType> valueWrapper = factory.createContainerValueWrapper(getModelObject(), newAssignment,
ValueStatus.ADDED, new ItemPath(FocusType.F_ASSIGNMENT));
Expand Down
Expand Up @@ -24,6 +24,7 @@
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.web.component.prism.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down
Expand Up @@ -18,10 +18,13 @@
import java.util.ArrayList;
import java.util.List;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapperFactory;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.page.admin.users.dto.UserDtoStatus;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
Expand Down Expand Up @@ -143,29 +146,23 @@ private AssignmentsTabStorage getPolicyRulesTabStorage(){

@Override
protected void newAssignmentClickPerformed(AjaxRequestTarget target) {
// TODO Auto-generated method stub
ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());

AssignmentType assignment = new AssignmentType();
PrismContainerValue<AssignmentType> newAssignment = getModelObject().getItem().createNewValue();
newAssignment.asContainerable().setPolicyRule(new PolicyRuleType());

PolicyRuleType policyRule = new PolicyRuleType(getPageBase().getPrismContext());
policyRule.setDescription("");
assignment.setPolicyRule(policyRule);

// ContainerValueWrapper<AssignmentType> newAssignmentContainerWrapper = assignmentContainerWrapper.createItem(false);
// newAssignmentContainerWrapper.setStatus(ValueStatus.ADDED);
// newAssignmentContainerWrapper.getContainerValue().getValue().setupContainerValue(assignment.asPrismContainerValue());
// getModelObject().add(newAssignmentContainerWrapper);
target.add(getAssignmentContainer());
ContainerValueWrapper<AssignmentType> valueWrapper = factory.createContainerValueWrapper(getModelObject(), newAssignment,
ValueStatus.ADDED, new ItemPath(FocusType.F_ASSIGNMENT));
getModelObject().getValues().add(valueWrapper);

refreshTable(target);
}

@Override
protected ObjectQuery createObjectQuery() {
return QueryBuilder.queryFor(AssignmentType.class, getParentPage().getPrismContext())
.block()
.not()
.item(getModelObject().getItemDefinition(), new ItemPath(AssignmentType.F_POLICY_RULE))
.isNull()
.endBlock()
.exists(AssignmentType.F_POLICY_RULE)
.build();
}

Expand Down
Expand Up @@ -87,7 +87,7 @@ public ExistsFilter cloneEmpty() {
@Override
public boolean match(PrismContainerValue value, MatchingRuleRegistry matchingRuleRegistry) throws SchemaException {
Item itemToFind = value.findItem(fullPath);
if (itemToFind == null || itemToFind.isEmpty()) {
if (itemToFind == null || itemToFind.getValues().isEmpty()) {
return false;
}
if (!(itemToFind instanceof PrismContainer)) {
Expand Down

0 comments on commit d818a79

Please sign in to comment.