use of net.sourceforge.processdash.ui.lib.autocomplete.AssignedToEditList.Change in project processdash by dtuma.
the class TeamTimeColumn method changeInitials.
public static void changeInitials(WBSModel wbsModel, Map<String, String> initialsToChange) {
AssignedToEditList initialsChanges = new AssignedToEditList();
for (Entry<String, String> e : initialsToChange.entrySet()) {
Change change = new Change();
change.origInitials = e.getKey();
change.newInitials = e.getValue();
initialsChanges.add(change);
}
updateRoleAssignments(initialsChanges, wbsModel.getRoot());
for (WBSNode node : wbsModel.getDescendants(wbsModel.getRoot())) updateRoleAssignments(initialsChanges, node);
}
use of net.sourceforge.processdash.ui.lib.autocomplete.AssignedToEditList.Change in project processdash by dtuma.
the class TeamTimeColumn method applyWorkflowRoleEdits.
private void applyWorkflowRoleEdits(AssignedToEditList edits, WBSNode node) {
// scan the list of edits, looking for role-related changes.
for (Iterator i = edits.iterator(); i.hasNext(); ) {
Change change = (Change) i.next();
String origInitials = change.origInitials;
boolean isRoleAssignment = false;
if (origInitials != null && origInitials.startsWith(ROLE_BEG)) {
if (change.isDelete()) {
deleteRole(node, origInitials);
} else if (change.isInitialsChange()) {
isRoleAssignment = true;
deleteRole(node, origInitials);
}
}
if (!isRoleAssignment)
i.remove();
}
// no role assignments were found, we're done.
if (edits.isEmpty())
return;
// find the parent node which bounds this workflow instantiation.
while (true) {
WBSNode parent = wbsModel.getParent(node);
if (parent == null || parent.getAttribute(WorkflowModel.WORKFLOW_SOURCE_IDS_ATTR) == null)
break;
else
node = parent;
}
// store these new role assignments on the parent node
storeRoleAssignments(edits, node);
// tell the decendants of that parent to apply these role assignments.
for (WBSNode child : wbsModel.getDescendants(node)) {
LeafTaskData leafTaskData = getLeafTaskData(child);
if (leafTaskData != null)
leafTaskData.applyWorkflowRoleAssignments(edits);
}
}
use of net.sourceforge.processdash.ui.lib.autocomplete.AssignedToEditList.Change in project processdash by dtuma.
the class TeamTimeColumn method storeRoleAssignments.
private void storeRoleAssignments(AssignedToEditList newRoleAssignments, WBSNode node) {
String knownRoles = (String) node.getAttribute(KNOWN_ROLES_ATTR);
for (Change change : newRoleAssignments) {
// add this role name to the list of roles that are known to be
// stored on this node
String roleName = change.origInitials;
if (knownRoles == null)
knownRoles = roleName;
else if (!knownRoles.contains(roleName))
knownRoles = knownRoles + "," + roleName;
// store the actual role assignment in a separate attribute.
node.setAttribute(ROLE_ASSIGNMENT_PREFIX + roleName, change.newInitials);
}
node.setAttribute(KNOWN_ROLES_ATTR, knownRoles);
}
use of net.sourceforge.processdash.ui.lib.autocomplete.AssignedToEditList.Change in project processdash by dtuma.
the class TeamTimeColumn method updateRoleAssignments.
private static void updateRoleAssignments(AssignedToEditList edits, WBSNode node) {
String knownRoles = (String) node.getAttribute(KNOWN_ROLES_ATTR);
if (knownRoles == null)
return;
// iterate over each role that is known to be stored on this node
for (String roleName : knownRoles.split(",")) {
// retrieve the person who used to be assigned to this role.
String attrName = ROLE_ASSIGNMENT_PREFIX + roleName;
String oldAssignment = (String) node.getAttribute(attrName);
if (oldAssignment != null) {
// update the role assignment accordingly.
for (Change change : edits) {
if (oldAssignment.equalsIgnoreCase(change.origInitials)) {
node.setAttribute(attrName, change.newInitials);
break;
}
}
}
}
}
Aggregations