You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Lars Ivar Igesund <la...@igesund.net> on 2008/10/29 15:45:53 UTC
Complex aggregations
Hi!
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 Person.id 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
though?
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