Skip to content

Commit

Permalink
assignment path metadata structure changed for roleMembershipRefs
Browse files Browse the repository at this point in the history
- each assignment path is stored in its own _metadata value
- type is streamlined, AssignmentPathType is not reused anymore
  • Loading branch information
virgo47 committed Feb 7, 2023
1 parent 0dc8604 commit 0729da9
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.constants.Channel;
import com.evolveum.midpoint.schema.expression.VariablesMap;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.web.application.PanelDisplay;
import com.evolveum.midpoint.web.application.PanelInstance;
Expand All @@ -38,15 +37,12 @@
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.export.AbstractExportableColumn;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -77,7 +73,7 @@ protected IColumn<SelectableBean<ObjectReferenceType>, String> createIconColumn(

@Override
protected ISelectableDataProvider<SelectableBean<ObjectReferenceType>> createProvider() {
return createSearchProvier(getSearchModel());
return createSearchProvider(getSearchModel());
}

@Override
Expand Down Expand Up @@ -152,18 +148,18 @@ public IModel<List<ObjectReferenceType>> extractDataModel(IModel<SelectableBean<
if (metadataValues == null) {
return null;
}
List<AssignmentPathType> assignmentPaths = new ArrayList<>();
List<AssignmentPathMetadataType> assignmentPaths = new ArrayList<>();
for (ProvenanceMetadataType metadataType : metadataValues) {
assignmentPaths.addAll(metadataType.getAssignmentPath());
assignmentPaths.add(metadataType.getAssignmentPath());
}

List<ObjectReferenceType> refs = new ArrayList<>();
for (AssignmentPathType assignmentPathType : assignmentPaths) {
List<AssignmentPathSegmentType> segments = assignmentPathType.getSegment();
for (AssignmentPathMetadataType assignmentPathType : assignmentPaths) {
List<AssignmentPathSegmentMetadataType> segments = assignmentPathType.getSegment();
if (CollectionUtils.isEmpty(segments) || segments.size() == 1) {
continue;
}
AssignmentPathSegmentType sourceSegment = segments.get(0);
AssignmentPathSegmentMetadataType sourceSegment = segments.get(0);
refs.add(getReferenceWithResolvedName(sourceSegment.getTargetRef()));
}
return refs;
Expand Down Expand Up @@ -202,9 +198,9 @@ public void populateItem(Item<ICellPopulator<SelectableBean<ObjectReferenceType>
if (metadataValues == null) {
return;
}
List<AssignmentPathType> assignmentPaths = new ArrayList<>();
List<AssignmentPathMetadataType> assignmentPaths = new ArrayList<>();
for (ProvenanceMetadataType metadataType : metadataValues) {
assignmentPaths.addAll(metadataType.getAssignmentPath());
assignmentPaths.add(metadataType.getAssignmentPath());
}

AssignmentPathPanel panel = new AssignmentPathPanel(componentId, Model.ofList(assignmentPaths));
Expand Down Expand Up @@ -286,7 +282,7 @@ public IModel<String> getDataModel(IModel<SelectableBean<ObjectReferenceType>> i
}
return () -> WebComponentUtil.formatDate(metadataType.getCreateTimestamp());

};
}

};
columns.add(since);
Expand Down Expand Up @@ -323,16 +319,15 @@ private List<String> resolvedPaths(SelectableBean<ObjectReferenceType> ref) {
if (metadataValues == null) {
return null;
}
List<AssignmentPathType> assignmentPaths = new ArrayList<>();
List<AssignmentPathMetadataType> assignmentPaths = new ArrayList<>();
for (ProvenanceMetadataType metadataType : metadataValues) {
assignmentPaths.addAll(metadataType.getAssignmentPath());
assignmentPaths.add(metadataType.getAssignmentPath());
}


List<String> resolvedPaths = new ArrayList<>();
for (int i = 0; i < assignmentPaths.size(); i++) {
AssignmentPathType assignmentPathType = assignmentPaths.get(i);
List<AssignmentPathSegmentType> segments = assignmentPathType.getSegment();
for (AssignmentPathMetadataType assignmentPathType : assignmentPaths) {
List<AssignmentPathSegmentMetadataType> segments = assignmentPathType.getSegment();
if (CollectionUtils.isEmpty(segments) || segments.size() == 1) {
continue;
}
Expand Down Expand Up @@ -393,7 +388,7 @@ private <R extends AbstractRoleType> R getResolvedTarget(ObjectReferenceType row
return null;
}

private ISelectableDataProvider<SelectableBean<ObjectReferenceType>> createSearchProvier(IModel<Search<ObjectReferenceType>> searchModel) {
private ISelectableDataProvider<SelectableBean<ObjectReferenceType>> createSearchProvider(IModel<Search<ObjectReferenceType>> searchModel) {
return new SelectableBeanReferenceDataProvider(AllAccessListPanel.this, searchModel, null, false) {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPathSegmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPathType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.wicket.markup.html.basic.Label;
Expand All @@ -24,11 +22,11 @@
import java.util.List;
import java.util.stream.Collectors;

public class AssignmentPathPanel extends BasePanel<List<AssignmentPathType>> {
public class AssignmentPathPanel extends BasePanel<List<AssignmentPathMetadataType>> {
private static final String ID_PATHS = "paths";
private static final String ID_PATH = "path";

public AssignmentPathPanel(String id, IModel<List<AssignmentPathType>> model) {
public AssignmentPathPanel(String id, IModel<List<AssignmentPathMetadataType>> model) {
super(id, model);
}

Expand All @@ -40,19 +38,19 @@ protected void onInitialize() {

private void initLayout() {

ListView<AssignmentPathType> assignmentPaths = new ListView<>(ID_PATHS, getModel()) {
ListView<AssignmentPathMetadataType> assignmentPaths = new ListView<>(ID_PATHS, getModel()) {
@Override
protected void populateItem(ListItem<AssignmentPathType> listItem) {
protected void populateItem(ListItem<AssignmentPathMetadataType> listItem) {
listItem.add(new AssignmentPathSegmentPanel(ID_PATH, loadSegmentsModel(listItem.getModel())));
}
};
add(assignmentPaths);
}

private IModel<List<AssignmentPathSegmentType>> loadSegmentsModel(IModel<AssignmentPathType> assignmentModel) {
private IModel<List<AssignmentPathSegmentMetadataType>> loadSegmentsModel(IModel<AssignmentPathMetadataType> assignmentModel) {
return () -> {
AssignmentPathType assignmentPathType = assignmentModel.getObject();
List<AssignmentPathSegmentType> segments = assignmentPathType.getSegment();
AssignmentPathMetadataType assignmentPathType = assignmentModel.getObject();
List<AssignmentPathSegmentMetadataType> segments = assignmentPathType.getSegment();
if (CollectionUtils.isEmpty(segments) || segments.size() == 1) {
return new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,20 @@

package com.evolveum.midpoint.web.component.data.column;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPathSegmentType;

import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPathType;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPathSegmentMetadataType;

public class AssignmentPathSegmentPanel extends BasePanel<List<AssignmentPathSegmentType>> {
public class AssignmentPathSegmentPanel extends BasePanel<List<AssignmentPathSegmentMetadataType>> {
private static final String ID_SEGMENTS = "segments";
private static final String ID_SEGMENT = "segment";


public AssignmentPathSegmentPanel(String id, IModel<List<AssignmentPathSegmentType>> model) {
public AssignmentPathSegmentPanel(String id, IModel<List<AssignmentPathSegmentMetadataType>> model) {
super(id, model);
}

Expand All @@ -42,9 +32,9 @@ protected void onInitialize() {

private void initLayout() {

ListView<AssignmentPathSegmentType> segments = new ListView<>(ID_SEGMENTS, getModel()) {
ListView<AssignmentPathSegmentMetadataType> segments = new ListView<>(ID_SEGMENTS, getModel()) {
@Override
protected void populateItem(ListItem<AssignmentPathSegmentType> listItem) {
protected void populateItem(ListItem<AssignmentPathSegmentMetadataType> listItem) {
listItem.add(new ObjectReferenceColumnPanel(ID_SEGMENT, () -> listItem.getModelObject().getTargetRef()));
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (C) 2020-2022 Evolveum and contributors
~ Copyright (C) 2020-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.
-->

<!--suppress XmlUnusedNamespaceDeclaration -->
<xsd:schema targetNamespace="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:tns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting/extension-3"
elementFormDefault="qualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
xmlns:tns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting/extension-3"
elementFormDefault="qualified"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">

<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -579,8 +579,7 @@
</xsd:element>
<xsd:element name="mappingSpecification" type="tns:MappingSpecificationType" minOccurs="0" maxOccurs="1">
</xsd:element>
<!-- TODO WIP accesses experiment, working name -->
<xsd:element name="assignmentPath" type="tns:AssignmentPathType" minOccurs="0" maxOccurs="unbounded">
<xsd:element name="assignmentPath" type="tns:AssignmentPathMetadataType" minOccurs="0" maxOccurs="1">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
Expand Down Expand Up @@ -881,4 +880,64 @@
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>
<xsd:element name="mappingItemApplicabilitySpecification" type="tns:MetadataProcessingItemApplicabilitySpecificationType"/>

<xsd:complexType name="AssignmentPathMetadataType">
<xsd:annotation>
<xsd:documentation>
Assignment path leading to this data.
This is typically applied to role membership refs.
Multiple paths can appear on a single value, but each in separate metadata container value.
</xsd:documentation>
<xsd:appinfo>
<a:operational>false</a:operational> <!-- intentionally -->
<a:container/>
<a:since>4.7</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="sourceRef" type="c:ObjectReferenceType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
References the owner of the first assignment, e.g. a user.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="segment" type="tns:AssignmentPathSegmentMetadataType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="AssignmentPathSegmentMetadataType">
<xsd:annotation>
<xsd:documentation>
One segment in the metadata assignment path.
Segment can either reference `assignmentId` containing the `targetRef` or `inducementId`,
which indicates, whether the segment is an assignment or inducement.
</xsd:documentation>
<xsd:appinfo>
<a:container/>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="segmentOrder" type="xsd:int" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Order of this segment in the whole assignment path.
First segment is numbered 1.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="assignmentId" type="xsd:long" minOccurs="0"/>
<xsd:element name="inducementId" type="xsd:long" minOccurs="0"/>
<xsd:element name="targetRef" type="c:ObjectReferenceType" minOccurs="0"/>
<xsd:element name="matchingOrder" type="xsd:boolean" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Can be used to filter out segments going through meta-role assignments,
which is indicated by `false` value.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

</xsd:schema>

0 comments on commit 0729da9

Please sign in to comment.