Add submodule subscriptions fetching by projects

While submodule subscriptions can be fetched by branch, some plugins
(e.g.: delete-project) would rather need to access all submodule
subscriptions of a project (regardless of the branch). Instead of
iterating over all branches of a project, and fetching the
subscription for each branch separately, we allow fetching of
subscriptions directly by projects.

Change-Id: I2780c2e9ff135c6afc582bc1fde7986ddd2f85ae
This commit is contained in:
Christian Aistleitner
2013-02-05 22:47:16 +01:00
parent a9a1c387b5
commit 724e432f4f

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.reviewdb.server;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.SubmoduleSubscription;
import com.google.gwtorm.server.Access;
import com.google.gwtorm.server.OrmException;
@@ -31,7 +32,39 @@ public interface SubmoduleSubscriptionAccess extends
ResultSet<SubmoduleSubscription> bySuperProject(Branch.NameKey superProject)
throws OrmException;
/**
* Fetches all <code>SubmoduleSubscription</code>s in which some branch of
* <code>superProject</code> subscribes a branch.
*
* Use {@link #bySuperproject(Branch.NameKey)} to fetch for a branch instead
* of a project.
*
* @param superProject the project to fetch subscriptions for
* @return <code>SubmoduleSubscription</code>s that are subscribed by some
* branch of <code>superProject</code>.
* @throws OrmException
*/
@Query("WHERE key.superProject.projectName = ?")
ResultSet<SubmoduleSubscription> bySuperProjectProject(Project.NameKey superProject)
throws OrmException;
@Query("WHERE submodule = ?")
ResultSet<SubmoduleSubscription> bySubmodule(Branch.NameKey submodule)
throws OrmException;
/**
* Fetches all <code>SubmoduleSubscription</code>s in which some branch of
* <code>submodule</code> is subscribed.
*
* Use {@link #bySubmodule(Branch.NameKey)} to fetch for a branch instead of
* a project.
*
* @param submodule the project to fetch subscriptions for.
* @return <code>SubmoduleSubscription</code>s that subscribe some branch of
* <code>submodule</code>.
* @throws OrmException
*/
@Query("WHERE submodule.projectName = ?")
ResultSet<SubmoduleSubscription> bySubmoduleProject(Project.NameKey submodule)
throws OrmException;
}