Search in sources :

Example 16 with StringData

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

the class EVTaskDependency method removeTaskID.

public static void removeTaskID(DataContext data, String taskPath, String id) {
    String dataName = DataRepository.createDataName(taskPath, TASK_ID_DATA_NAME);
    SimpleData currentValue = data.getSimpleValue(dataName);
    ListData list = null;
    if (currentValue instanceof ListData)
        list = (ListData) currentValue;
    else if (currentValue instanceof StringData)
        list = ((StringData) currentValue).asList();
    if (list != null && list.remove(id))
        data.putValue(dataName, list);
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) StringData(net.sourceforge.processdash.data.StringData) ImmutableStringData(net.sourceforge.processdash.data.ImmutableStringData) ListData(net.sourceforge.processdash.data.ListData)

Example 17 with StringData

use of net.sourceforge.processdash.data.StringData 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 18 with StringData

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

the class DataRepository method loadIncludedFileDefinitions.

/** Get the definitions for the given includable datafile, loading
     *  them if necessary.
     */
public Map loadIncludedFileDefinitions(String datafile) throws FileNotFoundException, IOException, InvalidDatafileFormat {
    //debug("loadIncludedFileDefinitions("+datafile+")");
    datafile = bracket(datafile);
    // Check in the defaultDefinitions map for any requested redirections.
    datafile = followDatafileRedirections(datafile);
    Map result = getIncludedFileDefinitions(datafile);
    if (result == null) {
        result = new HashMap();
        // Lookup any applicable default data definitions.
        DefinitionFactory defaultDefns = (DefinitionFactory) defaultDefinitions.get(datafile);
        if (defaultDefns != null)
            result.putAll(defaultDefns.getDefinitions(DataRepository.this));
        if (!isImaginaryDatafileName(datafile))
            loadDatafile(datafile, findDatafile(datafile), result, DO_FOLLOW_INCLUDES, DO_CLOSE, "UTF-8");
        // Although we aren't technically done creating this datafile,
        // we need to store it in the cache before calling
        // insertRollupDefinitions to avoid entering an infinite loop.
        includedFileCache.put(datafile, result);
        // check to see if the datafile requests a rollup
        Object rollupIDval = result.get("Use_Rollup");
        if (rollupIDval instanceof StringData) {
            String rollupID = ((StringData) rollupIDval).getString();
            insertRollupDefinitions(result, rollupID);
        }
        // prepare renaming operations for later use
        DataRenamingOperation.initRenamingOperations(result);
        result = Collections.unmodifiableMap(result);
        includedFileCache.put(datafile, result);
        definitionsDirty = true;
    }
    return result;
}
Also used : HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap) EscapeString(net.sourceforge.processdash.util.EscapeString) StringData(net.sourceforge.processdash.data.StringData) Map(java.util.Map) HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap)

Example 19 with StringData

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

the class ResultSet method get.

/** Perform a query and return a result set. */
public static ResultSet get(DataRepository data, String forParam, String[] conditions, String orderBy, String[] dataNames, String basePrefix) {
    // get the list of prefixes
    ListData prefixList = getFilteredList(data, forParam, conditions, orderBy, basePrefix);
    // Create a result set to return
    ResultSet result = new ResultSet(prefixList.size(), dataNames.length);
    // write the column headers into the result set.
    result.setColName(0, null);
    for (int i = 0; i < dataNames.length; i++) result.setColName(i + 1, dataNames[i]);
    // get the data and fill the result set.
    String prefix, dataName;
    if (basePrefix == null)
        basePrefix = "";
    int baseLen = basePrefix.length();
    // remove / as well
    if (baseLen > 0)
        baseLen++;
    for (int p = 0; p < prefixList.size(); p++) {
        // get the next prefix
        Object pfx = prefixList.get(p);
        if (pfx instanceof String)
            prefix = (String) pfx;
        else if (pfx instanceof SimpleData)
            prefix = ((SimpleData) pfx).format();
        else
            continue;
        // write the row headers into the result set.
        if (prefix.length() > baseLen && prefix.startsWith(basePrefix))
            result.setRowName(p + 1, prefix.substring(baseLen));
        else {
            result.setRowName(p + 1, prefix);
            if (!prefix.startsWith("/"))
                prefix = DataRepository.createDataName(basePrefix, prefix);
        }
        // look up the data for this row.
        for (int d = 0; d < dataNames.length; d++) if (dataNames[d].startsWith("\"")) {
            try {
                result.setData(p + 1, d + 1, new StringData(dataNames[d]));
            } catch (MalformedValueException mve) {
            }
        } else if (dataNames[d].indexOf('[') != -1) {
            try {
                result.setData(p + 1, d + 1, data.evaluate(dataNames[d], prefix));
            } catch (Exception e) {
            }
        } else {
            dataName = DataRepository.createDataName(prefix, dataNames[d]);
            result.setData(p + 1, d + 1, data.getSimpleValue(dataName));
        }
    }
    return result;
}
Also used : MalformedValueException(net.sourceforge.processdash.data.MalformedValueException) SimpleData(net.sourceforge.processdash.data.SimpleData) LocalizedString(net.sourceforge.processdash.util.LocalizedString) StringData(net.sourceforge.processdash.data.StringData) MalformedValueException(net.sourceforge.processdash.data.MalformedValueException) ListData(net.sourceforge.processdash.data.ListData)

Example 20 with StringData

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

the class DefectUtil method getInheritedPhaseList.

protected static Enumeration getInheritedPhaseList(String defectPath, DataRepository data) {
    Object inheritedPhaseList = data.getInheritableValue(defectPath, "Effective_Defect_Phase_List");
    ListData list = null;
    if (inheritedPhaseList instanceof ListData)
        list = (ListData) inheritedPhaseList;
    else if (inheritedPhaseList instanceof StringData)
        list = ((StringData) inheritedPhaseList).asList();
    if (list == null)
        return null;
    Vector result = new Vector();
    for (int i = 0; i < list.size(); i++) result.add(list.get(i).toString());
    return result.elements();
}
Also used : StringData(net.sourceforge.processdash.data.StringData) Vector(java.util.Vector) ListData(net.sourceforge.processdash.data.ListData)

Aggregations

StringData (net.sourceforge.processdash.data.StringData)26 ListData (net.sourceforge.processdash.data.ListData)15 SimpleData (net.sourceforge.processdash.data.SimpleData)13 ArrayList (java.util.ArrayList)3 List (java.util.List)3 DoubleData (net.sourceforge.processdash.data.DoubleData)3 ImmutableStringData (net.sourceforge.processdash.data.ImmutableStringData)3 MalformedValueException (net.sourceforge.processdash.data.MalformedValueException)3 SaveableData (net.sourceforge.processdash.data.SaveableData)3 EscapeString (net.sourceforge.processdash.util.EscapeString)3 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)2 EVTaskListData (net.sourceforge.processdash.ev.EVTaskListData)2 LocalizedString (net.sourceforge.processdash.util.LocalizedString)2 NodeList (org.w3c.dom.NodeList)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1