Skip to content

Commit

Permalink
focus mapping assignments tab
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jan 27, 2019
1 parent 39cff8a commit 36cefc8
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 9 deletions.
Expand Up @@ -1718,6 +1718,9 @@ public static <T extends ObjectType> String createDefaultBlackIcon(QName objectT
return GuiStyleConstants.CLASS_POLICY_RULES_ICON;
} else if (QNameUtil.match(SystemConfigurationType.COMPLEX_TYPE, objectType)) {
return GuiStyleConstants.CLASS_SYSTEM_CONFIGURATION_ICON;
} else if (QNameUtil.match(MappingType.COMPLEX_TYPE, objectType)) {
//TODO fix icon style for mapping type
return "";
} else {
return "";
}
Expand Down
Expand Up @@ -120,13 +120,7 @@ protected void initPaging() {

@Override
protected boolean enableActionNewObject() {
try {
return getParentPage().isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ASSIGN_ACTION_URI,
AuthorizationPhaseType.REQUEST, getFocusObject(),
null, null, null);
} catch (Exception ex){
return WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ASSIGN_ACTION_URI);
}
return isNewObjectButtonVisible(getFocusObject());
}

@Override
Expand Down Expand Up @@ -295,6 +289,16 @@ protected List<ContainerValueWrapper<AssignmentType>> customPostSearch(List<Cont
return assignments;
}

protected boolean isNewObjectButtonVisible(PrismObject focusObject){
try {
return getParentPage().isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ASSIGN_ACTION_URI,
AuthorizationPhaseType.REQUEST, focusObject,
null, null, null);
} catch (Exception ex){
return WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ASSIGN_ACTION_URI);
}
}

protected ObjectQuery createObjectQuery(){
Collection<QName> delegationRelations = getParentPage().getRelationRegistry()
.getAllRelationsFor(RelationKindType.DELEGATION);
Expand Down Expand Up @@ -361,7 +365,7 @@ private DisplayType getRelationDisplayType(AssignmentObjectRelation assignmentTa
return null;
}

private List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initBasicColumns() {
protected List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initBasicColumns() {
List<IColumn<ContainerValueWrapper<AssignmentType>, String>> columns = new ArrayList<>();

columns.add(new CheckBoxHeaderColumn<>());
Expand Down Expand Up @@ -842,7 +846,9 @@ public void onClick(AjaxRequestTarget target) {
PrismReferenceValue refValue = (PrismReferenceValue)refWrapper.getValue();
ObjectReferenceType ort = new ObjectReferenceType();
ort.setupReferenceValue(refValue);
WebComponentUtil.dispatchToObjectDetailsPage(ort, AssignmentPanel.this, false);
if (!StringUtils.isEmpty(ort.getOid())) {
WebComponentUtil.dispatchToObjectDetailsPage(ort, AssignmentPanel.this, false);
}
}
}
};
Expand Down
Expand Up @@ -407,6 +407,9 @@ public static QName getTargetType(AssignmentType assignment) {
if (assignment.getPersonaConstruction() != null) {
return PersonaConstructionType.COMPLEX_TYPE;
}
if (assignment.getFocusMappings() != null){
return MappingType.COMPLEX_TYPE;
}
// account assignment through account construction
return ConstructionType.COMPLEX_TYPE;

Expand Down
Expand Up @@ -25,6 +25,7 @@
<div wicket:id="resourceTypeAssignments" />
<div wicket:id="policyRuleTypeAssignments" />
<div wicket:id="entitlementAssignments" />
<div wicket:id="focusMappingAssignments" />
<!--<div wicket:id="consentAssignments" />-->
</div>
<div wicket:id="assignmentsPanel"/>
Expand Down
Expand Up @@ -17,20 +17,35 @@

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.data.column.IconColumn;
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.util.EnableBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
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.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
Expand All @@ -47,6 +62,7 @@ public class SwitchAssignmentTypePanel extends BasePanel<ContainerWrapper<Assign
private static final String ID_RESOURCE_TYPE_ASSIGNMENTS = "resourceTypeAssignments";
private static final String ID_POLICY_RULE_TYPE_ASSIGNMENTS = "policyRuleTypeAssignments";
private static final String ID_ENTITLEMENT_ASSIGNMENTS = "entitlementAssignments";
private static final String ID_FOCUS_MAPPING_ASSIGNMENTS = "focusMappingAssignments";
private static final String ID_CONSENT_ASSIGNMENTS = "consentAssignments";
private static final String ID_ASSIGNMENTS = "assignmentsPanel";

Expand Down Expand Up @@ -282,6 +298,82 @@ protected void cancelAssignmentDetailsPerformed(AjaxRequestTarget target) {
(getModelObject().getObjectWrapper().getObject().asObjectable() instanceof AbstractRoleType) && isInducement()));
buttonsContainer.add(entitlementAssignmentsButton);

AjaxButton focusMappingAssignmentsButton = new AjaxButton(ID_FOCUS_MAPPING_ASSIGNMENTS, createStringResource("AssignmentType.focusMappings")) {
private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
AssignmentPanel assignmentPanel =
new AssignmentPanel(ID_ASSIGNMENTS, SwitchAssignmentTypePanel.this.getModel()) {
private static final long serialVersionUID = 1L;

//TODO may be we will need FocusMappingsAssignmentsPanel later
@Override
protected List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initBasicColumns() {
List<IColumn<ContainerValueWrapper<AssignmentType>, String>> columns = new ArrayList<>();

columns.add(new IconColumn<ContainerValueWrapper<AssignmentType>>(Model.of("")) {

private static final long serialVersionUID = 1L;

@Override
protected IModel<String> createIconModel(IModel<ContainerValueWrapper<AssignmentType>> rowModel) {
return new IModel<String>() {

private static final long serialVersionUID = 1L;

@Override
public String getObject() {
return WebComponentUtil.createDefaultBlackIcon(AssignmentsUtil.getTargetType(rowModel.getObject().getContainerValue().asContainerable()));
}
};
}

});

columns.add(new AbstractColumn<ContainerValueWrapper<AssignmentType>, String>(createStringResource("PolicyRulesPanel.nameColumn")){
private static final long serialVersionUID = 1L;

@Override
public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentType>>> cellItem,
String componentId, final IModel<ContainerValueWrapper<AssignmentType>> rowModel) {
String name = AssignmentsUtil.getName(rowModel.getObject(), getParentPage());
if (StringUtils.isBlank(name)) {
name = createStringResource("AssignmentPanel.noName").getString();
}
cellItem.add(new Label(componentId, Model.of(name)));
}
});
return columns;
}

@Override
protected ObjectQuery createObjectQuery(){
ObjectQuery query = super.createObjectQuery();
ObjectQuery focusMappingsQuery = SwitchAssignmentTypePanel.this.getPageBase().getPrismContext()
.queryFor(AssignmentType.class)
.exists(AssignmentType.F_FOCUS_MAPPINGS)
.build();
query.addFilter(focusMappingsQuery.getFilter());
return query;
}

@Override
protected boolean isNewObjectButtonVisible(PrismObject focusObject){
return false;
}

};
assignmentPanel.setOutputMarkupId(true);
switchAssignmentTypePerformed(target, assignmentPanel, ID_FOCUS_MAPPING_ASSIGNMENTS);
}
};
focusMappingAssignmentsButton.add(AttributeAppender.append("class", getButtonStyleModel(ID_FOCUS_MAPPING_ASSIGNMENTS)));
focusMappingAssignmentsButton.setOutputMarkupId(true);
focusMappingAssignmentsButton.add(new VisibleBehaviour(() ->
getModelObject().getObjectWrapper().getObject().asObjectable() instanceof AbstractRoleType));
buttonsContainer.add(focusMappingAssignmentsButton);

//GDPR feature.. temporary disabled MID-4281
// AjaxButton consentsButton = new AjaxButton(ID_CONSENT_ASSIGNMENTS, createStringResource("FocusType.consents")) {
// private static final long serialVersionUID = 1L;
Expand Down
Expand Up @@ -119,6 +119,7 @@ AssignmentType.target.help=Target of assignment or inducement. This is the role,
AssignmentType.focusType=Focus type
AssignmentType.focusType.help=Type of focal object that this assignment/inducement applies to. E.g UserType, RoleType, OrgType, ...
AssignmentType.tenant=Tenant
AssignmentType.focusMappings=Focus mappings
AssignmentType.tenantReference=Tenant reference
AssignmentType.tenantReference.help=Reference to the tenant to which this assignment is associated with. This is an argument to the target of this assignment. E.g. is if frequently used to parametrize the role which is assigned by this assignment.
AssignmentType.orgReference=Organization reference
Expand Down

0 comments on commit 36cefc8

Please sign in to comment.