use of net.sourceforge.processdash.util.IteratorConcatenator in project processdash by dtuma.
the class PropertyKeyIterator method getForPrefixes.
public static Iterator getForPrefixes(DashHierarchy hier, Collection prefixes) {
List results = new ArrayList(prefixes.size());
for (Iterator i = prefixes.iterator(); i.hasNext(); ) {
String onePrefix = (String) i.next();
PropertyKey oneKey = hier.findExistingKey(onePrefix);
if (oneKey != null)
results.add(new PropertyKeyIterator(hier, oneKey));
}
if (results.isEmpty())
return Collections.EMPTY_LIST.iterator();
else if (results.size() == 1)
return (Iterator) results.get(0);
else
return new IteratorConcatenator(results);
}
use of net.sourceforge.processdash.util.IteratorConcatenator 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);
}
use of net.sourceforge.processdash.util.IteratorConcatenator in project processdash by dtuma.
the class TimeLogModifications method save.
public synchronized boolean save() {
if (saveFile == null || Settings.isReadOnly())
return false;
try {
RobustFileWriter out = new RobustFileWriter(saveFile, "UTF-8");
Iterator entries = new IteratorConcatenator(//
new RenamingOperationsIterator(), modifications.values().iterator());
TimeLogWriter.write(out, entries);
saveFileTimestamp = saveFile.lastModified();
dirty = false;
return true;
} catch (IOException ioe) {
System.err.println("Unable to save time log modifications to file '" + saveFile + "'");
ioe.printStackTrace();
return false;
}
}
use of net.sourceforge.processdash.util.IteratorConcatenator 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;
}
use of net.sourceforge.processdash.util.IteratorConcatenator in project processdash by dtuma.
the class WorkingTimeLog method maybeCleanup.
private synchronized void maybeCleanup() throws IOException {
if (Settings.isReadOnly())
return;
File oldStyleFile = getFile(OLD_TIME_LOG_FILENAME);
if (oldStyleFile.isFile() && oldStyleFile.length() > 0) {
Iterator currentEntries = realTimeMods.filter(null, null, null);
Iterator watcherCurrentEntries = new IDWatcher(currentEntries);
Iterator extraEntries = new OldStyleTimeLogReader(oldStyleFile, this);
Iterator allEntries = new IteratorConcatenator(watcherCurrentEntries, extraEntries);
doCleanup(allEntries);
getFile(OLD_TIME_LOG_FILENAME).delete();
} else if (realTimeMods.isEmpty() == false) {
Iterator currentEntries = realTimeMods.filter(null, null, null);
Iterator watcherCurrentEntries = new IDWatcher(currentEntries);
doCleanup(watcherCurrentEntries);
} else {
// no need to cleanup, but we still need to scan the existing log
// to find out the highest numbered TimeLogEntry ID in use
Iterator currentEntries = historicalTimeLog.filter(null, null, null);
Iterator watcherCurrentEntries = new IDWatcher(currentEntries);
while (watcherCurrentEntries.hasNext()) watcherCurrentEntries.next();
}
}
Aggregations