Skip to content

Commit

Permalink
Merge branch 'master' into feature/role-mining
Browse files Browse the repository at this point in the history
  • Loading branch information
tchrapovic committed Dec 1, 2023
2 parents fb364ce + c41595a commit e488755
Show file tree
Hide file tree
Showing 22 changed files with 421 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ boolean skipCreateWrapper(ItemDefinition<?> def, ItemStatus status, WrapperConte
}

protected boolean canCreateWrapper(ItemDefinition<?> def, ItemStatus status, WrapperContext context, boolean isEmptyValue) {
DisplayHint hint = def.getDisplayHint();
if (hint == DisplayHint.REGULAR) {
return true;
} else if (hint == DisplayHint.HIDDEN) {
return false;
}
if (def.isOperational() && !context.isCreateOperational()) {
LOGGER.trace("Skipping creating wrapper for {}, because it is operational.", def.getItemName());
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public boolean isDeprecated() {
return getItemDefinition().isDeprecated();
}

@Override
public boolean isOptionalCleanup() {
return getItemDefinition().isOptionalCleanup();
}

@Override
public boolean isRemoved() {
return getItemDefinition().isRemoved();
Expand Down Expand Up @@ -530,6 +535,16 @@ public boolean isElaborate() {
return getItemDefinition().isElaborate();
}

@Override
public DisplayHint getDisplayHint() {
return getItemDefinition().getDisplayHint();
}

@Override
public boolean isAlwaysUseForEquals() {
return getItemDefinition().isAlwaysUseForEquals();
}

@Override
public boolean isEmphasized() {
return getItemDefinition().isEmphasized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public boolean isIgnored() {
return metadataValueWrapper.isIgnored();
}

@Override
public boolean isOptionalCleanup() {
return metadataValueWrapper.isOptionalCleanup();
}

@Override
public ItemProcessing getProcessing() {
return metadataValueWrapper.getProcessing();
Expand Down Expand Up @@ -94,6 +99,16 @@ public String getDeprecatedSince() {
return metadataValueWrapper.getDeprecatedSince();
}

@Override
public DisplayHint getDisplayHint() {
return metadataValueWrapper.getDisplayHint();
}

@Override
public boolean isAlwaysUseForEquals() {
return metadataValueWrapper.isAlwaysUseForEquals();
}

@Override
public boolean isEmphasized() {
return metadataValueWrapper.isEmphasized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,11 @@ public boolean isRemoved() {
return false;
}

@Override
public boolean isOptionalCleanup() {
return false;
}

@Override
public String getRemovedSince() {
return null;
Expand All @@ -651,6 +656,11 @@ public String getDeprecatedSince() {
return null;
}

@Override
public DisplayHint getDisplayHint() {
return null;
}

@Override
public boolean isEmphasized() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ public List<SchemaMigration> getSchemaMigrations() {
@Override
public List<ItemDiagramSpecification> getDiagrams() { return structuralDefinition.getDiagrams(); }

@Override
public DisplayHint getDisplayHint() {
return structuralDefinition.getDisplayHint();
}

@Override
public boolean isEmphasized() {
return structuralDefinition.isEmphasized();
Expand Down Expand Up @@ -162,6 +167,11 @@ public boolean isRemoved() {
return structuralDefinition.isRemoved();
}

@Override
public boolean isOptionalCleanup() {
return structuralDefinition.isOptionalCleanup();
}

@Override
public String getRemovedSince() {
return structuralDefinition.getRemovedSince();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.evolveum.midpoint.prism.path.ItemPath;

import com.evolveum.midpoint.prism.util.CloneUtil;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.PrettyPrinter;

import com.evolveum.midpoint.util.exception.SystemException;
Expand Down Expand Up @@ -365,6 +366,20 @@ public boolean isIgnored() {
return isIgnored(currentLayer);
}

@Override
public boolean isAlwaysUseForEquals() {
return rawDefinition.isAlwaysUseForEquals();
}

@Override
public DisplayHint getDisplayHint() {
if (customizationBean.getDisplayHint() != null) {
return MiscSchemaUtil.toDisplayHint(customizationBean.getDisplayHint());
} else {
return rawDefinition.getDisplayHint();
}
}

@Override
public boolean isEmphasized() {
if (customizationBean.isEmphasized() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,11 @@ public void setRemoved(boolean removed) {
throw new UnsupportedOperationException();
}

@Override
public void setOptionalCleanup(boolean optionalCleanup) {
throw new UnsupportedOperationException();
}

@Override
public void setRemovedSince(String removedSince) {
throw new UnsupportedOperationException();
Expand All @@ -435,6 +440,11 @@ public void setExperimental(boolean experimental) {
throw new UnsupportedOperationException();
}

@Override
public void setDisplayHint(DisplayHint displayHint) {
throw new UnsupportedOperationException();
}

@Override
public void setEmphasized(boolean emphasized) {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

package com.evolveum.midpoint.schema.selector.spec;

import static com.evolveum.midpoint.schema.util.ObjectTypeUtil.getOidsFromRefs;
import static com.evolveum.midpoint.util.MiscUtil.configNonNull;

import java.util.*;

import com.evolveum.midpoint.schema.selector.eval.FilteringContext;
import com.evolveum.midpoint.schema.selector.eval.MatchingContext;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.util.DebugUtil;

import com.google.common.base.Preconditions;
Expand All @@ -26,6 +26,10 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;

/**
* Processes the `archetypeRef` clause. For checking assignments vs effective archetype references, please see
* javadoc for {@link #matches(PrismValue, MatchingContext)} method.
*/
public class ArchetypeRefClause extends SelectorClause {

/** Not empty, no null values. Immutable. */
Expand All @@ -52,13 +56,26 @@ static ArchetypeRefClause of(@NotNull List<ObjectReferenceType> archetypeRefList
return "archetypeRef";
}

/**
* Determines whether the archetype(s) do match the selector.
*
* We intentionally check assignments instead of "effective" archetype OIDs here. The reasons are:
*
* 1. When GUI creates an object, it sets the assignment, not the archetypeRef.
* 2. Deltas that change the archetype refer to the assignment, not the archetypeRef.
* (This is important when determining whether we are leaving the zone of control.)
*
* The #1 could be worked around by setting the archetypeRef before autz are checked. However, the #2 is more serious.
*
* To be seen if this is the correct way forward. An alternative would be to compute the effective object content
* (archetypeRef, but also e.g. parentOrgRef) before the actual matching. However, this could be quite complex and
* expensive. So, currently we have no option other than matching the assignments values.
*/
@Override
public boolean matches(@NotNull PrismValue value, @NotNull MatchingContext ctx) {
Object realValue = value.getRealValueIfExists();
if (realValue instanceof AssignmentHolderType) {
Collection<String> actualArchetypeOids =
getOidsFromRefs(
((AssignmentHolderType) realValue).getArchetypeRef());
if (realValue instanceof AssignmentHolderType assignmentHolder) {
Collection<String> actualArchetypeOids = ObjectTypeUtil.getAssignedArchetypeOids(assignmentHolder);
for (String actualArchetypeOid : actualArchetypeOids) {
if (archetypeOids.contains(actualArchetypeOid)) {
return true;
Expand All @@ -75,6 +92,13 @@ public boolean matches(@NotNull PrismValue value, @NotNull MatchingContext ctx)
return false;
}

/**
* Currently, we act upon the effective archetypeRef value, not the value in assignments. It should be far more efficient
* when running against the repository. Moreover, in the repository, it should be equivalent, as the effective value
* should precisely reflect the assignments' values there.
*
* @see #matches(PrismValue, MatchingContext)
*/
@Override
public boolean toFilter(@NotNull FilteringContext ctx) throws SchemaException {
addConjunct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.*;

import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.prism.ItemProcessing;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismReferenceValue;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
Expand Down Expand Up @@ -377,6 +375,20 @@ public static InformationType createInformationType(List<LocalizableMessageType>
return rv;
}

public static DisplayHint toDisplayHint(DisplayHintType hint) {
if (hint == null) {
return null;
}

return switch (hint) {
case HIDDEN -> DisplayHint.HIDDEN;
case COLLAPSED -> DisplayHint.COLLAPSED;
case EXPANDED -> DisplayHint.EXPANDED;
case REGULAR -> DisplayHint.REGULAR;
case EMPHASIZED -> DisplayHint.EMPHASIZED;
};
}

public static ItemProcessing toItemProcessing(ItemProcessingType type) {
if (type == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
<xsd:appinfo>
<a:displayName>ObjectType.name</a:displayName>
<a:displayOrder>0</a:displayOrder>
<a:emphasized>true</a:emphasized>
<a:displayHint>emphasized</a:displayHint>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand Down Expand Up @@ -2044,7 +2044,7 @@
<xsd:appinfo>
<a:displayName>UserType.fullName</a:displayName>
<a:displayOrder>100</a:displayOrder>
<a:emphasized>true</a:emphasized>
<a:displayHint>emphasized</a:displayHint>
<a:diagram>
<a:name>user-overview</a:name>
<a:inclusion>include</a:inclusion>
Expand Down Expand Up @@ -2076,7 +2076,7 @@
<xsd:appinfo>
<a:displayName>UserType.givenName</a:displayName>
<a:displayOrder>110</a:displayOrder>
<a:emphasized>true</a:emphasized>
<a:displayHint>emphasized</a:displayHint>
<a:diagram>
<a:name>user-overview</a:name>
<a:inclusion>include</a:inclusion>
Expand Down Expand Up @@ -2108,7 +2108,7 @@
<xsd:appinfo>
<a:displayName>UserType.familyName</a:displayName>
<a:displayOrder>120</a:displayOrder>
<a:emphasized>true</a:emphasized>
<a:displayHint>emphasized</a:displayHint>
<a:diagram>
<a:name>user-overview</a:name>
<a:inclusion>include</a:inclusion>
Expand Down Expand Up @@ -4301,6 +4301,17 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="displayHint" type="tns:DisplayHintType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<!-- todo -->
</xsd:documentation>
<xsd:appinfo>
<a:since>4.9</a:since>
<a:displayName>ItemRefinedDefinitionType.displayHint</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="emphasized" type="xsd:boolean" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Expand All @@ -4309,6 +4320,8 @@
interfaces (even if they are empty), they will always be included in the dumps, etc.
</xsd:documentation>
<xsd:appinfo>
<a:deprecated>true</a:deprecated>
<a:deprecatedSince>4.9</a:deprecatedSince>
<a:since>3.4</a:since>
<a:displayName>ItemRefinedDefinitionType.emphasized</a:displayName>
</xsd:appinfo>
Expand Down Expand Up @@ -4578,6 +4591,55 @@
</xsd:sequence>
</xsd:complexType>

<!-- TODO: somehow align with DisplayHintType in annotation-3.xsd -->
<xsd:simpleType name="DisplayHintType">
<xsd:annotation>
<xsd:documentation>
Display hints for an item.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumClass/>
</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="hidden">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="HIDDEN"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="regular">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="REGULAR"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="emphasized">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="EMPHASIZED"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="collapsed">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="COLLAPSED"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="expanded">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="EXPANDED"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>

<!-- TODO: somehow align with ItemProcessingType in annotation-3.xsd -->
<xsd:simpleType name="ItemProcessingType">
<xsd:annotation>
Expand Down

0 comments on commit e488755

Please sign in to comment.