use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.
the class DefaultImportInstructionSpecProvider method scanForInstructions.
private void scanForInstructions() {
Iterator keys = data.getKeys(null, new SimplePrefixLocalDataNameFilter(new PatternList(INSTRUCTIONS_DATANAME)));
while (keys.hasNext()) {
String dataName = (String) keys.next();
if (!dataName.endsWith("/" + INSTRUCTIONS_DATANAME))
continue;
ListData l = ListData.asListData(data.getSimpleValue(dataName));
if (l == null || !l.test())
continue;
for (int i = 1; i < l.size(); i += 2) {
String id = l.get(i - 1).toString();
if (cache.containsKey(id))
continue;
String spec = l.get(i).toString();
Element specXml;
try {
specXml = parseSpec(spec).getDocumentElement();
} catch (Exception e) {
specXml = null;
}
cache.put(id, specXml);
}
}
}
use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.
the class ProcessDashboard method createDatabasePlugin.
/**
* Create the database plugin and possibly start it.
*
* @return true if the plugin was started.
*/
private boolean createDatabasePlugin() {
try {
// create the database plugin object
List extensions = ExtensionManager.getExecutableExtensions(DatabasePlugin.EXTENSION_POINT_ID, this);
if (extensions == null || extensions.isEmpty())
return false;
// there should always only be one instance of this extension
// point. If multiple are present, go with the first one
DatabasePlugin plugin = (DatabasePlugin) extensions.get(0);
this.databasePlugin = plugin;
// register the plugin as an element in the data repository
ListData dbItem = new ListData();
dbItem.add(databasePlugin);
data.putValue(DatabasePlugin.DATA_REPOSITORY_NAME, dbItem);
data.pinElement(DatabasePlugin.DATA_REPOSITORY_NAME);
// setting, only start the plugin for team dashboard datasets.
if (Settings.getBool("tpidw.enabled", Settings.isTeamMode())) {
plugin.initialize();
data.addGlobalDefineDeclarations("#define DATABASE_PLUGIN t");
return true;
}
} catch (Exception e) {
// problem starting database plugin
logger.log(Level.SEVERE, "Unable to start the database plugin", e);
}
return false;
}
use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.
the class HierarchySynchronizer method doSync.
private void doSync() throws HierarchyAlterationException {
phaseIDs = initPhaseIDs(processID);
ListData nodeOrderData = new ListData();
collectNodeOrderData(projectXML, nodeOrderData);
getAllKnownWbsIds();
Map<String, String> milestoneNames = syncMilestoneData(projectXML);
ListData labelData = new ListData();
ListData milestoneData = new ListData();
if (isTeam()) {
// for a team, get label data for all nodes in a project before
// we prune the non-team nodes
getLabelData(projectXML, milestoneNames, labelData, milestoneData);
saveHierarchyFilterInfo(projectXML);
}
pruneWBS(projectXML, fullCopyMode, getNonprunableIDs(), Collections.EMPTY_SET);
if (!isTeam()) {
// for an individual, collect label data after pruning so we
// only see labels that are relevant to our tasks.
getLabelData(projectXML, milestoneNames, labelData, milestoneData);
getScheduleData(projectXML);
}
changes = new ArrayList();
discrepancies = new ListData();
discrepancies.add(new Date());
syncActions = buildSyncActions();
SyncWorker syncWorker;
if (whatIfMode) {
DashHierarchy mockHierarchy = new DashHierarchy("");
mockHierarchy.copy(this.hierarchy);
this.hierarchy = mockHierarchy;
syncWorker = new SyncWorkerWhatIf(dataRepository, mockHierarchy);
} else {
syncWorker = new SyncWorkerLive(dataRepository, deletionPermissions, completionPermissions);
}
if (debugLogInfo != null)
syncWorker = SyncWorkerLogger.wrapWorker(syncWorker, debugLogInfo);
this.data = syncWorker;
forceData(projectPath, LABEL_LIST_DATA_NAME, labelData);
forceData(projectPath, MILESTONE_LIST_DATA_NAME, milestoneData);
forceData(projectPath, NODE_ORDER_DATA_NAME, nodeOrderData);
forceData(projectPath, TeamDataConstants.CLOSED_PROJECT_FLAG, projectClosed ? ImmutableDoubleData.TRUE : null);
if (!isTeam()) {
syncSchedule();
saveWorkflowUrlData();
checkForUserInactivity();
}
sync(syncWorker, projectPath, projectXML);
if (!isTeam())
updateWorkflowPhasesInDefects();
processDeferredDeletions(syncWorker);
readChangesFromWorker(syncWorker);
String discrepancyDataName = DataRepository.createDataName(projectPath, SyncDiscrepancy.DISCREPANCIES_DATANAME);
dataRepository.putValue(discrepancyDataName, discrepancies);
if (!whatIfMode || changes.isEmpty()) {
String timestampDataName = DataRepository.createDataName(projectPath, TeamDataConstants.LAST_SYNC_TIMESTAMP);
dataRepository.putValue(timestampDataName, new DateData());
}
// unneeded files from the team dashboard directory.
if (isTeam() && !whatIfMode && !fullCopyMode && !syncWorker.getNodesDeleted().isEmpty()) {
try {
DashController.scrubDataDirectory();
logger.info("HierarchySynchronizer scrubbed team " + "dashboard directory.");
} catch (Throwable t) {
t.printStackTrace();
}
}
}
use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.
the class HierarchySynchronizer method syncSchedule.
/** If we are synchronizing a project for an individual, and that
* individual has not edited their earned value schedule yet, sync
* the initial period in their earned value schedule to reflect the
* information entered in the team plan.
*/
private void syncSchedule() {
// only operate on individual schedules.
if (isTeam())
return;
// if no schedule information was found, there is nothing to do.
if (startDate == null && hoursPerWeek == 0)
return;
// look up the name of the EV schedule for the individual. If we
// don't find a valid/existing schedule name, abort.
List names = EVTaskList.getPreferredTaskListsForPath(dataRepository, projectPath);
if (names == null || names.size() != 1)
return;
String taskListName = (String) names.get(0);
if (!EVTaskListData.validName(taskListName))
return;
if (!EVTaskListData.exists(dataRepository, taskListName))
return;
// open the schedule.
EVTaskListData tl = new EVTaskListData(taskListName, dataRepository, hierarchy, false);
EVSchedule currentSchedule = tl.getSchedule();
// schedule for future use.
if (tl.getID() != null) {
forceData(projectPath, TeamDataConstants.PROJECT_SCHEDULE_NAME, StringData.create(taskListName));
forceData(projectPath, TeamDataConstants.PROJECT_SCHEDULE_ID, StringData.create(tl.getID()));
}
// see if it is OK for us to change this schedule. If the dates are
// locked, then we must have created it, so we can change it.
// Otherwise, if it looks like a default schedule (only one manual row),
// it is fine to replace it.
boolean isLocked = currentSchedule.areDatesLocked();
boolean isDefault = (currentSchedule.getRowCount() == 1 || currentSchedule.get(2).isAutomatic());
if (!isLocked && !isDefault)
return;
// construct a schedule according to the specifications in the WBS.
EVSchedule wbsSchedule = new EVSchedule(startDate, hoursPerWeek, endWeek, scheduleExceptions, currentSchedule.getLevelOfEffort(), true);
// retrieve information about the last values we synced to the schedule
ListData lastSyncedHoursList = asListData(tl.getMetadata(TeamDataConstants.PROJECT_SCHEDULE_SYNC_SCHEDULE));
double syncPdt = asDouble(tl.getMetadata(TeamDataConstants.PROJECT_SCHEDULE_SYNC_PDT));
// flags to keep track of what changes are made.
boolean madeChange = false;
boolean needSyncUpdate = false;
if (isDefault || lastSyncedHoursList == null) {
if (!currentSchedule.isEquivalentTo(wbsSchedule)) {
currentSchedule.copyFrom(wbsSchedule);
madeChange = true;
}
needSyncUpdate = true;
} else {
EVSchedule lastSyncedSchedule = new EVSchedule(lastSyncedHoursList, true);
EVSchedule origSchedule = currentSchedule.copy();
mergeSchedules(currentSchedule, lastSyncedSchedule, syncPdt);
if (wbsSchedule.isEquivalentTo(lastSyncedSchedule))
// the wbs schedule hasn't changed since our last sync, so
// there are no new changes to incorporate. (Note that it
// was still necessary for us to call mergeSchedules though,
// to compute the list of user discrepancies for reverse sync)
madeChange = false;
else if (origSchedule.isEquivalentTo(currentSchedule))
// no changes were made to the schedule, but we still need
// to update the sync data.
needSyncUpdate = true;
else
madeChange = needSyncUpdate = true;
}
// make certain the dates in the schedule are locked
if (!currentSchedule.areDatesLocked()) {
currentSchedule.setDatesLocked(true);
madeChange = true;
}
// save the "last synced hours" value for future reference
tl.setMetadata(TeamDataConstants.PROJECT_SCHEDULE_SYNC_SCHEDULE, wbsSchedule.getSaveList().formatClean());
// save the "last synced pdt" value for future reference
tl.setMetadata(TeamDataConstants.PROJECT_SCHEDULE_SYNC_PDT, Double.toString(hoursPerWeek * 60));
if (madeChange) {
// record the timezone that we've used to sync the schedule
String tz = TimeZone.getDefault().getID();
tl.setMetadata(EVMetadata.TimeZone.ID, tz);
// save the task list
if (!whatIfMode)
tl.save();
changes.add("Updated the earned value schedule");
} else if (needSyncUpdate) {
// no changes were made, but we need to save sync data. It's OK to
// do this, even in what-if mode.
tl.saveMetadata();
}
}
use of net.sourceforge.processdash.data.ListData in project processdash by dtuma.
the class UserDataWriter method writeSizeData.
private void writeSizeData(XmlSerializer ser) throws IOException {
DashHierarchy hier = getPSPProperties();
PropertyKey projectRoot = hier.findExistingKey(getPrefix());
if (projectRoot != null)
writePspSizeData(ser, hier, projectRoot);
ListData sizedObjects = ListData.asListData(getData("Sized_Object_List"));
if (sizedObjects != null) {
for (int i = sizedObjects.size(); i-- > 0; ) writeLocalObjectSizeData(ser, (String) sizedObjects.get(i));
}
}
Aggregations