As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
I would like to customize the My task dashlet to display also the task that has been initiated or contributed by the user
public class WorkflowCustom extends Workflow { private ServiceRegistry services; /** * Sets the service registry * * @param services * the service registry */ @Override public void setServiceRegistry(ServiceRegistry services) { this.services = services; super.setServiceRegistry(this.services); } private WorkflowService getWorkflowService() { return this.services.getWorkflowService(); } /** * Convert a list of WorkflowTask items into bean objects accessable from * templates * * @param tasks * List of WorkflowTask objects to convert * * @return List of WorkflowTaskItem bean wrapper objects */ private List<WorkflowTaskItem> convertTasks(List<WorkflowTask> tasks) { List<WorkflowTaskItem> items = new ArrayList<WorkflowTaskItem>(tasks .size()); for (WorkflowTask task : tasks) { items.add(new WorkflowTaskItem(this.services, getTemplateImageResolver(), task)); } return items; } /** * Return a list of objects representing the tasks initialized by the * current user * * @return list of WorkflowTaskItem bean objects {@link WorkflowTaskItem} */ public List<WorkflowTaskItem> getInitializedTasks() { // get the initialized tasks by the current user List<WorkflowTask> 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(); // query for all active tasks WorkflowTaskQuery query = new WorkflowTaskQuery(); tasks = this.getWorkflowService().queryTasks(query); // 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 tasks initialized by the user: " + e.toString(), e); } List<WorkflowTaskItem> allTaskItems = convertTasks(tasks); List<WorkflowTaskItem> initializedTaskItems = new ArrayList<WorkflowTaskItem>( allTaskItems.size()); for (WorkflowTaskItem taskItem : allTaskItems) { if (taskItem.getInitiator().getNodeRef().equals(user.getPerson())) { initializedTaskItems.add(taskItem); } } Collections.reverse(initializedTaskItems); return initializedTaskItems; } /** * Return a list of objects representing the assigned tasks for the current * user * * @return list of WorkflowTaskItem bean objects {@link WorkflowTaskItem} */ @Override public List<WorkflowTaskItem> getAssignedTasks() { // get the "in progress" tasks for the current user List<WorkflowTaskItem> assignedTasks = super.getAssignedTasks(); Collections.reverse(assignedTasks); return assignedTasks; } /** * Return a list of objects representing the pooled tasks for the current * user * * @return list of WorkflowTaskItem bean objects {@link WorkflowTaskItem} */ @Override public List<WorkflowTaskItem> getPooledTasks() { // get the "pooled" tasks for the current user List<WorkflowTaskItem> pooledTasks = super.getPooledTasks(); Collections.reverse(pooledTasks); return pooledTasks; } /** * Returns owner first name * * @param owner * @return */ public String getTaskOwnerFirstName(String owner) { return UserUtilsGP.getUserFirstName(owner); } /** * Returns owners last name * * @param owner * @return */ public String getTaskOwnerLastName(String owner) { return UserUtilsGP.getUserLastName(owner); } /** * Returns pooled task group display name * * @param taskId * @return */ public String getTaskPooledActorsGroup(String taskId) { NodeRef group = WorkflowUtilsGP.getPooledActorsGroup(taskId); String displayName = ""; if (group != null) { displayName = UserUtilsGP.getGroupDisplayName(group); } return displayName; } }
<bean id="workflowTemplateExtension" parent="baseTemplateImplementation" class="org.alfresco.web.repo.template.WorkflowCustom"> <property name="extensionName"> <value>workflow</value> </property> <property name="serviceRegistry"> <ref bean="ServiceRegistry"/> </property> </bean>
<li <#if filter=6>class="taskCurrent"</#if>><a href="#" onclick="MyTasks.filter(6); return false;"><span id="todoInitializedHeader" >My initialized tasks</span></a></li>