Skip to content

Commit

Permalink
consents tab fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Oct 12, 2017
1 parent 10ca1a8 commit ff1e28c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 88 deletions.
Expand Up @@ -20,24 +20,24 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import com.evolveum.midpoint.gui.api.component.TypedAssignablePanel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.web.component.data.column.CheckBoxColumn;
import com.evolveum.midpoint.web.session.UserProfileStorage.TableId;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;

public class GdprAssignmentPanel extends AbstractRoleAssignmentPanel {

Expand All @@ -51,11 +51,18 @@ public GdprAssignmentPanel(String id, IModel<ContainerWrapper<AssignmentType>> a
@Override
protected List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initColumns() {
List<IColumn<ContainerValueWrapper<AssignmentType>, String>> columns = new ArrayList<>();
columns.add(new PropertyColumn<>(createStringResource("AssignmentType.lifecycleState"), AssignmentType.F_LIFECYCLE_STATE.getLocalPart()));
columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>(createStringResource("AssignmentType.lifecycleState")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> item, String componentId, IModel<ContainerValueWrapper<AssignmentType>> rowModel) {
item.add(new Label(componentId, rowModel.getObject().getContainerValue().asContainerable().getLifecycleState()));
}
});

columns.add(new CheckBoxColumn<ContainerValueWrapper<AssignmentType>>(createStringResource("AssignmnetType.accepted")) {

private static final long serialVersionUID = 1L;

@Override
protected IModel<Boolean> getEnabled() {
return Model.of(Boolean.FALSE);
Expand Down Expand Up @@ -99,4 +106,12 @@ protected <T extends ObjectType> void addSelectedAssignmentsPerformed(AjaxReques
super.addSelectedAssignmentsPerformed(target, assignmentsList, SchemaConstants.ORG_CONSENT);
}

protected ObjectQuery createObjectQuery() {
return QueryBuilder.queryFor(AssignmentType.class, getParentPage().getPrismContext())
.block()
.item(new ItemPath(AssignmentType.F_TARGET_REF))
.ref(SchemaConstants.ORG_CONSENT)
.endBlock()
.build();
}
}
Expand Up @@ -50,7 +50,7 @@ public void populateItem(final Item<ICellPopulator<T>> cellItem, String componen
final IModel<T> rowModel) {
IModel<Boolean> selected = getCheckBoxValueModel(rowModel);

CheckBoxPanel check = new CheckBoxPanel(componentId, selected, enabled) {
CheckBoxPanel check = new CheckBoxPanel(componentId, selected, getEnabled()) {

@Override
public void onUpdate(AjaxRequestTarget target) {
Expand Down
Expand Up @@ -61,49 +61,14 @@ public FocusAssignmentsTabPanel(String id, Form<?> mainForm, LoadableModel<Objec
}

private void initLayout() {
ContainerWrapper<AssignmentType> assignmentsContainerWrapper = getObjectWrapper().findContainerWrapper(new ItemPath(FocusType.F_ASSIGNMENT));

WebMarkupContainer assignments = new WebMarkupContainer(ID_ASSIGNMENTS);
assignments.setOutputMarkupId(true);
add(assignments);

new ContainerWrapperFromObjectWrapperModel<>(getObjectWrapperModel(), new ItemPath(FocusType.F_ASSIGNMENT));
AbstractRoleAssignmentPanel panel = new AbstractRoleAssignmentPanel(ID_ASSIGNMENTS_PANEL, Model.of(assignmentsContainerWrapper));
AbstractRoleAssignmentPanel panel = new AbstractRoleAssignmentPanel(ID_ASSIGNMENTS_PANEL,
new ContainerWrapperFromObjectWrapperModel<>(getObjectWrapperModel(), new ItemPath(FocusType.F_ASSIGNMENT)));

// new AbstractReadOnlyModel<ContainerWrapper<AssignmentType>>() {
// @Override
// public ContainerWrapper<AssignmentType> getObject() {
// return assignmentsContainerWrapper;
// }
// });
assignments.add(panel);
}

private IModel<List<ContainerValueWrapper<AssignmentType>>> getAssignmentsListModel(ContainerWrapper<AssignmentType> assignmentsContainerWrapper){
return new IModel<List<ContainerValueWrapper<AssignmentType>>>() {
private static final long serialVersionUID = 1L;

@Override
public List<ContainerValueWrapper<AssignmentType>> getObject() {
List<ContainerValueWrapper<AssignmentType>> assignmentsList = new ArrayList<>();
assignmentsContainerWrapper.getValues().forEach(a -> {
if (!AssignmentsUtil.isPolicyRuleAssignment(a.getContainerValue().getValue()) && !AssignmentsUtil.isConsentAssignment(a.getContainerValue().getValue())
&& AssignmentsUtil.isAssignmentRelevant(a.getContainerValue().getValue())) {
assignmentsList.add(a);
}
});
// Collections.sort(consentsList);
return assignmentsList;
}

@Override
public void setObject(List<ContainerValueWrapper<AssignmentType>> object){
assignmentsContainerWrapper.getValues().clear();
assignmentsContainerWrapper.getValues().addAll(object);
}

@Override
public void detach(){};
};
}
}
Expand Up @@ -15,6 +15,7 @@
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.prism.ObjectWrapper;
import com.evolveum.midpoint.web.model.ContainerWrapperFromObjectWrapperModel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import org.apache.wicket.model.AbstractReadOnlyModel;
Expand All @@ -37,31 +38,10 @@ public FocusConsentTabPanel(String id, Form<ObjectWrapper<F>> mainForm, Loadable
}

private void initLayout() {
ContainerWrapper<AssignmentType> assignmentsContainerWrapper = getObjectWrapper().findContainerWrapper(new ItemPath(FocusType.F_ASSIGNMENT));

GdprAssignmentPanel consentRoles = new GdprAssignmentPanel(ID_ROLES, new AbstractReadOnlyModel<ContainerWrapper<AssignmentType>>() {
@Override
public ContainerWrapper<AssignmentType> getObject() {
return assignmentsContainerWrapper;
}
});
GdprAssignmentPanel consentRoles = new GdprAssignmentPanel(ID_ROLES,
new ContainerWrapperFromObjectWrapperModel<>(getObjectWrapperModel(), new ItemPath(FocusType.F_ASSIGNMENT)));
add(consentRoles);
consentRoles.setOutputMarkupId(true);

}

private IModel<List<ContainerValueWrapper<AssignmentType>>> getConsentsModel(ContainerWrapper<AssignmentType> assignmentsContainerWrapper){
List<ContainerValueWrapper<AssignmentType>> consentsList = new ArrayList<>();
assignmentsContainerWrapper.getValues().forEach(a -> {
if (isConsentAssignment(a.getContainerValue().getValue())){
consentsList.add(a);
}
});
// Collections.sort(consentsList);
return Model.ofList(consentsList);
}

private boolean isConsentAssignment(AssignmentType assignment) {
return assignment.getTargetRef() != null && QNameUtil.match(assignment.getTargetRef().getRelation(), SchemaConstants.ORG_CONSENT);
}
}
Expand Up @@ -29,6 +29,7 @@
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.prism.ObjectWrapper;
import com.evolveum.midpoint.web.model.ContainerWrapperFromObjectWrapperModel;
import com.evolveum.midpoint.web.page.admin.PageAdminFocus;
import com.evolveum.midpoint.web.page.admin.users.component.AssignmentPreviewDialog;
import com.evolveum.midpoint.web.page.admin.users.component.AssignmentsPreviewDto;
Expand Down Expand Up @@ -66,29 +67,13 @@ public FocusPolicyRulesTabPanel(String id, Form mainForm, LoadableModel<ObjectWr
}

private void initLayout() {
ContainerWrapper<AssignmentType> assignmentsContainerWrapper = getObjectWrapper().findContainerWrapper(new ItemPath(FocusType.F_ASSIGNMENT));

WebMarkupContainer policyRules = new WebMarkupContainer(ID_POLICY_RULES_CONTAINER);
policyRules.setOutputMarkupId(true);
add(policyRules);

PolicyRulesPanel policyRulesPanel = new PolicyRulesPanel(ID_POLICY_RULES_PANEL, new AbstractReadOnlyModel<ContainerWrapper<AssignmentType>>() {
@Override
public ContainerWrapper<AssignmentType> getObject() {
return assignmentsContainerWrapper;
}
});
policyRules.add(policyRulesPanel);
}
PolicyRulesPanel policyRulesPanel = new PolicyRulesPanel(ID_POLICY_RULES_PANEL,
new ContainerWrapperFromObjectWrapperModel<>(getObjectWrapperModel(), new ItemPath(FocusType.F_ASSIGNMENT)));

private IModel<List<ContainerValueWrapper<AssignmentType>>> getPolicyRulesModel(ContainerWrapper<AssignmentType> assignmentsContainerWrapper){
List<ContainerValueWrapper<AssignmentType>> policyRuleList = new ArrayList<>();
assignmentsContainerWrapper.getValues().forEach(a -> {
if (AssignmentsUtil.isPolicyRuleAssignment(a.getContainerValue().getValue())){
policyRuleList.add(a);
}
});
// Collections.sort(consentsList);
return Model.ofList(policyRuleList);
policyRules.add(policyRulesPanel);
}
}

0 comments on commit ff1e28c

Please sign in to comment.