Search in sources :

Example 96 with SimpleData

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);
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) SimpleData(net.sourceforge.processdash.data.SimpleData) ProcessUtil(net.sourceforge.processdash.process.ProcessUtil)

Example 97 with SimpleData

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

Example 98 with SimpleData

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

Example 99 with SimpleData

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();
            }
        }
    }
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Example 100 with SimpleData

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

Aggregations

SimpleData (net.sourceforge.processdash.data.SimpleData)164 ListData (net.sourceforge.processdash.data.ListData)20 DoubleData (net.sourceforge.processdash.data.DoubleData)15 SaveableData (net.sourceforge.processdash.data.SaveableData)14 StringData (net.sourceforge.processdash.data.StringData)13 IOException (java.io.IOException)11 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)11 DateData (net.sourceforge.processdash.data.DateData)10 Iterator (java.util.Iterator)9 List (java.util.List)7 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 ImmutableDoubleData (net.sourceforge.processdash.data.ImmutableDoubleData)6 NumberData (net.sourceforge.processdash.data.NumberData)6 Element (org.w3c.dom.Element)6 Map (java.util.Map)5 DataContext (net.sourceforge.processdash.data.DataContext)5 EscapeString (net.sourceforge.processdash.util.EscapeString)5 File (java.io.File)4