Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jul 26, 2018
2 parents f43c704 + 9b9b1aa commit e39721d
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 32 deletions.
Expand Up @@ -15,29 +15,25 @@
*/
package com.evolveum.midpoint.gui.api.component;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.model.api.ModelInteractionService;
import com.evolveum.midpoint.model.api.RoleSelectionSpecification;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.schema.constants.RelationTypes;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior;
import com.evolveum.midpoint.web.component.input.RelationDropDownChoicePanel;
import com.evolveum.midpoint.web.security.SecurityUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AreaCategoryType;
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.commons.collections.map.HashedMap;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.model.Model;

import javax.xml.namespace.QName;
import java.util.*;
Expand Down Expand Up @@ -66,13 +62,7 @@ protected void initParametersPanel(Fragment parametersPanel){
relationContainer.setOutputMarkupId(true);
parametersPanel.add(relationContainer);

DropDownChoicePanel<RelationTypes> relationSelector = WebComponentUtil.createEnumPanel(RelationTypes.class, ID_RELATION,
WebComponentUtil.createReadonlyModelFromEnum(RelationTypes.class), Model.of(RelationTypes.MEMBER),
FocusTypeAssignmentPopupTabPanel.this, false);
relationSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
relationSelector.setOutputMarkupId(true);
relationSelector.setOutputMarkupPlaceholderTag(true);
relationContainer.add(relationSelector);
relationContainer.add(new RelationDropDownChoicePanel(ID_RELATION, null, AreaCategoryType.SELF_SERVICE));
}

@Override
Expand All @@ -88,16 +78,12 @@ protected Map<String, AssignmentType> getSelectedAssignmentsMap(){
}

public QName getRelationValue(){
DropDownChoicePanel<RelationTypes> relationPanel = getRelationDropDown();
RelationTypes relation = relationPanel.getModel().getObject();
if (relation == null) {
return SchemaConstants.ORG_DEFAULT;
}
return relation.getRelation();
RelationDropDownChoicePanel relationPanel = getRelationDropDown();
return relationPanel.getRelationValue();
}

private DropDownChoicePanel getRelationDropDown(){
return (DropDownChoicePanel)get(ID_PARAMETERS_PANEL).get(ID_RELATION_CONTAINER).get(ID_RELATION);
private RelationDropDownChoicePanel getRelationDropDown(){
return (RelationDropDownChoicePanel)get(ID_PARAMETERS_PANEL).get(ID_RELATION_CONTAINER).get(ID_RELATION);
}

@Override
Expand Down
Expand Up @@ -61,7 +61,11 @@ public RelationDropDownChoicePanel(String id, IModel<QName> model, AreaCategoryT
protected void onInitialize(){
super.onInitialize();

DropDownChoice<QName> input = new DropDownChoice<>(ID_INPUT, getModel(), Model.ofList(getChoicesList()), getRenderer());
List<QName> choicesList = getChoicesList();
QName defaultValue = choicesList.size() > 0 ? choicesList.get(0) : null;

DropDownChoice<QName> input = new DropDownChoice<>(ID_INPUT, getModel() == null ? Model.of(defaultValue) : getModel(),
Model.ofList(choicesList), getRenderer());
input.setNullValid(false);
input.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
add(input);
Expand Down Expand Up @@ -110,4 +114,8 @@ public String getIdValue(QName object, int index) {
}
};
}

public QName getRelationValue() {
return ((DropDownChoice<QName>) get(ID_INPUT)).getModelObject();
}
}
Expand Up @@ -125,14 +125,20 @@ private static void applyAdminGuiConfiguration(AdminGuiConfigurationType composi
composite.setFeedbackMessagesHook(adminGuiConfiguration.getFeedbackMessagesHook().clone());
}

if (adminGuiConfiguration.getAssignmentApprovalRequestLimit() != null) {
if (composite.getAssignmentApprovalRequestLimit() != null) {
if (adminGuiConfiguration.getRoleManagement() != null &&
adminGuiConfiguration.getRoleManagement().getAssignmentApprovalRequestLimit() != null) {
if (composite.getRoleManagement() != null && composite.getRoleManagement().getAssignmentApprovalRequestLimit() != null) {
// the greater value wins (so it is possible to give an exception to selected users)
composite.setAssignmentApprovalRequestLimit(Math.max(
adminGuiConfiguration.getAssignmentApprovalRequestLimit(),
composite.getAssignmentApprovalRequestLimit()));
Integer newValue = Math.max(
adminGuiConfiguration.getRoleManagement().getAssignmentApprovalRequestLimit(),
composite.getRoleManagement().getAssignmentApprovalRequestLimit());
composite.getRoleManagement().setAssignmentApprovalRequestLimit(newValue);
} else {
composite.setAssignmentApprovalRequestLimit(adminGuiConfiguration.getAssignmentApprovalRequestLimit());
if (composite.getRoleManagement() == null) {
composite.setRoleManagement(new AdminGuiConfigurationRoleManagementType());
}
composite.getRoleManagement().setAssignmentApprovalRequestLimit(
adminGuiConfiguration.getRoleManagement().getAssignmentApprovalRequestLimit());
}
}
}
Expand Down
Expand Up @@ -14066,7 +14066,6 @@
<xsd:annotation>
<xsd:documentation>
Administration GUI configuration.
Note: This complexType is NOT a container. We need to guarantee ordering of some sub-items (e.g. links)
</xsd:documentation>
<xsd:appinfo>
<a:container/>
Expand Down Expand Up @@ -14226,18 +14225,44 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="roleManagement" type="tns:AdminGuiConfigurationRoleManagementType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<p>
User-specific role management configuration.
</p>
</xsd:documentation>
<xsd:appinfo>
<a:since>3.7.3</a:since>
<a:since>3.8.1</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="AdminGuiConfigurationRoleManagementType">
<xsd:annotation>
<xsd:documentation>
Role management features that are potentially user-specific i.e. assigned as part of GUI configuration.
</xsd:documentation>
<xsd:appinfo>
<a:container/>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="assignmentApprovalRequestLimit" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<p>
How many assignment approvals (add/delete/modify) can be requested via any given operation?
EXPERIMENTAL. TEMPORARY. Just to validate the concept.
This parameter is checked by the model namely in the workflow hook. It should be eventually moved
to a more appropriate place, not related to the GUI.
</p>
</xsd:documentation>
<xsd:appinfo>
<a:since>3.7.3</a:since>
<a:since>3.8.1</a:since>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand Down
Expand Up @@ -116,7 +116,8 @@ void extractAssignmentBasedInstructions(ObjectTreeDeltas<?> objectTreeDeltas, Pr
int instructionsAdded = instructions.size() - instructionsBefore;
LOGGER.trace("Assignment-related approval instructions: {}", instructionsAdded);
AdminGuiConfigurationType adminGuiConfiguration = modelInteractionService.getAdminGuiConfiguration(ctx.taskFromModel, result);
Integer limit = adminGuiConfiguration.getAssignmentApprovalRequestLimit();
Integer limit = adminGuiConfiguration.getRoleManagement() != null ?
adminGuiConfiguration.getRoleManagement().getAssignmentApprovalRequestLimit() : null;
LOGGER.trace("Allowed approval instructions: {}", limit);
if (limit != null && instructionsAdded > limit) {
// TODO think about better error reporting
Expand Down

0 comments on commit e39721d

Please sign in to comment.