Skip to content

Commit

Permalink
Revert disable outlier components
Browse files Browse the repository at this point in the history
  • Loading branch information
tchrapovic committed Apr 23, 2024
1 parent 466be44 commit c92be56
Show file tree
Hide file tree
Showing 43 changed files with 1,611 additions and 38 deletions.
1 change: 1 addition & 0 deletions config/sql/native/postgres-audit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ DO $$ BEGIN
'ROLE',
'ROLE_ANALYSIS_CLUSTER',
'ROLE_ANALYSIS_SESSION',
'ROLE_ANALYSIS_OUTLIER',
'SECURITY_POLICY',
'SEQUENCE',
'SERVICE',
Expand Down
27 changes: 27 additions & 0 deletions config/sql/native/postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ CREATE TYPE ObjectType AS ENUM (
'ROLE',
'ROLE_ANALYSIS_CLUSTER',
'ROLE_ANALYSIS_SESSION',
'ROLE_ANALYSIS_OUTLIER',
'SCHEMA',
'SECURITY_POLICY',
'SEQUENCE',
Expand Down Expand Up @@ -1284,6 +1285,32 @@ CREATE TRIGGER m_role_analysis_session_update_tr BEFORE UPDATE ON m_role_analysi
CREATE TRIGGER m_role_analysis_session_oid_delete_tr AFTER DELETE ON m_role_analysis_session
FOR EACH ROW EXECUTE FUNCTION delete_object_oid();

CREATE TABLE m_role_analysis_outlier (
oid UUID NOT NULL PRIMARY KEY REFERENCES m_object_oid(oid),
objectType ObjectType GENERATED ALWAYS AS ('ROLE_ANALYSIS_OUTLIER') STORED
CHECK (objectType = 'ROLE_ANALYSIS_OUTLIER'),
targetObjectRefTargetOid UUID,
targetObjectRefTargetType ObjectType,
targetObjectRefRelationId INTEGER REFERENCES m_uri(id),
targetClusterRefTargetOid UUID,
targetClusterRefTargetType ObjectType,
targetClusterRefRelationId INTEGER REFERENCES m_uri(id)
)
INHERITS (m_assignment_holder);

CREATE TRIGGER m_role_analysis_outlier_oid_insert_tr BEFORE INSERT ON m_role_analysis_outlier
FOR EACH ROW EXECUTE FUNCTION insert_object_oid();
CREATE TRIGGER m_role_analysis_outlier_update_tr BEFORE UPDATE ON m_role_analysis_outlier
FOR EACH ROW EXECUTE FUNCTION before_update_object();
CREATE TRIGGER m_role_analysis_outlier_oid_delete_tr AFTER DELETE ON m_role_analysis_outlier
FOR EACH ROW EXECUTE FUNCTION delete_object_oid();

CREATE INDEX m_role_analysis_outlier_targetObjectRefTargetOid_idx ON m_role_analysis_outlier (targetObjectRefTargetOid);
CREATE INDEX m_role_analysis_outlier_targetObjectRefTargetType_idx ON m_role_analysis_outlier (targetObjectRefTargetType);
CREATE INDEX m_role_analysis_outlier_targetObjectRefRelationId_idx ON m_role_analysis_outlier (targetObjectRefRelationId);
CREATE INDEX m_role_analysis_outlier_targetClusterRefTargetOid_idx ON m_role_analysis_outlier (targetClusterRefTargetOid);
CREATE INDEX m_role_analysis_outlier_targetClusterRefTargetType_idx ON m_role_analysis_outlier (targetClusterRefTargetType);
CREATE INDEX m_role_analysis_outlier_targetClusterRefRelationId_idx ON m_role_analysis_outlier (targetClusterRefRelationId);


-- Represents LookupTableType, see https://docs.evolveum.com/midpoint/reference/misc/lookup-tables/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,6 @@ public class GuiStyleConstants {
public static final String CLASS_MARK = "fa-solid fa-tag";

public static final String CLASS_AUDIT = "fa-solid fa-magnifying-glass-chart";

public static final String CLASS_ICON_OUTLIER = "fa fa-user-circle";
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,19 @@ public IModel<List<ContainerPanelConfigurationType>> getPanelConfigurations() {
return super.getPanelConfigurations();
}

List<ContainerPanelConfigurationType> object = panelConfigurations.getObject();
for (ContainerPanelConfigurationType containerPanelConfigurationType : object) {
if (containerPanelConfigurationType.getIdentifier().equals("outlierPanel")) {
if (!analysisCategory.equals(RoleAnalysisCategoryType.OUTLIERS)) {
containerPanelConfigurationType.setVisibility(UserInterfaceElementVisibilityType.HIDDEN);
}
}else if(containerPanelConfigurationType.getIdentifier().equals("detectedPattern")){
if (analysisCategory.equals(RoleAnalysisCategoryType.OUTLIERS)) {
containerPanelConfigurationType.setVisibility(UserInterfaceElementVisibilityType.HIDDEN);
}
}
}

return panelConfigurations;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*
* Copyright (C) 2010-2023 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.page;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.string.StringValue;

import com.evolveum.midpoint.authentication.api.authorization.AuthorizationAction;
import com.evolveum.midpoint.authentication.api.authorization.PageDescriptor;
import com.evolveum.midpoint.authentication.api.authorization.Url;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.impl.component.wizard.AbstractWizardPanel;
import com.evolveum.midpoint.gui.impl.component.wizard.WizardPanelHelper;
import com.evolveum.midpoint.gui.impl.error.ErrorPanel;
import com.evolveum.midpoint.gui.impl.page.admin.DetailsFragment;
import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.AssignmentHolderDetailsModel;
import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.PageAssignmentHolderDetails;
import com.evolveum.midpoint.gui.impl.page.admin.role.mining.page.panel.session.OutlierSummaryPanel;
import com.evolveum.midpoint.gui.impl.page.admin.role.mining.page.wizard.RoleAnalysisSessionWizardPanel;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleAnalysisOutlierType;

//TODO correct authorizations
@PageDescriptor(
urls = {
@Url(mountUrl = "/admin/roleAnalysisOutlier", matchUrlForSecurity = "/admin/roleAnalysisOutlier")
},
encoder = OnePageParameterEncoder.class, action = {
@AuthorizationAction(actionUri = AuthorizationConstants.AUTZ_UI_ROLE_ANALYSIS_ALL_URL,
label = "PageRoleAnalysis.auth.roleAnalysisAll.label",
description = "PageRoleAnalysis.auth.roleAnalysisAll.description"),
@AuthorizationAction(actionUri = AuthorizationConstants.AUTZ_UI_ROLE_ANALYSIS_SESSION_URL,
label = "PageRoleAnalysis.auth.roleAnalysisSession.label",
description = "PageRoleAnalysis.auth.roleAnalysisSession.description")
})

public class PageRoleAnalysisOutlier extends PageAssignmentHolderDetails<RoleAnalysisOutlierType, AssignmentHolderDetailsModel<RoleAnalysisOutlierType>> {

private static final String DOT_CLASS = PageRoleAnalysisOutlier.class.getName() + ".";
private static final String OP_DELETE_CLEANUP = DOT_CLASS + "deleteCleanup";
private static final String OP_PERFORM_CLUSTERING = DOT_CLASS + "performClustering";
public static final String PARAM_IS_WIZARD = "isWizard";
boolean isWizardPanel = false;
private static final Trace LOGGER = TraceManager.getTrace(RoleAnalysisOutlierType.class);

public boolean isWizardPanel() {
StringValue stringValue = getPageParameters().get(PARAM_IS_WIZARD);
if (stringValue != null) {
if ("true".equalsIgnoreCase(stringValue.toString())
|| "false".equalsIgnoreCase(stringValue.toString())) {
this.isWizardPanel = getPageParameters().get(PARAM_IS_WIZARD).toBoolean();
} else {
getPageParameters().remove(PARAM_IS_WIZARD);
}
}
return isWizardPanel;
}

public PageRoleAnalysisOutlier() {
super();
}

@Override
public void savePerformed(AjaxRequestTarget target) {
super.savePerformed(target);
}

@Override
protected void onInitialize() {
super.onInitialize();
}

@Override
public Class<RoleAnalysisOutlierType> getType() {
return RoleAnalysisOutlierType.class;
}

@Override
protected Panel createSummaryPanel(String id, IModel<RoleAnalysisOutlierType> summaryModel) {
return new OutlierSummaryPanel(id, summaryModel, null);
}

public PageBase getPageBase() {
return ((PageBase) getPage());
}

@Override
protected IModel<String> createPageTitleModel() {
return createStringResource("RoleMining.page.cluster.title");
}

protected boolean canShowWizard() {
return isWizardPanel();
}

protected DetailsFragment createDetailsFragment() {
if (!isNativeRepo()) {
return new DetailsFragment(ID_DETAILS_VIEW, ID_TEMPLATE_VIEW, PageRoleAnalysisOutlier.this) {
@Override
protected void initFragmentLayout() {
add(new ErrorPanel(ID_TEMPLATE,
createStringResource("RoleAnalysis.menu.nonNativeRepositoryWarning")));
}
};
}

if (canShowWizard()) {
setShowedByWizard(true);
getObjectDetailsModels().reset();
return createRoleWizardFragment(RoleAnalysisSessionWizardPanel.class);
}

return super.createDetailsFragment();
}

@Override
protected AssignmentHolderDetailsModel<RoleAnalysisOutlierType> createObjectDetailsModels(PrismObject<RoleAnalysisOutlierType> object) {
return super.createObjectDetailsModels(object);
}

@Override
protected void onBackPerform(AjaxRequestTarget target) {
((PageBase) getPage()).navigateToNext(PageRoleAnalysis.class);
}

private DetailsFragment createRoleWizardFragment(Class<? extends AbstractWizardPanel> clazz) {

return new DetailsFragment(ID_DETAILS_VIEW, ID_TEMPLATE_VIEW, PageRoleAnalysisOutlier.this) {
@Override
protected void initFragmentLayout() {
try {
Constructor<? extends AbstractWizardPanel> constructor = clazz.getConstructor(String.class, WizardPanelHelper.class);
AbstractWizardPanel wizard = constructor.newInstance(ID_TEMPLATE, createObjectWizardPanelHelper());
add(wizard);
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException |
InvocationTargetException ignored) {

}
}
};

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ public IModel<List<ContainerPanelConfigurationType>> getPanelConfigurations() {
List<ContainerPanelConfigurationType> object = panelConfigurations.getObject();
for (ContainerPanelConfigurationType containerPanelConfigurationType : object) {

if (containerPanelConfigurationType.getIdentifier().equals("matchingOptions")) {
if (!analysisCategory.equals(RoleAnalysisCategoryType.ADVANCED)) {
if (containerPanelConfigurationType.getIdentifier().equals("topDetectedPattern")) {
if (analysisCategory.equals(RoleAnalysisCategoryType.OUTLIERS)) {
containerPanelConfigurationType.setVisibility(UserInterfaceElementVisibilityType.HIDDEN);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--
~ Copyright (C) 2010-2023 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>

<div class="row">
<div class="col-md-12">
<div wicket:id="container">
<div wicket:id="panelId" />
</div>
</div>
</div>

</wicket:panel>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (C) 2010-2023 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.panel.cluster;

import org.apache.wicket.markup.html.WebMarkupContainer;

import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.impl.page.admin.AbstractObjectMainPanel;
import com.evolveum.midpoint.gui.impl.page.admin.ObjectDetailsModels;
import com.evolveum.midpoint.gui.impl.page.admin.role.mining.tables.RoleAnalysisDetectedPatternTable;
import com.evolveum.midpoint.gui.impl.page.admin.role.mining.tables.RoleAnalysisOutlierPropertyTable;
import com.evolveum.midpoint.web.application.PanelDisplay;
import com.evolveum.midpoint.web.application.PanelInstance;
import com.evolveum.midpoint.web.application.PanelType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleAnalysisOutlierType;

@PanelType(name = "outlierProperty")
@PanelInstance(
identifier = "outlierProperty",
applicableForType = RoleAnalysisOutlierType.class,
display = @PanelDisplay(
label = "RoleAnalysisOutlierType.outlierProperty",
icon = GuiStyleConstants.CLASS_ICON_OUTLIER,
order = 70
)
)
public class OutlierPropertyPanel extends AbstractObjectMainPanel<RoleAnalysisOutlierType, ObjectDetailsModels<RoleAnalysisOutlierType>> {

private static final String ID_CONTAINER = "container";
private static final String ID_PANEL = "panelId";

public OutlierPropertyPanel(String id, ObjectDetailsModels<RoleAnalysisOutlierType> model,
ContainerPanelConfigurationType config) {
super(id, model, config);
}

@Override
protected void initLayout() {

WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
container.setOutputMarkupId(true);
add(container);

RoleAnalysisOutlierType objectType = getObjectDetailsModels().getObjectType();
RoleAnalysisOutlierPropertyTable components = new RoleAnalysisOutlierPropertyTable(ID_PANEL, objectType);
container.add(components);
}

public PageBase getPageBase() {
return ((PageBase) getPage());
}

protected RoleAnalysisDetectedPatternTable getTable() {
return (RoleAnalysisDetectedPatternTable) get(((PageBase) getPage()).createComponentPath(ID_CONTAINER, ID_PANEL));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--
~ Copyright (C) 2010-2023 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>

<div class="row">
<div class="col-md-12">
<div wicket:id="container">
<div wicket:id="panelId" />
</div>
</div>
</div>

</wicket:panel>
</html>

0 comments on commit c92be56

Please sign in to comment.