///*
// * Created on 6/03/2005
// */
//package Rules.fixture;
//
//import ilog.rules.engine.IlrContext;
//import ilog.rules.engine.IlrRuleset;
//
//import java.io.File;
//import java.net.MalformedURLException;
//import java.util.Iterator;
//import java.util.LinkedList;
//import java.util.List;
//
//import fit.Parse;
//
///**
// * @author <a href="mailto:michael.neale@gmail.com"> Michael Neale</a>
// *
// * Generic rule engine fixture.
// * One of the parameters will tell it what rule engine to load up.
// * Will allow easy mocking for testing when I don't have ILog licence.
// */
//public class JRulesFixture extends AbstractRulesTestingFixture {
//
//	
//	private List _objects;
//	private String _ruleSet;
//	
//	public JRulesFixture() {
//		_objects = new LinkedList();
//	}
//	
//	/**
//	 * Only expectation on this usage is that "Execute" is called last, that is the instruction
//	 * for the rules engine to light the fires and kick the tyres.
//	 * (Yes I think that is backwards, but I was 30 before I got around to seeing Top Gun).
//	 */
//	void processRow(Parse cell) {
//		//hmmm... will need to accumulate attributes for each call.
//		if (cell.text().equalsIgnoreCase("Execute")) {
//			executeRulesEngine();
//		} else if (cell.text().equalsIgnoreCase("Insert")) {
//			_objects.add(getDomainObjects().getObject(cell.more.text()));
//		} else if (cell.text().equalsIgnoreCase("Ruleset")) {
//			_ruleSet = cell.more.text();
//		}
//	}
//
//	
//	void executeRulesEngine() {
//		  //URL rulesetURL = JRulesFixture.class.getResource("/" + _ruleSet);
//          File irlFile = new File(_ruleSet);
//
//		  IlrContext context = new IlrContext();
//		  IlrRuleset ruleset = context.getRuleset();
//		  try {
//		  	ruleset.parseURL(irlFile.toURL());
//		  	for (Iterator iter = _objects.iterator(); iter.hasNext();) {
//		  		Object element = (Object) iter.next();
//		  		context.insert(element);
//		  	}
//	  		context.execute();
//	  		context.retractAll();
//	  		context.end();
//		  } catch (MalformedURLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		  }
//		  
//			
//	}
//	
//}
//       
//  
//
