use of net.sourceforge.processdash.util.HashTree in project processdash by dtuma.
the class ImportedDefectManager method run.
/**
* Run a defect analysis against a set of defects that were imported via the
* {@link #importDefects(String, List)} method of this class.
*/
public static void run(DashHierarchy props, DataRepository data, String[] prefixes, boolean includeChildren, DefectAnalyzer.Task t) {
Map wbsIdMap = buildWbsIdMap(props, data);
Set keys = new HashSet();
for (int i = 0; i < prefixes.length; i++) {
String prefix = prefixes[i] + "/";
HashTree context = (HashTree) importedDefects.get(prefix);
if (context != null) {
if (includeChildren) {
Iterator j = context.getAllKeys();
while (j.hasNext()) keys.add(prefix + j.next());
} else {
if (context.get(DEFECT_LIST_ELEM) != null)
keys.add(prefix + DEFECT_LIST_ELEM);
}
}
}
List defects = new LinkedList();
for (Iterator i = keys.iterator(); i.hasNext(); ) {
String key = (String) i.next();
if (key.endsWith(DEFECT_LIST_SUFFIX)) {
List defectList = (List) importedDefects.get(key);
String defectPath = key.substring(0, key.length() - DEFECT_LIST_SUFFIX.length());
defectPath = rerootPath(data, defectPath, wbsIdMap);
for (Iterator j = defectList.iterator(); j.hasNext(); ) {
defects.add(new DefectToAnalyze(defectPath, (Defect) j.next()));
}
}
}
Collections.sort(defects);
for (Iterator i = defects.iterator(); i.hasNext(); ) {
DefectToAnalyze defect = (DefectToAnalyze) i.next();
t.analyze(defect.path, defect.defect);
}
}
use of net.sourceforge.processdash.util.HashTree in project processdash by dtuma.
the class DataExporterXMLv1 method sortDataElements.
private HashTree sortDataElements(Iterator dataElements) {
HashTree result = new HashTree(TreeMap.class);
while (dataElements.hasNext()) {
ExportedDataValue v = (ExportedDataValue) dataElements.next();
String name = v.getName();
SimpleData simpleValue = v.getSimpleValue();
if (simpleValue != null)
result.put(name, simpleValue);
}
return result;
}
use of net.sourceforge.processdash.util.HashTree in project processdash by dtuma.
the class DataExporterXMLv1 method writeDataElementsForNode.
private void writeDataElementsForNode(XmlSerializer xml, HashTree data, int depth) throws IOException {
// write all the tags for this node first.
for (Iterator iter = data.getContents(); iter.hasNext(); ) {
Map.Entry e = (Map.Entry) iter.next();
String dataName = (String) e.getKey();
SimpleData dataValue = (SimpleData) e.getValue();
if (dataValue instanceof TagData)
writeDataElement(xml, dataName, dataValue, depth);
}
// now, write the rest of the data elements.
for (Iterator iter = data.getContents(); iter.hasNext(); ) {
Map.Entry e = (Map.Entry) iter.next();
String dataName = (String) e.getKey();
SimpleData dataValue = (SimpleData) e.getValue();
if (!(dataValue instanceof TagData))
writeDataElement(xml, dataName, dataValue, depth);
}
// finally, write all the children.
for (Iterator iter = data.getChildren(); iter.hasNext(); ) {
Map.Entry e = (Map.Entry) iter.next();
String childName = (String) e.getKey();
HashTree child = (HashTree) e.getValue();
writeChildElement(xml, childName, child, depth);
}
}
use of net.sourceforge.processdash.util.HashTree in project processdash by dtuma.
the class DataExporterXMLv1 method export.
public void export(OutputStream out, Iterator dataElements) throws IOException {
HashTree sorted = sortDataElements(dataElements);
writeDataElements(new OutputStreamWriter(out, ENCODING), sorted);
}
use of net.sourceforge.processdash.util.HashTree in project processdash by dtuma.
the class ImportedDefectManager method importDefects.
/** Import a list of defects, and associate them with the given prefix.
*
* If other defects are already present in the cache with the same prefix,
* these defects will be added to that list. (To replace the defects with
* a given prefix, call {@link #closeDefects(String)} first.)
*
* @param prefix the prefix where the defects should be mounted
* @param defects a List of {@link ImportedDefect} objects
*/
public static synchronized void importDefects(String prefix, List defects) {
HashTree context = getContext(importedDefects, prefix + "/");
for (Iterator iter = defects.iterator(); iter.hasNext(); ) {
ImportedDefect d = (ImportedDefect) iter.next();
List l = getList(context, d.path);
l.add(d.defect);
}
}
Aggregations