public class EvalSelectStreamWUndRecastObjectArrayFactory {
public static SelectExprProcessor make(EventType[] eventTypes, SelectExprContext selectExprContext, int streamNumber, EventType targetType, ExprNode[] exprNodes, EngineImportService engineImportService)
throws ExprValidationException
{
ObjectArrayEventType oaResultType = (ObjectArrayEventType) targetType;
ObjectArrayEventType oaStreamType = (ObjectArrayEventType) eventTypes[streamNumber];
// (A) fully assignment-compatible: same number, name and type of fields, no additional expressions: Straight repackage
if (oaResultType.isDeepEqualsConsiderOrder(oaStreamType) && selectExprContext.getExpressionNodes().length == 0) {
return new OAInsertProcessorSimpleRepackage(selectExprContext, streamNumber, targetType);
}
// (B) not completely assignable: find matching properties
Set<WriteablePropertyDescriptor> writables = selectExprContext.getEventAdapterService().getWriteableProperties(oaResultType, true);
List<Item> items = new ArrayList<Item>();
List<WriteablePropertyDescriptor> written = new ArrayList<WriteablePropertyDescriptor>();
// find the properties coming from the providing source stream
for (WriteablePropertyDescriptor writeable : writables) {
String propertyName = writeable.getPropertyName();
Integer indexSource = oaStreamType.getPropertiesIndexes().get(propertyName);
Integer indexTarget = oaResultType.getPropertiesIndexes().get(propertyName);
if (indexSource != null) {
Object setOneType = oaStreamType.getTypes().get(propertyName);
Object setTwoType = oaResultType.getTypes().get(propertyName);
boolean setTwoTypeFound = oaResultType.getTypes().containsKey(propertyName);
String message = BaseNestableEventUtil.comparePropType(propertyName, setOneType, setTwoType, setTwoTypeFound, oaResultType.getName());
if (message != null) {
throw new ExprValidationException(message);