use of net.sourceforge.processdash.log.time.TimeLogEntry in project processdash by dtuma.
the class TimeLogReport method queryDatabaseForTimeLogEntries.
private List queryDatabaseForTimeLogEntries(UserFilter privacyFilter) {
// retrieve a mapping of dataset IDs, if we need it for testing privacy
PDashQuery query = getPdash().getQuery();
Map<Object, String> datasetIDs = null;
if (!UserGroup.isEveryone(privacyFilter))
datasetIDs = QueryUtils.mapColumns(query.query(DATASET_ID_QUERY));
// retrieve the ID of the process whose phases we should map to
String processID = getParameter("processID");
if (processID == null)
processID = new ProcessUtil(getDataContext()).getProcessID();
// retrieve the raw data for the time log entries themselves
List<Object[]> rawData = query.query(TIME_LOG_HQL, processID);
rawData.addAll(query.query(TIME_LOG_UNCAT_HQL));
// build a list of time log entries
List<TimeLogEntry> result = new ArrayList<TimeLogEntry>();
for (Object[] row : rawData) {
String path = row[0] + "/" + row[1];
if (path.startsWith("//"))
path = path.substring(1);
Date start = (Date) row[2];
long delta = ((Number) row[3]).longValue();
long interrupt = ((Number) row[4]).longValue();
String comment = (String) row[5];
// if a privacy filter is in effect, see if it excludes this entry
if (datasetIDs != null) {
String datasetID = datasetIDs.get(row[6]);
if (!privacyFilter.getDatasetIDs().contains(datasetID)) {
someEntriesBlocked = true;
continue;
}
}
// create a time log entry and add it to the list
result.add(new //
TimeLogEntryVO(//
0, //
path, //
start, //
delta, interrupt, comment));
}
return result;
}
use of net.sourceforge.processdash.log.time.TimeLogEntry in project processdash by dtuma.
the class EVCalculatorData method saveActualScheduleTime.
private void saveActualScheduleTime(TimeLog log) throws IOException {
try {
Date start = rezeroAtStartDate ? scheduleStartDate : null;
Iterator entries = log.filter(null, start, null);
while (entries.hasNext()) saveActualScheduleTime((TimeLogEntry) entries.next());
} catch (IONoSuchElementException ion) {
throw ion.getIOException();
}
}
use of net.sourceforge.processdash.log.time.TimeLogEntry in project processdash by dtuma.
the class RestoreIndivDataWorker method restoreTimeLogData.
private void restoreTimeLogData() throws IOException {
// make a list of the time log entries that are already logged against
// the project within the current dashboard.
Set<Date> knownEntries = new HashSet();
ModifiableTimeLog timeLog = (ModifiableTimeLog) ctx.getTimeLog();
Iterator i = timeLog.filter(projectPrefix, null, null);
while (i.hasNext()) {
TimeLogEntry tle = (TimeLogEntry) i.next();
knownEntries.add(tle.getStartTime());
}
// now scan the imported time log entries, and add any missing entries
// to the time log.
i = ImportedTimeLogManager.getInstance().getImportedTimeLogEntries(importPrefix);
while (i.hasNext()) {
TimeLogEntry tle = (TimeLogEntry) i.next();
if (!knownEntries.contains(tle.getStartTime())) {
String importedPath = tle.getPath();
String hierPath = mapPathToHierarchy(importedPath, MapType.KeepExtra);
TimeLogEntryVO newTle = new TimeLogEntryVO(timeLog.getNextID(), hierPath, tle.getStartTime(), tle.getElapsedTime(), tle.getInterruptTime(), tle.getComment(), ChangeFlagged.ADDED);
timeLog.addModification(newTle);
}
}
}
use of net.sourceforge.processdash.log.time.TimeLogEntry in project processdash by dtuma.
the class EVWeekReport method getActualTimeSpentIndiv.
private void getActualTimeSpentIndiv(Map<String, Map<String, Double>> result, Date fromDate, Date toDate) {
// scan the time log and gather up the actual time spent per task
Map<String, Double> actualTimes = new HashMap();
try {
EnumerIterator timeLogEntries = getDashboardContext().getTimeLog().filter(null, fromDate, toDate);
while (timeLogEntries.hasNext()) {
TimeLogEntry tle = (TimeLogEntry) timeLogEntries.next();
String path = tle.getPath();
double time = tle.getElapsedTime();
sumActualTime(actualTimes, path, time);
}
} catch (IOException e) {
}
result.put(getOwner(), actualTimes);
}
use of net.sourceforge.processdash.log.time.TimeLogEntry in project processdash by dtuma.
the class TextMetricsFileExporter method run.
public void run() {
try {
outWriter = new RobustFileWriter(dest, "UTF-8");
PrintWriter out = new PrintWriter(new BufferedWriter(outWriter));
// Find and print any applicable task lists.
Iterator i = ctx.getData().getKeys();
Set taskListNames = new HashSet();
String name;
int pos;
while (i.hasNext()) {
name = (String) i.next();
pos = name.indexOf(TASK_ORD_PREF);
if (pos != -1 && Filter.matchesFilter(filter, name))
taskListNames.add(name.substring(pos + TASK_ORD_PREF.length()));
}
i = taskListNames.iterator();
String owner = ProcessDashboard.getOwnerName(ctx.getData());
while (i.hasNext()) {
name = (String) i.next();
EVTaskList tl = EVTaskList.openExisting(name, ctx.getData(), ctx.getHierarchy(), ctx.getCache(), false);
if (tl == null)
continue;
tl.recalc();
String xml = tl.getAsXML(false);
name = exportedScheduleDataName(owner, name);
out.write(name + ",");
out.write(StringData.escapeString(xml));
out.println();
}
ctx.getData().dumpRepository(out, filter, DataRepository.DUMP_STYLE_TEXT);
TimeLog tl = ctx.getTimeLog();
Iterator keys = tl.filter(null, null, null);
while (keys.hasNext()) {
TimeLogEntry tle = (TimeLogEntry) keys.next();
if (Filter.matchesFilter(filter, tle.getPath()))
out.println(toAbbrevString(tle));
}
out.println(DefectXmlConstantsv1.DEFECT_START_TOKEN);
DefectExporterXMLv1 exp = new DefectExporterXMLv1();
exp.dumpDefects(ctx.getHierarchy(), filter, out);
out.close();
outWriter = null;
completionStatus = new CompletionStatus(CompletionStatus.SUCCESS, dest, null);
} catch (Exception ioe) {
completionStatus = new CompletionStatus(CompletionStatus.ERROR, dest, ioe);
System.out.println("IOException: " + ioe);
tryCancel();
}
ctx.getData().gc(filter);
}
Aggregations