<%@ 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" %>
<h:outputText value="#{msg.no_tasks}" rendered="#{empty CustomWorkflowBean.allActiveTasks}" />
<a:richList id="personal-tasks-active-list" viewMode="details" value="#{CustomWorkflowBean.allActiveTasks}" var="r"
styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow"
altRowStyleClass="recordSetRowAlt" width="100%" pageSize="10"
initialSortColumn="created" initialSortDescending="true"
rendered="#{not empty CustomWorkflowBean.allActiveTasks}" refreshOnBind="true">
<%– Primary column for details view mode –%>
<a:column id="col1" primary="true" width="200" style="padding:2px;text-align:left">
<f:facet name="header">
<a:sortLink id="col1-sort" label="#{msg.description}" value="bpm:description" mode="case-insensitive" styleClass="header"/>
</f:facet>
<f:facet name="small-icon">
<a:actionLink id="col1-act1" value="#{r['bpm:description']}" image="/images/icons/workflow_task.gif" showLink="false"
actionListener="#{CustomWorflowBean.setupTaskDialog}" action="dialog:manageTask">
<f:param name="id" value="#{r.id}" />
<f:param name="type" value="#{r.type}" />
</a:actionLink>
</f:facet>
<a:actionLink id="col1-act2" value="#{r['bpm:description']}" actionListener="#{CustomWorflowBean.setupTaskDialog}"
action="dialog:manageTask">
<f:param name="id" value="#{r.id}" />
<f:param name="type" value="#{r.type}" />
</a:actionLink>
</a:column>
<%– Task type –%>
<a:column id="col2" style="padding:2px;text-align:left">
<f:facet name="header">
<a:sortLink id="col2-sort" label="#{msg.type}" value="name" mode="case-insensitive" styleClass="header"/>
</f:facet>
<h:outputText id="col2-txt" value="#{r.name}" />
</a:column>
<%– Task owner column –%>
<a:column id="col2a" style="padding:2px;text-align:left">
<f:facet name="header">
<a:sortLink id="col2a-sort" label="#{msg.owner}" value="cm:owner" styleClass="header"/>
</f:facet>
<h:outputText id="col2a-txt" value="#{r['cm:owner']}" />
</a:column>
<%– Task id column –%>
<a:column id="col3" style="padding:2px;text-align:left">
<f:facet name="header">
<a:sortLink id="col3-sort" label="#{msg.id}" value="bpm:taskId" styleClass="header"/>
</f:facet>
<h:outputText id="col3-txt" value="#{r['bpm:taskId']}" />
</a:column>
<%– Created Date column –%>
<a:column id="col4" style="padding:2px;text-align:left">
<f:facet name="header">
<a:sortLink id="col4-sort" label="#{msg.created}" value="created" styleClass="header"/>
</f:facet>
<h:outputText id="col4-txt" value="#{r.created}">
<a:convertXMLDate type="both" pattern="#{msg.date_time_pattern}" />
</h:outputText>
</a:column>
<%– Due date column –%>
<a:column id="col5" style="padding:2px;text-align:left">
<f:facet name="header">
<a:sortLink id="col5-sort" label="#{msg.due_date}" value="bpm:dueDate" styleClass="header"/>
</f:facet>
<h:outputText id="col5-txt" value="#{r['bpm:dueDate']}">
<a:convertXMLDate type="both" pattern="#{msg.date_pattern}" />
</h:outputText>
</a:column>
<%– Status column –%>
<a:column id="col6" style="padding:2px;text-align:left">
<f:facet name="header">
<a:sortLink id="col6-sort" label="#{msg.status}" value="bpm:status" styleClass="header"/>
</f:facet>
<h:outputText id="col6-txt" value="#{r['bpm:status']}" />
</a:column>
<%– Priority column –%>
<a:column id="col7" style="padding:2px;text-align:left">
<f:facet name="header">
<a:sortLink id="col7-sort" label="#{msg.priority}" value="bpm:priority" styleClass="header"/>
</f:facet>
<h:outputText id="col7-txt" value="#{r['bpm:priority']}" />
</a:column>
<%– Actions column –%>
<a:column id="col8" actions="true" style="padding:2px;text-align:left">
<f:facet name="header">
<h:outputText id="col8-txt" value="#{msg.actions}"/>
</f:facet>
<r:actions id="col8-actions" value="dashlet_todo_actions" context="#{r}" showLink="false"
styleClass="inlineAction" />
</a:column>
<a:dataPager styleClass="pager" />
</a:richList>
package lpr.alfresco.web.bean.workflow;
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.service.cmr.workflow.WorkflowTaskDefinition;
import org.alfresco.service.cmr.workflow.WorkflowTaskQuery;
import org.alfresco.service.cmr.workflow.WorkflowTaskState;
import org.alfresco.service.cmr.workflow.WorkflowTransition;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.TransientMapNode;
import org.alfresco.web.bean.repository.TransientNode;
import org.alfresco.web.bean.repository.User;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIActionLink;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Managed bean used for providing support for the workflow task dashlets
*
* @author gavinc
*/
public class CustomWorkflowBean
{
protected NavigationBean navigationBean;
protected NodeService nodeService;
protected WorkflowService workflowService;
protected List<Node> tasks;
protected List<Node> activeTasks;
protected List<Node> pooledTasks;
protected List<Node> completedTasks;
private static final Log logger = LogFactory.getLog(CustomWorkflowBean.class);
public static final String BEAN_NAME = "CustomWorkflowBean";
// ——————————————————————————
// Bean Getters and Setters
/**
* Returns a list of nodes representing the "all" active tasks.
*
* @return List of all active tasks
*/
public List<Node> getAllActiveTasks()
{
if (this.activeTasks == 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();
// query for all active tasks
WorkflowTaskQuery query = new WorkflowTaskQuery();
List<WorkflowTask> tasks = this.workflowService.queryTasks(query);
// create a list of transient nodes to represent
this.activeTasks = new ArrayList<Node>(tasks.size());
for (WorkflowTask task : tasks)
{
Node node = createTask(task);
this.activeTasks.add(node);
if (logger.isDebugEnabled())
logger.debug("Added active 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 all active tasks: " + e.toString(), e);
}
}
return this.activeTasks;
}
/**
* Returns a list of nodes representing the "pooled" to do tasks the
* current user has.
*
* @return List of to do tasks
*/
public List<Node> 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<WorkflowTask> tasks = this.workflowService.getPooledTasks(userName);
// create a list of transient nodes to represent
this.pooledTasks = new ArrayList<Node>(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.
*
* @return List of to do tasks
*/
public List<Node> getTasksToDo()
{
if (this.tasks == 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 in progress tasks for the current user
List<WorkflowTask> tasks = this.workflowService.getAssignedTasks(
userName, WorkflowTaskState.IN_PROGRESS);
// create a list of transient nodes to represent
this.tasks = new ArrayList<Node>(tasks.size());
for (WorkflowTask task : tasks)
{
Node node = createTask(task);
this.tasks.add(node);
if (logger.isDebugEnabled())
logger.debug("Added to do 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 to do tasks: " + e.toString(), e);
}
}
return this.tasks;
}
/**
* Returns a list of nodes representing the completed tasks the
* current user has.
*
* @return List of completed tasks
*/
public List<Node> getTasksCompleted()
{
if (this.completedTasks == 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 in progress tasks for the current user
List<WorkflowTask> tasks = this.workflowService.getAssignedTasks(
userName, WorkflowTaskState.COMPLETED);
// create a list of transient nodes to represent
this.completedTasks = new ArrayList<Node>(tasks.size());
for (WorkflowTask task : tasks)
{
Node node = createTask(task);
this.completedTasks.add(node);
if (logger.isDebugEnabled())
logger.debug("Added completed 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 completed tasks: " + e.toString(), e);
}
}
return this.completedTasks;
}
/**
* Sets the navigation bean to use
*
* @param navigationBean The NavigationBean to set.
*/
public void setNavigationBean(NavigationBean navigationBean)
{
this.navigationBean = navigationBean;
}
/**
* Sets the workflow service to use
*
* @param workflowService WorkflowService instance
*/
public void setWorkflowService(WorkflowService workflowService)
{
this.workflowService = workflowService;
}
/**
* Sets the node service to use
*
* @param nodeService NodeService instance
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
// ——————————————————————————
// Navigation handlers
public void setupTaskDialog(ActionEvent event)
{
UIActionLink link = (UIActionLink)event.getComponent();
Map<String, String> params = link.getParameterMap();
String id = params.get("id");
String type = params.get("type");
// setup the dispatch context with the task we're opening a dialog for
TransientNode node = new TransientNode(QName.createQName(type), id, null);
this.navigationBean.setupDispatchContext(node);
// pass on parameters for the dialog
Application.getDialogManager().setupParameters(event);
}
public void setupTaskDialog(String id, String type)
{
ParameterCheck.mandatoryString("Task ID", id);
ParameterCheck.mandatoryString("Task Type", type);
// setup the dispatch context with the task we're opening a dialog for
TransientNode node = new TransientNode(QName.createQName(type), id, null);
this.navigationBean.setupDispatchContext(node);
// pass on parameters for the dialog
Map<String, String> params = new HashMap<String, String>(2, 1.0f);
params.put("id", id);
params.put("type", type);
Application.getDialogManager().setupParameters(params);
}
// ——————————————————————————
// Helper methods
/**
* Creates and populates a TransientNode to represent the given
* workflow task from the repository workflow engine
*
* @param task The task to create a representation of
*/
protected TransientMapNode createTask(WorkflowTask task)
{
// get the type of the task
WorkflowTaskDefinition taskDef = task.definition;
// create the basic transient node
TransientMapNode node = new TransientMapNode(taskDef.metadata.getName(),
task.title, task.properties);
// add properties for the other useful metadata
node.getProperties().put(ContentModel.PROP_NAME.toString(), task.title);
node.getProperties().put("type", node.getType().toString());
node.getProperties().put("id", task.id);
// add extra properties for completed tasks
if (task.state.equals(WorkflowTaskState.COMPLETED))
{
// add the outcome label for any completed task
String outcome = null;
String transition = (String)task.properties.get(WorkflowModel.PROP_OUTCOME);
if (transition != null)
{
WorkflowTransition[] transitions = task.definition.node.transitions;
for (WorkflowTransition trans : transitions)
{
if (trans.id.equals(transition))
{
outcome = trans.title;
break;
}
}
if (outcome != null)
{
node.getProperties().put("outcome", outcome);
}
}
// add the workflow instance id and name this taks belongs to
node.getProperties().put("workflowInstanceId", task.path.instance.id);
// add the task itself as a property
node.getProperties().put("workflowTask", task);
}
return node;
}
}
<managed-bean>
<managed-bean-name>CustomWorkflowBean</managed-bean-name>
<managed-bean-class>lpr.alfresco.web.bean.workflow.CustomWorkflowBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>navigationBean</property-name>
<value>#{NavigationBean}</value>
</managed-property>
<managed-property>
<property-name>nodeService</property-name>
<value>#{NodeService}</value>
</managed-property>
<managed-property>
<property-name>workflowService</property-name>
<value>#{WorkflowService}</value>
</managed-property>
</managed-bean>
log4j.logger.lpr.alfresco.web.bean.workflow=info
log4j.logger.lpr.alfresco.web.bean.workflow.CustomWorkflowBean=info
log4j.logger.lpr.alfresco.web.bean.workflow.CustomWorkflowBean=debug
<!– test –>
<action id="manage_task">
<label-id>manage_task</label-id>
<image>/images/icons/manage_workflow_task.gif</image>
<action>dialog:manageTask</action>
<action-listener>#{CustomWorkflowBean.setupTaskDialog}</action-listener>
<params>
<param name="id">#{actionContext.id}</param>
<param name="type">#{actionContext.type}</param>
</params>
</action>
<action id="view_completed_task">
<label-id>view_completed_task_title</label-id>
<image>/images/icons/view_workflow_task.gif</image>
<action>dialog:viewCompletedTask</action>
<action-listener>#{CustomWorkflowBean.setupTaskDialog}</action-listener>
<params>
<param name="id">#{actionContext.id}</param>
<param name="type">#{actionContext.type}</param>
</params>
</action>
<action id="reassign_task">
<label-id>reassign</label-id>
<image>/images/icons/reassign_task.gif</image>
<action>dialog:reassignTask</action>
<action-listener>#{CustomWorkflowBean.setupTaskDialog}</action-listener>
<params>
<param name="id">#{actionContext.id}</param>
<param name="type">#{actionContext.type}</param>
</params>
</action>
<!– fin du test –>
<managed-bean-name>WorkflowBean</managed-bean-name>
<managed-bean-class>lpr.alfresco.web.bean.workflow.WorkflowBean</managed-bean-class>
Je ne comprends toujours pas la différence avec le dashlet "mes tâches à réaliser".
Pourrais-tu expliquer la différence entre les deux, car j'avoue que "Les tâches actives sont déjà en cours. Donc elles ont déjà débutées" n'apporte que peu d'éclairage :
il y a en effet peu de chances que "mes tâches à réaliser" affiche des workflows qui n'ont pas encore commencé… et qui donc n'existent pas !
"Je m'explique, un initiateur initialise un workflow avec une série d'acteur. Le process de workflow crée autant de tâches que d'acteurs demandé, ce qui est normal pour le moment."
"Mon problème est le suivant : n'importe quel utilisateurs d'Alfresco peut voir la liste des tâches actives, et même les gérer si le coeur lui en dit. Comment peut-on y remédier pour interdire quiconque de gérer les tâches qui ne le concerne pas ?
Serait-il éventuellemnt possible de masquer les tâches attribuées aux utilisateurs qui n'ont aucune interraction avec ces tâches ?"
je crois que ton besoin n'est pas évident pour nous.
Je ne comprends pas, même en lisant attentivement ton message sur l'autre topic :"Je m'explique, un initiateur initialise un workflow avec une série d'acteur. Le process de workflow crée autant de tâches que d'acteurs demandé, ce qui est normal pour le moment."
Sont-ce des tâches en parallèle (fork) ?
A vrai dire, il n'est pas évident de saisir la "topologie" de ce debut de workflow."Mon problème est le suivant : n'importe quel utilisateurs d'Alfresco peut voir la liste des tâches actives, et même les gérer si le cœur lui en dit. Comment peut-on y remédier pour interdire quiconque de gérer les tâches qui ne le concerne pas ?
Serait-il éventuellement possible de masquer les tâches attribuées aux utilisateurs qui n'ont aucune interaction avec ces tâches ?"
Là je ne comprends plus du tout.
Si tu évoques le webscript "toutes les tâches actives", en effet celui-ci n'est pas "secure", c'est d'ailleurs pour cela qu'il est désactivé par défaut.
Si tu parles de "mes tâches à réaliser", je ne comprends rien. Un utilisateur n'y verra que les tâches dont il est propriétaire … ce qui semble répondre à ton besoin !!!.
<!–dashlet id="tasks-active" label-id="tasks_active_title" description-id="tasks_active_desc"
jsp="/jsp/workflow/tasks-active-dashlet.jsp" allow-narrow="false" /–>
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.