Home | History | Annotate | Download | only in vogar
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package vogar;
     18 
     19 import java.util.LinkedHashSet;
     20 import java.util.List;
     21 import java.util.Set;
     22 import vogar.commands.Command;
     23 
     24 /**
     25  * A bug database that shells out to another process.
     26  */
     27 class CommandBugDatabase implements ExpectationStore.BugDatabase {
     28     private final Log log;
     29     private final String openBugsCommand;
     30 
     31     public CommandBugDatabase(Log log, String openBugsCommand) {
     32         this.log = log;
     33         this.openBugsCommand = openBugsCommand;
     34     }
     35 
     36     @Override public Set<Long> bugsToOpenBugs(Set<Long> bugs) {
     37         // query the external app for open bugs
     38         List<String> openBugs = new Command.Builder(log)
     39                 .args(openBugsCommand)
     40                 .args(bugs)
     41                 .execute();
     42         Set<Long> openBugsSet = new LinkedHashSet<Long>();
     43         for (String bug : openBugs) {
     44             openBugsSet.add(Long.parseLong(bug));
     45         }
     46         return openBugsSet;
     47     }
     48 }
     49