Question

Requirement: Requirement is to pull (execute()) a set of data sources. The pulls are are Ordered, can be grouped into small sub groups.

Design: Each pull is abstracted as a Step. A subgroup is represented as a WaterFallStep because the pull of each of the data source in a group is conditional and follows waterfall model i.e. if 1st data source pull in the group is successful then I' break out of the group.

Questions

  1. Is this a good enough abstraction or i can do better?
  2. How to represent this in JPA 2? I know we can use descriminators to map inheritance but my main concern is the 1-to-many relationship between WaterFallStep-to-BasicStep

Thank you.

alt text

Was it helpful?

Solution

I think that you should use a composite pattern here. I'd say that each step should handle reference to a collection of steps. If you want yo can move this collection to your WaterfallStep but it still should be a collection of Steps, not BasicSteps and not AbstractSteps.

Concerning JPA you should use OneToMany annotation. There are a lot of examples of usage of this annotation.

Good luck

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top