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);
}
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;
}
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;
}
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;
}
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();
}
Aggregations