Search in sources :

Example 1 with DefectTypeStandard

use of net.sourceforge.processdash.process.DefectTypeStandard in project processdash by dtuma.

the class Report4 method initValues.

/** Initialize internal data structures to zero */
private void initValues() {
    categories = new LinkedList();
    injCategories = new LinkedList();
    remCategories = new LinkedList();
    develPhases = getProcessListPlain("Development_Phase_List");
    failPhases = getProcessListPlain("Failure_Phase_List");
    allPhases = getProcessListPlain("Phase_List");
    for (Iterator i = develPhases.iterator(); i.hasNext(); ) {
        Category c = new InjCategory((String) i.next());
        categories.add(c);
        injCategories.add(c);
    }
    for (Iterator i = failPhases.iterator(); i.hasNext(); ) {
        Category c = new RemCategory((String) i.next());
        categories.add(c);
        remCategories.add(c);
    }
    hasCompile = allPhases.contains("Compile");
    if (hasCompile) {
        atCompile = new AtEntryCategory(allPhases, "Compile");
        remCompile = new FilteredByPhaseCategory(allPhases, "Compile");
        categories.add(atCompile);
        categories.add(remCompile);
    }
    totals = emptyRow();
    defectCounts = new TreeMap();
    if (strict) {
        DefectTypeStandard dts = DefectTypeStandard.get(getPrefix(), getDataRepository());
        for (int i = dts.options.size(); i-- > 0; ) getRow((String) dts.options.elementAt(i));
    }
}
Also used : Iterator(java.util.Iterator) DefectTypeStandard(net.sourceforge.processdash.process.DefectTypeStandard) TreeMap(java.util.TreeMap) LinkedList(java.util.LinkedList)

Example 2 with DefectTypeStandard

use of net.sourceforge.processdash.process.DefectTypeStandard in project processdash by dtuma.

the class Report5 method initValues.

/** Initialize internal data structures to zero */
private void initValues() {
    String typeParam = getParameter("type");
    reportType = 0;
    for (int i = 0; i < PARAM_FLAG.length; i++) if (PARAM_FLAG[i].equals(typeParam)) {
        reportType = i;
        break;
    }
    defectData = new HashMap();
    if (parameters.get("strict") != null) {
        DefectTypeStandard dts = DefectTypeStandard.get(getPrefix(), getDataRepository());
        for (int i = dts.options.size(); i-- > 0; ) getRow((String) dts.options.elementAt(i));
    }
}
Also used : HashMap(java.util.HashMap) DefectTypeStandard(net.sourceforge.processdash.process.DefectTypeStandard)

Example 3 with DefectTypeStandard

use of net.sourceforge.processdash.process.DefectTypeStandard in project processdash by dtuma.

the class EditDefectTypeStandards method handleImportForm.

private void handleImportForm() throws IOException {
    writeHeader();
    // retrieve the file that was uploaded in the form
    byte[] file = (byte[]) parameters.remove("file_CONTENTS");
    if (file == null || file.length == 0) {
        showImportForm("Import.No_File_Uploaded");
        return;
    }
    // parse the file as XML and find the defect type standards
    NodeList nl = null;
    try {
        Element xml = XMLUtils.parse(new ByteArrayInputStream(file)).getDocumentElement();
        if (DefectTypeStandard.STANDARDS_TAG.equals(xml.getTagName()))
            nl = xml.getElementsByTagName(DefectTypeStandard.STANDARD_TAG);
    } catch (Exception e) {
    }
    if (nl == null || nl.getLength() == 0) {
        showImportForm("Import.Not_DTS_File");
        return;
    }
    // parse the defect type standards from the XML
    List<DefectTypeStandard> standards = new ArrayList();
    for (int i = 0; i < nl.getLength(); i++) standards.add(new DefectTypeStandard((Element) nl.item(i)));
    // display a page asking the user which standards they wish to import
    writeHTMLHeader();
    out.print("<h2>");
    out.print(resources.getHTML("Import.Title"));
    out.println("</h2>\n<p>");
    out.print(resources.getHTML("Import.Confirm_Prompt"));
    out.println("<form action='dtsEdit.class' method='POST'>");
    out.print("<ul style='list-style:none'>");
    for (int i = 0; i < standards.size(); i++) {
        DefectTypeStandard standard = standards.get(i);
        out.print("<li><input type='hidden' name='name" + i + "' value='");
        out.print(XMLUtils.escapeAttribute(standard.getName()));
        out.print("'/><input type='hidden' name='spec" + i + "' value='");
        out.print(XMLUtils.escapeAttribute(standard.getSpec()));
        out.print("'/><input type='checkbox' name='sel' value='" + i + "'/> ");
        out.print(HTMLUtils.escapeEntities(standard.getName()));
        out.print("</li>\n");
    }
    out.print("</ul>");
    out.print("<p><input type=submit name='" + IMPORT_CONFIRM + "' value='");
    out.print(resources.getHTML("Import"));
    out.print("'>&nbsp;");
    out.print("<input type=submit name='cancel' value='");
    out.print(resources.getHTML("Cancel"));
    out.print("'>");
    out.print("</form></body></html>");
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) DefectTypeStandard(net.sourceforge.processdash.process.DefectTypeStandard) IOException(java.io.IOException)

Example 4 with DefectTypeStandard

use of net.sourceforge.processdash.process.DefectTypeStandard in project processdash by dtuma.

the class EditDefectTypeStandards method handleExport.

protected void handleExport() throws IOException {
    List<DefectTypeStandard> standardsToExport = getStandardsToExport();
    if (standardsToExport.isEmpty()) {
        writeHeader();
        showExportPage();
        return;
    }
    out.print("Content-Type: text/xml\r\n");
    out.print("Content-Disposition: attachment; " + "filename=\"defectTypeStandards.dtsxml\"\r\n\r\n");
    out.flush();
    XmlSerializer xml = XMLUtils.getXmlSerializer(true);
    xml.setOutput(outStream, "UTF-8");
    xml.startDocument("UTF-8", null);
    xml.startTag(null, DefectTypeStandard.STANDARDS_TAG);
    xml.attribute(null, "exportTime", XMLUtils.saveDate(new Date()));
    xml.attribute(null, "srcDataset", DashController.getDatasetID());
    for (DefectTypeStandard std : standardsToExport) {
        std.getAsXml(xml, false);
    }
    xml.endTag(null, DefectTypeStandard.STANDARDS_TAG);
    xml.endDocument();
}
Also used : DefectTypeStandard(net.sourceforge.processdash.process.DefectTypeStandard) Date(java.util.Date) XmlSerializer(org.xmlpull.v1.XmlSerializer)

Example 5 with DefectTypeStandard

use of net.sourceforge.processdash.process.DefectTypeStandard in project processdash by dtuma.

the class EditDefectTypeStandards method showEditBox.

protected void showEditBox(String standardName) throws IOException {
    DefectTypeStandard defectTypeStandard = null;
    if (standardName != null)
        defectTypeStandard = DefectTypeStandard.getByName(standardName, getDataRepository());
    out.print("<p>");
    out.println(resources.getHTML("Edit_Instructions"));
    out.print("<br><textarea name='" + CONTENTS + "' rows=12 cols=80>");
    if (defectTypeStandard == null) {
        out.print(resources.getHTML("Sample_Defect_Type"));
    } else {
        String type, description;
        for (int i = 0; i < defectTypeStandard.options.size(); i++) {
            type = (String) defectTypeStandard.options.elementAt(i);
            description = (String) defectTypeStandard.comments.get(type);
            out.print(HTMLUtils.escapeEntities(type));
            if (description != null && description.length() > 0) {
                out.print(" (");
                out.print(HTMLUtils.escapeEntities(description));
                out.print(")");
            }
            out.println();
        }
    }
    out.println("</textarea>");
}
Also used : DefectTypeStandard(net.sourceforge.processdash.process.DefectTypeStandard)

Aggregations

DefectTypeStandard (net.sourceforge.processdash.process.DefectTypeStandard)7 ArrayList (java.util.ArrayList)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 TreeMap (java.util.TreeMap)1 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1 XmlSerializer (org.xmlpull.v1.XmlSerializer)1