Search in sources :

Example 1 with EnumerIterator

use of net.sourceforge.processdash.util.EnumerIterator 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 2 with EnumerIterator

use of net.sourceforge.processdash.util.EnumerIterator in project processdash by dtuma.

the class TimeLogModifications method filter.

public EnumerIterator filter(String path, Date from, Date to) throws IOException {
    if (isEmpty())
        // optimization if there are no modifications to perform
        return parent.filter(path, from, to);
    Iterator baseEntries = parent.filter(null, null, null);
    Iterator modifiedEntries = new ModifiedEntriesFilter(baseEntries);
    Iterator addedEntries = new AddedEntriesFilter();
    EnumerIterator allEntries = new IteratorConcatenator(modifiedEntries, addedEntries);
    if (path == null && from == null && to == null)
        return allEntries;
    else
        return new TimeLogIteratorFilter(allEntries, path, from, to);
}
Also used : EnumerIterator(net.sourceforge.processdash.util.EnumerIterator) Iterator(java.util.Iterator) EnumerIterator(net.sourceforge.processdash.util.EnumerIterator) IteratorConcatenator(net.sourceforge.processdash.util.IteratorConcatenator)

Example 3 with EnumerIterator

use of net.sourceforge.processdash.util.EnumerIterator in project processdash by dtuma.

the class TimeLogIOTest method testOldStyleBoundaryCases.

public void testOldStyleBoundaryCases() throws Exception {
    // nonexistent file
    EnumerIterator iter = new OldStyleTimeLogReader(new File("foo"), new DummyIDSource());
    assertFalse(iter.hasNext());
    assertFalse(iter.hasMoreElements());
    try {
        iter.next();
        fail("Expected NoSuchElementException");
    } catch (NoSuchElementException nsee) {
    }
    try {
        iter.nextElement();
        fail("Expected NoSuchElementException");
    } catch (NoSuchElementException nsee) {
    }
    try {
        iter.remove();
        fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException nsee) {
    }
    try {
        iter = new OldStyleTimeLogReader(new IOExceptionInputStream(openFile(TIMELOG1_TXT), 200));
        fail("Expected IOException");
    } catch (IOException ioe) {
    }
    try {
        iter = new OldStyleTimeLogReader(new IOExceptionInputStream(openFile(TIMELOG1_TXT), 10000));
        while (iter.hasNext()) iter.next();
        fail("Expected IONoSuchElementException");
    } catch (IONoSuchElementException ionsee) {
    // expected behavior
    } catch (IOException ioe) {
        fail("Expected IONoSuchElementException");
    }
}
Also used : EnumerIterator(net.sourceforge.processdash.util.EnumerIterator) IOException(java.io.IOException) File(java.io.File) NoSuchElementException(java.util.NoSuchElementException)

Example 4 with EnumerIterator

use of net.sourceforge.processdash.util.EnumerIterator in project processdash by dtuma.

the class TimeLogIOTest method testNewStyleBoundaryCases.

public void testNewStyleBoundaryCases() throws Exception {
    // nonexistent file
    EnumerIterator iter = new TimeLogReader(new File("foo"));
    assertFalse(iter.hasNext());
    assertFalse(iter.hasMoreElements());
    try {
        iter.next();
        fail("Expected NoSuchElementException");
    } catch (NoSuchElementException nsee) {
    }
    try {
        iter.nextElement();
        fail("Expected NoSuchElementException");
    } catch (NoSuchElementException nsee) {
    }
    try {
        iter.remove();
        fail("Expected UnsupportedOperationException");
    } catch (UnsupportedOperationException nsee) {
    }
}
Also used : EnumerIterator(net.sourceforge.processdash.util.EnumerIterator) File(java.io.File) NoSuchElementException(java.util.NoSuchElementException)

Example 5 with EnumerIterator

use of net.sourceforge.processdash.util.EnumerIterator in project processdash by dtuma.

the class RolledUpTimeLog method filter.

public EnumerIterator filter(String path, Date from, Date to) throws IOException {
    List entries = new ArrayList();
    String[] prefixes = getPrefixes();
    StringMapper pathRemapper = getPathRemapper(prefixes);
    for (int i = 0; i < prefixes.length; i++) {
        String onePrefix = prefixes[i];
        // find any imported entries for the given prefix
        Iterator importedEntries = ImportedTimeLogManager.getInstance().getImportedTimeLogEntries(onePrefix);
        maybeAddEntries(entries, importedEntries, pathRemapper);
        // find any regular entries for the given prefix
        Iterator regularEntries = context.getTimeLog().filter(onePrefix, from, to);
        maybeAddEntries(entries, regularEntries, pathRemapper);
    }
    EnumerIterator result = new IteratorConcatenator(entries);
    result = new TimeLogIteratorFilter(result, path, from, to);
    return result;
}
Also used : StringMapper(net.sourceforge.processdash.util.StringMapper) EnumerIterator(net.sourceforge.processdash.util.EnumerIterator) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) EnumerIterator(net.sourceforge.processdash.util.EnumerIterator) IteratorConcatenator(net.sourceforge.processdash.util.IteratorConcatenator) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

EnumerIterator (net.sourceforge.processdash.util.EnumerIterator)6 File (java.io.File)3 Iterator (java.util.Iterator)3 IteratorConcatenator (net.sourceforge.processdash.util.IteratorConcatenator)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 NoSuchElementException (java.util.NoSuchElementException)2 Map (java.util.Map)1 TimeLogEntry (net.sourceforge.processdash.log.time.TimeLogEntry)1 StringMapper (net.sourceforge.processdash.util.StringMapper)1