Search in sources :

Example 81 with ListData

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);
        }
    }
}
Also used : SimplePrefixLocalDataNameFilter(net.sourceforge.processdash.data.repository.SimplePrefixLocalDataNameFilter) Element(org.w3c.dom.Element) Iterator(java.util.Iterator) PatternList(net.sourceforge.processdash.util.PatternList) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) ListData(net.sourceforge.processdash.data.ListData)

Example 82 with ListData

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;
}
Also used : DatabasePlugin(net.sourceforge.processdash.tool.db.DatabasePlugin) EventListenerList(javax.swing.event.EventListenerList) List(java.util.List) LinkedList(java.util.LinkedList) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) LockUncertainException(net.sourceforge.processdash.util.lock.LockUncertainException) TamperException(net.sourceforge.processdash.security.TamperDeterrent.TamperException) CannotCreateLockException(net.sourceforge.processdash.util.lock.CannotCreateLockException) IOException(java.io.IOException) SentLockMessageException(net.sourceforge.processdash.util.lock.SentLockMessageException) ReadOnlyLockFailureException(net.sourceforge.processdash.util.lock.ReadOnlyLockFailureException) FileNotFoundException(java.io.FileNotFoundException) OfflineLockLostException(net.sourceforge.processdash.util.lock.OfflineLockLostException) HttpException(net.sourceforge.processdash.util.HttpException) AlreadyLockedException(net.sourceforge.processdash.util.lock.AlreadyLockedException) ListData(net.sourceforge.processdash.data.ListData)

Example 83 with ListData

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();
        }
    }
}
Also used : DateData(net.sourceforge.processdash.data.DateData) DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) ArrayList(java.util.ArrayList) Date(java.util.Date) ListData(net.sourceforge.processdash.data.ListData) EVTaskListData(net.sourceforge.processdash.ev.EVTaskListData)

Example 84 with ListData

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();
    }
}
Also used : EVSchedule(net.sourceforge.processdash.ev.EVSchedule) EVTaskListData(net.sourceforge.processdash.ev.EVTaskListData) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) EVTaskList(net.sourceforge.processdash.ev.EVTaskList) NodeList(org.w3c.dom.NodeList) ListData(net.sourceforge.processdash.data.ListData) EVTaskListData(net.sourceforge.processdash.ev.EVTaskListData)

Example 85 with ListData

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));
    }
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) PropertyKey(net.sourceforge.processdash.hier.PropertyKey) ListData(net.sourceforge.processdash.data.ListData)

Aggregations

ListData (net.sourceforge.processdash.data.ListData)129 SimpleData (net.sourceforge.processdash.data.SimpleData)20 ArrayList (java.util.ArrayList)18 List (java.util.List)16 Iterator (java.util.Iterator)15 StringData (net.sourceforge.processdash.data.StringData)15 EVTaskListData (net.sourceforge.processdash.ev.EVTaskListData)9 Map (java.util.Map)8 HashSet (java.util.HashSet)7 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 LinkedList (java.util.LinkedList)5 DoubleData (net.sourceforge.processdash.data.DoubleData)5 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)5 LocalizedString (net.sourceforge.processdash.util.LocalizedString)5 NodeList (org.w3c.dom.NodeList)5 Date (java.util.Date)4 EVTaskList (net.sourceforge.processdash.ev.EVTaskList)4 Element (org.w3c.dom.Element)4