-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for creating business role from detected pattern
- Loading branch information
1 parent
558bc9a
commit c0dc226
Showing
2 changed files
with
276 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
.../java/com/evolveum/midpoint/gui/impl/page/admin/role/mining/panel/MigratedRolesPanel.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="panel" /> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</wicket:panel> | ||
</html> |
255 changes: 255 additions & 0 deletions
255
.../java/com/evolveum/midpoint/gui/impl/page/admin/role/mining/panel/MigratedRolesPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,255 @@ | ||
/* | ||
* 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.panel; | ||
|
||
import java.io.Serial; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
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.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 org.apache.wicket.model.util.ListModel; | ||
import org.apache.wicket.request.mapper.parameter.PageParameters; | ||
|
||
import com.evolveum.midpoint.gui.api.GuiStyleConstants; | ||
import com.evolveum.midpoint.gui.api.page.PageBase; | ||
import com.evolveum.midpoint.gui.api.util.GuiDisplayTypeUtil; | ||
import com.evolveum.midpoint.gui.api.util.WebComponentUtil; | ||
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.PageRole; | ||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
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.web.component.data.BoxedTablePanel; | ||
import com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel; | ||
import com.evolveum.midpoint.web.component.data.column.IconColumn; | ||
import com.evolveum.midpoint.web.component.util.RoleMiningProvider; | ||
import com.evolveum.midpoint.web.util.OnePageParameterEncoder; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.*; | ||
|
||
import static com.evolveum.midpoint.gui.impl.page.admin.role.mining.utils.ClusterObjectUtils.*; | ||
|
||
@PanelType(name = "migratedRoles") | ||
@PanelInstance( | ||
identifier = "migratedRoles", | ||
applicableForType = RoleAnalysisClusterType.class, | ||
display = @PanelDisplay( | ||
label = "RoleAnalysisClusterType.migratedRoles", | ||
icon = GuiStyleConstants.CLASS_CIRCLE_FULL, | ||
order = 2 | ||
) | ||
) | ||
public class MigratedRolesPanel extends AbstractObjectMainPanel<RoleAnalysisClusterType, ObjectDetailsModels<RoleAnalysisClusterType>> { | ||
|
||
private static final String ID_CONTAINER = "container"; | ||
private static final String ID_PANEL = "panel"; | ||
|
||
OperationResult operationResult = new OperationResult("LoadMigratedRoles"); | ||
|
||
public MigratedRolesPanel(String id, ObjectDetailsModels<RoleAnalysisClusterType> model, | ||
ContainerPanelConfigurationType config) { | ||
super(id, model, config); | ||
} | ||
|
||
@Override | ||
protected void initLayout() { | ||
|
||
RoleAnalysisClusterType cluster = getObjectDetailsModels().getObjectType(); | ||
List<ObjectReferenceType> reductionObject = cluster.getReductionObject(); | ||
List<RoleType> roles = new ArrayList<>(); | ||
for (ObjectReferenceType objectReferenceType : reductionObject) { | ||
String oid = objectReferenceType.getOid(); | ||
if (oid != null) { | ||
PrismObject<RoleType> roleTypeObject = getRoleTypeObject(getPageBase(), oid, operationResult); | ||
if (roleTypeObject != null) { | ||
roles.add(roleTypeObject.asObjectable()); | ||
} | ||
} | ||
} | ||
|
||
WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER); | ||
container.setOutputMarkupId(true); | ||
add(container); | ||
|
||
RoleMiningProvider<RoleType> provider = new RoleMiningProvider<>( | ||
this, new ListModel<>(roles) { | ||
|
||
@Serial private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public void setObject(List<RoleType> object) { | ||
super.setObject(roles); | ||
} | ||
}, false); | ||
|
||
BoxedTablePanel<RoleType> panel = generateTable(provider); | ||
container.add(panel); | ||
|
||
} | ||
|
||
private BoxedTablePanel<RoleType> generateTable(RoleMiningProvider<RoleType> provider) { | ||
|
||
BoxedTablePanel<RoleType> table = new BoxedTablePanel<>( | ||
ID_PANEL, provider, initColumns()); | ||
table.setOutputMarkupId(true); | ||
return table; | ||
} | ||
|
||
private List<IColumn<RoleType, String>> initColumns() { | ||
|
||
List<IColumn<RoleType, String>> columns = new ArrayList<>(); | ||
|
||
columns.add(new IconColumn<>(null) { | ||
@Serial private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public void populateItem(Item<ICellPopulator<RoleType>> cellItem, String componentId, IModel<RoleType> rowModel) { | ||
super.populateItem(cellItem, componentId, rowModel); | ||
} | ||
|
||
@Override | ||
protected DisplayType getIconDisplayType(IModel<RoleType> rowModel) { | ||
return GuiDisplayTypeUtil | ||
.createDisplayType(WebComponentUtil.createDefaultBlackIcon(RoleType.COMPLEX_TYPE)); | ||
} | ||
}); | ||
|
||
columns.add(new AbstractColumn<>(createStringResource("ObjectType.name")) { | ||
|
||
@Override | ||
public String getSortProperty() { | ||
return RoleType.F_NAME.getLocalPart(); | ||
} | ||
|
||
@Override | ||
public boolean isSortable() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void populateItem(Item<ICellPopulator<RoleType>> item, String componentId, | ||
IModel<RoleType> rowModel) { | ||
|
||
String name = rowModel.getObject().getName().toString(); | ||
String oid = rowModel.getObject().getOid(); | ||
|
||
AjaxLinkPanel ajaxLinkPanel = new AjaxLinkPanel(componentId, Model.of(name)) { | ||
@Override | ||
public void onClick(AjaxRequestTarget target) { | ||
|
||
PageParameters parameters = new PageParameters(); | ||
parameters.add(OnePageParameterEncoder.PARAMETER, oid); | ||
|
||
((PageBase) getPage()).navigateToNext(PageRole.class, parameters); | ||
} | ||
}; | ||
ajaxLinkPanel.setOutputMarkupId(true); | ||
item.add(ajaxLinkPanel); | ||
} | ||
|
||
}); | ||
|
||
columns.add(new AbstractColumn<>(createStringResource("Status")) { | ||
|
||
@Override | ||
public String getSortProperty() { | ||
return RoleType.F_ACTIVATION.getLocalPart(); | ||
} | ||
|
||
@Override | ||
public boolean isSortable() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void populateItem(Item<ICellPopulator<RoleType>> item, String componentId, | ||
IModel<RoleType> rowModel) { | ||
item.add(new Label(componentId, rowModel.getObject().getActivation().getEffectiveStatus())); | ||
} | ||
|
||
}); | ||
|
||
columns.add(new AbstractColumn<>(createStringResource("Members count")) { | ||
|
||
@Override | ||
public String getSortProperty() { | ||
return RoleType.F_ASSIGNMENT.getLocalPart(); | ||
} | ||
|
||
@Override | ||
public boolean isSortable() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void populateItem(Item<ICellPopulator<RoleType>> item, String componentId, | ||
IModel<RoleType> rowModel) { | ||
int membersCount = extractRoleMembers(operationResult, getPageBase(), rowModel.getObject().getOid()).size(); | ||
item.add(new Label(componentId, membersCount)); | ||
} | ||
|
||
}); | ||
|
||
columns.add(new AbstractColumn<>(createStringResource("Inducement count")) { | ||
|
||
@Override | ||
public String getSortProperty() { | ||
return RoleType.F_INDUCEMENT.getLocalPart(); | ||
} | ||
|
||
@Override | ||
public boolean isSortable() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void populateItem(Item<ICellPopulator<RoleType>> item, String componentId, | ||
IModel<RoleType> rowModel) { | ||
item.add(new Label(componentId, rowModel.getObject().getInducement().size())); | ||
} | ||
|
||
}); | ||
|
||
columns.add(new AbstractColumn<>(createStringResource("Created Timestamp")) { | ||
|
||
@Override | ||
public String getSortProperty() { | ||
return RoleType.F_INDUCEMENT.getLocalPart(); | ||
} | ||
|
||
@Override | ||
public boolean isSortable() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void populateItem(Item<ICellPopulator<RoleType>> item, String componentId, | ||
IModel<RoleType> rowModel) { | ||
item.add(new Label(componentId, resolveDateAndTime(rowModel.getObject().getMetadata().getCreateTimestamp()))); | ||
} | ||
|
||
}); | ||
|
||
return columns; | ||
} | ||
|
||
public PageBase getPageBase() { | ||
return ((PageBase) getPage()); | ||
} | ||
|
||
} |