Search in sources :

Example 16 with SaveableData

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

the class DefectUtil method getDefectPhaseList.

/**
     * Return the same information as
     * {@link #getDefectPhases(String, DashboardContext)}, but in the form of a
     * DefectPhaseList.
     */
public static DefectPhaseList getDefectPhaseList(String defectPath, String taskPath, DashboardContext context) {
    List<String> phaseNames = getDefectPhases(defectPath, context);
    String removalPhase = guessRemovalPhase(defectPath, taskPath, context);
    String injectionPhase = guessInjectionPhase(phaseNames, removalPhase, taskPath, context);
    String processName = null;
    SaveableData sd = context.getData().getInheritableValue(taskPath, TeamDataConstants.PROCESS_NAME);
    if (sd != null)
        processName = sd.getSimpleValue().format();
    DefectPhaseList result = new DefectPhaseList();
    for (String onePhase : phaseNames) {
        DefectPhase dp = new DefectPhase(onePhase);
        dp.processName = processName;
        if (onePhase.equals(injectionPhase))
            result.defaultInjectionPhase = result.size();
        if (onePhase.equals(removalPhase))
            result.defaultRemovalPhase = result.size();
        result.add(dp);
    }
    return result;
}
Also used : SaveableData(net.sourceforge.processdash.data.SaveableData)

Example 17 with SaveableData

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

the class TimingMetricsRecorder method saveTiming.

protected boolean saveTiming(String basePath) {
    Map timings = getTimings(basePath);
    if (timings == null)
        return false;
    for (Iterator i = timings.entrySet().iterator(); i.hasNext(); ) {
        Map.Entry e = (Map.Entry) i.next();
        String pathName = (String) e.getKey();
        long[] pathValue = (long[]) e.getValue();
        String timeElementName = DataRepository.createDataName(pathName, "Time");
        String orphanElementName = DataRepository.createDataName(pathName, "Orphaned Time");
        SaveableData currentVal = data.getValue(timeElementName);
        SaveableData orphanedVal = data.getValue(orphanElementName);
        if (pathValue == null) {
            if (orphanedVal != null)
                // if a previous orphan value exists, clear it.
                data.putValue(orphanElementName, null);
            if (currentVal == null)
                // the data repository agrees with us.  All is well.
                continue;
            else if (!(currentVal instanceof DoubleData) || (currentVal instanceof NumberFunction))
                // there.  Leave it alone.
                continue;
            else
                // there is an existing number there;  erase it.
                data.putValue(timeElementName, null);
        } else if (approver.isTimeLoggingAllowed(pathName) == false) {
            // the time log has entries for this path, but the time isn't
            // supposed to be logged there.  Record it as orphaned time.
            allPathsTouched.add(pathName);
            storeNumberIfChanged(orphanElementName, orphanedVal, pathValue);
        } else {
            allPathsTouched.add(pathName);
            storeNumberIfChanged(timeElementName, currentVal, pathValue);
            if (orphanedVal != null)
                data.putValue(orphanElementName, null);
        }
    }
    return true;
}
Also used : NumberFunction(net.sourceforge.processdash.data.NumberFunction) Iterator(java.util.Iterator) SaveableData(net.sourceforge.processdash.data.SaveableData) HashMap(java.util.HashMap) Map(java.util.Map) DoubleData(net.sourceforge.processdash.data.DoubleData)

Example 18 with SaveableData

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

the class ImportedDefectManager method rerootPath.

private static String rerootPath(DataRepository data, String defectPath, Map wbsIdMap) {
    SaveableData wbsIdValue = data.getInheritableValue(defectPath, "Project_WBS_ID");
    if (wbsIdValue == null)
        return defectPath;
    SimpleData wbsIdSimpleValue = wbsIdValue.getSimpleValue();
    if (wbsIdSimpleValue == null)
        return defectPath;
    String wbsID = wbsIdSimpleValue.format();
    while (wbsID != null && wbsID.length() > 0) {
        String result = (String) wbsIdMap.get(wbsID);
        if (result != null)
            return result;
        wbsID = DataRepository.chopPath(wbsID);
    }
    return defectPath;
}
Also used : SimpleData(net.sourceforge.processdash.data.SimpleData) SaveableData(net.sourceforge.processdash.data.SaveableData)

Example 19 with SaveableData

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

the class TaskStatusApi method storeCompletionDate.

private void storeCompletionDate(String path, String newDateParam) {
    DateData newDate = null;
    if (!"".equals(newDateParam) && !"null".equals(newDateParam)) {
        try {
            Date d;
            if ("now".equals(newDateParam))
                d = new Date();
            else
                d = WebApiUtils.DATE_FMT.parse(newDateParam);
            newDate = new DateData(d, true);
        } catch (ParseException e) {
            throw new WebApiException("parameter-invalid", 400, "The 'completionDate' parameter value '" + newDateParam + "' is not a valid date.").causedBy(e).putAttr("param", "completionDate");
        }
    }
    String dataName = path + "/Completed";
    SaveableData currentDate = getDataContext().getValue(dataName);
    if (currentDate != null && !(currentDate instanceof DateData))
        throw new WebApiException("date-not-editable", 400, "The completion date is not editable for task '" + path + "'.");
    getDataContext().putValue(dataName, newDate);
}
Also used : DateData(net.sourceforge.processdash.data.DateData) ParseException(java.text.ParseException) SaveableData(net.sourceforge.processdash.data.SaveableData) Date(java.util.Date)

Example 20 with SaveableData

use of net.sourceforge.processdash.data.SaveableData 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)

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