Package net.sourceforge.processdash.tool.db

Examples of net.sourceforge.processdash.tool.db.QueryRunner


     * @param dbCriteria the criteria to use against the database
     * @param t the analysis task to run
     */
    public static void run(DatabasePlugin plugin, List dbCriteria,
            DefectAnalyzer.Task t) {
        QueryRunner queryRunner = plugin.getObject(QueryRunner.class);
        if (queryRunner == null)
            return;

        StringBuilder query = new StringBuilder(DEFECT_HQL_QUERY);
        List args = QueryUtils.addCriteriaToHql(query, "d", null, dbCriteria);

        List<DefectToAnalyze> defects = new ArrayList();
        List<Object[]> rawData = queryRunner.queryHql(query.toString(),
            args.toArray());
        for (Object[] oneRow : rawData) {
            String path = getDefectPathFromHqlResultRow(oneRow);
            Defect d = getDefectFromHqlResultRow(oneRow);
            defects.add(new DefectToAnalyze(path, d));
View Full Code Here


     * @return the results of the HQL query
     */
    protected List queryHql(ExpressionContext context, String baseQuery,
            String entityName, List criteria, Object... baseQueryArgs) {
        // get the object for executing database queries
        QueryRunner queryRunner = getDbObject(context, QueryRunner.class);
        if (queryRunner == null)
            return null;

        // build the effective query and associated argument list
        StringBuilder query = new StringBuilder(baseQuery);
        List queryArgs = new ArrayList(Arrays.asList(baseQueryArgs));
        QueryUtils.addCriteriaToHql(query, entityName, queryArgs, criteria);

        // if we know that the query won't return any result, don't bother
        // running it against the database.
        if (query.indexOf(QueryUtils.IMPOSSIBLE_CONDITION) != -1)
            return new ArrayList();

        // run the query
        Object[] queryArgArray = queryArgs.toArray();
        List result = queryRunner.queryHql(query.toString(), queryArgArray);
        return result;
    }
View Full Code Here

     *
     * Expected arguments: (project selection criteria)
     */
    public Object call(List arguments, ExpressionContext context) {
        // get the object for executing database queries
        QueryRunner queryRunner = getDbObject(context, QueryRunner.class);
        if (queryRunner == null)
            return null;

        // retrieve the criteria that should be used to narrow the query
        List criteria = collapseLists(arguments, 0);
View Full Code Here

     *
     * This method <b>must</b> be thread-safe.
     */
    public Object call(List arguments, ExpressionContext context) {
        // get the object for executing database queries
        QueryRunner queryRunner = getDbObject(context, QueryRunner.class);
        if (queryRunner == null)
            return null;

        // retrieve the WBS element name we are being asked to look up.
        String wbsElementName = asString(getArg(arguments, 0));
        if (wbsElementName == null)
            return null;
        if (wbsElementName.startsWith("/"))
            wbsElementName = wbsElementName.substring(1);
        if (wbsElementName.length() == 0)
            return null;
        wbsElementName = StringUtils.limitLength(wbsElementName, 255);

        // retrieve the plan item ID of the item we are being asked to look up.
        String planItemId = asString(getArg(arguments, 1));

        // look up this WBS element in the database.
        try {
            int key;
            List result = queryRunner.queryHql(NAME_QUERY, wbsElementName);
            if ((result == null || result.isEmpty())
                    && StringUtils.hasValue(planItemId))
                result = queryRunner.queryHql(ID_QUERY, planItemId);
            if (result != null && !result.isEmpty()) {
                // extract the value from the result set
                key = (Integer) result.get(0);
            } else {
                // not found? Use an impossible WBS key to result in no matches
View Full Code Here

        DatabasePlugin db = getDashboardContext().getDatabasePlugin();
        if (db == null)
            return;

        ProjectLocator loc = db.getObject(ProjectLocator.class);
        QueryRunner query = db.getObject(QueryRunner.class);
        if (loc == null || query == null)
            return;

        int fromDateKey = DatabasePluginUtils.getKeyForDate(fromDate, 10000);
        int toDateKey = DatabasePluginUtils.getKeyForDate(toDate, -10000);
        Set<Integer> projectKeys = getProjectKeys(tasks, loc);
        if (projectKeys.isEmpty())
            return;

        List data;
        try {
            data = query.queryHql(TIME_LOG_QUERY, projectKeys, fromDateKey,
                toDateKey);
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
View Full Code Here

TOP

Related Classes of net.sourceforge.processdash.tool.db.QueryRunner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.