Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/upgrade-pro…
Browse files Browse the repository at this point in the history
…cess
  • Loading branch information
1azyman committed Jun 20, 2023
2 parents b5b2dec + 95cabc3 commit 7b60575
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

import java.util.List;
import java.util.stream.Collectors;
import jakarta.annotation.PostConstruct;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.xml.ns._public.common.common_3.CollectionRefSpecificationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import com.evolveum.midpoint.xml.ns._public.common.common_3.CompositeCorrelatorType;
import jakarta.annotation.PostConstruct;
import javax.xml.namespace.QName;

import org.springframework.stereotype.Component;

Expand All @@ -23,9 +22,10 @@
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractPolicyConstraintType;

/**
* Just like {@link PrismContainerWrapperFactoryImpl} but sets {@link PrismContainerValueWrapper#isHeterogenous()} flag to `true`.
*
* @author katka
*/
@Component
Expand Down Expand Up @@ -55,43 +55,45 @@ private boolean filterDefinitins(PrismContainerValue<C> value, ItemDefinition<?>
* match single value containers which contains a looot of other conainers, e.g. policy rule, policy action, notification configuration, etc
*/
@Override
public boolean match(ItemDefinition<?> def) {
if (def.getTypeClass() != null && def.getTypeClass().isAssignableFrom(CompositeCorrelatorType.class)) {
public boolean match(ItemDefinition<?> itemDef) {
if (itemDef.getTypeClass() != null && itemDef.getTypeClass().isAssignableFrom(CompositeCorrelatorType.class)) {
return false;
}

QName defName = def.getTypeName();
QName typeName = itemDef.getTypeName();

if (CollectionRefSpecificationType.COMPLEX_TYPE.equals(defName)
&& def.getItemName().equivalent(CollectionRefSpecificationType.F_BASE_COLLECTION_REF)) {
if (CollectionRefSpecificationType.COMPLEX_TYPE.equals(typeName)
&& itemDef.getItemName().equivalent(CollectionRefSpecificationType.F_BASE_COLLECTION_REF)) {
return true;
}

// TODO
// if (TaskPartsDefinitionType.COMPLEX_TYPE.equals(defName)) {
// return true;
// }
if (AuthorizationParentSelectorType.COMPLEX_TYPE.equals(typeName)
&& itemDef.getItemName().equivalent(AuthorizationObjectSelectorType.F_PARENT)) {
// The AuthorizationObjectSelectorType#parent points back to AuthorizationObjectSelectorType
// (via AuthorizationParentSelectorType), so normally an endless recursion would occur here.
// Therefore, we treat it as a heterogeneous container. At least for now.
//
// TODO review this; see MID-8910.
return true;
}

if (!(def instanceof PrismContainerDefinition)) {
if (!(itemDef instanceof PrismContainerDefinition<?> containerDef)) {
return false;
}

PrismContainerDefinition<?> containerDef = (PrismContainerDefinition<?>) def;

if (containerDef.isMultiValue() && isNotPolicyConstraint(containerDef)) {
return false;
}

List<? extends ItemDefinition> defs = containerDef.getDefinitions();
int containers = 0;
for (ItemDefinition<?> itemDef : defs) {
if (itemDef instanceof PrismContainerDefinition<?> && itemDef.isMultiValue()) {
containers++;
List<? extends ItemDefinition<?>> childDefs = containerDef.getDefinitions();
int multiValuedChildContainers = 0;
for (ItemDefinition<?> childItemDef : childDefs) {
if (childItemDef instanceof PrismContainerDefinition<?> && childItemDef.isMultiValue()) {
multiValuedChildContainers++;
}
}

return containers > 2;

return multiValuedChildContainers > 2;
}

private boolean isNotPolicyConstraint(PrismContainerDefinition<?> containerDef) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public class PrismContainerValueWrapperImpl<C extends Containerable>
private boolean showEmpty;
private boolean readOnly;
private boolean selected;

/**
* This flag marks a single-valued container which contains a lot of other containers that we do NOT want
* expand automatically. Typical use: policy rule, policy action, notification configuration, etc.
*/
private boolean heterogenous;
private boolean metadata;

Expand Down
128 changes: 0 additions & 128 deletions infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -7679,19 +7679,6 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="itemValue" type="tns:ItemValueSelectorType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Limits the authorization to specified values of specified items. For example,
when providing an ability to read a work item, we may allow reading of those assigned
to the current principal only.

Cannot be combined with "exceptItem".

TODO other limitations
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="target" type="tns:OwnedObjectSelectorType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -7939,121 +7926,6 @@
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="ItemValueSelectorType">
<xsd:annotation>
<xsd:documentation>
Limits the authorization to specified values of specified items.

WORK IN PROGRESS.
</xsd:documentation>
<xsd:appinfo>
<a:container/>
<a:since>4.8</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element ref="tns:description" minOccurs="0">
<xsd:annotation>
<xsd:appinfo>
<a:displayName>ValueSelectorType.description</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element ref="tns:documentation" minOccurs="0"/>
<xsd:element name="path" type="t:ItemPathType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Item to which this selector applies.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>ItemValueSelectorType.item</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="value" type="tns:ValueSelectorType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Selectors for the values of the item.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>ItemValueSelectorType.value</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="item" type="t:ItemPathType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="exceptItem" type="t:ItemPathType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="itemValue" type="tns:ItemValueSelectorType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
<xsd:appinfo>
<a:elaborate>true</a:elaborate> <!-- because of the recursion -->
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="ValueSelectorType">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
<xsd:appinfo>
<a:container/>
<a:since>4.8</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element ref="tns:description" minOccurs="0">
<xsd:annotation>
<xsd:appinfo>
<a:displayName>ValueSelectorType.description</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element ref="tns:documentation" minOccurs="0"/>
<xsd:element name="filter" type="q:SearchFilterType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Filter that the value must match to be considered selected by this statement.
This filter MUST NOT contain organization unit clauses. It may only contain
property clauses, logical operations and so on.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>ValueSelectorType.filter</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="assignee" type="tns:SubjectedObjectSelectorType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
The object matches the specification if it has a (current) assignee specified by this element.
(So it is applicable only to case work items, certification cases and certification work items.)
</xsd:documentation>
<xsd:appinfo>
<a:displayName>ValueSelectorType.filter</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="ObjectSelectorType">
<xsd:annotation>
<xsd:documentation>
Expand Down

0 comments on commit 7b60575

Please sign in to comment.