List<NamedWindowUpdateItem> updateItems = new ArrayList<NamedWindowUpdateItem>();
List<String> properties = new ArrayList<String>();
for (int i = 0; i < assignments.size(); i++)
{
OnTriggerSetAssignment assignment = assignments.get(i);
NamedWindowUpdateItem updateItem;
// determine whether this is a "property=value" assignment, we use property setters in this case
Pair<String, ExprNode> possibleAssignment = ExprNodeUtility.checkGetAssignmentToProp(assignment.getExpression());
// handle assignment "property = value"
if (possibleAssignment != null) {
String propertyName = possibleAssignment.getFirst();
EventPropertyDescriptor writableProperty = eventTypeSPI.getWritableProperty(propertyName);
// check assignment to indexed or mapped property
if (writableProperty == null) {
Pair<String, EventPropertyDescriptor> nameWriteablePair = checkIndexedOrMappedProp(possibleAssignment.getFirst(), namedWindowName, namedWindowAlias, eventTypeSPI);
propertyName = nameWriteablePair.getFirst();
writableProperty = nameWriteablePair.getSecond();
}
ExprEvaluator evaluator = possibleAssignment.getSecond().getExprEvaluator();
EventPropertyWriter writers = eventTypeSPI.getWriter(propertyName);
boolean notNullableField = writableProperty.getPropertyType().isPrimitive();
properties.add(propertyName);
TypeWidener widener = TypeWidenerFactory.getCheckPropertyAssignType(ExprNodeUtility.toExpressionStringMinPrecedence(possibleAssignment.getSecond()), possibleAssignment.getSecond().getExprEvaluator().getType(),
writableProperty.getPropertyType(), propertyName);
// check event type assignment
if (optionalTriggeringEventType != null && possibleAssignment.getSecond() instanceof ExprIdentNode) {
ExprIdentNode node = (ExprIdentNode) possibleAssignment.getSecond();
FragmentEventType fragmentRHS = optionalTriggeringEventType.getFragmentType(node.getResolvedPropertyName());
FragmentEventType fragmentLHS = eventTypeSPI.getFragmentType(possibleAssignment.getFirst());
if (fragmentRHS != null && fragmentLHS != null && !EventTypeUtility.isTypeOrSubTypeOf(fragmentRHS.getFragmentType(), fragmentLHS.getFragmentType())) {
throw new ExprValidationException("Invalid assignment to property '" +
possibleAssignment.getFirst() + "' event type '" + fragmentLHS.getFragmentType().getName() +
"' from event type '" + fragmentRHS.getFragmentType().getName() + "'");
}
}
updateItem = new NamedWindowUpdateItem(evaluator, propertyName, writers, notNullableField, widener);
}
// handle non-assignment, i.e. UDF or other expression
else {
ExprEvaluator evaluator = assignment.getExpression().getExprEvaluator();
updateItem = new NamedWindowUpdateItem(evaluator, null, null, false, null);
}
updateItems.add(updateItem);
}