Search in sources :

Example 66 with SimpleData

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

the class EVTaskDependency method getTaskIDs.

public static List getTaskIDs(DataContext data, String taskPath) {
    String dataName = DataRepository.createDataName(taskPath, TASK_ID_DATA_NAME);
    SimpleData currentValue = data.getSimpleValue(dataName);
    ListData list = null;
    if (currentValue == null || currentValue.test() == false)
        return null;
    if (currentValue instanceof ListData)
        list = (ListData) currentValue;
    else if (currentValue instanceof StringData)
        list = ((StringData) currentValue).asList();
    else
        return null;
    List result = new LinkedList();
    for (int i = 0; i < list.size(); i++) result.add(list.get(i));
    if (!result.isEmpty())
        return result;
    else
        return null;
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) NodeList(org.w3c.dom.NodeList) List(java.util.List) StringData(net.sourceforge.processdash.data.StringData) ImmutableStringData(net.sourceforge.processdash.data.ImmutableStringData) LinkedList(java.util.LinkedList) ListData(net.sourceforge.processdash.data.ListData)

Example 67 with SimpleData

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

the class EVTaskDependency method addTaskIDs.

public static void addTaskIDs(DataContext data, String taskPath, String id) {
    if (id == null || id.length() == 0)
        return;
    String dataName = DataRepository.createDataName(taskPath, TASK_ID_DATA_NAME);
    SimpleData currentValue = data.getSimpleValue(dataName);
    ListData newValue;
    if (currentValue instanceof ListData)
        newValue = (ListData) currentValue;
    else if (currentValue instanceof StringData)
        newValue = ((StringData) currentValue).asList();
    else
        newValue = new ListData();
    boolean valueChanged = false;
    String[] idList = id.split(",");
    for (int i = 0; i < idList.length; i++) {
        if (newValue.setAdd(idList[i]))
            valueChanged = true;
    }
    if (valueChanged)
        data.putValue(dataName, newValue);
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) StringData(net.sourceforge.processdash.data.StringData) ImmutableStringData(net.sourceforge.processdash.data.ImmutableStringData) ListData(net.sourceforge.processdash.data.ListData)

Example 68 with SimpleData

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

the class EVTask method saveDataElement.

private void saveDataElement(String oldTaskListName, String newTaskListName, String dataNamePrefix, int savedValue, int newValue, int defaultValue) {
    if (fullName == null || fullName.length() == 0)
        return;
    String oldDataName = null;
    if (savedValue != defaultValue)
        oldDataName = dataNamePrefix + oldTaskListName;
    if (newTaskListName != null && newValue != defaultValue) {
        String newDataName = dataNamePrefix + newTaskListName;
        if (newDataName.equals(oldDataName))
            oldDataName = null;
        if (newValue != savedValue || oldDataName != null) {
            SimpleData d = new DoubleData(newValue, false);
            String dataName = DataRepository.createDataName(fullName, newDataName);
            data.putValue(dataName, d);
        }
    }
    if (oldDataName != null) {
        String dataName = DataRepository.createDataName(fullName, oldDataName);
        data.putValue(dataName, null);
    }
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) DoubleData(net.sourceforge.processdash.data.DoubleData)

Example 69 with SimpleData

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

the class AnalysisPage method setSizeUnits.

private static boolean setSizeUnits(ChartData chartData, DataRepository data, String dataName) {
    SimpleData sd = data.getSimpleValue("/Workflow_Prefs/" + dataName);
    if (sd == null || !sd.test())
        return false;
    chartData.setPrimarySizeUnits(sd.format());
    return true;
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 70 with SimpleData

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

the class EVTaskList method getSnapshotFromData.

/**
     * Retrieve a single snapshot of this task list.
     * 
     * @param data the DataRepository
     * @param snapshotId the ID of the snapshot to retrieve
     * @return the {@link EVSnapshot} of this schedule with the given ID, or
     *     null if no such snapshot exists.
     */
protected EVSnapshot getSnapshotFromData(DataRepository data, String snapshotId) {
    String globalPrefix = MAIN_DATA_PREFIX + taskListName;
    String dataName = globalPrefix + "/" + SNAPSHOT_DATA_PREFIX + "/" + snapshotId;
    SimpleData d = data.getSimpleValue(dataName);
    if (d != null && d.test()) {
        try {
            return new EVSnapshot(snapshotId, d.format());
        } catch (Exception e) {
            logger.warning("Couldn't open snapshot '" + snapshotId + "' for task list '" + taskListName + "' - aborting");
        }
    }
    return null;
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) IOException(java.io.IOException)

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