jcolibri.test.test3
Class Test3

java.lang.Object
  extended by jcolibri.test.test3.Test3
All Implemented Interfaces:
StandardCBRApplication

public class Test3
extends java.lang.Object
implements StandardCBRApplication

This example shows how to use a compound attribute in the description of a case and how to complete the CBR cycle.
Now, the description has not a string defining the region. Instead that, it has other bean named "Region" that stores different attributes about the region (nearest city, airport, currency...). This way, the structure of the case is:

 Case
  |
  +- Description
          |
          +- caseId
          +- HollidayType
          +- Price
          +- NumberOfPersons
          +- Region
          |     |
          |     +- regionId
          |     +- regionName
          |     +- NearestCity
          |     +- Airport
          |     +- Currency
          +- Transportation
          +- Duration
          +- Season
          +- Accomodation
          +- Hotel
 

This structure is mapped to the travelext data base that can be created using the travelext.sql file. It is composed by two tables: travel and region. Travel has a number in the regionid column identifying the row in the region table that contains the information:
 travel:
 +-----------+-------------+-------+-----------------+----------+----------------+----------+-----------+---------------+-----------------------------+
 | caseId    | HolidayType | Price | NumberOfPersons | regionId | Transportation | Duration | Season    | Accommodation | Hotel                       |
 +-----------+-------------+-------+-----------------+----------+----------------+----------+-----------+---------------+-----------------------------+
 | Journey11 | City        |  1978 |               2 |        1 | Plane          |        7 | April     | ThreeStars    | Hotel Victoria, Cairo       |
 | Journey21 | Recreation  |  1568 |               2 |        2 | Car            |       14 | May       | TwoStars      | Hotel Ostend, Belgium       |
  ...
 region:
 +----------+------------+-------------+---------------------------+----------------+
 | regionId | RegionName | NearestCity | Airport                   | Currency       |
 +----------+------------+-------------+---------------------------+----------------+
 |        1 | Cairo      | Cairo       | Cairo Airport             | Egyptian Pound |
 |        2 | Belgium    | Brussels    | Brussels National Airport | Euro           |
  ...
 
To map the case structure with the data base we have to modify these lines in hibernate.cfg.xml:
 <hibernate-mapping default-lazy="false">
   <class name="jcolibri.test.test3.TravelDescription" table="travel">
      ...
      <many-to-one name="Region" column="regionId" not-null="true" cascade="save-update"/> 
      ...
   </class>
   <class name="jcolibri.test.test3.Region" table="region">
        <id name="id" column="regionId">
        </id>
        <property name="region" column="RegionName"/>
        <property name="city" column="NearestCity"/>
        <property name="airport" column="Airport"/>
        <property name="currency" column="Currency"/>
   </class>
 </hibernate-mapping>
 
The many-to-one tag indicates the association between the regionId column in the travel table with the values of the region table.

This example also shows how to complete the CBR cycle including reuse, revise and retain methods:

Version:
1.0
Author:
Juan A. Recio-Garcia
See Also:
TravelDescription, Region, CombineQueryAndCasesMethod, DefineNewIdsMethod, StoreCasesMethod

Constructor Summary
Test3()
           
 
Method Summary
 void configure()
          Configures the application: case base, connectors, etc.
 void cycle(CBRQuery query)
          Executes a CBR cycle with the given query.
static void main(java.lang.String[] args)
           
 void postCycle()
          Runs the code to shutdown the application.
 CBRCaseBase preCycle()
          Runs the precyle where typically cases are read and organized into a case base.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Test3

public Test3()
Method Detail

configure

public void configure()
               throws ExecutionException
Description copied from interface: StandardCBRApplication
Configures the application: case base, connectors, etc.

Specified by:
configure in interface StandardCBRApplication
Throws:
ExecutionException

preCycle

public CBRCaseBase preCycle()
                     throws ExecutionException
Description copied from interface: StandardCBRApplication
Runs the precyle where typically cases are read and organized into a case base.

Specified by:
preCycle in interface StandardCBRApplication
Returns:
The created case base with the cases in the storage.
Throws:
ExecutionException

cycle

public void cycle(CBRQuery query)
           throws ExecutionException
Description copied from interface: StandardCBRApplication
Executes a CBR cycle with the given query.

Specified by:
cycle in interface StandardCBRApplication
Throws:
ExecutionException

postCycle

public void postCycle()
               throws ExecutionException
Description copied from interface: StandardCBRApplication
Runs the code to shutdown the application. Typically it closes the connector.

Specified by:
postCycle in interface StandardCBRApplication
Throws:
ExecutionException

main

public static void main(java.lang.String[] args)
Parameters:
args -

GAIA - Group for Artificial Intelligence Applications
http://gaia.fdi.ucm.es