SequentialProcess folderProcess = new SequentialProcess();
folderProcess.add(downloadProcess);
folderMap.put((FolderIndex) file, folderProcess);
} else {
// when a file, the process can run in parallel with all siblings (done in next step)
fileMap.put((FileIndex) file, new AsyncComponent(downloadProcess));
}
}
// find children with same parents and make them run in parallel
// idea: iterate through all children and search for parent in other map. If not there, they can be
// added to the root process anyway
for (FileIndex file : fileMap.keySet()) {
AsyncComponent fileProcess = fileMap.get(file);
Index parent = file.getParent();
if (parent == null) {
// file is in root, thus we can add it to the root process
rootProcess.add(fileProcess);
} else if (folderMap.containsKey(parent)) {
// the parent exists here
SequentialProcess parentProcess = folderMap.get(parent);
parentProcess.add(fileProcess);
} else {
// file is not in root and parent is not here, thus we simply add it to the root process
rootProcess.add(fileProcess);
}
}
// files and folder are linked. We now link the folders with other folders
for (FolderIndex folder : folderMap.keySet()) {
SequentialProcess folderProcess = folderMap.get(folder);
// In addition, we can make this process run asynchronous because it does not affect the siblings
AsyncComponent asyncFolderProcess = new AsyncComponent(folderProcess);
Index parent = folder.getParent();
if (parent == null) {
// file is in root, thus we can add it to the root process.
rootProcess.add(asyncFolderProcess);
} else if (folderMap.containsKey(parent)) {