Search in sources :

Example 41 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class EditSubprojectList method findValidSubprojectNames.

private void findValidSubprojectNames(ListData result, PropertyKey key, String templateID) {
    DashHierarchy hier = getPSPProperties();
    String id = hier.getID(key);
    if (templateID.equals(id))
        result.add(key.path());
    else {
        int numChildren = hier.getNumChildren(key);
        for (int i = 0; i < numChildren; i++) findValidSubprojectNames(result, hier.getChildKey(key, i), templateID);
    }
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy)

Example 42 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class OpenDefectDialog method getDefectLog.

private DefectLogID getDefectLog(String path) {
    DashHierarchy hier = getPSPProperties();
    PropertyKey key = hier.findExistingKey(path);
    if (key == null)
        return null;
    ProcessDashboard dash = getDash();
    DefectLogID defectLog = hier.defectLog(key, dash.getDirectory());
    if (defectLog == null)
        return null;
    if (Filter.matchesFilter(dash.getBrokenDataPaths(), defectLog.path.path()))
        return null;
    return defectLog;
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) ProcessDashboard(net.sourceforge.processdash.ProcessDashboard) DefectLogID(net.sourceforge.processdash.log.defects.DefectLogID) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 43 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class DefectImportForm method importDefects.

private void importDefects(List defects) {
    DashHierarchy hier = dashboardContext.getHierarchy();
    PropertyKey defectLogKey = hier.findExistingKey(defectLogPath);
    ProcessDashboard dashboard = (ProcessDashboard) dashboardContext;
    String filename = hier.pget(defectLogKey).getDefectLog();
    if (!StringUtils.hasValue(filename)) {
        AbortImport.showError("Hierarchy_Changed", selectedPath);
        return;
    }
    DefectLog defectLog = new DefectLog(dashboard.getDirectory() + filename, defectLogPath, dashboardContext.getData());
    int addedCount = 0;
    int updatedCount = 0;
    int unchangedCount = 0;
    for (Iterator i = defects.iterator(); i.hasNext(); ) {
        Defect newDefect = (Defect) i.next();
        Defect oldDefect = defectLog.getDefect(newDefect.number);
        if (oldDefect == null) {
            addedCount++;
            defectLog.writeDefect(newDefect);
        } else {
            Defect originalDefect = (Defect) oldDefect.clone();
            oldDefect.defect_type = merge(oldDefect.defect_type, newDefect.defect_type);
            oldDefect.injected = merge(oldDefect.injected, newDefect.injected);
            oldDefect.phase_injected = oldDefect.injected.legacyPhase;
            oldDefect.removed = merge(oldDefect.removed, newDefect.removed);
            oldDefect.phase_removed = oldDefect.removed.legacyPhase;
            oldDefect.description = merge(oldDefect.description, newDefect.description);
            oldDefect.fix_time = merge(oldDefect.fix_time, newDefect.fix_time);
            oldDefect.fix_defect = merge(oldDefect.fix_defect, newDefect.fix_defect);
            if (originalDefect.equals(oldDefect)) {
                unchangedCount++;
            } else {
                updatedCount++;
                defectLog.writeDefect(oldDefect);
            }
        }
    }
    if (addedCount == 0 && updatedCount == 0) {
        JOptionPane.showMessageDialog(frame, resources.getStrings("Nothing_To_Do.Message"), resources.getString("Nothing_To_Do.Title"), JOptionPane.INFORMATION_MESSAGE);
    } else if (addedCount < defects.size()) {
        String title = resources.getString("Defects_Updated.Title");
        Object[] message = new Object[4];
        message[0] = resources.getStrings("Defects_Updated.Message");
        message[1] = getUpdatedSegment("Added", addedCount);
        message[2] = getUpdatedSegment("Unchanged", unchangedCount);
        message[3] = getUpdatedSegment("Updated", updatedCount);
        JOptionPane.showMessageDialog(frame, message, title, JOptionPane.INFORMATION_MESSAGE);
    }
}
Also used : DefectLog(net.sourceforge.processdash.log.defects.DefectLog) DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) ProcessDashboard(net.sourceforge.processdash.ProcessDashboard) Iterator(java.util.Iterator) Defect(net.sourceforge.processdash.log.defects.Defect) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Example 44 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class TemplateLoader method loadTemplates.

public static DashHierarchy loadTemplates(DataRepository data) {
    LOAD_TEMPLATES_PERMISSION.checkPermission();
    DashHierarchy templates = new DashHierarchy(null);
    ProfTimer pt = new ProfTimer(TemplateLoader.class, "TemplateLoader.loadTemplates");
    List<URL> roots = new ArrayList<URL>(Arrays.asList(getTemplateURLs()));
    pt.click("Got template roots");
    for (int i = roots.size(); i-- > 0; ) {
        String templateDirURL = roots.get(i).toString();
        if (templateDirURL.startsWith("file:/")) {
            /* If the /Templates directory exists as a local file
                 * somewhere, search through that directory for process
                 * templates.
                 */
            // strip "file:" from the beginning of the url.
            String dirname = templateDirURL.substring(5);
            dirname = HTMLUtils.urlDecode(dirname);
            searchDirForTemplates(templates, dirname, data);
            pt.click("searched dir '" + dirname + "' for templates");
        } else if (templateDirURL.startsWith("jar:")) {
            /* If the /Templates directory found is in a jar somewhere,
                 * search through the jar for process templates.
                 */
            // Strip "jar:" from the beginning and the "!/Templates/"
            // from the end of the URL.
            String jarFileURL = templateDirURL.substring(4, templateDirURL.indexOf('!'));
            JarSearchResult searchResult = searchJarForTemplates(templates, jarFileURL, data);
            // if this was an MCF JAR, remove its URL from the search path
            if (searchResult == JarSearchResult.Mcf) {
                logger.fine("Processed MCF URL " + templateDirURL);
                mcf_url_list.add(roots.remove(i));
            }
            pt.click("searched jar '" + jarFileURL + "' for templates");
        }
    }
    // find any missing MCFs that came bundled within a data backup file
    searchExternalResourcesForMissingMcfs(templates, data);
    // store the new list of template URLs, stripped of MCF JAR files
    template_url_list = roots.toArray(new URL[roots.size()]);
    generateRollupTemplates(templates, data);
    createProcessRoot(templates);
    pt.click("done loading templates");
    return templates;
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) ProfTimer(net.sourceforge.processdash.util.ProfTimer) ArrayList(java.util.ArrayList) URL(java.net.URL)

Example 45 with DashHierarchy

use of net.sourceforge.processdash.hier.DashHierarchy in project processdash by dtuma.

the class TemplateLoader method loadProcessTemplate.

private static void loadProcessTemplate(DashHierarchy templates, InputStream in, boolean close) throws IOException {
    DashHierarchy template = new DashHierarchy(null);
    template.load(in, close);
    createScriptMaps(template);
    templates.putAll(template);
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy)

Aggregations

DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)56 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)40 ArrayList (java.util.ArrayList)7 ListData (net.sourceforge.processdash.data.ListData)6 List (java.util.List)5 HashMap (java.util.HashMap)4 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)4 Point (java.awt.Point)3 Iterator (java.util.Iterator)3 ProcessDashboard (net.sourceforge.processdash.ProcessDashboard)3 SimpleData (net.sourceforge.processdash.data.SimpleData)3 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)3 IOException (java.io.IOException)2 Enumeration (java.util.Enumeration)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 HierarchyAlterer (net.sourceforge.processdash.hier.HierarchyAlterer)2 Prop (net.sourceforge.processdash.hier.Prop)2 DefectLog (net.sourceforge.processdash.log.defects.DefectLog)2 DefectLogID (net.sourceforge.processdash.log.defects.DefectLogID)2