Skip to content

Commit

Permalink
Fix minor typo after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tchrapovic committed Apr 23, 2024
1 parent 2e97257 commit 466be44
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 105 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
/*
* Copyright (C) 2010-2023 Evolveum and contributors
* Copyright (C) 2010-2024 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.page.admin.role.mining.page.wizard;

import com.evolveum.midpoint.common.mining.objects.analysis.RoleAnalysisAttributeDef;

import com.evolveum.midpoint.common.mining.utils.RoleAnalysisAttributeDefUtils;

import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.*;
import com.evolveum.midpoint.gui.impl.component.wizard.AbstractFormWizardStepPanel;
import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.AssignmentHolderDetailsModel;
import com.evolveum.midpoint.model.api.ModelService;
Expand All @@ -26,17 +19,15 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.web.component.prism.ItemVisibility;
import com.evolveum.midpoint.web.model.PrismContainerWrapperModel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import java.util.ArrayList;
import java.util.List;

public class RoleAnalysisSessionSimpleObjectsWizardPanel extends AbstractFormWizardStepPanel<AssignmentHolderDetailsModel<RoleAnalysisSessionType>> {
public class FilteringRoleAnalysisSessionOptionWizardPanel extends AbstractFormWizardStepPanel<AssignmentHolderDetailsModel<RoleAnalysisSessionType>> {

private static final String WORK_PANEL_TYPE = "rm-options";
private static final String WORK_PANEL_TYPE = "rm-option-filtering";

public RoleAnalysisSessionSimpleObjectsWizardPanel(AssignmentHolderDetailsModel<RoleAnalysisSessionType> model) {
public FilteringRoleAnalysisSessionOptionWizardPanel(AssignmentHolderDetailsModel<RoleAnalysisSessionType> model) {
super(model);

}
Expand All @@ -49,95 +40,42 @@ protected void onInitialize() {
LoadableModel<PrismObjectWrapper<RoleAnalysisSessionType>> objectWrapperModel = getDetailsModel().getObjectWrapperModel();
RoleAnalysisOptionType processModeObject = objectWrapperModel.getObject().getObject().asObjectable().getAnalysisOption();
RoleAnalysisProcessModeType processMode = processModeObject.getProcessMode();
RoleAnalysisCategoryType analysisCategory = processModeObject.getAnalysisCategory();

PrismContainerValueWrapper<AbstractAnalysisSessionOptionType> sessionType = getContainerFormModel().getObject()
.getValue();

Class<? extends ObjectType> propertiesClass = UserType.class;
Class<? extends ObjectType> membersClass = RoleType.class;
if (processMode.equals(RoleAnalysisProcessModeType.USER)) {
propertiesClass = RoleType.class;
membersClass = UserType.class;
}

Integer maxPropertiesObjects;
Integer maxMembersObjects;

ModelService modelService = getPageBase().getModelService();

maxPropertiesObjects = modelService.countObjects(propertiesClass, null, null, task, result);
maxMembersObjects = modelService.countObjects(membersClass, null, null, task, result);

if (maxPropertiesObjects == null) {
maxPropertiesObjects = 1000000;
}

if (maxMembersObjects == null) {
maxMembersObjects = 1000000;
}

double minMembersObject = maxMembersObjects < 10 ? 2.0 : 10;
double minObject = maxPropertiesObjects < 10 ? 1.0 : 10;
boolean isIndirect = analysisCategory.equals(RoleAnalysisCategoryType.OUTLIERS);
boolean isIndirect = false;

if (sessionType.getNewValue().getValue().isIsIndirect() == null) {
setNewValue(sessionType, AbstractAnalysisSessionOptionType.F_IS_INDIRECT, isIndirect);
}

if (sessionType.getNewValue().getValue().getSimilarityThreshold() == null) {
setNewValue(sessionType, AbstractAnalysisSessionOptionType.F_SIMILARITY_THRESHOLD, 80.0);
}

if (sessionType.getNewValue().getValue().getMinMembersCount() == null) {
setNewValue(sessionType, AbstractAnalysisSessionOptionType.F_MIN_MEMBERS_COUNT, minMembersObject);
}

if (sessionType.getNewValue().getValue().getPropertiesRange() == null
|| sessionType.getNewValue().getValue().getPropertiesRange().getMin() == null
|| sessionType.getNewValue().getValue().getPropertiesRange().getMax() == null) {
setNewValue(sessionType, AbstractAnalysisSessionOptionType.F_PROPERTIES_RANGE, new RangeType()
.min(minObject)
.max(maxPropertiesObjects.doubleValue()));
}
if (sessionType.getNewValue().getValue().getMinPropertiesOverlap() == null) {
setNewValue(sessionType, AbstractAnalysisSessionOptionType.F_MIN_PROPERTIES_OVERLAP, minObject);
}

AnalysisAttributeSettingType value = new AnalysisAttributeSettingType();
List<AnalysisAttributeRuleType> analysisAttributeRule = new ArrayList<>();
RoleAnalysisAttributeDef title = RoleAnalysisAttributeDefUtils.getTitle();
RoleAnalysisAttributeDef archetypeRef = RoleAnalysisAttributeDefUtils.getArchetypeRef();
RoleAnalysisAttributeDef locality = RoleAnalysisAttributeDefUtils.getLocality();
RoleAnalysisAttributeDef orgAssignment = RoleAnalysisAttributeDefUtils.getOrgAssignment();

analysisAttributeRule
.add(new AnalysisAttributeRuleType()
.attributeIdentifier(title.getDisplayValue())
.propertyType(UserType.COMPLEX_TYPE));
analysisAttributeRule
.add(new AnalysisAttributeRuleType()
.attributeIdentifier(archetypeRef.getDisplayValue())
.propertyType(UserType.COMPLEX_TYPE));
analysisAttributeRule
.add(new AnalysisAttributeRuleType()
.attributeIdentifier(locality.getDisplayValue())
.propertyType(UserType.COMPLEX_TYPE));
analysisAttributeRule
.add(new AnalysisAttributeRuleType()
.attributeIdentifier(orgAssignment.getDisplayValue())
.propertyType(UserType.COMPLEX_TYPE));
analysisAttributeRule
.add(new AnalysisAttributeRuleType()
.attributeIdentifier(archetypeRef.getDisplayValue())
.propertyType(RoleType.COMPLEX_TYPE));

value.getAnalysisAttributeRule().addAll(analysisAttributeRule);
setNewValue(sessionType, AbstractAnalysisSessionOptionType.F_ANALYSIS_ATTRIBUTE_SETTING, value);
setNewValue(sessionType, AbstractAnalysisSessionOptionType.F_MIN_PROPERTIES_OVERLAP, minObject);

} catch (SchemaException e) {
throw new RuntimeException("Failed to update values session clustering options values", e);
throw new RuntimeException("Failed to update values session filtering options values", e);
} catch (ObjectNotFoundException | SecurityViolationException | ConfigurationException |
CommunicationException | ExpressionEvaluationException e) {
throw new RuntimeException("Cloud not count objects", e);
Expand Down Expand Up @@ -169,13 +107,37 @@ protected IModel<? extends PrismContainerWrapper<AbstractAnalysisSessionOptionTy

protected boolean checkMandatory(ItemWrapper itemWrapper) {
ItemName itemName = itemWrapper.getItemName();
if (itemName.equivalent(AbstractAnalysisSessionOptionType.F_MIN_MEMBERS_COUNT)
|| itemName.equivalent(AbstractAnalysisSessionOptionType.F_MIN_PROPERTIES_OVERLAP)
|| itemName.equivalent(AbstractAnalysisSessionOptionType.F_SIMILARITY_THRESHOLD)
|| itemName.equivalent(AbstractAnalysisSessionOptionType.F_PROPERTIES_RANGE)) {
return true;
}
return itemWrapper.isMandatory();
return itemName.equivalent(AbstractAnalysisSessionOptionType.F_QUERY)
|| itemName.equivalent(AbstractAnalysisSessionOptionType.F_IS_INDIRECT)
|| itemName.equivalent(AbstractAnalysisSessionOptionType.F_PROPERTIES_RANGE);
}

@Override
protected ItemVisibilityHandler getVisibilityHandler() {
return wrapper -> {
ItemName itemName = wrapper.getItemName();
if (itemName.equals(AbstractAnalysisSessionOptionType.F_MIN_PROPERTIES_OVERLAP)
|| itemName.equals(AbstractAnalysisSessionOptionType.F_MIN_MEMBERS_COUNT)
|| itemName.equals(AbstractAnalysisSessionOptionType.F_SIMILARITY_THRESHOLD)
|| itemName.equals(AbstractAnalysisSessionOptionType.F_CLUSTERING_ATTRIBUTE_SETTING)
|| itemName.equals(AbstractAnalysisSessionOptionType.F_ANALYSIS_ATTRIBUTE_SETTING)) {
return ItemVisibility.HIDDEN;
}

if (itemName.equals(AbstractAnalysisSessionOptionType.F_IS_INDIRECT)) {
LoadableModel<PrismObjectWrapper<RoleAnalysisSessionType>> objectWrapperModel = getDetailsModel().getObjectWrapperModel();
RoleAnalysisOptionType option = objectWrapperModel.getObject().getObject().asObjectable().getAnalysisOption();
RoleAnalysisProcessModeType processMode = option.getProcessMode();
if (!processMode.equals(RoleAnalysisProcessModeType.USER)) {
return ItemVisibility.HIDDEN;
} else {
return ItemVisibility.AUTO;

}
}

return ItemVisibility.AUTO;
};
}

@Override
Expand All @@ -190,17 +152,17 @@ protected String getIcon() {

@Override
public IModel<String> getTitle() {
return createStringResource("PageRoleAnalysisSession.wizard.step.work.detection.option");
return createStringResource("PageRoleAnalysisSession.wizard.step.work.filtering.option");
}

@Override
protected IModel<String> getTextModel() {
return createStringResource("PageRoleAnalysisSession.wizard.step.work.detection.option.text");
return createStringResource("PageRoleAnalysisSession.wizard.step.work.filtering.option.text");
}

@Override
protected IModel<String> getSubTextModel() {
return createStringResource("PageRoleAnalysisSession.wizard.step.work.detection.option.subText");
return createStringResource("PageRoleAnalysisSession.wizard.step.work.filtering.option.subText");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
<xsd:annotation>
<xsd:documentation>
<p>
Object clustering options.
Session process options.

Specification of parameters utilized for establishing cluster
generation conditions, specifically pertaining to the role analysis clusters.
Expand All @@ -353,7 +353,7 @@
<xsd:annotation>
<xsd:documentation>
<p>
Object clustering options.
Session process options.

Specification of parameters utilized for establishing cluster
generation conditions, specifically pertaining to the role analysis clusters.
Expand Down Expand Up @@ -551,7 +551,7 @@
<xsd:complexType name="AbstractAnalysisSessionOptionType">
<xsd:annotation>
<xsd:documentation>
Object clustering options.
Session process options.

Specification of parameters utilized for establishing cluster
generation conditions, specifically pertaining to the RoleAnalysisClusterType.
Expand Down Expand Up @@ -631,7 +631,8 @@
<xsd:annotation>
<xsd:documentation>
<p>
Contains information about the attribute analysis settings.
Contains information about the clustering attribute analysis settings.
It allows for configuration of settings related to attribute analysis within clustering process.
</p>
</xsd:documentation>
</xsd:annotation>
Expand All @@ -641,7 +642,8 @@
<xsd:annotation>
<xsd:documentation>
<p>
Contains information about the attribute analysis settings.
Contains information about attribute analysis settings.
It allows for configuration of settings related to attribute analysis within the analysis process.
</p>
</xsd:documentation>
</xsd:annotation>
Expand Down Expand Up @@ -1486,7 +1488,7 @@
<xsd:complexType name="ClusteringAttributeSettingType">
<xsd:annotation>
<xsd:documentation>
<p>Contains information about matching rules for role analysis.</p>
<p>Contains information about matching rules for clustering process.</p>
<p>Matching rule presupposes the business logic for the comparison of objects.</p>
</xsd:documentation>
</xsd:annotation>
Expand All @@ -1509,19 +1511,13 @@
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:element name="clusteringAttributeSettingType" type="tns:ClusteringAttributeSettingType">
<xsd:annotation>
<xsd:documentation>
Settings for attribute clustering.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="clusteringAttributeSettingType" type="tns:ClusteringAttributeSettingType"/>


<xsd:complexType name="AnalysisAttributeSettingType">
<xsd:annotation>
<xsd:documentation>
<p>Contains information about matching rules for role analysis.</p>
<p>Contains information about matching rules for object analysis process.</p>
<p>Matching rule presupposes the business logic for the comparison of objects.</p>
</xsd:documentation>
</xsd:annotation>
Expand All @@ -1543,19 +1539,12 @@
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:element name="analysisAttributeSettingType" type="tns:AnalysisAttributeSettingType">
<xsd:annotation>
<xsd:documentation>
Settings for attribute analysis.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="analysisAttributeSettingType" type="tns:AnalysisAttributeSettingType"/>

<xsd:complexType name="ClusteringAttributeRuleType">
<xsd:annotation>
<xsd:documentation>
<p>Contains information about matching rules for role analysis.</p>
<p>Contains information about matching rules for clustering process.</p>
<p>Matching rule presupposes the business logic for the comparison of objects.</p>
</xsd:documentation>
<xsd:appinfo>
Expand Down Expand Up @@ -1803,7 +1792,17 @@
<xsd:complexType name="RoleAnalysisOptionType">
<xsd:annotation>
<xsd:documentation>
Contains information about outliers regarding cluster objects.
This complex type defines options for role analysis.
It encapsulates elements related to the process mode and analysis category,
providing flexibility in configuring the specific approach for analysis.

The "processMode" element determines the methodology used during the analysis,
considering either a role perspective or a user perspective.

The "analysisCategory" element specifies the mode for categorizing the analysis,
allowing for differentiation between standard and advanced approaches.

The "id" attribute uniquely identifies each role analysis option.
</xsd:documentation>
<xsd:appinfo>
<a:container>true</a:container>
Expand Down Expand Up @@ -1838,7 +1837,25 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="analysisCategory" type="tns:RoleAnalysisCategoryType" minOccurs="0"/>
<xsd:element name="analysisCategory" type="tns:RoleAnalysisCategoryType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<p>
Analysis category mode for role analysis. It determines the specific approach
or methodology used during the analysis.

We currently use an enum type to identify the mode (STANDARD MODE, ADVANCED MODE)
For Standard Mode (STANDARD):
This mode represents a basic approach to role analysis, focusing on fundamental criteria
and techniques for identifying and analyzing roles within the system.

For Advanced Mode (ADVANCED):
This mode represents a more sophisticated approach, often involving complex matching rules
and additional criteria for role identification and analysis.
</p>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>
Expand Down

0 comments on commit 466be44

Please sign in to comment.