Search in sources :

Example 26 with DataRepository

use of net.sourceforge.processdash.data.repository.DataRepository in project processdash by dtuma.

the class EditDefectTypeStandards method getStandardsToExport.

private List<DefectTypeStandard> getStandardsToExport() {
    String[] selected = (String[]) parameters.get("sel_ALL");
    if (selected == null || selected.length == 0)
        return Collections.EMPTY_LIST;
    List<DefectTypeStandard> result = new ArrayList(selected.length);
    DataRepository data = getDataRepository();
    for (String selectedNum : selected) {
        String selectedName = getParameter("std" + selectedNum);
        DefectTypeStandard selectedStandard = DefectTypeStandard.getByName(selectedName, data);
        if (selectedStandard != null)
            result.add(selectedStandard);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) DataRepository(net.sourceforge.processdash.data.repository.DataRepository) DefectTypeStandard(net.sourceforge.processdash.process.DefectTypeStandard)

Example 27 with DataRepository

use of net.sourceforge.processdash.data.repository.DataRepository in project processdash by dtuma.

the class EditDefectTypeStandards method showListOfDefinedStandards.

protected void showListOfDefinedStandards() throws IOException {
    DataRepository data = getDataRepository();
    String[] standards = DefectTypeStandard.getDefinedStandards(data);
    boolean canEdit = canEdit();
    String defaultName = DefectTypeStandard.get("", data).getName();
    writeHTMLHeader();
    out.print("<p>");
    out.println(resources.getHTML("Welcome_Prompt"));
    out.println("<ul>");
    if (canEdit) {
        out.print("<li><a href=\"dtsEdit.class?" + ACTION + "=" + CREATE + "\">");
        out.print(resources.getHTML("Create_Option"));
        out.println("</a></li>");
    }
    if (standards.length > 0) {
        out.print("<li>");
        out.print(resources.getHTML("Manage_Option"));
        out.println("<table>");
        for (int i = 0; i < standards.length; i++) {
            String htmlName = HTMLUtils.escapeEntities(standards[i]);
            String urlName = HTMLUtils.urlEncode(standards[i]);
            out.print("<tr><td><ul><li>&quot;<b>");
            out.print(htmlName);
            out.print("</b>&quot;</li></ul></td>");
            int numOptions = (canEdit ? OPTIONS.length : 1);
            for (int o = 0; o < numOptions; o++) {
                if (o == DEFAULT && standards[i].equals(defaultName)) {
                    out.print("<td><i>(default)</i></td>");
                } else {
                    String opt = OPTIONS[o];
                    out.print("<td><a href='dtsEdit.class?" + ACTION + "=" + opt + "&" + NAME + "=" + urlName + "'>");
                    out.print(resources.getHTML(opt));
                    out.print("</a></td>");
                }
            }
            out.println("</tr>");
        }
        out.print("</table></li>");
    }
    out.print("<li>");
    if (canEdit) {
        out.print("<a href=\"dtsEdit.class?" + ACTION + "=" + IMPORT + "\">");
        out.print(resources.getHTML("Import_Option"));
        out.println("</a> / ");
    }
    out.print("<a href=\"dtsEdit.class?" + ACTION + "=" + EXPORT + "\">");
    out.print(resources.getHTML("Export_Option"));
    out.println("</a></li>");
    out.print("</ul></body></html>");
}
Also used : DataRepository(net.sourceforge.processdash.data.repository.DataRepository)

Example 28 with DataRepository

use of net.sourceforge.processdash.data.repository.DataRepository in project processdash by dtuma.

the class HistoricalDataReport method writeHeader.

/** Write the CGI header. */
protected void writeHeader() {
    DataRepository data = getDataRepository();
    String prefix = getPrefix();
    String dataName = DataRepository.createDataName(prefix, DATA_NAME);
    SimpleData d = data.getSimpleValue(dataName);
    String subsetPrefix = null;
    if (d != null)
        subsetPrefix = d.format();
    if (subsetPrefix == null || subsetPrefix.length() == 0)
        subsetPrefix = DEFAULT_PREFIX;
    out.print("Location: ");
    out.print(WebServer.urlEncodePath(subsetPrefix));
    out.print(DEST_URL);
    out.print("\r\n\r\n");
}
Also used : DataRepository(net.sourceforge.processdash.data.repository.DataRepository) SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 29 with DataRepository

use of net.sourceforge.processdash.data.repository.DataRepository in project processdash by dtuma.

the class OpenDocument method findFile.

/** Find a file in the document list.
     * @param name the name of the file to find
     * @return the XML element corresponding to the named document.
     */
protected Element findFile(String name) throws IOException {
    // Look for an inheritable value for the FILE_XML element in the
    // data repository.
    DataRepository data = getDataRepository();
    String pfx = getPrefix();
    if (pfx == null)
        pfx = "/";
    StringBuffer prefix = new StringBuffer(pfx);
    ListData list;
    Element result = null;
    SaveableData val;
    for (val = data.getInheritableValue(prefix, FILE_XML_DATANAME); val != null; val = data.getInheritableValue(chop(prefix), FILE_XML_DATANAME)) {
        if (val != null && !(val instanceof SimpleData))
            val = val.getSimpleValue();
        if (val instanceof StringData)
            list = ((StringData) val).asList();
        else if (val instanceof ListData)
            list = (ListData) val;
        else
            list = null;
        if (list != null)
            for (int i = 0; i < list.size(); i++) {
                String url = (String) list.get(i);
                Document docList = getDocumentTree(url);
                if (docList != null) {
                    result = (new FileFinder(name, docList)).file;
                    if (result != null)
                        return result;
                }
            }
        if (prefix.length() == 0)
            break;
    }
    return null;
}
Also used : Element(org.w3c.dom.Element) DataRepository(net.sourceforge.processdash.data.repository.DataRepository) SimpleData(net.sourceforge.processdash.data.SimpleData) SaveableData(net.sourceforge.processdash.data.SaveableData) StringData(net.sourceforge.processdash.data.StringData) Document(org.w3c.dom.Document) ListData(net.sourceforge.processdash.data.ListData)

Example 30 with DataRepository

use of net.sourceforge.processdash.data.repository.DataRepository in project processdash by dtuma.

the class RollupDatasetSelectElem method writeContents.

protected void writeContents() throws IOException {
    DataRepository data = getDataRepository();
    if (data == null)
        return;
    init(data);
    // get the [Use_Rollup] data element for the current
    // project. If it is null, return immediately.
    String prefix = getPrefix();
    if (prefix == null)
        return;
    String useRollupName = DataRepository.createDataName(prefix, "Use_Rollup");
    ListData rollupIDs = getList(data, useRollupName);
    if (rollupIDs == null)
        return;
    String tableStart = TABLE_START, tableEnd = "", tableRow;
    for (int i = 0; i < rollupIDs.size(); i++) {
        tableRow = getFragment(data, rollupIDs.get(i).toString());
        if (tableRow != null && tableRow.length() > 0) {
            out.print(tableStart);
            out.print(tableRow);
            tableStart = "";
            tableEnd = TABLE_END;
        }
    }
    out.print(tableEnd);
}
Also used : DataRepository(net.sourceforge.processdash.data.repository.DataRepository) ListData(net.sourceforge.processdash.data.ListData)

Aggregations

DataRepository (net.sourceforge.processdash.data.repository.DataRepository)37 SimpleData (net.sourceforge.processdash.data.SimpleData)11 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)4 IOException (java.io.IOException)3 ListData (net.sourceforge.processdash.data.ListData)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 StringData (net.sourceforge.processdash.data.StringData)2 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1