camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lars Ivar Igesund <>
Subject Complex aggregations
Date Wed, 29 Oct 2008 14:45:53 GMT

I have the following object types:

class Person {
   String id;
   ArrayList<Travel> travels;

class Travel {
   int sequencenumber;
   Person owner;

The input to the aggregation is instances of Travel, with sequencenumbers from 
1 to x, 1 to y, etc (ordered that way), or instances of Person with a list of 
travels. The output of the aggregation should be instances of Person. The 
meaning of the sequence number can generally be interpreted as saying 
something about where in an itinerary a Travel belongs such that 1 is you 
leaving home, and x is the last leg in the return.

Until now i have used a correlationexpression that returns the id of Person, 
and an aggregationstrategy that either collects travels in one Person, or 
takes a Travel and adds to a Person. Problem is that this strategy doesn't 
take the sequence numbers of Travel into account, as I would have each Person 
only have Travel instances such that there is one sequence from home to home.  
This means that in the aggregation, each time a Travel with seqnum == 1 is 
encountered, a new Person should be returned, even if is the same.

I looked at bit at the completedPredicate, but it needs both new and old to 
find out. Potentially it can be done with a specialized aggregate collection 

Any tips would be of interest. Note that this isn't crucial as the information 
can be checked later on in the pipeline.

Best regards,
Lars Ivar Igesund

View raw message