//evaluate the the first parameter to get the source instance
Object refExpressionResult = referenceExpression.evaluate();
String refExpressionStr=refExpressionResult.toString();
//System.out.println("self = "+refExpressionResult);
DataCollector dc = DataCollectorFactory.getDataCollector();
//NRJ verify this works
// String refTypeName = referenceExpression.getReferenceTypeName();
//String refTypeName=dc.getReferenceTypeName(refExpressionStr);
List targetClassInstanceReferences = null;
// traverse association to get an array of target class instances. Each instance is a Map of key=values
if(logger.isLoggable(Level.FINE))
logger.fine(Thread.currentThread().getName()+" refExpressionResult evaluateFlavour1 "+refExpressionStr);
targetClassInstanceReferences = dc.getAssociatedInstanceReferences((Object)refExpressionResult,symTab.getDefaultQualifier(),targetClassName,associationName,sourceRole,targetRole);
//System.out.println("targetClassInstanceReferences size "+targetClassInstanceReferences.size());
if(logger.isLoggable(Level.FINE))
logger.fine(Thread.currentThread().getName()+" got associated references");
// targetClassInstance = dc.getAssociatedInstanceReferences(refTypeName, symTab.getDefaultQualifier(), targetClassName,associationName,sourceRole,targetRole, refExpressionResult);
if(logger.isLoggable(Level.FINE))
logger.fine(Thread.currentThread().getName()+" got associated instances");
// filter the List based on the target filter expression
List filteredTargetClassInstanceReferences = filterTargetClassInstanceReferencesWithTargetExpression(targetClassInstanceReferences , this.targetClassName,this.symTab.getDefaultQualifier());
//System.out.println("filteredTargetClassInstanceReferences size "+filteredTargetClassInstanceReferences.size());
if(logger.isLoggable(Level.FINE))
logger.fine(Thread.currentThread().getName()+" got filtered references");
List filteredTargetClassInstances = new ArrayList();
Iterator filteredTargetClassInstanceReferencesIt=filteredTargetClassInstanceReferences.iterator();
while(filteredTargetClassInstanceReferencesIt.hasNext())
{
Object ref=filteredTargetClassInstanceReferencesIt.next();
//System.out.println("filter passed : "+ref.toString());
Map instanceProperties=dc.getSymbolsForInstance(this.targetClassName,this.symTab.getDefaultQualifier(), ref);
filteredTargetClassInstances.add(instanceProperties);
}
if(logger.isLoggable(Level.FINE))
logger.fine(Thread.currentThread().getName()+" got filtered instances");