Building a Maintainable Product Catalogue with OpenRules Dialog

This year I will chair a workshop “CPSOLVERS-2013” at the major Constraint Programming conference “CP 2013“. Preparing the workshop, we’ve decided to create an industrial overview of all supported constraint solvers currently available to business application developers. I started with a simple HTML editor (MS SharePoint Designer) and created a simple html questionnaire. After receiving submissions from authors of different product, we planned to manually fill out an html-summary of all products. However, we quickly understood that such a catalogue can be valuable and attractive for the product authors only if they will be able to keep it up-to-date all the time (including long after the conference).  So, I decided to create a web application that will do the following:

  • Allow a product author to register with his/her own id/password
  • Create a new questionnaire for every product
  • Save the answers
  • Modify the saved questionnaire interactively whenever necessary to keep it up-to-date
  • Automatically generate a catalogue of all products in their latest state
  • Keep this generated catalogue publicly available all the time.

I devoted almost the entire weekend to the development of this web application. First of all, I subscribed to a Tomcat hosting (JVMhost) that allows me to:

  1. Use FileZilla to transfer files from my machine to the remote Tomcat;
  2. Start/Stop Tomcat whenever I need to do it.

That’s all I needed from my Tomcat host, and I quickly tested that standard OpenRules-based web applications work fine at this new JVMhost. They did, and now you may try to play the notorious game “Nim” online by clicking on http://openjvm.jvmhost.net/Nim/.

So, my only challenge was to design a new web-based Product Catalogue. As usual, the internal logic was not as simple as it usually looks from the first glance, and it took me two full days to implement it. There are only 3 web pages in this application:

  • Initial Page with an introductory text and 3 action buttons: “Add/Modify Solver”,  “Generate Short Catalogue”, and “Generate Complete Catalogue”CataloguePage1 Note that the very first view of this page should not show any catalogue as the questions/answers were not defined yet.
  • Login Page with a product ID and Password. I used the standard pair of questions ID/Password included into the OpenRules DialogCatalogueLogin
  • Questionnaire Page that allows an authorized user to enter/modify a product profile and to save it on the server. CatalogueQuestionnaire

I decided to save/load answers to each questionnaire in a separate file on the server using the standard Dialog’s methods saveDialog(filename) and loadDialog(filename)

I did not write any new Java classes and managed to create the entire application within two Excel files: Main.xls and Rules.xls. You may look at the final result at http://openjvm.jvmhost.net/CPSolvers/. The only challenge was to decide how to generate complete and short versions of the catalogue.  I think I made a quite natural design decision by using questions/answers as main building blocks for the generated catalogues.  As I keep access attributes to all entered products in one Excel table, it means I already know the names of all files with saved answers – they all have similar names like “<product>.answers”. First, I sort the list of files in the alphabetical order, and then read all files one by one. The title for the catalog can be placed in a simple layout like below:

CatalogueTitle

Here the method colName(questionId) simply produces a layout for the proper question name (title).

Then iterating through all read products I may create a layout for the current row (product) and merge it with “already accumulate” rows. As I use  the method loadDialog(filename) to get the next row, I receive answers to all questions in my current set of all questions. So, the row layout may look as follows:

CatalogueRow

Here the method answer(questionId) produces a layout with an answer to the proper question.

For a short catalogue I simply removed some columns from the above two layouts and called them “shortCatalogueTitle” and “shortCatalogueRow”.  Based on which action button is selected I choose short or complete pair of these layouts.  This approach really simplifies catalogue generation with minimal coding of just a few presentation methods.  You may find more details by looking inside this file Rules.xls.

This was a good weekend exercise with some useful results. I plan to reuse the same approach for maintaining similar catalogue of products in other decision management areas.

Advertisements

About jacobfeldman

CTO at www.openrules.com http://www.linkedin.com/in/jacobfeldmanopenrules
This entry was posted in OpenRules Specific, Tools and Technologies, Web Applications. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s