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
- Is this a good enough abstraction or i can do better?
- How to represent this in JPA 2? I know we can use descriminato开发者_如何学编程rs to map inheritance but my main concern is the 1-to-many relationship between WaterFallStep-to-BasicStep
Thank you.
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
精彩评论