Search in sources :

Example 1 with ProjectLocator

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

the class Dblookupprojects method call.

/**
     * Perform a procedure call.
     * 
     * This method <b>must</b> be thread-safe.
     */
public Object call(List arguments, ExpressionContext context) {
    // retrieve the list of IDs that we wish to look up, and the name of
    // the data element we are looking them up for
    List projectIDs = collapseLists(arguments, 0);
    String listenerName = asStringVal(context.get(SubscribingExpressionContext.LISTENERVAR_NAME));
    try {
        ProjectLocator loc = getDbObject(context, ProjectLocator.class);
        if (loc == null)
            return null;
        ListData result = new ListData();
        for (Iterator i = projectIDs.iterator(); i.hasNext(); ) {
            Integer key = null;
            String oneProjectId = asStringVal(i.next());
            if (oneProjectId != null)
                key = loc.getKeyForProject(oneProjectId, listenerName);
            if (key == null)
                key = -999;
            result.add(new ImmutableDoubleData(key, false, true));
        }
        return result;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : ProjectLocator(net.sourceforge.processdash.tool.db.ProjectLocator) Iterator(java.util.Iterator) List(java.util.List) ImmutableDoubleData(net.sourceforge.processdash.data.ImmutableDoubleData) ListData(net.sourceforge.processdash.data.ListData)

Example 2 with ProjectLocator

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

the class EVWeekReport method getActualTimeSpentTeam.

private void getActualTimeSpentTeam(Map<String, Map<String, Double>> result, TableModel tasks, Date fromDate, Date toDate) {
    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;
    }
    for (Object[] row : (List<Object[]>) data) {
        String dbPlanItemId = (String) row[0];
        String person = (String) row[1];
        double time = ((Number) row[2]).doubleValue();
        if (dbPlanItemId != null && person != null && time > 0) {
            Map<String, Double> personTime = result.get(person);
            if (personTime == null) {
                personTime = new HashMap();
                result.put(person, personTime);
            }
            String taskId = DatabasePluginUtils.getTaskIdFromPlanItemId(dbPlanItemId);
            sumActualTime(personTime, taskId, time);
        }
    }
}
Also used : ProjectLocator(net.sourceforge.processdash.tool.db.ProjectLocator) HashMap(java.util.HashMap) DatabasePlugin(net.sourceforge.processdash.tool.db.DatabasePlugin) QueryRunner(net.sourceforge.processdash.tool.db.QueryRunner) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException) IOException(java.io.IOException) ArrayList(java.util.ArrayList) EVTaskList(net.sourceforge.processdash.ev.EVTaskList) List(java.util.List)

Aggregations

List (java.util.List)2 ProjectLocator (net.sourceforge.processdash.tool.db.ProjectLocator)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 ImmutableDoubleData (net.sourceforge.processdash.data.ImmutableDoubleData)1 ListData (net.sourceforge.processdash.data.ListData)1 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)1 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)1 DatabasePlugin (net.sourceforge.processdash.tool.db.DatabasePlugin)1 QueryRunner (net.sourceforge.processdash.tool.db.QueryRunner)1