use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class EVTaskList method renameSnapshots.
/** Rename the snapshots for this task list.
*
* @param oldNames the names of old data elements associated with this
* task list
* @param newName the new name of the task list
* @param data the data repository
* @return the names of the new data elements used to store snapshots
*/
protected void renameSnapshots(Set oldNames, String newName, DataRepository data) {
String globalPrefix = MAIN_DATA_PREFIX + taskListName + "/";
String oldSnapshotPrefix = globalPrefix + SNAPSHOT_DATA_PREFIX + "/";
int oldPrefixLen = globalPrefix.length();
boolean nameIsChanging = !taskListName.equals(newName);
for (Iterator i = oldNames.iterator(); i.hasNext(); ) {
String oldDataName = (String) i.next();
if (oldDataName.startsWith(oldSnapshotPrefix)) {
if (nameIsChanging) {
SimpleData value = data.getSimpleValue(oldDataName);
String dataName = oldDataName.substring(oldPrefixLen);
persistDataValue(newName, data, dataName, value);
}
i.remove();
}
}
}
use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class EVTaskList method loadMetadata.
/** Load the metadata for this task list.
* @param taskListName the name of this task list.
* @param data the DataRepository
*/
protected void loadMetadata(String taskListName, DataRepository data) {
metaData = new Properties();
String globalPrefix = MAIN_DATA_PREFIX + taskListName;
String dataName = DataRepository.createDataName(globalPrefix, METADATA_DATA_NAME);
SimpleData d = data.getSimpleValue(dataName);
String val = (d == null ? null : d.format());
if (StringUtils.hasValue(val)) {
try {
metaData.load(new ByteArrayInputStream(val.getBytes("ISO-8859-1")));
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class EVTaskList method getRegisteredTaskListForPath.
/** This method checks to see if a project schedule has been registered
* for path (or one of its parents) via the "Project_Schedule_Name" or
* "Project_Schedule_ID" data elements. If so, it returns the name of
* the registered schedule (which will be guaranteed to exist).
*
* In the process of making this inquiry, this method will update /
* synchronize the "Name" and "ID" attributes above if they have gotten
* out of sync with each other.
*
* @param data the data repository
* @param projectPath the path to a hierarchy node
* @return the name of a schedule
*/
private static String getRegisteredTaskListForPath(DataRepository data, String projectPath) {
// check to see if one of our parents names a registered schedule.
StringBuffer path = new StringBuffer(projectPath);
SaveableData sd = data.getInheritableValue(path, PROJECT_SCHEDULE_NAME);
if (sd == null)
return null;
SimpleData val = sd.getSimpleValue();
if (val == null || !val.test())
return null;
// We found a named schedule. Remember the prefix of the project that
// registered this schedule name. Also, save the data name for the
// corresponding schedule ID attribute.
String prefix = path.toString();
String projSchedIdDataName = DataRepository.createDataName(prefix, PROJECT_SCHEDULE_ID);
// Next, check to see if the named schedule actually exists.
String taskListName = val.format();
if (EVTaskListData.exists(data, taskListName) || EVTaskListRollup.exists(data, taskListName)) {
// The named schedule exists! Retrieve its actual task list ID,
// and record this for posterity. Note that in the most common
// case, we will be recording the exact same ID value that is
// already present - but the data repository will be able to
// efficiently figure out whether a real change was made.
String taskListIdDataName = DataRepository.createDataName(MAIN_DATA_PREFIX + taskListName, ID_DATA_NAME);
SimpleData taskListID = data.getSimpleValue(taskListIdDataName);
data.putValue(projSchedIdDataName, taskListID);
// Finally, return the name we found.
return taskListName;
}
// We found a registered name, but it does not point to an existing
// schedule. Check to see if we have a schedule ID to fall back to.
val = data.getSimpleValue(projSchedIdDataName);
if (val == null || !val.test())
// no fall-back schedule ID was provided.
return null;
String taskListID = val.format();
taskListName = getTaskListNameForID(data, taskListID);
if (taskListName == null)
// the fall-back ID doesn't name a real schedule.
return null;
// The fall-back ID named a real schedule. Save that schedule name
// for posterity, then return it to our caller.
String projSchedNameDataName = DataRepository.createDataName(prefix, PROJECT_SCHEDULE_NAME);
data.putValue(projSchedNameDataName, StringData.create(taskListName));
return taskListName;
}
use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class EVTaskList method loadID.
/** Load the unique ID for this task list.
* @param taskListName the name of this task list.
* @param data the DataRepository
* @param savedDataName the name of a data element that is used for the
* persistence of this task list. (It will be used to check and see if
* this task list is new, or is an existing task list.)
*/
protected void loadID(String taskListName, DataRepository data, String savedDataName) {
String globalPrefix = MAIN_DATA_PREFIX + taskListName;
String dataName = DataRepository.createDataName(globalPrefix, ID_DATA_NAME);
SimpleData d = data.getSimpleValue(dataName);
if (d != null) {
taskListID = d.format();
} else {
// This task list doesn't have a unique ID yet. Generate one.
// It should be a value that needs no special handling to
// appear as an XML attribute.
int i = Math.abs((new Random()).nextInt());
taskListID = Integer.toString(i, Character.MAX_RADIX) + "." + Long.toString(System.currentTimeMillis(), Character.MAX_RADIX);
// Since unique task list IDs were introduced after version 1.5
// of the dashboard, we may be in this branch of code not
// because this is a new task list, but because this is the
// first time the list has been opened. In the latter case,
// we need to save the unique ID.
String savedDataFullName = DataRepository.createDataName(globalPrefix, savedDataName);
if (data.getValue(savedDataFullName) != null) {
// getting to this point indicates that this task list is
// not new - it has been previously saved to the repository.
data.putValue(dataName, StringData.create(taskListID));
} else {
isBrandNewTaskList = true;
}
}
setPseudoTaskIdForRoot();
}
use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class EVTaskListData method scanSubtasksForExportPaths.
private void scanSubtasksForExportPaths(Set<String> exportPaths, EVTask task) {
for (int i = task.getNumChildren(); i-- > 0; ) {
EVTask child = task.getChild(i);
SimpleData sd = child.getValue(ExportManager.EXPORT_DATANAME, false);
if (sd != null && sd.test()) {
exportPaths.add(child.getFullName());
} else {
scanSubtasksForExportPaths(exportPaths, child);
}
}
}
Aggregations