Skip to content

Commit

Permalink
Add assignment.subtype item (MID-4825)
Browse files Browse the repository at this point in the history
This is to categorize assignments based on purpose, origin, etc.

Cleaned up assignmentTargetSearch/referenceSearch properties;
un-deprecating referenceSearch.relation.

Also fixed a typo in "AssignmnetType.accepted" property.
  • Loading branch information
mederly committed Aug 15, 2018
1 parent 4b7fade commit a47de37
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 29 deletions.
Expand Up @@ -59,7 +59,7 @@ public void populateItem(Item<ICellPopulator<ContainerValueWrapper<AssignmentTyp
}
});

columns.add(new CheckBoxColumn<ContainerValueWrapper<AssignmentType>>(createStringResource("AssignmnetType.accepted")) {
columns.add(new CheckBoxColumn<ContainerValueWrapper<AssignmentType>>(createStringResource("AssignmentType.accepted")) {

private static final long serialVersionUID = 1L;

Expand Down
Expand Up @@ -99,10 +99,12 @@ AssignmentPolicyEnforcementType.POSITIVE=Positive
AssignmentPolicyEnforcementType.RELATIVE=Relative
AssignmentType.description=Description
AssignmentType.description.help=Free-form description of the assignment (comment).
AssignmentType.subtype=Subtype
AssignmentType.subtype.help=More specific characterization of the assignment e.g. by purpose, by origin, etc.
AssignmentType.activation=Activation
AssignmentType.lifecycleState=Lifecycle state
AssignmentType.lifecycleState.help=Lifecycle state of the assignment. This property defines whether the assignment represents a draft, proposed definition, whether it is active, deprecated, and so on.
AssignmnetType.accepted=Accepted
AssignmentType.accepted=Accepted
AssignmentType.policyRule=Policy rule
AssignmentType.policyRule.help=Policy rule that should be applied to the target object.
AssignmentType.policySituation=Policy situation
Expand Down
Expand Up @@ -4595,8 +4595,25 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

<xsd:element ref="tns:extension" minOccurs="0">

<xsd:element name="subtype" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
<p>
Type of the assignment. It is used to describe the assignment e.g. from the point of view
of its origin or purpose. A typical use could be marking assignments created by a given
inbound mapping in order to efficiently delineate the mapping's range.
</p>
</xsd:documentation>
<xsd:appinfo>
<a:displayName>AssignmentType.subtype</a:displayName>
<a:help>AssignmentType.subtype.help</a:help>
<a:since>3.9</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

<xsd:element ref="tns:extension" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
The assignment extension used to add parameters to the assignment.
Expand Down Expand Up @@ -9306,11 +9323,10 @@
</xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="SearchObjectRefExpressionEvaluatorType">
<xsd:complexType name="AssignmentTargetSearchExpressionEvaluatorType">
<xsd:annotation>
<xsd:documentation>
Create an expression based on search results. This is supposed to create an object reference.
Therefore it has additional parameter (relation).
Create an expression that provides an assignment based on search results.
</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
Expand Down Expand Up @@ -9352,8 +9368,31 @@
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="assignmentTargetSearch" type="tns:SearchObjectRefExpressionEvaluatorType" substitutionGroup="tns:expressionEvaluator"/>
<xsd:element name="referenceSearch" type="tns:SearchObjectRefExpressionEvaluatorType" substitutionGroup="tns:expressionEvaluator"/>
<xsd:element name="assignmentTargetSearch" type="tns:AssignmentTargetSearchExpressionEvaluatorType" substitutionGroup="tns:expressionEvaluator"/>

<xsd:complexType name="ReferenceSearchExpressionEvaluatorType">
<xsd:annotation>
<xsd:documentation>
Create an expression that provides a reference based on search results.
</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:SearchObjectExpressionEvaluatorType">
<xsd:sequence>
<xsd:element name="relation" type="xsd:QName" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
Relation that will be set for new reference.
</xsd:documentation>
<xsd:appinfo>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="referenceSearch" type="tns:ReferenceSearchExpressionEvaluatorType" substitutionGroup="tns:expressionEvaluator"/>

<xsd:complexType name="ShadowDiscriminatorExpressionEvaluatorType">
<xsd:annotation>
Expand Down Expand Up @@ -11615,6 +11654,16 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="subtype" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Subtype(s) that will be set for new assignment.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.9</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<!-- TODO: later: activation, lifecycle -->
</xsd:sequence>
</xsd:complexType>
Expand Down
Expand Up @@ -35,11 +35,9 @@
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPropertiesSpecificationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchObjectRefExpressionEvaluatorType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import static java.util.Collections.emptyList;

/**
* @author Radovan Semancik
Expand All @@ -50,22 +48,23 @@ public class AssignmentTargetSearchExpressionEvaluator

private static final Trace LOGGER = TraceManager.getTrace(AssignmentTargetSearchExpressionEvaluator.class);

public AssignmentTargetSearchExpressionEvaluator(SearchObjectRefExpressionEvaluatorType expressionEvaluatorType,
public AssignmentTargetSearchExpressionEvaluator(AssignmentTargetSearchExpressionEvaluatorType expressionEvaluatorType,
PrismContainerDefinition<AssignmentType> outputDefinition, Protector protector, ObjectResolver objectResolver,
ModelService modelService, PrismContext prismContext, SecurityContextManager securityContextManager,
LocalizationService localizationService) {
super(expressionEvaluatorType, outputDefinition, protector, objectResolver, modelService, prismContext, securityContextManager, localizationService);
}

protected PrismContainerValue<AssignmentType> createPrismValue(String oid, QName targetTypeQName, List<ItemDelta<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>>> additionalAttributeDeltas, ExpressionEvaluationContext params) {
AssignmentType assignmentType = new AssignmentType();
AssignmentType assignmentType = new AssignmentType(getPrismContext());
PrismContainerValue<AssignmentType> assignmentCVal = assignmentType.asPrismContainerValue();

ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(oid);
targetRef.setType(targetTypeQName);
targetRef.setRelation(getRelation());
assignmentType.setTargetRef(targetRef);
assignmentType.getSubtype().addAll(getSubtypes());

try {
if (additionalAttributeDeltas != null) {
Expand All @@ -84,7 +83,7 @@ protected PrismContainerValue<AssignmentType> createPrismValue(String oid, QName
}

private QName getRelation() {
SearchObjectRefExpressionEvaluatorType expressionEvaluatorType = (SearchObjectRefExpressionEvaluatorType) getExpressionEvaluatorType();
AssignmentTargetSearchExpressionEvaluatorType expressionEvaluatorType = (AssignmentTargetSearchExpressionEvaluatorType) getExpressionEvaluatorType();
AssignmentPropertiesSpecificationType assignmentProperties = expressionEvaluatorType.getAssignmentProperties();
if (assignmentProperties != null) {
return assignmentProperties.getRelation();
Expand All @@ -93,6 +92,11 @@ private QName getRelation() {
}
}

private List<String> getSubtypes() {
AssignmentTargetSearchExpressionEvaluatorType evaluator = (AssignmentTargetSearchExpressionEvaluatorType) getExpressionEvaluatorType();
return evaluator.getAssignmentProperties() != null ? evaluator.getAssignmentProperties().getSubtype() : emptyList();
}

/* (non-Javadoc)
* @see com.evolveum.midpoint.common.expression.ExpressionEvaluator#shortDebugDump()
*/
Expand Down
Expand Up @@ -33,9 +33,9 @@
import com.evolveum.midpoint.security.api.SecurityContextManager;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentTargetSearchExpressionEvaluatorType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchObjectRefExpressionEvaluatorType;

import org.apache.commons.lang.Validate;

Expand Down Expand Up @@ -64,7 +64,7 @@ public AssignmentTargetSearchExpressionEvaluatorFactory(ExpressionFactory expres
*/
@Override
public QName getElementName() {
return new ObjectFactory().createAssignmentTargetSearch(new SearchObjectRefExpressionEvaluatorType()).getName();
return new ObjectFactory().createAssignmentTargetSearch(new AssignmentTargetSearchExpressionEvaluatorType()).getName();
}

/* (non-Javadoc)
Expand All @@ -88,10 +88,10 @@ public <V extends PrismValue,D extends ItemDefinition> ExpressionEvaluator<V,D>
if (evaluatorElement != null) {
evaluatorTypeObject = evaluatorElement.getValue();
}
if (evaluatorTypeObject != null && !(evaluatorTypeObject instanceof SearchObjectRefExpressionEvaluatorType)) {
if (evaluatorTypeObject != null && !(evaluatorTypeObject instanceof AssignmentTargetSearchExpressionEvaluatorType)) {
throw new SchemaException("assignment expression evaluator cannot handle elements of type " + evaluatorTypeObject.getClass().getName()+" in "+contextDescription);
}
AssignmentTargetSearchExpressionEvaluator expressionEvaluator = new AssignmentTargetSearchExpressionEvaluator((SearchObjectRefExpressionEvaluatorType)evaluatorTypeObject,
AssignmentTargetSearchExpressionEvaluator expressionEvaluator = new AssignmentTargetSearchExpressionEvaluator((AssignmentTargetSearchExpressionEvaluatorType)evaluatorTypeObject,
(PrismContainerDefinition<AssignmentType>) outputDefinition, protector, getObjectResolver(), modelService, prismContext, securityContextManager, getLocalizationService());
return (ExpressionEvaluator<V,D>) expressionEvaluator;
}
Expand Down
Expand Up @@ -31,7 +31,7 @@
import com.evolveum.midpoint.security.api.SecurityContextManager;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchObjectRefExpressionEvaluatorType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReferenceSearchExpressionEvaluatorType;

/**
* @author Radovan Semancik
Expand All @@ -41,7 +41,7 @@ public class ReferenceSearchExpressionEvaluator

private static final Trace LOGGER = TraceManager.getTrace(ReferenceSearchExpressionEvaluator.class);

public ReferenceSearchExpressionEvaluator(SearchObjectRefExpressionEvaluatorType expressionEvaluatorType,
public ReferenceSearchExpressionEvaluator(ReferenceSearchExpressionEvaluatorType expressionEvaluatorType,
PrismReferenceDefinition outputDefinition, Protector protector, ObjectResolver objectResolver,
ModelService modelService, PrismContext prismContext, SecurityContextManager securityContextManager,
LocalizationService localizationService) {
Expand All @@ -54,7 +54,7 @@ protected PrismReferenceValue createPrismValue(String oid, QName targetTypeQName

refVal.setOid(oid);
refVal.setTargetType(targetTypeQName);
refVal.setRelation(((SearchObjectRefExpressionEvaluatorType)getExpressionEvaluatorType()).getRelation());
refVal.setRelation(((ReferenceSearchExpressionEvaluatorType)getExpressionEvaluatorType()).getRelation());

return refVal;
}
Expand Down
Expand Up @@ -34,7 +34,7 @@
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchObjectRefExpressionEvaluatorType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReferenceSearchExpressionEvaluatorType;

import org.apache.commons.lang.Validate;

Expand Down Expand Up @@ -62,7 +62,7 @@ public ReferenceSearchExpressionEvaluatorFactory(ExpressionFactory expressionFac
*/
@Override
public QName getElementName() {
return new ObjectFactory().createReferenceSearch(new SearchObjectRefExpressionEvaluatorType()).getName();
return new ObjectFactory().createReferenceSearch(new ReferenceSearchExpressionEvaluatorType()).getName();
}

/* (non-Javadoc)
Expand All @@ -86,10 +86,10 @@ public <V extends PrismValue,D extends ItemDefinition> ExpressionEvaluator<V,D>
if (evaluatorElement != null) {
evaluatorTypeObject = evaluatorElement.getValue();
}
if (evaluatorTypeObject != null && !(evaluatorTypeObject instanceof SearchObjectRefExpressionEvaluatorType)) {
if (evaluatorTypeObject != null && !(evaluatorTypeObject instanceof ReferenceSearchExpressionEvaluatorType)) {
throw new SchemaException("reference search expression evaluator cannot handle elements of type " + evaluatorTypeObject.getClass().getName()+" in "+contextDescription);
}
ReferenceSearchExpressionEvaluator expressionEvaluator = new ReferenceSearchExpressionEvaluator((SearchObjectRefExpressionEvaluatorType)evaluatorTypeObject,
ReferenceSearchExpressionEvaluator expressionEvaluator = new ReferenceSearchExpressionEvaluator((ReferenceSearchExpressionEvaluatorType)evaluatorTypeObject,
(PrismReferenceDefinition) outputDefinition, protector, getObjectResolver(), modelService, prismContext, securityContextManager, getLocalizationService());
return (ExpressionEvaluator<V,D>) expressionEvaluator;
}
Expand Down
Expand Up @@ -90,9 +90,10 @@ public <V extends PrismValue, D extends ItemDefinition, F extends FocusType> Sou
AssignmentPropertiesSpecificationType assignmentProperties = autoassignMappingType.getAssignmentProperties();
if (assignmentProperties != null) {
relation = assignmentProperties.getRelation();
assignmentType.getSubtype().addAll(assignmentProperties.getSubtype());
}
assignmentType.targetRef(role.getOid(), role.asPrismObject().getDefinition().getTypeName(), relation);
Source<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> source =
Source<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> source =
new Source<>(assignment, null, assignment, FocusType.F_ASSIGNMENT);
return (Source<V, D>) source;
}
Expand Down

0 comments on commit a47de37

Please sign in to comment.