use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class TeamProjectSetupWizard method copyNodeIDsToHierarchy.
private static boolean copyNodeIDsToHierarchy(DataContext data, DashHierarchy hier, PropertyKey key) {
boolean madeChange = false;
SimpleData projectID = data.getSimpleValue(DataRepository.createDataName(key.path(), TeamDataConstants.PROJECT_ID));
if (projectID != null && projectID.test()) {
String nodeID = projectID.format() + ":root";
Prop p = hier.pget(key);
if (!nodeID.equals(p.getNodeID())) {
p.setNodeID(nodeID);
madeChange = true;
}
} else {
for (int i = hier.getNumChildren(key); i-- > 0; ) {
PropertyKey child = hier.getChildKey(key, i);
if (copyNodeIDsToHierarchy(data, hier, child))
madeChange = true;
}
}
return madeChange;
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class MigrationToolIndivLauncher method getPhaseChildren.
private List<String> getPhaseChildren(PropertyKey node) {
List<String> result = new ArrayList<String>();
Prop p = ctx.getHierarchy().pget(node);
for (int i = 0; i < p.getNumChildren(); i++) {
PropertyKey childKey = p.getChild(i);
Prop child = ctx.getHierarchy().pget(childKey);
String templateID = child.getID();
if (templateID != null && templateID.contains("/PHASE/"))
result.add(childKey.name());
}
return result;
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class TeamStartBootstrap method maybeSetDefaultProjectPath.
private void maybeSetDefaultProjectPath() {
// Look for an existing, unused stub in the hierarchy. If one is
// found, use its name and location and exit. Users will still be
// able to overwrite these values; but this helps them to pick up
// where they left off if they got confused.
PropertyKey stub = findUnusedTeamProjectStub(getPSPProperties(), PropertyKey.ROOT);
if (stub != null) {
putValue(NODE_NAME, stub.name());
putValue(NODE_LOCATION, stub.getParent().path());
return;
}
// if the prefix is not set, set it to the localized default location.
if (!StringUtils.hasValue(getValue(NODE_LOCATION))) {
putValue(NODE_LOCATION, getDefaultProjectLocation());
}
// if the prefix/name points to a project that already exists (a common
// pattern if the team leader is creating several projects in
// succession), clear the name.
String nodePath = getTeamNodePathOrErrToken();
if (!nodePath.startsWith("/")) {
putValue(NODE_NAME, (SimpleData) null);
}
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class McfSizeMetricApiHandler method getTargetPrefix.
/**
* Look in the data repository and validate that the targetPath is an
* acceptable place to store size metrics data. If so, find an empty row in
* the Size Inventory Form, and return the complete data repository prefix
* for that empty row.
*/
private String getTargetPrefix(SizeMetricApiRequestData request) {
// make certain a task exists in the hierarchy at the specified path
PropertyKey pathKey = request.ctx.getHierarchy().findExistingKey(request.targetPath);
if (pathKey == null)
return null;
// make certain the task is an Indiv node within a team project
String pathTemplateId = request.ctx.getHierarchy().getID(pathKey);
if (!pathTemplateId.contains("/Indiv"))
return null;
// make certain the task is capable of storing size metrics
if (!hasData(request, "Local_Sized_Object_List//All"))
return null;
// data prefix for the corresponding row
for (int rowNum = 0; true; rowNum++) {
String rowPrefix = SIZED_OBJ_PREFIX + "/" + rowNum;
boolean rowHasData = false;
for (String oneElem : DATA_ELEMS) rowHasData = rowHasData || hasData(request, rowPrefix + "/" + oneElem);
if (!rowHasData)
return request.targetPath + "/" + rowPrefix;
}
}
use of net.sourceforge.processdash.hier.PropertyKey in project processdash by dtuma.
the class TaskStatusApi method getTargetPath.
/** Retrieve the target path from the incoming HTTP request */
private String getTargetPath() {
// use the prefix, if one was supplied in the request
String result = getPrefix();
// selected task
if (!StringUtils.hasValue(result)) {
DashboardContext ctx = getDashboardContext();
DashboardTimeLog tl = (DashboardTimeLog) ctx.getTimeLog();
TimeLoggingModel tlm = tl.getTimeLoggingModel();
result = tlm.getActiveTaskModel().getPath();
}
// verify that the named path exists and is a leaf task
DashHierarchy hier = getPSPProperties();
PropertyKey key = hier.findExistingKey(result);
if (key == null)
throw new WebApiException("no-such-task", 404, "The task '" + result + "' was not found.");
else if (hier.getNumChildren(key) != 0)
throw new WebApiException("not-leaf-task", 400, "The item '" + result + "' is not a leaf task.");
return result;
}
Aggregations