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;
}
}
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);
}
}
}
Aggregations