Skip to content

Commit

Permalink
Object merge, step 3: expressions (MID-3460)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Oct 21, 2016
1 parent cbb33c6 commit a1f118e
Show file tree
Hide file tree
Showing 8 changed files with 397 additions and 50 deletions.
Expand Up @@ -382,4 +382,16 @@ public static <T> Set<T> getRealValuesOfCollection(Collection<PrismPropertyValue
}
return retval;
}

public static <V extends PrismValue> boolean collectionContainsEquivalentValue(Collection<V> collection, V value) {
if (collection == null) {
return false;
}
for (V collectionVal: collection) {
if (collectionVal.equals(value, true)) {
return true;
}
}
return false;
}
}
Expand Up @@ -65,6 +65,11 @@ public class ExpressionConstants {
*/
public static final QName VAR_ITERATION_TOKEN = new QName(SchemaConstants.NS_C, "iterationToken");

// Variables used in object mergign expressions
public static final QName VAR_SIDE = new QName(SchemaConstants.NS_C, "side");
public static final QName VAR_OBJECT_LEFT = new QName(SchemaConstants.NS_C, "objectLeft");
public static final QName VAR_OBJECT_RIGHT = new QName(SchemaConstants.NS_C, "objectRight");

public static final QName OUTPUT_ELMENT_NAME = new QName(SchemaConstants.NS_C, "output");

}
Expand Up @@ -12392,8 +12392,29 @@
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="left" type="tns:MergeStategyType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="right" type="tns:MergeStategyType" minOccurs="0" maxOccurs="1"/>
<xsd:element name="left" type="tns:MergeStategyType" minOccurs="0" maxOccurs="1" default="ignore">
<xsd:annotation>
<xsd:documentation>
Strategy to process values from the left-hand-side object.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="right" type="tns:MergeStategyType" minOccurs="0" maxOccurs="1" default="ignore">
<xsd:annotation>
<xsd:documentation>
Strategy to process values from the right-hand-side object.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="valueExpression" type="tns:ExpressionType" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
Expression to process every value (if specified by strategy). The value that the
expression returns will be taken. If the expression returns null then the value will
be skipped.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

Expand Down Expand Up @@ -12425,6 +12446,7 @@
<xsd:enumeration value="ignore">
<xsd:annotation>
<xsd:documentation>
Ignore all the values.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="IGNORE"/>
Expand All @@ -12434,12 +12456,24 @@
<xsd:enumeration value="take">
<xsd:annotation>
<xsd:documentation>
Take all the values.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="TAKE"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="expression">
<xsd:annotation>
<xsd:documentation>
Take only values that are selected and processed by the expression.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="EXPRESSION"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<!-- TODO: values for manual selection may come here in the future. -->
</xsd:restriction>
</xsd:simpleType>

Expand Down
Expand Up @@ -181,10 +181,10 @@ ConnectorOperationalStatus getConnectorOperationalStatus(String resourceOid, Ope

<O extends ObjectType> ObjectDelta<O> mergeObjectsPreviewDelta(Class<O> type,
String leftOid, String rightOid, String mergeConfigurationName, Task task, OperationResult result)
throws ObjectNotFoundException, SchemaException, ConfigurationException;
throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException;

<O extends ObjectType> PrismObject<O> mergeObjectsPreviewObject(Class<O> type,
String leftOid, String rightOid, String mergeConfigurationName, Task task, OperationResult result)
throws ObjectNotFoundException, SchemaException, ConfigurationException;
throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException;

}
Expand Up @@ -697,7 +697,7 @@ public ConnectorOperationalStatus getConnectorOperationalStatus(String resourceO
@Override
public <O extends ObjectType> ObjectDelta<O> mergeObjectsPreviewDelta(Class<O> type, String leftOid,
String rightOid, String mergeConfigurationName, Task task, OperationResult parentResult)
throws ObjectNotFoundException, SchemaException, ConfigurationException {
throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException {
OperationResult result = parentResult.createMinorSubresult(MERGE_OBJECTS_PREVIEW_DELTA);

try {
Expand All @@ -707,7 +707,7 @@ public <O extends ObjectType> ObjectDelta<O> mergeObjectsPreviewDelta(Class<O> t
result.computeStatus();
return objectDelta;

} catch (ObjectNotFoundException | SchemaException | ConfigurationException | RuntimeException | Error e) {
} catch (ObjectNotFoundException | SchemaException | ConfigurationException | ExpressionEvaluationException | RuntimeException | Error e) {
result.recordFatalError(e);
throw e;
}
Expand All @@ -716,7 +716,7 @@ public <O extends ObjectType> ObjectDelta<O> mergeObjectsPreviewDelta(Class<O> t
@Override
public <O extends ObjectType> PrismObject<O> mergeObjectsPreviewObject(Class<O> type, String leftOid,
String rightOid, String mergeConfigurationName, Task task, OperationResult parentResult)
throws ObjectNotFoundException, SchemaException, ConfigurationException {
throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException {
OperationResult result = parentResult.createMinorSubresult(MERGE_OBJECTS_PREVIEW_OBJECT);

try {
Expand All @@ -735,7 +735,7 @@ public <O extends ObjectType> PrismObject<O> mergeObjectsPreviewObject(Class<O>
result.computeStatus();
return objectLeft;

} catch (ObjectNotFoundException | SchemaException | ConfigurationException | RuntimeException | Error e) {
} catch (ObjectNotFoundException | SchemaException | ConfigurationException | ExpressionEvaluationException | RuntimeException | Error e) {
result.recordFatalError(e);
throw e;
}
Expand Down

0 comments on commit a1f118e

Please sign in to comment.