Search in sources :

Example 11 with DataContext

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

the class ScanItemListBulkHandler method writeContents.

@Override
protected void writeContents() throws IOException {
    parseFormData();
    String[] itemIDs = (String[]) parameters.get("id_ALL");
    boolean checked = "true".equals(parameters.get("checked"));
    DateData valueToStore = checked ? new DateData() : null;
    DataContext data = getDataContext();
    for (String itemID : itemIDs) {
        if (!checkValidID(itemID))
            throw new TinyCGIException(400, "Bad item ID");
        data.putValue(itemID, valueToStore);
    }
    out.write("OK");
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext) DateData(net.sourceforge.processdash.data.DateData) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException)

Example 12 with DataContext

use of net.sourceforge.processdash.data.DataContext 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 13 with DataContext

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

the class MoveProjectWorker method saveNewDataValues.

/*
     * Methods to update the values in the data repository
     */
private void saveNewDataValues() {
    DataContext data = ctx.getData().getSubcontext(projectPrefix);
    saveDataValue(data, TeamDataConstants.TEAM_DIRECTORY, newTeamDir);
    saveDataValue(data, TeamDataConstants.TEAM_DIRECTORY_UNC, newTeamDirUNC);
    RepairImportInstruction.maybeRepairForTeam(data);
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext)

Example 14 with DataContext

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

the class SyncWBS method precacheWbsImportDirectory.

private void precacheWbsImportDirectory() {
    DataContext data = getDataRepository().getSubcontext(projectRoot);
    SimpleData d = data.getSimpleValue(TeamDataConstants.TEAM_DATA_DIRECTORY);
    String dir = (d == null ? null : d.format());
    d = data.getSimpleValue(TeamDataConstants.TEAM_DATA_DIRECTORY_URL);
    String url = (d == null ? null : d.format());
    ImportDirectoryFactory.getInstance().get(url, dir);
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext) SimpleData(net.sourceforge.processdash.data.SimpleData)

Example 15 with DataContext

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

the class ProbeItemSizeHistogram method buildData.

@Override
protected void buildData() {
    int[] histogram = new int[SIZE_NAMES.size()];
    DataContext data = getDataContext();
    ListData partsAdditions = ListData.asListData(data.getSimpleValue(PARTS_LIST));
    if (partsAdditions != null) {
        for (int i = 0; i < partsAdditions.size(); i++) {
            String path = asString(partsAdditions.get(i));
            double itemCount = asDoubleData(data.getSimpleValue(path + METHODS));
            String relSize = asString(data.getSimpleValue(path + REL_SIZE));
            if (!StringUtils.hasValue(relSize) && itemCount == 0)
                continue;
            int relSizePos = SIZE_NAMES.indexOf(relSize);
            if (relSizePos == -1)
                relSizePos = UNCATEGORIZED_POS;
            if (itemCount == 0)
                itemCount = 1;
            histogram[relSizePos]++;
        }
    }
    // if no items were present in the "[BLANK]" category, don't show it.
    int len = histogram.length;
    if (histogram[len - 1] == 0)
        len--;
    ResultSet result = new ResultSet(len, 1);
    result.setColName(0, "");
    result.setColName(1, "Total # Items");
    for (int i = 0; i < len; i++) {
        result.setRowName(i + 1, SIZE_NAMES.get(i));
        result.setData(i + 1, 1, new DoubleData(histogram[i]));
    }
    this.data = result;
}
Also used : DataContext(net.sourceforge.processdash.data.DataContext) ResultSet(net.sourceforge.processdash.data.util.ResultSet) DoubleData(net.sourceforge.processdash.data.DoubleData) ListData(net.sourceforge.processdash.data.ListData)

Aggregations

DataContext (net.sourceforge.processdash.data.DataContext)18 SimpleData (net.sourceforge.processdash.data.SimpleData)5 ArrayList (java.util.ArrayList)4 Iterator (java.util.Iterator)4 List (java.util.List)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ProcessDashboard (net.sourceforge.processdash.ProcessDashboard)2 DateData (net.sourceforge.processdash.data.DateData)2 ListData (net.sourceforge.processdash.data.ListData)2 ProcessUtil (net.sourceforge.processdash.process.ProcessUtil)2 BufferedOutputStream (java.io.BufferedOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 URL (java.net.URL)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 DoubleData (net.sourceforge.processdash.data.DoubleData)1