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;
}
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;
}
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();
}
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, "/"));
}
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();
}
Aggregations