Search in sources :

Example 1 with NumberData

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

the class RadarChart method maybeScaleDataAxes.

private void maybeScaleDataAxes() {
    for (int i = 0; i < data.numCols(); i++) {
        int n = i + 1;
        String target = getParameter("t" + n);
        if (!StringUtils.hasValue(target))
            continue;
        double targetVal = 0;
        try {
            targetVal = FormatUtil.parseNumber(target);
        } catch (Exception e) {
            SaveableData val = getDataRepository().getInheritableValue(getPrefix(), target);
            if (val != null) {
                SimpleData sVal = val.getSimpleValue();
                if (sVal instanceof NumberData)
                    targetVal = ((NumberData) sVal).getDouble();
            }
        }
        if (targetVal == 0)
            continue;
        boolean reverse = parameters.containsKey("r" + n);
        SimpleData d = data.getData(1, n);
        if (d instanceof NumberData) {
            NumberData num = (NumberData) d;
            double val = num.getDouble();
            if (Double.isInfinite(val) || Double.isNaN(val))
                val = 1.0;
            else if (reverse)
                val = 2.0 / (1.0 + (val / targetVal));
            else
                val = val / targetVal;
            data.setData(1, n, new DoubleData(val));
        }
    }
}
Also used : NumberData(net.sourceforge.processdash.data.NumberData) SimpleData(net.sourceforge.processdash.data.SimpleData) SaveableData(net.sourceforge.processdash.data.SaveableData) DoubleData(net.sourceforge.processdash.data.DoubleData)

Example 2 with NumberData

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

the class Dblabelfiltergroup method call.

/**
     * Perform a procedure call.
     * 
     * This method <b>must</b> be thread-safe.
     * 
     * Arguments: Project key list, filtered task IDs
     */
public Object call(List arguments, ExpressionContext context) {
    // get the name of the data element we are calculating for
    String listenerName = asStringVal(context.get(SubscribingExpressionContext.LISTENERVAR_NAME));
    // get the database keys of the projects in question
    ListData projectKeyList = asList(getArg(arguments, 0));
    if (projectKeyList == null)
        return null;
    List<Integer> projectKeys = new ArrayList();
    for (int i = 0; i < projectKeyList.size(); i++) {
        Object oneKeyVal = projectKeyList.get(i);
        if (oneKeyVal instanceof NumberData) {
            int oneKey = ((NumberData) oneKeyVal).getInteger();
            projectKeys.add(oneKey);
        }
    }
    if (projectKeys.isEmpty())
        return null;
    // get the list of task IDs we are searching for, and convert them to
    // plain String objects
    Set<String> taskIds = new HashSet();
    for (Object oneTaskIdVal : collapseLists(arguments, 1)) {
        String oneTaskId = asStringVal(oneTaskIdVal);
        if (oneTaskId != null)
            taskIds.add(oneTaskId);
    }
    // study group.
    if (taskIds.isEmpty())
        return new DoubleData(-1, false);
    // retrieve the study group manager
    StudyGroupManager mgr = getDbObject(context, StudyGroupManager.class);
    if (mgr == null)
        return null;
    // create a study group for this list of items, and return its key
    try {
        int result = mgr.getPlanItemGroup(projectKeys, taskIds, true, listenerName);
        return new DoubleData(result, false);
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Unexpected error while calculating", e);
        return null;
    }
}
Also used : ArrayList(java.util.ArrayList) DoubleData(net.sourceforge.processdash.data.DoubleData) ListData(net.sourceforge.processdash.data.ListData) StudyGroupManager(net.sourceforge.processdash.tool.db.StudyGroupManager) NumberData(net.sourceforge.processdash.data.NumberData) HashSet(java.util.HashSet)

Example 3 with NumberData

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

the class Dbuserfiltergroup method call.

/**
     * Perform a procedure call.
     * 
     * This method <b>must</b> be thread-safe.
     * 
     * Arguments: Project key list, dataset ID list
     */
public Object call(List arguments, ExpressionContext context) {
    // get the name of the data element we are calculating for
    String listenerName = asStringVal(context.get(SubscribingExpressionContext.LISTENERVAR_NAME));
    // get the database keys of the projects in question
    ListData projectKeyList = asList(getArg(arguments, 0));
    if (projectKeyList == null)
        return null;
    List<Integer> projectKeys = new ArrayList();
    for (int i = 0; i < projectKeyList.size(); i++) {
        Object oneKeyVal = projectKeyList.get(i);
        if (oneKeyVal instanceof NumberData) {
            int oneKey = ((NumberData) oneKeyVal).getInteger();
            projectKeys.add(oneKey);
        }
    }
    if (projectKeys.isEmpty())
        return null;
    // get the list of dataset IDs we are searching for, and convert them
    // to plain String objects
    Set<String> datasetIds = new HashSet();
    for (Object oneDatasetIdVal : collapseLists(arguments, 1)) {
        String oneDatasetId = asStringVal(oneDatasetIdVal);
        if (oneDatasetId != null)
            datasetIds.add(oneDatasetId);
    }
    // either way, return null to indicate "no filtering"
    if (datasetIds.isEmpty())
        return null;
    // error code signifying an empty group
    if (datasetIds.contains(UserGroupManagerDash.EMPTY_GROUP_TOKEN))
        return new DoubleData(-1, false);
    // retrieve the study group manager
    StudyGroupManager mgr = getDbObject(context, StudyGroupManager.class);
    if (mgr == null)
        return null;
    try {
        int result = mgr.getDataBlockGroup(projectKeys, datasetIds, listenerName);
        return new DoubleData(result, false);
    } catch (Throwable t) {
        // disable user group filtering.
        return null;
    }
}
Also used : ArrayList(java.util.ArrayList) DoubleData(net.sourceforge.processdash.data.DoubleData) ListData(net.sourceforge.processdash.data.ListData) StudyGroupManager(net.sourceforge.processdash.tool.db.StudyGroupManager) NumberData(net.sourceforge.processdash.data.NumberData) HashSet(java.util.HashSet)

Example 4 with NumberData

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

the class EVTask method taskIsPruned.

public static boolean taskIsPruned(DataRepository data, String taskListName, String taskPath) {
    SaveableData d = data.getInheritableValue(taskPath, TASK_PRUNING_PREFIX + taskListName);
    int pruningFlag = INFER_FROM_CONTEXT;
    if (d != null && d.getSimpleValue() instanceof NumberData)
        pruningFlag = ((NumberData) d.getSimpleValue()).getInteger();
    return pruningFlag == USER_PRUNED;
}
Also used : NumberData(net.sourceforge.processdash.data.NumberData) SaveableData(net.sourceforge.processdash.data.SaveableData)

Example 5 with NumberData

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

the class AbstractSyncWorker method markLeafComplete.

public void markLeafComplete(String path) {
    if (completionPermissions == null || completionPermissions.contains(getOriginalPath(path))) {
        String completionDataName = dataName(path, "Completed");
        if (getSimpleValue(completionDataName) != null)
            return;
        SimpleData actualTime = getSimpleValue(dataName(path, "Time"));
        if (actualTime instanceof NumberData) {
            double time = ((NumberData) actualTime).getDouble();
            DoubleData estimatedTime = new DoubleData(time, true);
            doPutValue(dataName(path, "Estimated Time"), estimatedTime);
            doPutValue(dataName(path, syncDataName("Estimated Time")), estimatedTime);
        }
        DateData now = new DateData();
        doPutValue(completionDataName, now);
        doPutValue(syncDataName(completionDataName), now);
        nodesCompleted.add(path);
    }
}
Also used : DateData(net.sourceforge.processdash.data.DateData) NumberData(net.sourceforge.processdash.data.NumberData) SimpleData(net.sourceforge.processdash.data.SimpleData) DoubleData(net.sourceforge.processdash.data.DoubleData)

Aggregations

NumberData (net.sourceforge.processdash.data.NumberData)10 SimpleData (net.sourceforge.processdash.data.SimpleData)6 DoubleData (net.sourceforge.processdash.data.DoubleData)5 SaveableData (net.sourceforge.processdash.data.SaveableData)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ListData (net.sourceforge.processdash.data.ListData)2 StudyGroupManager (net.sourceforge.processdash.tool.db.StudyGroupManager)2 DateData (net.sourceforge.processdash.data.DateData)1