Search in sources :

Example 1 with ProcessUtil

use of net.sourceforge.processdash.process.ProcessUtil in project processdash by dtuma.

the class AddTeamProjectTask method getTaskTypes.

@Override
public List<AddTaskTypeOption<String[]>> getTaskTypes(String targetParent, String activeTask) {
    // find the root node of the enclosing project
    StringBuffer path = new StringBuffer(activeTask);
    ctx.getData().getInheritableValue(path, "Project_ID");
    String projectRoot = path.toString();
    // create a ProcessUtil object to extract process metadata
    ProcessUtil proc = new ProcessUtil(ctx.getData(), projectRoot);
    String templateID = proc.getProcessID() + "/Indiv2Task";
    List<String> phaseNames = proc.getProcessListPlain("Phase_List");
    TeamPhaseIconSet icons = new TeamPhaseIconSet(phaseNames);
    String currentPhase = proc.getEffectivePhase(activeTask, true);
    SimpleData currentWorkflowID = ctx.getData().getSimpleValue(DataRepository.createDataName(activeTask, TeamDataConstants.WORKFLOW_ID_DATA_NAME));
    // create a list of types representing the phases in our MCF
    List<AddTaskTypeOption<String[]>> result = new ArrayList();
    for (String phase : phaseNames) {
        AddTaskTypeOption<String[]> oneType = new AddTaskTypeOption();
        oneType.typeID = new String[] { phase, null };
        oneType.displayName = phase;
        oneType.icon = icons.get(phase);
        oneType.templateID = templateID;
        oneType.isDefault = phase.equalsIgnoreCase(currentPhase);
        if (oneType.isDefault && currentWorkflowID != null && currentWorkflowID.test()) {
            oneType.typeID[1] = currentWorkflowID.format();
        }
        result.add(oneType);
    }
    // if any problems occurred, create a single, simple task type
    if (result.isEmpty()) {
        AddTaskTypeOption oneType = new AddTaskTypeOption();
        oneType.icon = HierarchyIcons.getTaskIcon();
        oneType.templateID = templateID;
        result.add(oneType);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) SimpleData(net.sourceforge.processdash.data.SimpleData) ProcessUtil(net.sourceforge.processdash.process.ProcessUtil) AddTaskTypeOption(net.sourceforge.processdash.hier.ui.AddTaskTypeOption)

Example 2 with ProcessUtil

use of net.sourceforge.processdash.process.ProcessUtil in project processdash by dtuma.

the class TimeLogReport method queryDatabaseForTimeLogEntries.

private List queryDatabaseForTimeLogEntries(UserFilter privacyFilter) {
    // retrieve a mapping of dataset IDs, if we need it for testing privacy
    PDashQuery query = getPdash().getQuery();
    Map<Object, String> datasetIDs = null;
    if (!UserGroup.isEveryone(privacyFilter))
        datasetIDs = QueryUtils.mapColumns(query.query(DATASET_ID_QUERY));
    // retrieve the ID of the process whose phases we should map to
    String processID = getParameter("processID");
    if (processID == null)
        processID = new ProcessUtil(getDataContext()).getProcessID();
    // retrieve the raw data for the time log entries themselves
    List<Object[]> rawData = query.query(TIME_LOG_HQL, processID);
    rawData.addAll(query.query(TIME_LOG_UNCAT_HQL));
    // build a list of time log entries
    List<TimeLogEntry> result = new ArrayList<TimeLogEntry>();
    for (Object[] row : rawData) {
        String path = row[0] + "/" + row[1];
        if (path.startsWith("//"))
            path = path.substring(1);
        Date start = (Date) row[2];
        long delta = ((Number) row[3]).longValue();
        long interrupt = ((Number) row[4]).longValue();
        String comment = (String) row[5];
        // if a privacy filter is in effect, see if it excludes this entry
        if (datasetIDs != null) {
            String datasetID = datasetIDs.get(row[6]);
            if (!privacyFilter.getDatasetIDs().contains(datasetID)) {
                someEntriesBlocked = true;
                continue;
            }
        }
        // create a time log entry and add it to the list
        result.add(new //
        TimeLogEntryVO(//
        0, //
        path, //
        start, //
        delta, interrupt, comment));
    }
    return result;
}
Also used : PDashQuery(net.sourceforge.processdash.api.PDashQuery) ArrayList(java.util.ArrayList) ProcessUtil(net.sourceforge.processdash.process.ProcessUtil) Date(java.util.Date) TimeLogEntry(net.sourceforge.processdash.log.time.TimeLogEntry)

Example 3 with ProcessUtil

use of net.sourceforge.processdash.process.ProcessUtil in project processdash by dtuma.

the class PieChart method maybeConfigurePhaseColors.

private void maybeConfigurePhaseColors(final PiePlot plot, PieDataset pieData) {
    ProcessUtil procUtil = new ProcessUtil(getDataContext());
    new PhaseChartColorer(procUtil, pieData.getKeys()) {

        public void setItemColor(Object key, int pos, Color c) {
            plot.setSectionPaint((Comparable) key, c);
        }
    }.run();
}
Also used : PhaseChartColorer(net.sourceforge.processdash.ui.lib.chart.PhaseChartColorer) Color(java.awt.Color) ProcessUtil(net.sourceforge.processdash.process.ProcessUtil) Paint(java.awt.Paint)

Example 4 with ProcessUtil

use of net.sourceforge.processdash.process.ProcessUtil in project processdash by dtuma.

the class MigrationToolIndivLauncher method loadData.

private void loadData() throws Exception {
    // validate the project path, and add to args
    projectRoot = ctx.getHierarchy().findExistingKey(projectPath);
    if (projectRoot == null)
        throw new MigrationException("notTeamProject");
    args.put(MigrationToolIndiv.PROJECT_PATH, projectPath);
    // retrieve the target directory, validate it, and add to args
    String targetDirName = ProcessDashboard.getDefaultDirectory();
    targetDir = new File(targetDirName);
    if (!targetDir.isDirectory())
        throw new MigrationException(new FileNotFoundException(targetDirName));
    args.put(MigrationToolIndiv.TARGET_DIR, targetDir.getAbsolutePath());
    // check that the backup subdirectory exists - otherwise we're
    // probably in bridged mode.
    File backupSubdir = new File(targetDir, "backup");
    if (!backupSubdir.isDirectory())
        throw new MigrationException("cannotMigrate").add("bridgedMode");
    // check to see if we are performing a migration
    String rootTemplateID = ctx.getHierarchy().pget(projectRoot).getID();
    if (!rootTemplateID.endsWith(INDIV2_ROOT))
        args.put(MigrationToolIndiv.MIGRATION_NEEDED, "true");
    // add the process ID to the args
    String processId = getValue("Team_Process_PID").format();
    args.put(MigrationToolIndiv.PROCESS_ID, processId);
    // for a conversion, add the target process ID to the args
    SimpleData sd = getValue("Team_Project_Conversion_Needed");
    if (sd != null && sd.test()) {
        targetPID = sd.format();
        args.put(MigrationToolIndiv.TARGET_PROCESS_ID, targetPID);
    }
    // add the phase list to the args
    ProcessUtil proc = new ProcessUtil(ctx.getData(), projectPath);
    List phases = proc.getProcessListPlain("Phase_List");
    args.put(MigrationToolIndiv.PHASE_LIST, StringUtils.join(phases, "/"));
}
Also used : FileNotFoundException(java.io.FileNotFoundException) SimpleData(net.sourceforge.processdash.data.SimpleData) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) ProcessUtil(net.sourceforge.processdash.process.ProcessUtil)

Example 5 with ProcessUtil

use of net.sourceforge.processdash.process.ProcessUtil in project processdash by dtuma.

the class SizeEstimatingTemplate2 method initSizeTypeData.

private void initSizeTypeData() {
    StringBuffer options = new StringBuffer("<option>\n");
    StringBuffer sizeData = new StringBuffer("<script>DashSET.itemSizes = { \n");
    String sizeUnits = new ProcessUtil(getDataContext()).getSizeUnits();
    SortedMap<String, SizePerItemTable> tables = SizePerItemTable.getDefinedTables(getDataRepository(), sizeUnits);
    for (Entry<String, SizePerItemTable> e : tables.entrySet()) {
        String sizePerItemTableName = e.getKey();
        SizePerItemTable sizePerItemTable = e.getValue();
        String valuePrefix = getCategoryValuePrefix(sizePerItemTableName);
        options.append("<optgroup label=\"").append(esc(sizePerItemTableName)).append("\">\n");
        for (String category : sizePerItemTable.getCategoryNames()) {
            String fullCat = valuePrefix + category;
            options.append("<option value=\"").append(esc(fullCat)).append("\">").append(esc(category)).append("\n");
            for (RelativeSize relSize : RelativeSize.values()) {
                sizeData.append('"').append(StringUtils.javaEncode(fullCat)).append("/").append(REL_SIZE_NAMES[relSize.ordinal()]).append("\" : ").append(sizePerItemTable.getSize(category, relSize)).append(",\n");
            }
        }
        options.append("</optgroup>\n");
    }
    if (tables.isEmpty()) {
        String messageHtml = resources.getHTML("SizePerItem.Errors.No_Types_Message");
        String tooltip = resources.format("SizePerItem.Errors.No_Types_Tooltip_FMT", sizeUnits);
        options.append("<option value=\"-\" title=\"").append(esc(tooltip)).append("\">").append(messageHtml).append("\n");
    }
    sizeData.setLength(sizeData.length() - 2);
    sizeData.append(" };\n");
    if (USE_COMMA)
        sizeData.append("DashSET.useCommaForDecimal = true;\n");
    if (freezePlan || Settings.getBool("sizeEst.disableBasePartsGraph", false))
        sizeData.append("DashSET.disableBasePartsGraph = true;\n");
    sizeData.append("</script>\n");
    this.sizeTypeInit = sizeData.toString();
    this.sizeTypeOptions = options.toString();
}
Also used : SizePerItemTable(net.sourceforge.processdash.tool.probe.SizePerItemTable) RelativeSize(net.sourceforge.processdash.tool.probe.SizePerItemTable.RelativeSize) ProcessUtil(net.sourceforge.processdash.process.ProcessUtil)

Aggregations

ProcessUtil (net.sourceforge.processdash.process.ProcessUtil)12 ArrayList (java.util.ArrayList)8 List (java.util.List)5 Iterator (java.util.Iterator)3 SimpleData (net.sourceforge.processdash.data.SimpleData)3 DataContext (net.sourceforge.processdash.data.DataContext)2 TimeLogEntry (net.sourceforge.processdash.log.time.TimeLogEntry)2 Color (java.awt.Color)1 Paint (java.awt.Paint)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 Date (java.util.Date)1 Enumeration (java.util.Enumeration)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 PDashQuery (net.sourceforge.processdash.api.PDashQuery)1 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)1 PropertyKey (net.sourceforge.processdash.hier.PropertyKey)1 AddTaskTypeOption (net.sourceforge.processdash.hier.ui.AddTaskTypeOption)1 SizePerItemTable (net.sourceforge.processdash.tool.probe.SizePerItemTable)1