// Copyright (C) 2011 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.gerrit.reviewdb.server;

import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.SubmoduleSubscription;
import com.google.gwtorm.server.Access;
import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.PrimaryKey;
import com.google.gwtorm.server.Query;
import com.google.gwtorm.server.ResultSet;

public interface SubmoduleSubscriptionAccess extends
    Access<SubmoduleSubscription, SubmoduleSubscription.Key> {
  @PrimaryKey("key")
  SubmoduleSubscription get(SubmoduleSubscription.Key key) throws OrmException;

  @Query("WHERE key.superProject = ?")
  ResultSet<SubmoduleSubscription> bySuperProject(Branch.NameKey superProject)
      throws OrmException;

  @Query("WHERE submodule = ?")
  ResultSet<SubmoduleSubscription> bySubmodule(Branch.NameKey submodule)
      throws OrmException;
}

@@ -695,16 +695,66 @@
 Branch;%0A
+import com.google.gerrit.reviewdb.client.Project;%0A
 import c
@@ -1392,91 +1392,1301 @@
 %0A%0A  
-@Query(%22WHERE submodule = ?%22)%0A  ResultSet%3CSubmoduleSubscription%3E bySubmodule(Branch
+/**%0A   * Fetches all %3Ccode%3ESubmoduleSubscription%3C/code%3Es in which some branch of%0A   * %3Ccode%3EsuperProject%3C/code%3E subscribes a branch.%0A   *%0A   * Use %7B@link #bySuperproject(Branch.NameKey)%7D to fetch for a branch instead%0A   * of a project.%0A   *%0A   * @param superProject the project to fetch subscriptions for%0A   * @return %3Ccode%3ESubmoduleSubscription%3C/code%3Es that are subscribed by some%0A   * branch of %3Ccode%3EsuperProject%3C/code%3E.%0A   * @throws OrmException%0A   */%0A  @Query(%22WHERE key.superProject.projectName = ?%22)%0A  ResultSet%3CSubmoduleSubscription%3E bySuperProjectProject(Project.NameKey superProject)%0A      throws OrmException;%0A%0A  @Query(%22WHERE submodule = ?%22)%0A  ResultSet%3CSubmoduleSubscription%3E bySubmodule(Branch.NameKey submodule)%0A      throws OrmException;%0A%0A  /**%0A   * Fetches all %3Ccode%3ESubmoduleSubscription%3C/code%3Es in which some branch of%0A   * %3Ccode%3Esubmodule%3C/code%3E is subscribed.%0A   *%0A   * Use %7B@link #bySubmodule(Branch.NameKey)%7D to fetch for a branch instead of%0A   * a project.%0A   *%0A   * @param submodule the project to fetch subscriptions for.%0A   * @return %3Ccode%3ESubmoduleSubscription%3C/code%3Es that subscribe some branch of%0A   * %3Ccode%3Esubmodule%3C/code%3E.%0A   * @throws OrmException%0A   */%0A  @Query(%22WHERE submodule.projectName = ?%22)%0A  ResultSet%3CSubmoduleSubscription%3E bySubmoduleProject(Project
 .Nam

Add submodule subscriptions fetching by projects