Search in sources :

Example 21 with SaveableData

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

the class OpenWBSEditor method getItemHrefForIndivActiveTask.

private String getItemHrefForIndivActiveTask() {
    String activeTask = ((ProcessDashboard) getDashboardContext()).getActiveTaskModel().getPath();
    if (activeTask == null || !activeTask.startsWith(getPrefix()))
        return null;
    SaveableData wbsID = getDataRepository().getInheritableValue(activeTask, "WBS_Unique_ID");
    if (wbsID == null)
        return null;
    else
        return "wbs/" + wbsID.getSimpleValue().format();
}
Also used : SaveableData(net.sourceforge.processdash.data.SaveableData)

Example 22 with SaveableData

use of net.sourceforge.processdash.data.SaveableData 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;
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) SaveableData(net.sourceforge.processdash.data.SaveableData)

Example 23 with SaveableData

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

the class AbstractSyncWorker method putValue.

public void putValue(String name, SaveableData newValue) {
    SaveableData currVal = getValue(name);
    SaveableData lastRevSyncVal = lastReverseSyncedValue;
    lastReverseSyncedValue = null;
    if (lastRevSyncVal == null && !(newValue instanceof NumberData)) {
        // in a positive match (while the reverse order would return false)
        if (dataEquals(newValue, currVal))
            // no need to store the new value if it matches the current value.
            return;
        else {
            // the value has changed. save the new value.
            doPutValue(name, newValue);
            noteDataChange(name);
            return;
        }
    }
    String syncName = syncDataName(name);
    SimpleData lastSyncVal = getSimpleValue(syncName);
    if (dataEquals(newValue, currVal) && (currVal instanceof SimpleData)) {
        if (dataEquals(newValue, lastSyncVal)) {
            // all three values are in agreement. Nothing needs to be done.
            return;
        } else {
            // the new and old values match, but the sync doesn't.  This
            // would occur if:
            //   (a) the user has synced a value manually,
            //   (b) the WBS was updated via reverse sync, or
            //   (c) the sync occurred before sync records were kept.
            // The right action is to store the sync value for future
            // reference.  We will do this silently, even in what-if mode,
            // and won't report any change having been made.
            doPutValueForce(syncName, newValue);
        }
    } else if (isFalseSimpleValue(currVal) || !(currVal instanceof SimpleData) || dataEquals(currVal, lastSyncVal) || dataEquals(currVal, lastRevSyncVal)) {
        // Update the value, and make a note of the value we're syncing.
        doPutValue(name, newValue);
        doPutValue(syncName, newValue);
        noteDataChange(name);
    }
}
Also used : NumberData(net.sourceforge.processdash.data.NumberData) SimpleData(net.sourceforge.processdash.data.SimpleData) SaveableData(net.sourceforge.processdash.data.SaveableData)

Example 24 with SaveableData

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

the class McfSizeMetricApiHandler method addNotification.

/** Register a notification with the UserNotificationManager */
private void addNotification(SizeMetricApiRequestData request, DateData timestamp) {
    // find the root node of the team project, and retrieve the project ID
    StringBuffer projectPrefixBuf = new StringBuffer(request.targetPath);
    SaveableData projID = request.ctx.getData().getInheritableValue(projectPrefixBuf, "Project_ID");
    if (projID == null)
        return;
    String projectPrefix = projectPrefixBuf.toString();
    // construct an ID representing this user notification. We construct
    // an ID that will be the same for multiple API invocations against
    // this same team project; this way, the multiple invocations will
    // only spawn a single notification
    String notificationId = McfSizeMetricApiHandler.class.getName() + ":" + projID.getSimpleValue().format();
    // retrieve the message that should be displayed to the user
    String message = resources.format("Notification_Message_FMT", projectPrefix);
    // construct the URL that we will use to open the Size Inventory Form,
    // and make a Runnable action to open it.
    String processID = getStringData(request, projectPrefix + "/Process_ID");
    String notificationUri = this.notificationUri;
    notificationUri = //
    StringUtils.findAndReplace(//
    notificationUri, "[PID]", processID);
    notificationUri = //
    StringUtils.findAndReplace(//
    notificationUri, "[TIME]", Long.toString(timestamp.getValue().getTime()));
    if (notificationUri.startsWith("/"))
        notificationUri = notificationUri.substring(1);
    final String notificationUrl = WebServer.urlEncodePath(projectPrefix) + "//" + notificationUri;
    Runnable action = new Runnable() {

        public void run() {
            Browser.launch(notificationUrl);
        }
    };
    // register this notification info with the UserNotificationManager
    UserNotificationManager.getInstance().addNotification(notificationId, message, action);
}
Also used : SaveableData(net.sourceforge.processdash.data.SaveableData)

Example 25 with SaveableData

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

the class McfSizeMetricApiHandler method getStringData.

private String getStringData(SizeMetricApiRequestData request, String dataElemName) {
    SaveableData value = getData(request, dataElemName);
    SimpleData result = null;
    if (value != null)
        result = value.getSimpleValue();
    return (result == null ? null : result.format());
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) SaveableData(net.sourceforge.processdash.data.SaveableData)

Aggregations

SaveableData (net.sourceforge.processdash.data.SaveableData)38 SimpleData (net.sourceforge.processdash.data.SimpleData)14 EscapeString (net.sourceforge.processdash.util.EscapeString)11 MalformedValueException (net.sourceforge.processdash.data.MalformedValueException)6 Iterator (java.util.Iterator)5 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 ConcurrentModificationException (java.util.ConcurrentModificationException)4 HashMap (java.util.HashMap)4 PatternSyntaxException (java.util.regex.PatternSyntaxException)4 DoubleData (net.sourceforge.processdash.data.DoubleData)4 CompilationException (net.sourceforge.processdash.data.compiler.CompilationException)4 ExecutionException (net.sourceforge.processdash.data.compiler.ExecutionException)4 LexerException (net.sourceforge.processdash.data.compiler.lexer.LexerException)4 ParserException (net.sourceforge.processdash.data.compiler.parser.ParserException)4 Map (java.util.Map)3 WeakHashMap (java.util.WeakHashMap)3 DateData (net.sourceforge.processdash.data.DateData)3 NumberData (net.sourceforge.processdash.data.NumberData)3 StringData (net.sourceforge.processdash.data.StringData)3