use of net.sourceforge.processdash.data.DoubleData in project processdash by dtuma.
the class EVTask method saveDataElement.
private void saveDataElement(String oldTaskListName, String newTaskListName, String dataNamePrefix, int savedValue, int newValue, int defaultValue) {
if (fullName == null || fullName.length() == 0)
return;
String oldDataName = null;
if (savedValue != defaultValue)
oldDataName = dataNamePrefix + oldTaskListName;
if (newTaskListName != null && newValue != defaultValue) {
String newDataName = dataNamePrefix + newTaskListName;
if (newDataName.equals(oldDataName))
oldDataName = null;
if (newValue != savedValue || oldDataName != null) {
SimpleData d = new DoubleData(newValue, false);
String dataName = DataRepository.createDataName(fullName, newDataName);
data.putValue(dataName, d);
}
}
if (oldDataName != null) {
String dataName = DataRepository.createDataName(fullName, oldDataName);
data.putValue(dataName, null);
}
}
use of net.sourceforge.processdash.data.DoubleData in project processdash by dtuma.
the class AbstractSyncWorker method markLeafComplete.
public void markLeafComplete(String path) {
if (completionPermissions == null || completionPermissions.contains(getOriginalPath(path))) {
String completionDataName = dataName(path, "Completed");
if (getSimpleValue(completionDataName) != null)
return;
SimpleData actualTime = getSimpleValue(dataName(path, "Time"));
if (actualTime instanceof NumberData) {
double time = ((NumberData) actualTime).getDouble();
DoubleData estimatedTime = new DoubleData(time, true);
doPutValue(dataName(path, "Estimated Time"), estimatedTime);
doPutValue(dataName(path, syncDataName("Estimated Time")), estimatedTime);
}
DateData now = new DateData();
doPutValue(completionDataName, now);
doPutValue(syncDataName(completionDataName), now);
nodesCompleted.add(path);
}
}
use of net.sourceforge.processdash.data.DoubleData in project processdash by dtuma.
the class EVTaskListData method save.
public void save(String newName) {
EVTask r = (EVTask) root;
boolean nameIsChanging = (!taskListName.equals(newName));
saveScheduleNotes();
// First, compile a list of all the elements in the datafile that
// were previously used to save this task list. (That way we'll
// know what we need to delete.)
String globalPrefix = MAIN_DATA_PREFIX + taskListName + "/";
String ordinalPrefix = "/" + TASK_ORDINAL_PREFIX + taskListName;
Iterator i = data.getKeys(null, DataNameFilter.EXPLICIT_ONLY);
Set oldNames = new HashSet();
String dataName;
while (i.hasNext()) {
dataName = (String) i.next();
if (dataName.startsWith(globalPrefix) || dataName.endsWith(ordinalPrefix))
oldNames.add(dataName);
}
// Now, save the data to the repository.
if (newName != null) {
globalPrefix = MAIN_DATA_PREFIX + newName;
ordinalPrefix = TASK_ORDINAL_PREFIX + newName;
for (int j = r.getNumChildren(); j-- > 0; ) {
dataName = DataRepository.createDataName(r.getChild(j).getFullName(), ordinalPrefix);
data.putValue(dataName, new DoubleData(j, false));
oldNames.remove(dataName);
}
// save the schedule
dataName = DataRepository.createDataName(globalPrefix, EST_HOURS_DATA_NAME);
data.putValue(dataName, schedule.getSaveList());
oldNames.remove(dataName);
if (schedule.areDatesLocked()) {
dataName = DataRepository.createDataName(globalPrefix, DATES_LOCKED_DATA_NAME);
data.putValue(dataName, ImmutableDoubleData.TRUE);
oldNames.remove(dataName);
}
// save the task list unique ID and the metadata
oldNames.remove(saveID(newName, data));
oldNames.remove(saveMetadata(newName, data));
renameSnapshots(oldNames, newName, data);
taskListName = newName;
}
// Finally, delete any old unused data elements.
i = oldNames.iterator();
while (i.hasNext()) {
dataName = (String) i.next();
if (!nameIsChanging && dataName.startsWith(MAIN_DATA_PREFIX))
// (introduced in a later version of the dashboard)
;
else
data.removeValue(dataName);
}
// allow our tasks to do the same thing.
r.saveStructuralData(newName);
r.saveDependencyInformation();
super.save(newName);
// rearranging tasks might alter data in a lot of data files. Flush
// all of those changes to disk, then export project data if needed.
data.saveAllDatafiles();
maybeStartBackgroundExport();
}
use of net.sourceforge.processdash.data.DoubleData in project processdash by dtuma.
the class RollupAutoData method buildRollupData.
private void buildRollupData(DataRepository data) {
//System.out.println("buildRollupData for " + definesRollupID);
Map baseDefinitions = null;
try {
baseDefinitions = data.loadIncludedFileDefinitions(basedOnDataFile);
// can exit immediately.
if (definitions != null)
return;
} catch (Exception e) {
logger.log(Level.WARNING, "Caught Exception", e);
return;
}
Map rollupDefinitions = new HashMap();
StringBuffer definitionBuffer = new StringBuffer();
definitionBuffer.append("#define ROLLUP_ID ").append(esc(definesRollupID));
// Define macros for rolling up numbers and lists
definitionBuffer.append("\n#define ROLLUP_NUMBER(Data) ");
rollupDouble(definitionBuffer, "Data");
definitionBuffer.append("\n#define ROLLUP_LIST(Data) ");
rollupList(definitionBuffer, "Data");
// Include the standard rollup data definitions
definitionBuffer.append("\n").append(ROLLUP_DATA).append("\n");
Map toDateAliasDefinitions = new HashMap();
String toDatePrefix = "/To Date/" + definesRollupID + "/All";
toDateAliasDefinitions.put(definesRollupID + " To Date Subset Prefix", StringData.create(toDatePrefix));
StringBuffer toDateAliasBuffer = new StringBuffer();
Iterator i = baseDefinitions.entrySet().iterator();
Map.Entry definition;
String name;
Object value;
while (i.hasNext()) {
definition = (Map.Entry) i.next();
name = (String) definition.getKey();
value = definition.getValue();
if (skipElement(name, value))
// filter out elements which should not be rolled up.
continue;
else if (value instanceof DoubleData) {
// roll up the values of any literal double data elements.
rollupDouble(definitionBuffer, name);
addAlias(toDateAliasBuffer, name, definesRollupID);
} else if (value instanceof ListFunction)
// roll up the values of any search()-generated lists.
rollupList(definitionBuffer, name);
else if (value != null) {
if (value instanceof CompiledScript)
addAlias(toDateAliasBuffer, name, definesRollupID);
// DO NOT roll up dates, strings, lists, tags,
// compiled functions, or old-style definitions - just
// copy them into the rollup set verbatim.
rollupDefinitions.put(name, value);
}
}
// Calculate the rollup aliases
parseDefinitions(data, toDateAliasBuffer.toString(), toDateAliasDefinitions);
aliasDefs = toDateAliasDefinitions;
// If the user specified a datafile for this rollup, include it.
if (XMLUtils.hasValue(rollupDataFile))
try {
URLConnection conn = TemplateLoader.resolveURLConnection(rollupDataFile);
String contents = new String(FileUtils.slurpContents(conn.getInputStream(), true));
definitionBuffer.append("\n").append(contents).append("\n");
} catch (IOException ioe) {
logger.log(Level.WARNING, "IOException", ioe);
}
// Calculate the rollup definitions and return them.
parseDefinitions(data, definitionBuffer.toString(), rollupDefinitions);
definitions = rollupDefinitions;
debugPrint(rollupDefinitions);
try {
// Mount this rollup data set in the repository.
data.mountPhantomData(toDatePrefix, rollupDefinitions);
} catch (Exception e) {
logger.log(Level.WARNING, "Caught Exception", e);
}
}
use of net.sourceforge.processdash.data.DoubleData in project processdash by dtuma.
the class TextMetricsFileImporter method parseValue.
private static Object parseValue(String value) {
SimpleData result;
// is it a tag?
if ("TAG".equalsIgnoreCase(value))
return TagData.getInstance();
// first, try to interpret the string as a number.
if ("0.0".equals(value))
return ImmutableDoubleData.READ_ONLY_ZERO;
if ("NaN".equals(value))
return ImmutableDoubleData.READ_ONLY_NAN;
if (DoubleData.P_INF_STR.equals(value) || DoubleData.N_INF_STR.equals(value))
return ImmutableDoubleData.DIVIDE_BY_ZERO;
if (value.length() > 0)
switch(value.charAt(0)) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '-':
case '+':
case '.':
case ',':
try {
result = new DoubleData(value);
result.setEditable(false);
return result;
} catch (MalformedValueException mfe) {
}
}
// next, try to interpret the string as a date.
try {
result = DateData.create(value);
result.setEditable(false);
return result;
} catch (MalformedValueException mfe) {
}
// give up and interpret it as a plain string.
result = StringData.create(StringData.unescapeString(value));
result.setEditable(false);
return result;
}
Aggregations