Search in sources :

Example 1 with CompletionStatus

use of net.sourceforge.processdash.tool.export.mgr.CompletionStatus in project processdash by dtuma.

the class TextMetricsFileExporter method run.

public void run() {
    try {
        outWriter = new RobustFileWriter(dest, "UTF-8");
        PrintWriter out = new PrintWriter(new BufferedWriter(outWriter));
        // Find and print any applicable task lists.
        Iterator i = ctx.getData().getKeys();
        Set taskListNames = new HashSet();
        String name;
        int pos;
        while (i.hasNext()) {
            name = (String) i.next();
            pos = name.indexOf(TASK_ORD_PREF);
            if (pos != -1 && Filter.matchesFilter(filter, name))
                taskListNames.add(name.substring(pos + TASK_ORD_PREF.length()));
        }
        i = taskListNames.iterator();
        String owner = ProcessDashboard.getOwnerName(ctx.getData());
        while (i.hasNext()) {
            name = (String) i.next();
            EVTaskList tl = EVTaskList.openExisting(name, ctx.getData(), ctx.getHierarchy(), ctx.getCache(), false);
            if (tl == null)
                continue;
            tl.recalc();
            String xml = tl.getAsXML(false);
            name = exportedScheduleDataName(owner, name);
            out.write(name + ",");
            out.write(StringData.escapeString(xml));
            out.println();
        }
        ctx.getData().dumpRepository(out, filter, DataRepository.DUMP_STYLE_TEXT);
        TimeLog tl = ctx.getTimeLog();
        Iterator keys = tl.filter(null, null, null);
        while (keys.hasNext()) {
            TimeLogEntry tle = (TimeLogEntry) keys.next();
            if (Filter.matchesFilter(filter, tle.getPath()))
                out.println(toAbbrevString(tle));
        }
        out.println(DefectXmlConstantsv1.DEFECT_START_TOKEN);
        DefectExporterXMLv1 exp = new DefectExporterXMLv1();
        exp.dumpDefects(ctx.getHierarchy(), filter, out);
        out.close();
        outWriter = null;
        completionStatus = new CompletionStatus(CompletionStatus.SUCCESS, dest, null);
    } catch (Exception ioe) {
        completionStatus = new CompletionStatus(CompletionStatus.ERROR, dest, ioe);
        System.out.println("IOException: " + ioe);
        tryCancel();
    }
    ctx.getData().gc(filter);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) BufferedWriter(java.io.BufferedWriter) TimeLog(net.sourceforge.processdash.log.time.TimeLog) TimeLogEntry(net.sourceforge.processdash.log.time.TimeLogEntry) CompletionStatus(net.sourceforge.processdash.tool.export.mgr.CompletionStatus) Iterator(java.util.Iterator) EVTaskList(net.sourceforge.processdash.ev.EVTaskList) RobustFileWriter(net.sourceforge.processdash.util.RobustFileWriter) PrintWriter(java.io.PrintWriter) HashSet(java.util.HashSet)

Example 2 with CompletionStatus

use of net.sourceforge.processdash.tool.export.mgr.CompletionStatus in project processdash by dtuma.

the class ExportNow method run.

/** Export the data, and tell the user the results.
     */
private void run() {
    CompletionStatus result = null;
    if (parameters.containsKey("all"))
        DashController.exportAllData();
    else
        result = DashController.exportDataForPrefix(getPrefix());
    if (result == null || CompletionStatus.SUCCESS.equals(result.getStatus())) {
        interpOut("<HTML><HEAD><TITLE>${ExportComplete}</TITLE></HEAD>\n" + "<BODY><H1>${ExportComplete}</H1>\n");
        out.println(HTMLUtils.escapeEntities(resources.format("ExportDataComplete_FMT", new Date())));
        out.println("</BODY></HTML>");
    } else if (CompletionStatus.NO_WORK_NEEDED.equals(result.getStatus())) {
        interpOut("<HTML><HEAD><TITLE>${ExportNotNeeded.Title}</TITLE></HEAD>\n" + "<BODY><H1>${ExportNotNeeded.Title}</H1>\n" + "${ExportNotNeeded.Message}" + "</BODY></HTML>");
    } else {
        interpOut("<HTML><HEAD><TITLE>${ExportError.Title}</TITLE></HEAD>\n" + "<BODY><H1>${ExportError.Title}</H1>\n");
        if (result != null && result.getTarget() != null && result.getException() instanceof IOException) {
            String target = result.getTarget().toString();
            String resKey = TeamServerSelector.isUrlFormat(target) ? "ExportError.Server_IO_FMT" : "ExportError.IO_FMT";
            out.println(HTMLUtils.escapeEntities(resources.format(resKey, target)));
        } else {
            out.println(resources.getHTML("ExportError.Message"));
            if (result != null && result.getException() != null) {
                out.print("<PRE>");
                result.getException().printStackTrace(out);
                out.print("</PRE>");
            }
        }
        out.println("</BODY></HTML>");
    }
}
Also used : CompletionStatus(net.sourceforge.processdash.tool.export.mgr.CompletionStatus) IOException(java.io.IOException) Date(java.util.Date)

Example 3 with CompletionStatus

use of net.sourceforge.processdash.tool.export.mgr.CompletionStatus in project processdash by dtuma.

the class ArchiveMetricsFileExporter method run.

public void run() {
    try {
        doExport();
        completionStatus = new CompletionStatus(CompletionStatus.SUCCESS, dest.getTarget(), null);
    } catch (Exception ioe) {
        completionStatus = new CompletionStatus(CompletionStatus.ERROR, dest.getTarget(), ioe);
        ioe.printStackTrace();
        tryCancel();
    }
    ctx.getData().gc(filter);
}
Also used : CompletionStatus(net.sourceforge.processdash.tool.export.mgr.CompletionStatus) IOException(java.io.IOException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Aggregations

CompletionStatus (net.sourceforge.processdash.tool.export.mgr.CompletionStatus)3 IOException (java.io.IOException)2 BufferedWriter (java.io.BufferedWriter)1 PrintWriter (java.io.PrintWriter)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)1 TimeLog (net.sourceforge.processdash.log.time.TimeLog)1 TimeLogEntry (net.sourceforge.processdash.log.time.TimeLogEntry)1 RobustFileWriter (net.sourceforge.processdash.util.RobustFileWriter)1 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)1