diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index df2ad1fd3c..8f63fde456 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -270,6 +270,7 @@ language=Language export=Export import=Import take_ownership=Take Ownership +return_ownership=Return to Pool create_forums=Create Forum Space create_forum=Create Forum create_topic=Create Topic @@ -1227,6 +1228,7 @@ manage_task_desc=This dialog allows the task to be managed. view_completed_task_title=View Completed Task view_completed_task_desc=This dialog allows the completed task details to be viewed. task_properties=Task Properties +task_pooled_properties=Task Pool id=Id status=Status completed=Completed @@ -1236,6 +1238,8 @@ my_tasks_todo_title=My Tasks To Do my_tasks_todo_desc=List of your tasks still to complete my_tasks_completed_title=My Completed Tasks my_tasks_completed_desc=List of your completed tasks +pooled_tasks_title=My Pooled Tasks +pooled_tasks_desc=List of tasks allocated to your pool due_date=Due Date completed_on=Completed on outcome=Outcome diff --git a/config/alfresco/web-client-config-workflow-actions.xml b/config/alfresco/web-client-config-workflow-actions.xml index 8004e97e49..249b9edbe2 100644 --- a/config/alfresco/web-client-config-workflow-actions.xml +++ b/config/alfresco/web-client-config-workflow-actions.xml @@ -148,6 +148,10 @@ + + + + diff --git a/config/alfresco/web-client-config.xml b/config/alfresco/web-client-config.xml index e0eaf70946..d5ad96782d 100644 --- a/config/alfresco/web-client-config.xml +++ b/config/alfresco/web-client-config.xml @@ -198,6 +198,8 @@ + (this.transitions.length); - - for (WorkflowTransition trans : this.transitions) - { - buttons.add(new DialogButtonConfig(ID_PREFIX + trans.title, trans.title, null, - "#{DialogManager.bean.transition}", "false", null)); - } + buttons = new ArrayList(this.transitions.length + 1); + + if (isPooledTask) + { + if (this.taskNode.getProperties().get(ContentModel.PROP_OWNER) == null) + { + buttons.add(new DialogButtonConfig("button_take_ownership", null, "take_ownership", + "#{DialogManager.bean.takeOwnership}", "false", null)); + } + else + { + buttons.add(new DialogButtonConfig("button_return_to_pool", null, "return_ownership", + "#{DialogManager.bean.returnOwnership}", "false", null)); + } + } + + if (this.transitions != null) + { + for (WorkflowTransition trans : this.transitions) + { + buttons.add(new DialogButtonConfig(ID_PREFIX + trans.title, trans.title, null, + "#{DialogManager.bean.transition}", "false", null)); + } + } } } @@ -246,6 +263,82 @@ public class ManageTaskDialog extends BaseDialogBean // ------------------------------------------------------------------------------ // Event handlers + @SuppressWarnings("unused") + public String takeOwnership() + { + String outcome = getDefaultFinishOutcome(); + + if (LOGGER.isDebugEnabled()) + LOGGER.debug("Taking ownership of task: " + this.task.id); + + FacesContext context = FacesContext.getCurrentInstance(); + UserTransaction tx = null; + + try + { + tx = Repository.getUserTransaction(context); + tx.begin(); + + // prepare the edited parameters for saving + User user = Application.getCurrentUser(context); + String userName = user.getUserName(); + Map params = new HashMap(); + params.put(ContentModel.PROP_OWNER, userName); + + // update the task with the updated parameters + this.workflowService.updateTask(this.task.id, params, null, null); + + // commit the changes + tx.commit(); + } + catch (Throwable e) + { + // rollback the transaction + try { if (tx != null) {tx.rollback();} } catch (Exception ex) {} + Utils.addErrorMessage(formatErrorMessage(e), e); + outcome = this.getErrorOutcome(e); + } + + return outcome; + } + + @SuppressWarnings("unused") + public String returnOwnership() + { + String outcome = getDefaultFinishOutcome(); + + if (LOGGER.isDebugEnabled()) + LOGGER.debug("Returning ownership of task to pool: " + this.task.id); + + FacesContext context = FacesContext.getCurrentInstance(); + UserTransaction tx = null; + + try + { + tx = Repository.getUserTransaction(context); + tx.begin(); + + // prepare the edited parameters for saving + Map params = new HashMap(); + params.put(ContentModel.PROP_OWNER, null); + + // update the task with the updated parameters + this.workflowService.updateTask(this.task.id, params, null, null); + + // commit the changes + tx.commit(); + } + catch (Throwable e) + { + // rollback the transaction + try { if (tx != null) {tx.rollback();} } catch (Exception ex) {} + Utils.addErrorMessage(formatErrorMessage(e), e); + outcome = this.getErrorOutcome(e); + } + + return outcome; + } + @SuppressWarnings("unused") public String transition() { @@ -481,6 +574,17 @@ public class ManageTaskDialog extends BaseDialogBean { return this.taskNode; } + + /** + * Returns whether this is a pooled task + * + * @return true => pooled + */ + public boolean isPooledTask() + { + List pooledActors = (List)taskNode.getAssociations().get(WorkflowModel.ASSOC_POOLED_ACTORS); + return (pooledActors != null && pooledActors.size() > 0); + } /** * Returns the WorkflowInstance that the current task belongs to diff --git a/source/java/org/alfresco/web/bean/workflow/WorkflowBean.java b/source/java/org/alfresco/web/bean/workflow/WorkflowBean.java index ec73ed45de..941d339bdb 100644 --- a/source/java/org/alfresco/web/bean/workflow/WorkflowBean.java +++ b/source/java/org/alfresco/web/bean/workflow/WorkflowBean.java @@ -40,6 +40,7 @@ public class WorkflowBean protected NodeService nodeService; protected WorkflowService workflowService; protected List tasks; + protected List pooledTasks; protected List completedTasks; private static final Log logger = LogFactory.getLog(WorkflowBean.class); @@ -47,6 +48,55 @@ public class WorkflowBean // ------------------------------------------------------------------------------ // Bean Getters and Setters + /** + * Returns a list of nodes representing the "pooled" to do tasks the + * current user has. + * + * @return List of to do tasks + */ + public List getPooledTasks() + { + if (this.pooledTasks == null) + { + // get the current username + FacesContext context = FacesContext.getCurrentInstance(); + User user = Application.getCurrentUser(context); + String userName = user.getUserName(); + + UserTransaction tx = null; + try + { + tx = Repository.getUserTransaction(context, true); + tx.begin(); + + // get the current pooled tasks for the current user + List tasks = this.workflowService.getPooledTasks(userName); + + // create a list of transient nodes to represent + this.pooledTasks = new ArrayList(tasks.size()); + for (WorkflowTask task : tasks) + { + Node node = createTask(task); + this.pooledTasks.add(node); + + if (logger.isDebugEnabled()) + logger.debug("Added pooled task: " + node); + } + + // commit the changes + tx.commit(); + } + catch (Throwable e) + { + // rollback the transaction + try { if (tx != null) {tx.rollback();} } catch (Exception ex) {} + Utils.addErrorMessage("Failed to get pooled tasks: " + e.toString(), e); + } + } + + return this.pooledTasks; + } + /** * Returns a list of nodes representing the to do tasks the * current user has. diff --git a/source/java/org/alfresco/web/ui/repo/component/property/UIAssociationEditor.java b/source/java/org/alfresco/web/ui/repo/component/property/UIAssociationEditor.java index 169a05cb9f..56d819d095 100644 --- a/source/java/org/alfresco/web/ui/repo/component/property/UIAssociationEditor.java +++ b/source/java/org/alfresco/web/ui/repo/component/property/UIAssociationEditor.java @@ -160,6 +160,11 @@ public class UIAssociationEditor extends BaseAssociationEditor { out.write(User.getFullName(nodeService, targetNode)); } + else if (ContentModel.TYPE_AUTHORITY_CONTAINER.equals(nodeService.getType(targetNode))) + { + String groupName = (String)nodeService.getProperty(targetNode, ContentModel.PROP_AUTHORITY_NAME); + out.write(groupName.substring("GROUP_".length())); + } else { out.write(Repository.getDisplayPath(nodeService.getPath(targetNode))); diff --git a/source/web/jsp/workflow/manage-task-dialog.jsp b/source/web/jsp/workflow/manage-task-dialog.jsp index d7e4fac2d5..d8b1def23b 100644 --- a/source/web/jsp/workflow/manage-task-dialog.jsp +++ b/source/web/jsp/workflow/manage-task-dialog.jsp @@ -19,6 +19,18 @@ <%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> <%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> + + + + + + + + + + + diff --git a/source/web/jsp/workflow/pooled-tasks-todo-dashlet.jsp b/source/web/jsp/workflow/pooled-tasks-todo-dashlet.jsp new file mode 100644 index 0000000000..3586bd9d34 --- /dev/null +++ b/source/web/jsp/workflow/pooled-tasks-todo-dashlet.jsp @@ -0,0 +1,95 @@ +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> +<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> + + + + + + <%-- Primary column for details view mode --%> + + + + + + + + + + + + + + + + + <%-- Task type --%> + + + + + + + + <%-- Task id column --%> + + + + + + + + <%-- Created Date column --%> + + + + + + + + + + <%-- Due date column --%> + + + + + + + + + + <%-- Status column --%> + + + + + + + + <%-- Priority column --%> + + + + + + + + <%-- Actions column --%> + + + + + + + + + \ No newline at end of file