Search in sources :

Example 21 with DateData

use of net.sourceforge.processdash.data.DateData in project processdash by dtuma.

the class TinyCGIBase method generatePostToken.

/**
     * Generate a new, unique token and save it in the data repository.
     * 
     * @param dataNameSuffix
     *            a suffix to use when constructing the name of the data
     *            repository data element
     * @return a new, unique token.
     * @since 1.14.0.1
     */
protected String generatePostToken(String dataNameSuffix) {
    UUID uuid = UUID.randomUUID();
    String result = uuid.toString();
    String dataName = getPostTokenDataName(dataNameSuffix);
    getDataRepository().putValue(dataName, StringData.create(result));
    getDataRepository().putValue(dataName + "/TS", new DateData());
    return result;
}
Also used : DateData(net.sourceforge.processdash.data.DateData) UUID(java.util.UUID)

Example 22 with DateData

use of net.sourceforge.processdash.data.DateData in project processdash by dtuma.

the class EVTask method userSetActualDate.

/** Messaged to indicate that the user has entered a new value for the
     * actual completion date of this task.
     * 
     * @param aValue the value entered by the user (a Date is expected)
     */
public void userSetActualDate(Object aValue) {
    if (!isCompletionDateEditable())
        return;
    if (isLeaf()) {
        String dataName = DataRepository.createDataName(fullName, DATE_COMPLETED_DATA_NAME);
        // save the Date object to the data repository
        if (aValue instanceof Date) {
            dateCompleted = (Date) aValue;
            data.userPutValue(dataName, new DateData(dateCompleted, true));
        } else {
            dateCompleted = null;
            data.userPutValue(dataName, null);
        }
    } else if (getNumChildren() == 1) {
        getChild(0).userSetActualDate(aValue);
        recalcDateCompleted();
        notifyListener(true);
    }
}
Also used : DateData(net.sourceforge.processdash.data.DateData) Date(java.util.Date)

Example 23 with DateData

use of net.sourceforge.processdash.data.DateData in project processdash by dtuma.

the class ArchiveMetricsFileExporter method maybeSaveMaxActivityDate.

private void maybeSaveMaxActivityDate() {
    if (maxActivityDate != null && filter.size() == 1) {
        String path = (String) filter.iterator().next();
        String dataName = DataRepository.createDataName(path, DATA_TIMESTAMP_NAME);
        DateData timestamp = new DateData(maxActivityDate, true);
        ctx.getData().putValue(dataName, timestamp);
    }
}
Also used : DateData(net.sourceforge.processdash.data.DateData)

Example 24 with DateData

use of net.sourceforge.processdash.data.DateData 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 25 with DateData

use of net.sourceforge.processdash.data.DateData in project processdash by dtuma.

the class HierarchySynchronizer method getUserActivityAgeRange.

/** Check to see if the user has recorded project data recently */
private int getUserActivityAgeRange() {
    // get the activity timestamp.  If it is not present, we don't have
    // any idea when the user recorded project data last. Stay on the
    // safe side and assume that they are working on the project.
    SimpleData d = getData(projectPath, TeamDataConstants.USER_ACTIVITY_TIMESTAMP);
    if (!(d instanceof DateData))
        return USER_ACTIVITY_MODERATE;
    // get the age of the activity timestamp
    DateData activityDate = (DateData) d;
    long now = System.currentTimeMillis();
    long activityAge = now - activityDate.getValue().getTime();
    // if the activity timestamp is more than 30 days old, they are
    // definitely not working on the project anymore
    int activityCutoff = Settings.getInt("teamProject.inactivityAge", 30);
    if (activityAge > activityCutoff * DateUtils.DAYS)
        return USER_ACTIVITY_OLD;
    // if the activity timestamp is less than 7 days old, they are
    // definitely working on the project.
    activityCutoff = Settings.getInt("teamProject.recentActivityAge", 7);
    if (activityAge < activityCutoff * DateUtils.DAYS)
        return USER_ACTIVITY_RECENT;
    // their last activity was between 7 and 30 days ago.
    return USER_ACTIVITY_MODERATE;
}
Also used : DateData(net.sourceforge.processdash.data.DateData) SimpleData(net.sourceforge.processdash.data.SimpleData)

Aggregations

DateData (net.sourceforge.processdash.data.DateData)31 SimpleData (net.sourceforge.processdash.data.SimpleData)10 Date (java.util.Date)6 Iterator (java.util.Iterator)3 SaveableData (net.sourceforge.processdash.data.SaveableData)3 DataContext (net.sourceforge.processdash.data.DataContext)2 DoubleData (net.sourceforge.processdash.data.DoubleData)2 ListData (net.sourceforge.processdash.data.ListData)2 EscapeString (net.sourceforge.processdash.util.EscapeString)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 UUID (java.util.UUID)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 MalformedData (net.sourceforge.processdash.data.MalformedData)1 MalformedValueException (net.sourceforge.processdash.data.MalformedValueException)1