Skip to content

Commit

Permalink
Support for relation in assignmentTargetSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Feb 24, 2015
1 parent bd06358 commit 3b57547
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
Expand Up @@ -5112,9 +5112,26 @@
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="assignmentTargetSearch" type="tns:SearchObjectExpressionEvaluatorType" substitutionGroup="tns:expressionEvaluator"/>
<xsd:element name="associationTargetSearch" type="tns:SearchObjectExpressionEvaluatorType" substitutionGroup="tns:expressionEvaluator"/>

<xsd:complexType name="SearchObjectRefExpressionEvaluatorType">
<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).
</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:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="assignmentTargetSearch" type="tns:SearchObjectRefExpressionEvaluatorType" substitutionGroup="tns:expressionEvaluator"/>

<xsd:complexType name="ShadowDiscriminatorExpressionEvaluatorType">
<xsd:annotation>
<xsd:documentation>
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2015 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@
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.SearchObjectExpressionEvaluatorType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchObjectRefExpressionEvaluatorType;

/**
* @author Radovan Semancik
Expand All @@ -44,7 +44,7 @@ public class AssignmentTargetSearchExpressionEvaluator

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

public AssignmentTargetSearchExpressionEvaluator(SearchObjectExpressionEvaluatorType expressionEvaluatorType,
public AssignmentTargetSearchExpressionEvaluator(SearchObjectRefExpressionEvaluatorType expressionEvaluatorType,
ItemDefinition outputDefinition, Protector protector, ObjectResolver objectResolver,
ModelService modelService, PrismContext prismContext, SecurityEnforcer securityEnforcer) {
super(expressionEvaluatorType, outputDefinition, protector, objectResolver, modelService, prismContext, securityEnforcer);
Expand All @@ -57,6 +57,7 @@ protected PrismContainerValue<AssignmentType> createPrismValue(String oid, QName
ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(oid);
targetRef.setType(targetTypeQName);
targetRef.setRelation(((SearchObjectRefExpressionEvaluatorType)getExpressionEvaluatorType()).getRelation());
assignmentType.setTargetRef(targetRef);

try {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014 Evolveum
* Copyright (c) 2014-2015 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,7 +33,8 @@
import com.evolveum.midpoint.security.api.SecurityEnforcer;
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.SearchObjectExpressionEvaluatorType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SearchObjectRefExpressionEvaluatorType;

import org.apache.commons.lang.Validate;

/**
Expand Down Expand Up @@ -62,7 +63,7 @@ public AssignmentTargetSearchExpressionEvaluatorFactory(PrismContext prismContex
*/
@Override
public QName getElementName() {
return new ObjectFactory().createAssignmentTargetSearch(new SearchObjectExpressionEvaluatorType()).getName();
return new ObjectFactory().createAssignmentTargetSearch(new SearchObjectRefExpressionEvaluatorType()).getName();
}

/* (non-Javadoc)
Expand All @@ -86,10 +87,10 @@ public <V extends PrismValue> ExpressionEvaluator<V> createEvaluator(Collection<
if (evaluatorElement != null) {
evaluatorTypeObject = evaluatorElement.getValue();
}
if (evaluatorTypeObject != null && !(evaluatorTypeObject instanceof SearchObjectExpressionEvaluatorType)) {
if (evaluatorTypeObject != null && !(evaluatorTypeObject instanceof SearchObjectRefExpressionEvaluatorType)) {
throw new SchemaException("assignment expression evaluator cannot handle elements of type " + evaluatorTypeObject.getClass().getName()+" in "+contextDescription);
}
AssignmentTargetSearchExpressionEvaluator expressionEvaluator = new AssignmentTargetSearchExpressionEvaluator((SearchObjectExpressionEvaluatorType)evaluatorTypeObject,
AssignmentTargetSearchExpressionEvaluator expressionEvaluator = new AssignmentTargetSearchExpressionEvaluator((SearchObjectRefExpressionEvaluatorType)evaluatorTypeObject,
outputDefinition, protector, objectResolver, modelService, prismContext, securityEnforcer);
return (ExpressionEvaluator<V>) expressionEvaluator;
}
Expand Down

0 comments on commit 3b57547

Please sign in to comment.