Search in sources :

Example 46 with DashHierarchy

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

the class TemplateLoader method loadXMLProcessTemplate.

private static void loadXMLProcessTemplate(DashHierarchy templates, DataRepository data, String filename, URL baseUrl, long modTime, InputStream in, boolean close) throws IOException {
    Element root = null;
    try {
        if (!close)
            in = new NonclosingInputStream(in);
        // this closes the file without our permission.
        Document doc = XMLUtils.parse(in);
        ExtensionManager.addXmlDoc(doc, filename, baseUrl, modTime);
        root = doc.getDocumentElement();
    } catch (SAXException se) {
        String message = XMLUtils.exceptionMessage(se);
        Resources r = Resources.getDashBundle("Templates");
        if (message == null)
            message = r.format("Error_FMT", filename);
        else
            message = r.format("Error_Message_FMT", filename, message);
        logTemplateError(message);
        return;
    }
    AutoData.registerTemplates(root, data);
    createScriptMaps(root);
    try {
        DashHierarchy template = new DashHierarchy(null);
        template.loadXMLTemplate(root);
        template.premove(PropertyKey.ROOT);
        createScriptMaps(template);
        templates.putAll(template);
    } catch (SAXException se) {
    // Can this happen?
    }
    generateDefaultScriptMaps(root);
}
Also used : Element(org.w3c.dom.Element) DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) NonclosingInputStream(net.sourceforge.processdash.util.NonclosingInputStream) Resources(net.sourceforge.processdash.i18n.Resources) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException)

Example 47 with DashHierarchy

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

the class ConfigureButton method startTimeLog.

public void startTimeLog(PropertyKey phase) {
    DashHierarchy hier = parent.getProperties();
    if (phase == null)
        phase = parent.getCurrentPhase();
    if (hier != null) {
        if (time_frame != null) {
            time_frame.setSelectedNode(phase);
            time_frame.show();
        } else {
            DashboardTimeLog timeLog = (DashboardTimeLog) parent.getTimeLog();
            TimeLoggingApprover approver = timeLog;
            time_frame = new TimeLogEditor(timeLog, hier, approver, phase);
            parent.addApplicationEventListener(time_frame);
        }
    }
}
Also used : DashboardTimeLog(net.sourceforge.processdash.log.time.DashboardTimeLog) TimeLoggingApprover(net.sourceforge.processdash.log.time.TimeLoggingApprover) DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) TimeLogEditor(net.sourceforge.processdash.log.ui.TimeLogEditor)

Example 48 with DashHierarchy

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

the class Hierchildren method call.

/** Perform a procedure call.
     *
     * This method <b>must</b> be thread-safe.
     */
public Object call(List arguments, ExpressionContext context) {
    String prefix;
    if (!arguments.isEmpty())
        prefix = asStringVal(getArg(arguments, 0));
    else
        prefix = context.get(ExpressionContext.PREFIXVAR_NAME).format();
    if (prefix == null)
        return null;
    try {
        ListData hierItem = (ListData) context.get(DashHierarchy.DATA_REPOSITORY_NAME);
        DashHierarchy hier = (DashHierarchy) hierItem.get(0);
        PropertyKey key = hier.findExistingKey(prefix);
        if (key == null)
            return null;
        ListData result = new ListData();
        for (int i = 0; i < hier.getNumChildren(key); i++) {
            PropertyKey child = hier.getChildKey(key, i);
            result.add(child.path());
        }
        return result;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey) ListData(net.sourceforge.processdash.data.ListData)

Example 49 with DashHierarchy

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

the class Hiertemplateid method call.

/** Perform a procedure call.
     *
     * This method <b>must</b> be thread-safe.
     */
public Object call(List arguments, ExpressionContext context) {
    String prefix;
    if (!arguments.isEmpty())
        prefix = asStringVal(getArg(arguments, 0));
    else
        prefix = context.get(ExpressionContext.PREFIXVAR_NAME).format();
    if (prefix == null)
        return null;
    try {
        ListData hierItem = (ListData) context.get(DashHierarchy.DATA_REPOSITORY_NAME);
        DashHierarchy hier = (DashHierarchy) hierItem.get(0);
        PropertyKey key = hier.findExistingKey(prefix);
        if (key == null)
            return null;
        String templateID = hier.getID(key);
        return StringData.create(templateID);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey) ListData(net.sourceforge.processdash.data.ListData)

Example 50 with DashHierarchy

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

the class TeamStartBootstrap method getTeamNodePathOrErrToken.

/**
     * Look at the node name and location, and make certain they refer to a
     * valid path. If so, the full path (which starts with a slash) will be
     * returned. If not, an error token (which does not start with a slash) will
     * be returned.
     */
private String getTeamNodePathOrErrToken() {
    String nodeName = getValue(NODE_NAME);
    if (nodeName == null || nodeName.trim().length() == 0)
        return "nodeNameMissing";
    nodeName = nodeName.trim();
    if (nodeName.indexOf('/') != -1)
        return "nodeNameSlash";
    // compute the desired effective path.
    String nodeLocation = tweakLocation(getValue(NODE_LOCATION));
    String nodePath = nodeLocation + "/" + nodeName;
    // does a node already exist in the hierarchy with this path?
    DashHierarchy hier = getPSPProperties();
    PropertyKey key = hier.findExistingKey(nodePath);
    if (key != null) {
        // if the preexisting node is a team project stub, all is well.
        if (TEAM_STUB_ID.equals(hier.getID(key)))
            return nodePath;
        else
            return "duplicateName";
    } else {
        // look at the ancestors of the target path, and make certain that
        // they are all plain nodes
        key = hier.findClosestKey(nodePath);
        while (key != null) {
            if (StringUtils.hasValue(hier.getID(key)))
                return "invalidParent";
            key = key.getParent();
        }
    }
    // path seems OK
    return nodePath;
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

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