public IDirectory getRootDirectory() {
List<IDirectory> directories = getDirectoryList();
Hashtable<Integer, IDirectory> ht = new Hashtable<Integer, IDirectory>();
IDirectory root = null;
for (IDirectory d : directories) {
if (d.getDirectory() == null) {
root = d;
}
d.setSubDirectoriesList(new ArrayList<IDirectory>());
d.setConfigList(new ArrayList<IConfig<?>>());
ht.put(d.getId(), d);
}
for (IDirectory d : directories) {
// Set parent
if (d.getDirectory() != null) {
int parentId = d.getDirectory().getId();
IDirectory parent = ht.get(parentId);
d.setDirectory(parent);
parent.getSubDirectoriesList().add(d);
}
}
List<Configuration> configs = getConfigList();
for (Configuration c : configs) {
String type = c.getType();
IConfig<?> scan = null;
if (type.equals("Config1DImpl") || type.equals("Config1D")) {
scan = new Config1DImpl(); // new Config1D();
scan.setType(IConfig.ScanType.SCAN_1D);
}
else if (type.equals("Config2DImpl") || type.equals("Config2D")) {
scan = new Config2DImpl(); // new Config1D();
scan.setType(IConfig.ScanType.SCAN_2D);
}
else if (type.equals("ConfigHCSImpl") || type.equals("ConfigHCS")) {
scan = new ConfigHCSImpl();
scan.setType(IConfig.ScanType.SCAN_HCS);
}
else if (type.equals("ConfigKImpl") || type.equals("ConfigK")) {
scan = new ConfigKImpl();
scan.setType(IConfig.ScanType.SCAN_K);
}
else if (type.equals("ConfigEnergyImpl") || type.equals("ConfigEnergy")) {
scan = new ConfigEnergyImpl();
scan.setType(IConfig.ScanType.SCAN_ENERGY);
}
// Former code
// if (type.equals("Config1DImpl") || type.equals("Config1D")) {
// scan = new ConfigImpl(); // new Config1D();
// scan.setType(IConfig.ScanType.SCAN_1D);
// }
// else if (type.equals("Config2DImpl") || type.equals("Config2D")) {
// scan = new ConfigImpl(); // new Config1D();
// scan.setType(IConfig.ScanType.SCAN_2D);
// }
// else if (type.equals("ConfigHCSImpl") || type.equals("ConfigHCS")) {
// scan = new ConfigImpl();
// scan.setType(IConfig.ScanType.SCAN_HCS);
// }
// else if (type.equals("ConfigKImpl") || type.equals("ConfigK")) {
// scan = new ConfigImpl();
// scan.setType(IConfig.ScanType.SCAN_K);
// }
// else if (type.equals("ConfigEnergyImpl") || type.equals("ConfigEnergy")) {
// scan = new ConfigImpl();
// scan.setType(IConfig.ScanType.SCAN_ENERGY);
// }
// else if (type.equals("ConfigEnergy")) {
// scan = new ConfigEnergyImpl();
// scan.setType(IConfig.ScanType.SCAN_ENERGY);
// }
/*
* else if (type.equals("Config2D")) { scan = new Config2D(); } else
* if (type.equals("ConfigK")) { scan = new ConfigK(); } else if
* (type.equals("ConfigEnergy")) { scan = new ConfigEnergy(); } else
* if (type.equals("ConfigHCS")) { scan = new ConfigHCS(); }
*/
scan.setName(c.getName());
scan.setId(c.getId());
scan.setTimestamp(c.getTimestamp());
int directoryId = c.getDirectoryId();// scan.getDirectory().getId();
IDirectory directory = ht.get(directoryId);
scan.setDirectory(directory);
directory.getConfigList().add(scan);
}
return root;
}