Category Archives: CSIP

Phil 4.12.12

8:00 – 12:30 CSIP

  • Started the day trying to hook up hibernate to the information_instance.TABLES table and got the following error:
  • This is attempting to use the following class
    package com.sample.information_schema;
    import java.math.BigInteger;
    import java.util.Date;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Table;
    import javax.persistence.Temporal;
    import javax.persistence.TemporalType;
    @Table(name = "TABLES")
    public class TableMySql {
    	@Column(name = "version")
    	private BigInteger version;
    	@Column(name = "table_rows")
    	private BigInteger table_rows;
    	@Column(name = "avg_row_length")
    	private BigInteger avg_row_length;
    	@Column(name = "data_length")
    	private BigInteger data_length;
    	@Column(name = "max_data_length")
    	private BigInteger max_data_length;
    	@Column(name = "index_length")
    	private BigInteger index_length;
    	@Column(name = "data_free")
    	private BigInteger data_free;
    	@Column(name = "auto_increment")
    	private BigInteger auto_increment;
    	@Column(name = "checksum")
    	private BigInteger checksum;
    	@Column(name = "create_time")
    	private Date create_time;
    	@Column(name = "update_time")
    	private Date update_time;
    	@Column(name = "check_time")
    	private Date check_time;
    	@Column(name = "table_catalog")
    	private String table_catalog;
    	@Column(name = "table_schema")
    	private String table_schema;
    	@Column(name = "table_name")
    	private String table_name;
    	@Column(name = "table_type")
    	private String table_type;
    	@Column(name = "engine")
    	private String engine;
    	@Column(name = "row_format")
    	private String row_format;
    	@Column(name = "table_collation")
    	private String table_collation;
    	@Column(name = "create_options")
    	private String create_options;
    	@Column(name = "table_comment")
    	private String table_comment;
    	public BigInteger getVersion() {
    		return version;
    	public BigInteger getTable_rows() {
    		return table_rows;
    	public BigInteger getAvg_row_length() {
    		return avg_row_length;
    	public BigInteger getData_length() {
    		return data_length;
    	public BigInteger getMax_data_length() {
    		return max_data_length;
    	public BigInteger getIndex_length() {
    		return index_length;
    	public BigInteger getData_free() {
    		return data_free;
    	public BigInteger getAuto_increment() {
    		return auto_increment;
    	public BigInteger getChecksum() {
    		return checksum;
    	public Date getCreate_time() {
    		return create_time;
    	public Date getUpdate_time() {
    		return update_time;
    	public Date getCheck_time() {
    		return check_time;
    	public String getTable_catalog() {
    		return table_catalog;
    	public String getTable_schema() {
    		return table_schema;
    	public String getTable_name() {
    		return table_name;
    	public String getTable_type() {
    		return table_type;
    	public String getEngine() {
    		return engine;
    	public String getRow_format() {
    		return row_format;
    	public String getTable_collation() {
    		return table_collation;
    	public String getCreate_options() {
    		return create_options;
    	public String getTable_comment() {
    		return table_comment;
  • to talk to hibernate using the following configuration file:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    <session-factory name="MySqlInformationSchema">
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/information_schema</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.password">edge</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.default_schema">information_schema</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="">update</property>
    <property name="show_sql">true</property>
    <property name="connection.pool_size">1</property>
    <!-- List all the annotated classes we're using -->
    <mapping class="com.sample.information_schema.tableMySql"/>
  • Well, connecting to the db with jdbc instead of running through Hibernate got things up to speed quite quickly. I am running arbitrary queries against the databases (including information_schema, which Hibernate chokes on). The results are wrapped in objects that rules can be run against.
    •  Handle what happens when a null is returned by WrappedMap.getObjectByName().
    • Determine primitive type and handle accordingly
  • Looks like my ability to charge the CSIP contract ran out on the 9th. Need to figure out what to do with the 12 hours I charged since then. Jim is working on it. Ok. Charge half of today and all of yesterday and stop.

12:30 – 4:30 FP

  • Worked on paper, then lost the ability to scroll past page one. Going to try this at home…

7:00 – 9:30 FP

  • Finished incorporating paper changes and sent back to Dr. Kuber.

Phil 4.11.12

8:00 – 4:00 CSIP

  • Working on building a Drools test case structured around wrapped Maps.
  • Built the wrapped objects and Maps, and have the sandbox created
  • And here’s how you do it. Probably not as efficient as it could be, but pretty general case.
    #created on: Apr 11, 2012
    package com.sample
    #list any import classes here.
    import com.sample.WrappedObject;
    import com.sample.WrappedMap;
    #declare any global variables here
    dialect "java"
    rule "rule Floats less than six"
            WrappedMap($wo:getObjectByName("myFloat")) // condition
  • Need to add some methods for handling String compares and for other types of objects
  • Working on getting Hibernate to talk to information_schema in mySql. I’m trying to use the eclipse tools, and I get this error:
  • Stopping for the day. Will talk to Dong about this tomorrow.

Phil 4.10.12

8:00 – 4:30 CSIP

  • Now that I have my Hibernate Eclipse plugins working, back to chapter 9.
  • Well, the plugins work fine, but when I tried to add an element to a query, the build broke and I was unable to get it to work again, even after restoring to the earliest version. Went on to chapter 12, but the DB appears to broken there too.
  • According to Dong, this is because the HSQL instance is not persisted in the test, so all the data drops out. Switching the dialect to MySQL, which runs as a service on my box fixed all problems but one – an exception that said the DB couldn’t be reached. Which was odd, because it was accessed and the tables were created and populated. Go figure.
  • Talked to Mike about his experience with dynamic object creation using Hibernate. It looks pretty straightforward, as long as you have a ‘generic’ object that is wrapped around Map(s) (Collections?) of some kind. Now I need to see if I can build a Drools engine that will reason over elements in a collection contained in an object.

Phil 4.9.12

7:30 – 1:30 FP

  • Seminar. Discovered I can resubmit the CHI paper to UIST. Started working on that.
  • Ordering parts for the boards, which came in Friday

1:30 – 4:30 CSIP

  • Continuing to Hibernate
  • Chapter 8
  • Chapter 9, with a short trip to chapter 11. I finally found out how to install Hibernate Tools without crashing and burning. Go here, and drag the link to somewhere on your eclipse workspace that doesn’t have text entry (it’s an URL), like the border. Presto! Magically installing plugins.
  • For reference, because I think this may be the way this effort finally goes. And hey, I always wanted to write code that generated bytecode…
    • ASM is an all purpose Java bytecode manipulation and analysis framework. It can be used to modify existing classes or dynamically generate classes, directly in binary form. Provided common transformations and analysis algorithms allow to easily assemble custom complex transformations and code analysis tools.
    • ASM offers similar functionality as other bytecode frameworks, but it is focused on simplicity of use and performance. Because it was designed and implemented to be as small and as fast as possible, it makes it very attractive for using in dynamic systems.

Phil 4.6.12

8:00 – 3:30 CSIP

  • Hibernate chapter 6
  • Chapter 7. Learning about annotations like all the other cool kids. Done. Chapter 8 on Monday.

Phil 4.5.12

8:00 – 4:00 CSIP

  • Hibernate Chapter 3. Working on getting to chapter 8, which covers dynamic creation. “Chapter 8 discusses criteria queries, an interesting mechanism that lets you express the constraints on the entities you want, using a natural Java API. This lets you build Java objects to represent the data you want to find, which is easier for people who aren’t database experts to understand; lets you leverage your IDE’s code completion as a memory aid; and even gives you compile-time checking of your syntax. It also supports a form of “query by example,” where you can supply objects that are similar to the ones you’re searching for, which is particularly handy for implementing search interfaces in an application.
  • Chapter 4
    • Tried to change a query from foo = :upper(mySearchTerm) to foo like ‘%upper(mySearchTerm)%’ and failed completely. Dong suggested restrictions, but I don’t see how to do that in the hbm.xml <![CDATA[…]]> section.
  • Chapter 5
  • Chapter 6

Phil 4.4.12

8:00 – 4:30 CSIP

  • Taking a small detour into Hibernate, to see if that can create a Java Object that Drools can operate on.
    • Some relevant articles from 2008-2009, also here
    • Installing hibernate eclipse plugins from here. Well I thought I was. It appears there is a conflict with Ant. Which is funny, because the book “Harnessing Hibernate” has all their examples built with Ant. It is to laugh.
    • Hmm. Ant using Maven is kind of nice. Definitely more explicitly clear. it depends on maven-ant-tasks-2.0.6.jar that needs to reside in the Ant library. And if you add a link to that library as an external jar in the Ant preferences in Eclipse, it seems to work quite well.
    • Well, not quite. The 2.0.6 jar only points to the default .m2/repository. You need the 2.1.3 jar if you want that to work. And that took 2 hours. Grr. Somebody should update the Safari book code repository.
    • Chapter 1
    • Chapter 2
    • Chapter 3

Phil 4.3.12

8:00 – 1:30, 3:30 -6:00  CSIP

  • Ok ,now that we have working(?) code, I have something to walk through while reading the book.
  • The Drools team suggests that you use the joda DateTime library. It looks pretty nice, too – They also have a bunch of other interesting libraries at
  • Setting a global value in a rule
    • Java
      // Import the class
      // create the session
      static StatelessKnowledgeSession session;
      // create rule engine
      KnowledgeBaseConfiguration configuration = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
      KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(configuration);
      // declare our global
      BankingInquiryService inquiryService = new BankingInquiryServiceImpl();
      // make a session
      session = knowledgeBase.newStatelessKnowledgeSession();
      // add the global to the session
      session.setGlobal("inquiryService", inquiryService);
    • Drools rule (.drl file)
      // import
      // declare
      global BankingInquiryService inquiryService;
      // use the global in a rule (note the surrounding eval(), which can evaluate any code that returns a TRUE or FALSE).
      rule "accountNumberUnique"
              $account : Account(eval(!inquiryService.isAccountNumberUnique($account)))
              error(kcontext, $account);
  • Chapter 4
  • Nice data visualization using webGL

Phil 4.2.12

8:00 – 5:00 CSIP

  • Went to the customer site to fill out paperwork
  • Proceeding somewhat blindly is a somewhat Droolsy direction. Documentation is pretty sucky.
  • Thinking about how to use rules against a database. This might require the creation of Java classes that have the structure of the table. It’s possible that this could be done with reflection, which I haven’t used since TUMMS. Here’s the Java trail just in case:
  • Found the source for the book:
    • Reindexing maven repositories…
    • had to add the following to the droolsBookParent/pom.xml in the <dependencyManagement><dependecies> section
    • had to add the JDK to the JRE section of Eclipse Java properties. It was overriding JAVA_HOME
    • Better. Maybe even good enough. The banking example is working:
      [INFO] Reactor Summary:
      [INFO] Drools Book Parent ................................ SUCCESS [0.694s]
      [INFO] Banking Core ...................................... SUCCESS [3.705s]
      [INFO] Validation ........................................ SUCCESS [7.324s]
      [INFO] ETL with iBatis ................................... SUCCESS [12.815s]
      [INFO] DSL ............................................... FAILURE [4.146s]
      [INFO] Decision Tables ................................... SKIPPED
      [INFO] Ruleflow .......................................... SKIPPED
      [INFO] Stateful Rules .................................... SKIPPED
      [INFO] Complex Event Processing .......................... SKIPPED
      [INFO] Drools Flow ....................................... SKIPPED
      [INFO] Testing ........................................... SKIPPED
      [INFO] Integration ....................................... SKIPPED
      [INFO] Performance ....................................... SKIPPED
      [INFO] Sample Application ................................ SKIPPED
      [INFO] ------------------------------------------------------------------------
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 29.097s
      [INFO] Finished at: Mon Apr 02 16:58:52 EDT 2012
      [INFO] Final Memory: 32M/199M
      [ERROR] Failed to execute goal on project dsl: Could not resolve dependencies for project droolsbook:dsl:jar:1.1-SNAPSHOT: The following artifacts could not be resolved: droolsbook:etl_iBatis:jar:tests:1.1-SNAPSHOT, droolsbook:validation:jar:tests:1.1-SNAPSHOT: Failure to find droolsbook:etl_iBatis:jar:tests:1.1-SNAPSHOT in was cached in the local repository, resolution will not be reattempted until the update interval of corprepo has elapsed or updates are forced -> [Help 1]

Phil 3.30.12

8:00 – 9:30 CSIP

  • More Drools JBoss Rules 5.0 Developer’s Guide, chapter 2
  • Drools JBoss Rules 5.0 Developer’s Guide, chapter 3
    • Starting the Banking Domain Model example

9:30 – 12:00 FP

  • Developer meeting at UMBC

12:00 – 4:00 CSIP

  • Building classes and interfaces for a pretty complex model. We’ll see if this can be made to work…

Phil 3.29.12

8:00 – 4:00 CSIP

  • Drools JBoss Rules 5.0 Developer’s Guide
    • It is not only difficult to represent business logic in a imperative programming style language, but also hard to differentiate between code that represents the business logic and the infrastructure code that supports it.
    • We declare rules in pretty much the same way as the business analyst does the requirements—as a group of if-then statements. The rule engine can then take these rules and execute them over our data in the most efficient way. Rules, which have all of their conditions true, have their then part evaluated. This is different from imperative style programming languages where the developer has to specify how it needs to be done explicitly (with a sequence of conditionals and loops).
    • rule represents one requirement. This is more readable and maps to business requirements more naturally.
    • Well, having the right resource makes a difference. I have compiled and run a simple set of rules against multiple objects!
    • eval is a catch-all solution. It allows execution of any Java/MVEL code (according to the selected dialect) that returns true or false. It should be used only as a last resort when all other options have failed. This is because the rule engine cannot optimize eval. The expression is evaluated every time there is a change in the current rule’s condition (a fact is added, modified, or removed). They don’t have to return time-constant values. Writing eval as the last condition in a rule is a good practice.
    • How to get a reference to the current class being evaluated: $a:Account ( balance < 100, name != “Ted”). The ‘$’ is convention and not required

Lunch meeting to go over Noveta changes

Phil 3.28.12

8:00 – 4:30 CSIP

  • Visualizing Drools (Visualizing Inference Process of a Rule Engine – VINCI’11, August 4–5, 2011, Hong Kong, China.)
  • Onward with chapter 2
    • When there is one or more Activations on the Agenda they are said to be in conflict, and a conflict resolver strategy is used to determine the order of execution. At the simplest level the default strategy uses salience to determine rule priority. Each rule has a default value of 0, the higher the value the higher the priority.
  • Sheesh, had a whole slew of computer problems this morning. I was missing dlls, Some projects were pointing to debug libraries so they couldn’t distribute properly, and then my TortoiseSVN  just… evaporated. Had to reboot, reinstall, and reboot again. Everything appears to be working now though.
  • Wish I could find where this tool (RuleFlow?) is hidden in eclipse
  • Chapter 3: Advanced Concepts and Theory
    • After regular inserts you have to retract facts explicitly. With logical assertions, the fact that was asserted will be automatically retracted when the conditions that asserted it in the first place are no longer true
    • It is important to note that for Truth Maintenance (and logical assertions) to work at all, your Fact objects (which may be JavaBeans) must override equals and hashCode methods (from java.lang.Object) correctly. As the truth maintenance system needs to know when two different physical objects are equal in value, both equals and hashCode must be overridden correctly, as per the Java standard.
  • Chapter 4: User Guide
  • ‘Hello world’ setup”
    • KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
      // Check the builder for errors
      if( kbuilder.hasErrors() ) {
          System.out.println( kbuilder.getErrors() );
      // Resources of any type can be added iteratively
      kbuilder.add( ResourceFactory.newFileResource( "/project/myrules1.drl" ), ResourceType.DRL);
      kbuilder.add( ResourceFactory.newFileResource( "/project/myrules2.drl" ), ResourceType.DRL);
      if( kbuilder.hasErrors() ) {
          System.out.println( kbuilder.getErrors() );
      Collection<KnowledgePackage> kpkgs = kbuilder.getKnowledgePackages();
  • Ok, this is a nice introduction to concepts, but I’m not really getting the opportunity to build something in an kind of understandable way. There’s not much documentation, and only one book that appears to provide the overview – That’s the “Drools JBoss Rules 5.0 Developer’s Guide”. The reviews on Amazon are mixed, leaning to bad, but it’s the only game in town. I’ve bought and downloaded the Kindle edition and will try that tomorrow.

Phil 3.27.12

8:00 – 8:30 FP

  • Tried running the hand code on my laptop but ran into DLL problems. It was the debug version, so I recompiled the release version today. Let’s see if that makes it easier.
  • A useful page explaining all this, including that debug dlls are not redistributable.

8:30 – 4:30 CSIP

  • Ok, now that I’ve got the examples compiled and running (In Swing! How quaint), let’s see how to use this thing.
  • Chapter 2. Use cases and examples
  • Sent Ed a status update
  • Ok, I got the Drools Developer’s Cookbook, and it looks like I was doing this in the wrong order. Going to start over with the rules engine (Expert)
  • Chapter 1. The Rule Engine
    • An object type constraint plus its zero or more field constraints is referred to as a pattern. When an inserted instance satisfies both the object type constraint and all the field constraints, it is said to be matched.
    • Downloaded drools-distribution-5.3.0.Final, which contains example code. Some problems compiling, but the HelloWorld works, so we won’t worry for now…
    • This process is called inference, and it’s essential for the working of a Stateful Session. Stateless Sessions typically do not use inference, so the engine does not need to be aware of changes to data. Inference can also be turned off explicitly by using the sequential mode.

Phil 3.26.12

8:00 – 10:00 CSIP

  • Starting to dig into Drools.
    • Starting documentation
    • Attempting to install the Drools Eclipse Plugins from the amazingly sullen JBoss update site
      • Well, at least it’s started updating. Heading off to class with high hopes of progress upon my return!
      • Yay – downloaded and installed
  • I came across this over the weekend that looks like an eclipse-based graphical rules engine that could be used as a reference case. It’s from Repast, a system that I did quite a bit of work with back when I was consulting for UMD/ONR. Looks like they’ve been doing quite a bit of work on the system.

10:00 – 1:00 FP

1:00 – 4:00 CSIP

  • Onward with Drools
  • Planner (, and
    • Huh, Drools uses fitness tests, but doesn’t have a genetic algorithm/programming component. Interesting.
    • Downloaded the drools-planner-distribution-5.3.0.Final
      • Added as a preexisting project. All kinds of Java errors, which were fixed by running Maven on the POM file followed by mvn eclipse:eclipse. Then all the .drl files were being flagged as errors. While flailing generally, I noticed that I could set the project as a drools project (which it wasn’t yet apparently). That seems to have fixed all the errors, though there are a bunch of “Java raw type” warnings
      • Got the following message: The directory dataDir (C:Droolsdrools-planner-distribution-5.3.0.Finalexamplessourcesdatanqueens) does not exist. The working directory should be set to the directory that contains the data directory. This is different in a git clone (drools-planner/drools-planner-examples) and the release zip (examples).
        • Fixed by copying the data directory from the examples level to the sources level.
      • Everything is running. Tomorrow, we figure out what it means!