|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjcolibri.test.test3.Test3
public class Test3
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
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:
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 |
---|
public Test3()
Method Detail |
---|
public void configure() throws ExecutionException
StandardCBRApplication
configure
in interface StandardCBRApplication
ExecutionException
public CBRCaseBase preCycle() throws ExecutionException
StandardCBRApplication
preCycle
in interface StandardCBRApplication
ExecutionException
public void cycle(CBRQuery query) throws ExecutionException
StandardCBRApplication
cycle
in interface StandardCBRApplication
ExecutionException
public void postCycle() throws ExecutionException
StandardCBRApplication
postCycle
in interface StandardCBRApplication
ExecutionException
public static void main(java.lang.String[] args)
args
-
|
GAIA - Group for Artificial Intelligence Applications http://gaia.fdi.ucm.es |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |