Search in sources :

Example 1 with HashTree

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);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashTree(net.sourceforge.processdash.util.HashTree) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) HashMap(java.util.HashMap) Map(java.util.Map) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 2 with HashTree

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;
}
Also used : HashTree(net.sourceforge.processdash.util.HashTree) SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 3 with HashTree

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);
    }
}
Also used : HashTree(net.sourceforge.processdash.util.HashTree) Iterator(java.util.Iterator) TagData(net.sourceforge.processdash.data.TagData) SimpleData(net.sourceforge.processdash.data.SimpleData) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 4 with HashTree

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);
}
Also used : HashTree(net.sourceforge.processdash.util.HashTree) OutputStreamWriter(java.io.OutputStreamWriter)

Example 5 with HashTree

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);
    }
}
Also used : HashTree(net.sourceforge.processdash.util.HashTree) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList)

Aggregations

HashTree (net.sourceforge.processdash.util.HashTree)6 Iterator (java.util.Iterator)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Map (java.util.Map)2 SimpleData (net.sourceforge.processdash.data.SimpleData)2 OutputStreamWriter (java.io.OutputStreamWriter)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 TagData (net.sourceforge.processdash.data.TagData)1