Search in sources :

Example 6 with QueryRunner

use of net.sourceforge.processdash.tool.db.QueryRunner in project processdash by dtuma.

the class WorkflowReport method getWorkflowsForCurrentProject.

private Map<String, String> getWorkflowsForCurrentProject(HttpServletRequest req) {
    DashboardContext dash = (DashboardContext) PDashServletUtils.buildEnvironment(req).get(TinyCGI.DASHBOARD_CONTEXT);
    DatabasePlugin databasePlugin = dash.getDatabasePlugin();
    QueryUtils.waitForAllProjects(databasePlugin);
    QueryRunner queryRunner = databasePlugin.getObject(QueryRunner.class);
    PDashContext ctx = PDashServletUtils.getContext(req);
    String projectID = ctx.getData().getString("Project_ID");
    String workflowProcessIDPattern = DatabasePluginUtils.getWorkflowPhaseIdentifier(projectID, "%");
    Map<String, String> result = new TreeMap<String, String>();
    String query = Settings.isTeamMode() ? WORKFLOW_LIST_QUERY : WORKFLOW_LIST_QUERY_PERSONAL;
    QueryUtils.mapColumns(result, //
    queryRunner.queryHql(//
    query, workflowProcessIDPattern));
    return result;
}
Also used : DashboardContext(net.sourceforge.processdash.DashboardContext) PDashContext(net.sourceforge.processdash.api.PDashContext) DatabasePlugin(net.sourceforge.processdash.tool.db.DatabasePlugin) TreeMap(java.util.TreeMap) QueryRunner(net.sourceforge.processdash.tool.db.QueryRunner)

Example 7 with QueryRunner

use of net.sourceforge.processdash.tool.db.QueryRunner in project processdash by dtuma.

the class UserGroupUtil method getProjectIDsForFilter.

public static Set<String> getProjectIDsForFilter(UserFilter filter, DashboardContext ctx) {
    if (filter == null)
        return null;
    Set<String> datasetIDs = filter.getDatasetIDs();
    if (datasetIDs == null)
        return null;
    else if (datasetIDs.isEmpty())
        return Collections.EMPTY_SET;
    DatabasePlugin databasePlugin = ctx.getDatabasePlugin();
    QueryUtils.waitForAllProjects(databasePlugin);
    QueryRunner query = databasePlugin.getObject(QueryRunner.class);
    return new HashSet(query.queryHql(PROJECT_FILTER_QUERY, datasetIDs));
}
Also used : DatabasePlugin(net.sourceforge.processdash.tool.db.DatabasePlugin) QueryRunner(net.sourceforge.processdash.tool.db.QueryRunner) HashSet(java.util.HashSet)

Example 8 with QueryRunner

use of net.sourceforge.processdash.tool.db.QueryRunner in project processdash by dtuma.

the class ImportedDefectManager method run.

/**
     * Run a defect analysis against a set of defects that were imported by
     * the database plugin
     * 
     * @param plugin the database plugin
     * @param dbCriteria the criteria to use against the database
     * @param processID the ID of the base process to map phase data to
     * @param t the analysis task to run
     */
public static void run(DatabasePlugin plugin, List dbCriteria, String processID, DefectAnalyzer.Task t) {
    QueryRunner queryRunner = plugin.getObject(QueryRunner.class);
    if (queryRunner == null)
        return;
    StringBuilder query = new StringBuilder(DEFECT_HQL_QUERY);
    List args = new ArrayList();
    args.add(processID);
    args.add(processID);
    QueryUtils.addCriteriaToHql(query, "d", args, dbCriteria);
    List<DefectToAnalyze> defects = new ArrayList();
    Map<Object, String> datasetIDs = QueryUtils.mapColumns(queryRunner.queryHql(DATASET_ID_QUERY));
    List<Object[]> rawData = queryRunner.queryHql(query.toString(), args.toArray());
    for (Object[] oneRow : rawData) {
        String path = getDefectPathFromHqlResultRow(oneRow);
        Defect d = getDefectFromHqlResultRow(oneRow, datasetIDs);
        defects.add(new DefectToAnalyze(path, d));
    }
    Collections.sort(defects);
    for (DefectToAnalyze defect : defects) t.analyze(defect.path, defect.defect);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) QueryRunner(net.sourceforge.processdash.tool.db.QueryRunner)

Aggregations

QueryRunner (net.sourceforge.processdash.tool.db.QueryRunner)8 List (java.util.List)5 ArrayList (java.util.ArrayList)4 DatabasePlugin (net.sourceforge.processdash.tool.db.DatabasePlugin)4 DashboardContext (net.sourceforge.processdash.DashboardContext)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 TreeMap (java.util.TreeMap)1 PDashContext (net.sourceforge.processdash.api.PDashContext)1 DoubleData (net.sourceforge.processdash.data.DoubleData)1 ListData (net.sourceforge.processdash.data.ListData)1 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)1 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)1 ProjectLocator (net.sourceforge.processdash.tool.db.ProjectLocator)1 WorkflowHistDataHelper (net.sourceforge.processdash.tool.db.WorkflowHistDataHelper)1 PatternList (net.sourceforge.processdash.util.PatternList)1