use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class TimeLogProblemReport method writeContents.
@Override
protected void writeContents() throws IOException {
out.println(HEADER);
DataContext data = getDataContext();
ProcessUtil process = new ProcessUtil(data);
List phases = process.getProcessListPlain("Phase_List");
phases = process.filterPhaseList(phases);
List<String> missingPhases = new ArrayList<String>();
for (Iterator i = phases.iterator(); i.hasNext(); ) {
String phase = (String) i.next();
if (getBoolParam("Check" + phase)) {
SimpleData phaseTime = data.getSimpleValue(phase + "/Time");
if (phaseTime == null || !phaseTime.test())
missingPhases.add(phase);
}
}
if (missingPhases.isEmpty()) {
printStudentDataOK(res().getString("OK_Message"));
} else {
String missingPhaseStr = joinList(missingPhases, "or");
String message = getParameter("Message");
if (!StringUtils.hasValue(message))
message = res().getString("Default_Error_Message");
message = StringUtils.findAndReplace(message, "[PHASES]", missingPhaseStr);
printStudentDataError(message);
}
out.println(FOOTER);
}
use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class DefaultTimeLoggingModelTest method assertTime.
protected void assertTime(String path, int i) {
String dataName = path + "/Time";
SimpleData d = data.getSimpleValue(dataName);
if (d == null && i == 0)
return;
assertNotNull("Missing time data for " + path, d);
assertTrue("Time data for " + path + " is not NumberData", d instanceof NumberData);
NumberData n = (NumberData) d;
assertEquals("Wrong time for path " + path, i, n.getDouble(), 0);
}
use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class MessageDispatcher method setMessageHandled.
private void setMessageHandled(String serverID, String messageID, boolean handled) {
if (serverID != null) {
ListData l = ListData.asListData(data.getValue(SERVER_MESSAGES));
if (l == null)
l = new ListData();
if (handled == true)
l.setAdd(serverID);
else
l.remove(serverID);
data.putValue(SERVER_MESSAGES, l);
if (messageID.contains("/pdes/"))
return;
}
SimpleData value = (handled ? ImmutableDoubleData.TRUE : null);
data.putValue(getHandledDataName(messageID), value);
}
use of net.sourceforge.processdash.data.SimpleData in project processdash by dtuma.
the class TeamStartNotifier method notifyUserOfPendingInvitations.
public static void notifyUserOfPendingInvitations(DashboardContext ctx) {
for (int i = MAX_OUTSTANDING_INVITES; i-- > 0; ) {
String dataPrefix = DATA_PREFIX + i;
String dataName = dataPrefix + DATA_SUFFIX;
SimpleData sd = ctx.getData().getSimpleValue(dataName);
if (sd != null) {
try {
handlePendingInvitation(ctx, dataPrefix, sd.format());
} catch (Exception e) {
ctx.getData().putValue(dataName, null);
if (!(e instanceof AlreadyJoinedException))
e.printStackTrace();
}
}
}
}
use of net.sourceforge.processdash.data.SimpleData 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);
}
}
Aggregations