@SuppressWarnings("unchecked")
public void execute(Map<String, Object> context,
List<String[]> args) {
if ( args.size() >= 1 ) {
WorkingMemory wm = (WorkingMemory) context.get( "WorkingMemory" );
List<FactHandle> handles = (List<FactHandle>) context.get( "Handles" );
if ( handles == null ) {
handles = new ArrayList<FactHandle>();
context.put( "Handles",
handles );
}
NodeTestCase testCase = (NodeTestCase) context.get( "TestCase" );
ParserConfiguration conf = new ParserConfiguration();
for( String imp : testCase.getImports() ) {
if( imp.endsWith( ".*" ) ) {
conf.addPackageImport( imp.substring( 0, imp.lastIndexOf( '.' ) ) );
} else {
try {
conf.addImport( imp.substring( imp.lastIndexOf( "." )+1 ), reteTesterHelper.getTypeResolver().resolveType( imp ) );
} catch ( ClassNotFoundException e ) {
throw new IllegalArgumentException( "Unable to resolve import: "+imp);
}
}
}
for ( String[] str : args ) {
Serializable expr = MVEL.compileExpression( Arrays.asList( str ).toString(), new ParserContext(conf) );
List< ? > objects = (List< ? >) MVEL.executeExpression( expr );
for ( Object object : objects ) {
FactHandle handle = wm.insert( object );
handles.add( handle );
}
}
} else {
throw new IllegalArgumentException( "Cannot arguments " + Arrays.asList( args ) );