Once the bundle id is retrieved everything else is a oozie related code. Create a method in oozie util that takes a coord id and then loops and use that method here.