Search in sources :

Example 1 with TimeLogEntry

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;
}
Also used : PDashQuery(net.sourceforge.processdash.api.PDashQuery) ArrayList(java.util.ArrayList) ProcessUtil(net.sourceforge.processdash.process.ProcessUtil) Date(java.util.Date) TimeLogEntry(net.sourceforge.processdash.log.time.TimeLogEntry)

Example 2 with TimeLogEntry

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();
    }
}
Also used : IONoSuchElementException(net.sourceforge.processdash.log.time.IONoSuchElementException) TimeLogEntry(net.sourceforge.processdash.log.time.TimeLogEntry) Iterator(java.util.Iterator) Date(java.util.Date)

Example 3 with TimeLogEntry

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);
        }
    }
}
Also used : ModifiableTimeLog(net.sourceforge.processdash.log.time.ModifiableTimeLog) TimeLogEntry(net.sourceforge.processdash.log.time.TimeLogEntry) Iterator(java.util.Iterator) TimeLogEntryVO(net.sourceforge.processdash.log.time.TimeLogEntryVO) Date(java.util.Date) HashSet(java.util.HashSet)

Example 4 with TimeLogEntry

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);
}
Also used : EnumerIterator(net.sourceforge.processdash.util.EnumerIterator) HashMap(java.util.HashMap) TimeLogEntry(net.sourceforge.processdash.log.time.TimeLogEntry) IOException(java.io.IOException)

Example 5 with TimeLogEntry

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);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) BufferedWriter(java.io.BufferedWriter) TimeLog(net.sourceforge.processdash.log.time.TimeLog) TimeLogEntry(net.sourceforge.processdash.log.time.TimeLogEntry) CompletionStatus(net.sourceforge.processdash.tool.export.mgr.CompletionStatus) Iterator(java.util.Iterator) EVTaskList(net.sourceforge.processdash.ev.EVTaskList) RobustFileWriter(net.sourceforge.processdash.util.RobustFileWriter) PrintWriter(java.io.PrintWriter) HashSet(java.util.HashSet)

Aggregations

TimeLogEntry (net.sourceforge.processdash.log.time.TimeLogEntry)9 Iterator (java.util.Iterator)7 Date (java.util.Date)4 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 IONoSuchElementException (net.sourceforge.processdash.log.time.IONoSuchElementException)2 ProcessUtil (net.sourceforge.processdash.process.ProcessUtil)2 EnumerIterator (net.sourceforge.processdash.util.EnumerIterator)2 BufferedWriter (java.io.BufferedWriter)1 PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 PDashQuery (net.sourceforge.processdash.api.PDashQuery)1 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)1 ChangeFlaggedTimeLogEntry (net.sourceforge.processdash.log.time.ChangeFlaggedTimeLogEntry)1 ModifiableTimeLog (net.sourceforge.processdash.log.time.ModifiableTimeLog)1 TimeLog (net.sourceforge.processdash.log.time.TimeLog)1