Search in sources :

Example 76 with ListData

use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.

the class EVTaskDependency method getTaskCollaborators.

public static EVTaskDependency getTaskCollaborators(DataContext data, String taskPath) {
    String dataName = DataRepository.createDataName(taskPath, COLLABORATORS_DATA_NAME);
    SimpleData sd = data.getSimpleValue(dataName);
    ListData ld = ListData.asListData(sd);
    if (ld == null || !ld.test())
        return null;
    else
        return new EVTaskDependency(ld.asList());
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) ListData(net.sourceforge.processdash.data.ListData)

Example 77 with ListData

use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.

the class EVTask method userSetNodeType.

/** Messaged to indicate that the user has entered a new value for the
     * node type of this task.
     * 
     * @param aValue the value entered by the user (a String is expected)
     */
public void userSetNodeType(Object aValue) {
    if (!isNodeTypeEditable() || aValue == null)
        return;
    String newType = aValue.toString();
    ListData allowedTypes = getAcceptableNodeTypes();
    if (allowedTypes == null || !allowedTypes.contains(newType))
        return;
    String dataName = DataRepository.createDataName(fullName, NODE_TYPE_DATA_NAME);
    this.nodeType = newType;
    data.userPutValue(dataName, StringData.create(newType));
}
Also used : ListData(net.sourceforge.processdash.data.ListData)

Example 78 with ListData

use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.

the class TemplateAutoData method buildDefaultData.

private void buildDefaultData(Element node, String path, DataRepository data, Map definitions, int globalDataLength, StringBuffer nodeDefinitions) {
    if (!isProcessNode(node))
        return;
    if (noAutoDataNode(node))
        return;
    // Check for a local redefinition of the Size metric.
    int localDataLength = globalDataLength;
    String sizeMetric = node.getAttribute(SIZE_METRIC_ATTR);
    if (XMLUtils.hasValue(sizeMetric)) {
        String localSizeDefn = "#define Size " + esc(sizeMetric) + "\n";
        nodeDefinitions.append(localSizeDefn);
        localDataLength += localSizeDefn.length();
    }
    // Iterate over the children of this element.
    NodeList children = node.getChildNodes();
    int numChildren = children.getLength();
    ListData childList = newEmptyList();
    Node c;
    Element child;
    for (int i = 0; i < numChildren; i++) {
        c = children.item(i);
        if (c instanceof Element && isProcessNode((Element) c) && !noAutoDataNode((Element) c)) {
            child = (Element) c;
            String childName = pathConcat(path, child.getAttribute(NAME_ATTR));
            childList.add(childName);
            buildDefaultData(child, childName, data, definitions, localDataLength, nodeDefinitions);
        }
    }
    childList.setImmutable();
    // truncate the nodeDefinitions StringBuffer so it only
    // contains the global data definitions plus the local size
    // definition (probably unnecessary, but a wise and safe thing
    // to do).
    nodeDefinitions.setLength(localDataLength);
    if (XMLUtils.hasValue(path))
        nodeDefinitions.append("#define ").append(PATH_MACRO).append(" ").append(esc(path)).append("\n");
    if (node.hasAttribute(DashHierarchy.IMAGINARY_NODE_ATTR))
        nodeDefinitions.append("#define IS_IMAGINARY_NODE\n");
    if (childList.size() > 0) {
        definitions.put(pathConcat(path, CHILD_LIST_ELEM), childList);
        nodeDefinitions.append(NODE_DATA);
    } else {
        // This is a phase.
        // #define various symbols based on the nature of this phase.
        String phaseType = node.getAttribute(PHASE_TYPE_ATTR);
        if (XMLUtils.hasValue(phaseType)) {
            phaseType = cleanupPhaseType(phaseType);
            nodeDefinitions.append("#define IS_").append(phaseType.toUpperCase()).append("_PHASE\n");
            if (isAppraisalPhaseType(phaseType))
                nodeDefinitions.append("#define IS_APPRAISAL_PHASE\n").append("#define IS_QUALITY_PHASE\n");
            else if (isFailurePhaseType(phaseType))
                nodeDefinitions.append("#define IS_FAILURE_PHASE\n").append("#define IS_QUALITY_PHASE\n");
            else if (isOverheadPhaseType(phaseType))
                nodeDefinitions.append("#define IS_OVERHEAD_PHASE\n");
            else if (isDevelopmentPhaseType(phaseType))
                nodeDefinitions.append("#define IS_DEVELOPMENT_PHASE\n");
        }
        nodeDefinitions.append(LEAF_DATA);
    }
    String finalData = nodeDefinitions.toString();
    if (!XMLUtils.hasValue(path))
        finalData = StringUtils.findAndReplace(finalData, PATH_MACRO + "/", "");
    /*
        System.out.println("For " + templateID+"->"+path + ", data is");
        System.out.println("------------------------------------------------");
        System.out.println(finalData);
        System.out.println("------------------------------------------------");
        */
    parseDefinitions(data, finalData, definitions);
    // truncate the nodeDefinitions StringBuffer so it only
    // contains the global data definitions.
    nodeDefinitions.setLength(globalDataLength);
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) ListData(net.sourceforge.processdash.data.ListData)

Example 79 with ListData

use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.

the class UserGroupManagerDash method getFilterById.

@Override
public UserFilter getFilterById(String filterId) {
    if (filterId != null && filterId.startsWith(UserGroupMember.ID_PREFIX)) {
        // if this is an individual, try looking up their details from the
        // data elements saved in the repository
        String dataName = DATA_PREFIX + filterId + NAME_SUFFIX;
        String displayName = getString(dataName);
        dataName = DATA_PREFIX + filterId + DATASET_IDS_SUFFIX;
        ListData l = ListData.asListData(dataRepository.getValue(dataName));
        if (displayName != null && l != null && l.test())
            return new UserGroupMember(displayName, (String) l.get(0));
    }
    return super.getFilterById(filterId);
}
Also used : ListData(net.sourceforge.processdash.data.ListData)

Example 80 with ListData

use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.

the class DataNameScriptSource method getScripts.

public List<ScriptID> getScripts(String path) {
    List<ScriptID> result = null;
    while (path != null) {
        String fullDataName = DataRepository.createDataName(path, dataName);
        ListData l = ListData.asListData(data.getSimpleValue(fullDataName));
        if (l != null && l.test()) {
            if (result == null)
                result = new ArrayList<ScriptID>();
            for (int i = 0; i < l.size(); i++) addScriptItem(result, l.get(i), path);
        }
        path = DataRepository.chopPath(path);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ListData(net.sourceforge.processdash.data.ListData)

Aggregations

ListData (net.sourceforge.processdash.data.ListData)129 SimpleData (net.sourceforge.processdash.data.SimpleData)20 ArrayList (java.util.ArrayList)18 List (java.util.List)16 Iterator (java.util.Iterator)15 StringData (net.sourceforge.processdash.data.StringData)15 EVTaskListData (net.sourceforge.processdash.ev.EVTaskListData)9 Map (java.util.Map)8 HashSet (java.util.HashSet)7 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 LinkedList (java.util.LinkedList)5 DoubleData (net.sourceforge.processdash.data.DoubleData)5 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)5 LocalizedString (net.sourceforge.processdash.util.LocalizedString)5 NodeList (org.w3c.dom.NodeList)5 Date (java.util.Date)4 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)4 Element (org.w3c.dom.Element)4