mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Checkpoint for workflow features
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3518 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -919,7 +919,12 @@ start_workflow_no_metadata=There is no metadata to collect for this particular w
|
||||
users_and_roles=Users and their Roles
|
||||
manage_workitem=Manage WorkItem
|
||||
manage_workitem_title=Manage WorkItem
|
||||
manage_workitem_desc=This dialog allows the workitem to be managed
|
||||
manage_workitem_desc=This dialog allows the work item to be managed
|
||||
id=Id
|
||||
status=Status
|
||||
my_workitems_todo_title=My Work Items To Do
|
||||
my_workitems_todo_desc=List of your workflow items still to complete
|
||||
due_date=Due Date
|
||||
reassign=Reassign
|
||||
|
||||
# Admin Console messages
|
||||
|
@@ -38,21 +38,6 @@
|
||||
icon="/images/icons/delete_large.gif" title-id="delete_file"
|
||||
description-id="delete_file_info" />
|
||||
|
||||
<!-- -->
|
||||
<!-- Workflow Dialogs -->
|
||||
|
||||
<dialog name="manageWorkItem" page="/jsp/workflow/manage-workitem.jsp"
|
||||
managed-bean="ManageWorkItemDialog" icon="/images/icons/create_space_large.gif"
|
||||
title-id="manage_workitem_title" description-id="manage_workitem_desc"
|
||||
actions-config-id="workitem_actions" show-ok-button="false">
|
||||
<buttons>
|
||||
<button id="approve-button" label="Approve" action="#{ManageWorkItemDialog.approve}"
|
||||
disabled="#{DialogManager.bean.approveDisabled}" onclick="alert('approve onclick')" />
|
||||
<button label-id="reject_flow" action="#{ManageWorkItemDialog.reject}"
|
||||
onclick="alert('reject onclick')" disabled="false" />
|
||||
</buttons>
|
||||
</dialog>
|
||||
|
||||
<!-- -->
|
||||
<!-- Forums Dialogs -->
|
||||
|
||||
|
@@ -182,31 +182,6 @@
|
||||
</step>
|
||||
</wizard>
|
||||
|
||||
<wizard name="startWorkflow" managed-bean="StartWorkflowWizard"
|
||||
title-id="start_workflow_wizard" description-id="start_workflow_desc"
|
||||
icon="/images/icons/users_large.gif">
|
||||
<step name="choose-workflow" title-id="step_choose_workflow"
|
||||
description-id="start_workflow_choose_desc">
|
||||
<page path="/jsp/workflow/start-workflow-wizard/choose-workflow.jsp"
|
||||
title-id="start_workflow_choose_title"
|
||||
description-id="start_workflow_choose_desc"
|
||||
instruction-id="default_instruction" />
|
||||
</step>
|
||||
<step name="options" title-id="step_workflow_options"
|
||||
description-id="start_workflow_options_desc">
|
||||
<page path="/jsp/workflow/start-workflow-wizard/workflow-options.jsp"
|
||||
title-id="start_workflow_options_title"
|
||||
description-id="start_workflow_options_desc"
|
||||
instruction-id="default_instruction" />
|
||||
</step>
|
||||
<step name="summary" title-id="summary" description-id="summary_step_description">
|
||||
<page path="/jsp/wizard/summary.jsp"
|
||||
title-id="summary"
|
||||
description-id="summary_desc"
|
||||
instruction-id="start_workflow_finish_instruction" />
|
||||
</step>
|
||||
</wizard>
|
||||
|
||||
</wizards>
|
||||
</config>
|
||||
|
||||
|
@@ -4,6 +4,18 @@
|
||||
<!-- Properties -->
|
||||
<!-- -->
|
||||
|
||||
<config evaluator="node-type" condition="bpm:workflowTask">
|
||||
<property-sheet>
|
||||
<separator name="sep1" display-label-id="general" component-generator="HeaderSeparatorGenerator" />
|
||||
<show-property name="bpm:taskId" ignore-if-missing="false" read-only="true" />
|
||||
<show-property name="bpm:dueDate" ignore-if-missing="false" />
|
||||
<!-- Need to show a text field not a drop down even though there are constraints!
|
||||
<show-property name="bpm:status" ignore-if-missing="false" /> -->
|
||||
<!-- Need to make sure that we can handle int/long based constraints!
|
||||
<show-property name="bpm:priority" ignore-if-missing="false" /> -->
|
||||
</property-sheet>
|
||||
</config>
|
||||
|
||||
<config evaluator="node-type" condition="wf:submitReviewTask">
|
||||
<property-sheet>
|
||||
<separator name="sep1" display-label-id="general" component-generator="HeaderSeparatorGenerator" />
|
||||
@@ -29,12 +41,66 @@
|
||||
</params>
|
||||
</action>
|
||||
|
||||
<!--
|
||||
<action id="reassign-workflow">
|
||||
<label-id>reassign</label-id>
|
||||
<image>/images/icons/create_forum.gif</image>
|
||||
<action>null</action>
|
||||
</action>
|
||||
|
||||
<action-group id="document_browse_menu">
|
||||
<action idref="start-workflow" />
|
||||
</action-group>
|
||||
-->
|
||||
|
||||
<action-group id="workitem_actions">
|
||||
<action idref="reassign-workflow" />
|
||||
</action-group>
|
||||
</actions>
|
||||
</config>
|
||||
|
||||
<!-- -->
|
||||
<!-- Wizards -->
|
||||
<!-- -->
|
||||
|
||||
<config>
|
||||
<wizards>
|
||||
<wizard name="startWorkflow" managed-bean="StartWorkflowWizard"
|
||||
title-id="start_workflow_wizard" description-id="start_workflow_desc"
|
||||
icon="/images/icons/users_large.gif">
|
||||
<step name="choose-workflow" title-id="step_choose_workflow"
|
||||
description-id="start_workflow_choose_desc">
|
||||
<page path="/jsp/workflow/start-workflow-wizard/choose-workflow.jsp"
|
||||
title-id="start_workflow_choose_title"
|
||||
description-id="start_workflow_choose_desc"
|
||||
instruction-id="default_instruction" />
|
||||
</step>
|
||||
<step name="options" title-id="step_workflow_options"
|
||||
description-id="start_workflow_options_desc">
|
||||
<page path="/jsp/workflow/start-workflow-wizard/workflow-options.jsp"
|
||||
title-id="start_workflow_options_title"
|
||||
description-id="start_workflow_options_desc"
|
||||
instruction-id="default_instruction" />
|
||||
</step>
|
||||
<step name="summary" title-id="summary" description-id="summary_step_description">
|
||||
<page path="/jsp/wizard/summary.jsp"
|
||||
title-id="summary"
|
||||
description-id="summary_desc"
|
||||
instruction-id="start_workflow_finish_instruction" />
|
||||
</step>
|
||||
</wizard>
|
||||
</wizards>
|
||||
</config>
|
||||
|
||||
<!-- -->
|
||||
<!-- Dialogs -->
|
||||
<!-- -->
|
||||
|
||||
<config>
|
||||
<dialogs>
|
||||
<dialog name="manageWorkItem" page="/jsp/workflow/manage-workitem-dialog.jsp"
|
||||
managed-bean="ManageWorkItemDialog" icon="/images/icons/create_space_large.gif"
|
||||
title-id="manage_workitem_title" description-id="manage_workitem_desc"
|
||||
actions-config-id="workitem_actions" />
|
||||
</dialogs>
|
||||
</config>
|
||||
|
||||
</alfresco-config>
|
||||
|
@@ -188,14 +188,14 @@
|
||||
<dashlet id="getting-started" label-id="dashlet_gettingstarted_label"
|
||||
description-id="dashlet_gettingstarted_desc"
|
||||
jsp="/jsp/dashboards/dashlets/getting-started.jsp" allow-narrow="false" />
|
||||
<dashlet id="workitems-todo" label-id="my_workitems_todo_title" description-id="my_workitems_todo_desc"
|
||||
jsp="/jsp/workflow/workitems-todo-dashlet.jsp" allow-narrow="false" />
|
||||
<!-- TEMP! -->
|
||||
<dashlet id="process-list" label="Workflows" description="List of workflows you may start"
|
||||
jsp="/jbpm/process_list.jsp" allow-narrow="true" />
|
||||
<dashlet id="my-docs-template" label="My Documents"
|
||||
description="My Documents Template Page"
|
||||
jsp="/jsp/dashboards/dashlets/my-docs.jsp" allow-narrow="true" />
|
||||
<dashlet id="task-list" label="My Tasklist To-do" description="List of your tasks still to complete"
|
||||
jsp="/jbpm/task_list.jsp" allow-narrow="true" />
|
||||
<dashlet id="process-list" label="Workflows" description="List of workflows you may start"
|
||||
jsp="/jbpm/process_list.jsp" allow-narrow="true" />
|
||||
<dashlet id="task-list-complete" label="My Tasks Completed" description="List of your completed tasks"
|
||||
jsp="/jsp/dashboards/dashlets/tasklist-completed.jsp" allow-narrow="false" />
|
||||
<dashlet id="content-checkedout" label="My Checkedout Content" description="List of the content checked out to you"
|
||||
|
@@ -0,0 +1,149 @@
|
||||
package org.alfresco.web.bean.repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Represents a transient node i.e. it is not and will not be present in the repository.
|
||||
* <p>
|
||||
* This type of node is typically used to drive rich lists where the Map implementation
|
||||
* is required for sorting columns.
|
||||
* </p>
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class TransientMapNode extends TransientNode implements Map<String, Object>
|
||||
{
|
||||
private static final long serialVersionUID = 1120307465342597322L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* <p>
|
||||
* NOTE: The name is NOT automatically added to the map of properties,
|
||||
* if you need the name of this node to be in the map then add it to
|
||||
* the map passed in to this constructor.
|
||||
* </p>
|
||||
*
|
||||
* @param type The type this node will represent
|
||||
* @param name The name of the node
|
||||
* @param data The properties and associations this node will have
|
||||
*/
|
||||
public TransientMapNode(QName type, String name, Map<QName, Serializable> data)
|
||||
{
|
||||
super(type, name, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Transient map node of type: " + getType() +
|
||||
"\nProperties: " + this.getProperties().toString();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Map implementation - allows the Node bean to be accessed using JSF expression syntax
|
||||
|
||||
/**
|
||||
* @see java.util.Map#clear()
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
getProperties().clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#containsKey(java.lang.Object)
|
||||
*/
|
||||
public boolean containsKey(Object key)
|
||||
{
|
||||
return getProperties().containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#containsValue(java.lang.Object)
|
||||
*/
|
||||
public boolean containsValue(Object value)
|
||||
{
|
||||
return getProperties().containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#entrySet()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Set entrySet()
|
||||
{
|
||||
return getProperties().entrySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#get(java.lang.Object)
|
||||
*/
|
||||
public Object get(Object key)
|
||||
{
|
||||
return getProperties().get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#isEmpty()
|
||||
*/
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return getProperties().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#keySet()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Set keySet()
|
||||
{
|
||||
return getProperties().keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#put(K, V)
|
||||
*/
|
||||
public Object put(String key, Object value)
|
||||
{
|
||||
return getProperties().put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#putAll(java.util.Map)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void putAll(Map t)
|
||||
{
|
||||
getProperties().putAll(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#remove(java.lang.Object)
|
||||
*/
|
||||
public Object remove(Object key)
|
||||
{
|
||||
return getProperties().remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#size()
|
||||
*/
|
||||
public int size()
|
||||
{
|
||||
return getProperties().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#values()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection values()
|
||||
{
|
||||
return getProperties().values();
|
||||
}
|
||||
}
|
@@ -20,6 +20,7 @@ import org.alfresco.util.GUID;
|
||||
* This type of node is typically used to drive the property sheet when data collection
|
||||
* is required for a type but the node does not need to be stored in the repository. An
|
||||
* example use is the workflow, transient nodes are used to collect workitem metadata.
|
||||
* </p>
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
@@ -33,6 +34,7 @@ public class TransientNode extends Node
|
||||
* NOTE: The name is NOT automatically added to the map of properties,
|
||||
* if you need the name of this node to be in the map then add it to
|
||||
* the map passed in to this constructor.
|
||||
* </p>
|
||||
*
|
||||
* @param type The type this node will represent
|
||||
* @param name The name of the node
|
||||
|
@@ -1,12 +1,24 @@
|
||||
package org.alfresco.web.bean.workflow;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
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.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.repository.TransientNode;
|
||||
import org.alfresco.web.config.DialogsConfigElement.DialogButtonConfig;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -17,51 +29,186 @@ import org.apache.commons.logging.LogFactory;
|
||||
*/
|
||||
public class ManageWorkItemDialog extends BaseDialogBean
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(ManageWorkItemDialog.class);
|
||||
protected WorkflowService workflowService;
|
||||
protected Node workItemNode;
|
||||
protected WorkflowTask workItem;
|
||||
protected String[] transitions;
|
||||
|
||||
protected static final String ID_PREFIX = "transition_";
|
||||
protected static final String CLIENT_ID_PREFIX = "dialog:" + ID_PREFIX;
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ManageWorkItemDialog.class);
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
String taskId = this.parameters.get("id");
|
||||
this.workItem = this.workflowService.getTaskById(taskId);
|
||||
|
||||
if (this.workItem != null)
|
||||
{
|
||||
// setup a transient node to represent the work item we're managing
|
||||
WorkflowTaskDefinition taskDef = this.workItem.definition;
|
||||
this.workItemNode = new TransientNode(taskDef.metadata.getName(),
|
||||
"task_" + System.currentTimeMillis(), this.workItem.properties);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Created node for work item: " + this.workItemNode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
return null;
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Saving work item with params: " + this.workItemNode.getProperties());
|
||||
|
||||
// prepare the edited parameters for saving
|
||||
Map<QName, Serializable> params = WorkflowBean.prepareWorkItemParams(this.workItemNode);
|
||||
|
||||
// update the task with the updated parameters
|
||||
this.workflowService.updateTask(this.workItem.id, params, null, null);
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DialogButtonConfig> getAdditionalButtons()
|
||||
{
|
||||
List<DialogButtonConfig> buttons = new ArrayList<DialogButtonConfig>(1);
|
||||
buttons.add(new DialogButtonConfig("reassign-button",
|
||||
"Reassign", null, "#{ManageWorkItemDialog.reassign}", "false", null));
|
||||
List<DialogButtonConfig> buttons = null;
|
||||
|
||||
if (this.workItem != null)
|
||||
{
|
||||
// get the transitions available from this work item and
|
||||
// show them in the dialog as additional buttons
|
||||
this.transitions = this.workItem.path.node.transitions;
|
||||
|
||||
if (this.transitions != null)
|
||||
{
|
||||
buttons = new ArrayList<DialogButtonConfig>(this.transitions.length);
|
||||
|
||||
for (String trans : this.transitions)
|
||||
{
|
||||
// TODO: Tidy this up when the service returns the list of labels
|
||||
String label = trans;
|
||||
if (label.length() == 0)
|
||||
{
|
||||
label = "Done";
|
||||
}
|
||||
|
||||
buttons.add(new DialogButtonConfig(ID_PREFIX + trans, label, null,
|
||||
"#{DialogManager.bean.transition}", "false", null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return buttons;
|
||||
return buttons;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), "save");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Event handlers
|
||||
|
||||
public void approve()
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String transition()
|
||||
{
|
||||
logger.info("approve button was pressed");
|
||||
}
|
||||
|
||||
public void reject()
|
||||
{
|
||||
logger.info("reject button was pressed");
|
||||
}
|
||||
|
||||
public void reassign()
|
||||
{
|
||||
logger.info("reassign button was pressed");
|
||||
String outcome = getDefaultFinishOutcome();
|
||||
|
||||
// to find out which transition button was pressed we need
|
||||
// to look for the button's id in the request parameters,
|
||||
// the first non-null result is the button that was pressed.
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
Map reqParams = context.getExternalContext().getRequestParameterMap();
|
||||
|
||||
String selectedTransition = null;
|
||||
for (String trans : this.transitions)
|
||||
{
|
||||
Object result = reqParams.get(CLIENT_ID_PREFIX + trans);
|
||||
if (result != null)
|
||||
{
|
||||
// this was the button that was pressed
|
||||
selectedTransition = trans;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedTransition != null)
|
||||
{
|
||||
UserTransaction tx = null;
|
||||
|
||||
try
|
||||
{
|
||||
tx = Repository.getUserTransaction(context);
|
||||
tx.begin();
|
||||
|
||||
// prepare the edited parameters for saving
|
||||
Map<QName, Serializable> params = WorkflowBean.prepareWorkItemParams(this.workItemNode);
|
||||
|
||||
// update the task with the updated parameters
|
||||
this.workflowService.updateTask(this.workItem.id, params, null, null);
|
||||
|
||||
// signal the selected transition to the workflow task
|
||||
this.workflowService.endTask(this.workItem.id, selectedTransition);
|
||||
|
||||
// commit the changes
|
||||
tx.commit();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Ended work item with transition: " + selectedTransition);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// reset the flag so we can re-attempt the operation
|
||||
isFinished = false;
|
||||
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
Utils.addErrorMessage(formatErrorMessage(e));
|
||||
outcome = this.getErrorOutcome(e);
|
||||
}
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
public boolean getApproveDisabled()
|
||||
|
||||
/**
|
||||
* Returns the Node representing the work item
|
||||
*
|
||||
* @return The node
|
||||
*/
|
||||
public Node getWorkItemNode()
|
||||
{
|
||||
return true;
|
||||
return this.workItemNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the workflow service to use
|
||||
*
|
||||
* @param workflowService
|
||||
* WorkflowService instance
|
||||
*/
|
||||
public void setWorkflowService(WorkflowService workflowService)
|
||||
{
|
||||
this.workflowService = workflowService;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package org.alfresco.web.bean.workflow;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -10,18 +9,14 @@ import java.util.ResourceBundle;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowPath;
|
||||
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.WorkflowTaskState;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.repository.TransientNode;
|
||||
import org.alfresco.web.bean.wizard.BaseWizardBean;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -74,7 +69,8 @@ public class StartWorkflowWizard extends BaseWizardBean
|
||||
logger.debug("Starting workflow with params: " + this.startTaskNode.getProperties());
|
||||
|
||||
// start the workflow to get access to the start task
|
||||
WorkflowPath path = this.workflowService.startWorkflow(this.selectedWorkflow, prepareTaskParams());
|
||||
WorkflowPath path = this.workflowService.startWorkflow(this.selectedWorkflow,
|
||||
WorkflowBean.prepareWorkItemParams(this.startTaskNode));
|
||||
if (path != null)
|
||||
{
|
||||
// extract the start task
|
||||
@@ -239,48 +235,4 @@ public class StartWorkflowWizard extends BaseWizardBean
|
||||
{
|
||||
this.workflowService = workflowService;
|
||||
}
|
||||
|
||||
protected Map<QName, Serializable> prepareTaskParams()
|
||||
{
|
||||
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
|
||||
|
||||
// marshal the properties and associations captured by the property sheet
|
||||
// back into a Map to pass to the workflow service
|
||||
|
||||
// go through all the properties in the transient node and add them to
|
||||
// params map
|
||||
Map<String, Object> props = this.startTaskNode.getProperties();
|
||||
for (String propName : props.keySet())
|
||||
{
|
||||
QName propQName = Repository.resolveToQName(propName);
|
||||
params.put(propQName, (Serializable)props.get(propName));
|
||||
}
|
||||
|
||||
// go through any associations that have been added to the start task
|
||||
// and build a list of NodeRefs representing the targets
|
||||
Map<String, Map<String, AssociationRef>> assocs = this.startTaskNode.getAddedAssociations();
|
||||
for (String assocName : assocs.keySet())
|
||||
{
|
||||
QName assocQName = Repository.resolveToQName(assocName);
|
||||
|
||||
// get the associations added and create list of targets
|
||||
Map<String, AssociationRef> addedAssocs = assocs.get(assocName);
|
||||
List<NodeRef> targets = new ArrayList<NodeRef>(addedAssocs.size());
|
||||
for (AssociationRef assoc : addedAssocs.values())
|
||||
{
|
||||
targets.add(assoc.getTargetRef());
|
||||
}
|
||||
|
||||
// add the targets for this particular association
|
||||
params.put(assocQName, (Serializable)targets);
|
||||
}
|
||||
|
||||
// String reviewer = (String)this.startTaskNode.getProperties().get(
|
||||
// ContentModel.PROP_NAME);
|
||||
// Map<QName, Serializable> params = new HashMap<QName, Serializable>(1);
|
||||
// params.put(QName.createQName(NamespaceService.DEFAULT_URI, "reviewer"), reviewer);
|
||||
|
||||
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
140
source/java/org/alfresco/web/bean/workflow/WorkflowBean.java
Normal file
140
source/java/org/alfresco/web/bean/workflow/WorkflowBean.java
Normal file
@@ -0,0 +1,140 @@
|
||||
package org.alfresco.web.bean.workflow;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
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.WorkflowTaskState;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ISO9075;
|
||||
import org.alfresco.web.app.Application;
|
||||
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.User;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Managed bean used for handling workflow related features
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class WorkflowBean
|
||||
{
|
||||
protected WorkflowService workflowService;
|
||||
protected List<Node> workItems;
|
||||
|
||||
private static final Log logger = LogFactory.getLog(WorkflowBean.class);
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
public List<Node> getWorkItemsToDo()
|
||||
{
|
||||
// get the current username
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
User user = Application.getCurrentUser(fc);
|
||||
String userName = ISO9075.encode(user.getUserName());
|
||||
|
||||
// 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.workItems = new ArrayList<Node>(tasks.size());
|
||||
for (WorkflowTask task : tasks)
|
||||
{
|
||||
createWorkItem(task);
|
||||
}
|
||||
|
||||
return this.workItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the workflow service to use
|
||||
*
|
||||
* @param workflowService WorkflowService instance
|
||||
*/
|
||||
public void setWorkflowService(WorkflowService workflowService)
|
||||
{
|
||||
this.workflowService = workflowService;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Helper methods
|
||||
|
||||
public static Map<QName, Serializable> prepareWorkItemParams(Node node)
|
||||
{
|
||||
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
|
||||
|
||||
// marshal the properties and associations captured by the property sheet
|
||||
// back into a Map to pass to the workflow service
|
||||
|
||||
// go through all the properties in the transient node and add them to
|
||||
// params map
|
||||
Map<String, Object> props = node.getProperties();
|
||||
for (String propName : props.keySet())
|
||||
{
|
||||
QName propQName = Repository.resolveToQName(propName);
|
||||
params.put(propQName, (Serializable)props.get(propName));
|
||||
}
|
||||
|
||||
// go through any associations that have been added to the start task
|
||||
// and build a list of NodeRefs representing the targets
|
||||
Map<String, Map<String, AssociationRef>> assocs = node.getAddedAssociations();
|
||||
for (String assocName : assocs.keySet())
|
||||
{
|
||||
QName assocQName = Repository.resolveToQName(assocName);
|
||||
|
||||
// get the associations added and create list of targets
|
||||
Map<String, AssociationRef> addedAssocs = assocs.get(assocName);
|
||||
List<NodeRef> targets = new ArrayList<NodeRef>(addedAssocs.size());
|
||||
for (AssociationRef assoc : addedAssocs.values())
|
||||
{
|
||||
targets.add(assoc.getTargetRef());
|
||||
}
|
||||
|
||||
// add the targets for this particular association
|
||||
params.put(assocQName, (Serializable)targets);
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 void createWorkItem(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.name, task.properties);
|
||||
|
||||
// add properties for the other useful metadata
|
||||
node.getProperties().put(ContentModel.PROP_NAME.toString(), task.name);
|
||||
node.getProperties().put("type", taskDef.metadata.getTitle());
|
||||
node.getProperties().put("id", task.id);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Created node for work item with id '" + task.id + "' " + node);
|
||||
|
||||
this.workItems.add(node);
|
||||
}
|
||||
}
|
@@ -1737,6 +1737,10 @@
|
||||
<property-name>namespaceService</property-name>
|
||||
<value>#{NamespaceService}</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>workflowService</property-name>
|
||||
<value>#{WorkflowService}</value>
|
||||
</managed-property>
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
@@ -1777,6 +1781,16 @@
|
||||
</managed-property>
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
<managed-bean-name>WorkflowBean</managed-bean-name>
|
||||
<managed-bean-class>org.alfresco.web.bean.workflow.WorkflowBean</managed-bean-class>
|
||||
<managed-bean-scope>session</managed-bean-scope>
|
||||
<managed-property>
|
||||
<property-name>workflowService</property-name>
|
||||
<value>#{WorkflowService}</value>
|
||||
</managed-property>
|
||||
</managed-bean>
|
||||
|
||||
<!-- ==================== COMPONENT GENERATOR BEANS ==================== -->
|
||||
<managed-bean>
|
||||
<description>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 15 KiB |
@@ -1,5 +1,5 @@
|
||||
<%--
|
||||
Copyright (C) 2006 Alfresco, Inc.
|
||||
Copyright (C) 2005 Alfresco, Inc.
|
||||
|
||||
Licensed under the Mozilla Public License version 1.1
|
||||
with a permitted attribution clause. You may obtain a
|
||||
@@ -19,4 +19,5 @@
|
||||
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
|
||||
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
|
||||
|
||||
<h:graphicImage value="/jsp/dashboards/dashlets/my-tasks-todo.png" />
|
||||
<r:propertySheetGrid id="work-item-props" value="#{DialogManager.bean.workItemNode}"
|
||||
var="workItemProps" columns="1" externalConfig="true" />
|
@@ -1,28 +0,0 @@
|
||||
<%--
|
||||
Copyright (C) 2005 Alfresco, Inc.
|
||||
|
||||
Licensed under the Mozilla Public License version 1.1
|
||||
with a permitted attribution clause. You may obtain a
|
||||
copy of the License at
|
||||
|
||||
http://www.alfresco.org/legal/license.txt
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
either express or implied. See the License for the specific
|
||||
language governing permissions and limitations under the
|
||||
License.
|
||||
--%>
|
||||
<%@ 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" %>
|
||||
|
||||
<%--
|
||||
<r:propertySheetGrid id="space-props" value="#{DialogManager.bean.editableNode}"
|
||||
var="spaceProps" columns="1" labelStyleClass="propertiesLabel"
|
||||
externalConfig="true" cellpadding="2" cellspacing="2" />
|
||||
--%>
|
||||
|
||||
<h:outputText value="Manage WorkItem In Here" />
|
@@ -19,7 +19,7 @@
|
||||
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
|
||||
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
|
||||
|
||||
<h:panelGrid columns="1" style="border: 1px solid #676767; background-color: #efefef; padding: 6px;">
|
||||
<h:panelGrid columns="1" style="border: 1px solid #676767; background-color: #efefef; padding: 6px 12px 12px 6px;">
|
||||
<h:outputText value="#{msg.available_workflows}:"/>
|
||||
<h:selectOneRadio id="selected-workflow" value="#{WizardManager.bean.selectedWorkflow}"
|
||||
layout="pageDirection">
|
||||
|
88
source/web/jsp/workflow/workitems-todo-dashlet.jsp
Normal file
88
source/web/jsp/workflow/workitems-todo-dashlet.jsp
Normal file
@@ -0,0 +1,88 @@
|
||||
<%@ 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" %>
|
||||
|
||||
<a:richList id="workt-items-list" viewMode="details" value="#{WorkflowBean.workItemsToDo}" var="r"
|
||||
styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow"
|
||||
altRowStyleClass="recordSetRowAlt" width="100%" pageSize="10"
|
||||
initialSortColumn="name" initialSortDescending="true">
|
||||
|
||||
<%-- Primary column for details view mode --%>
|
||||
<a:column primary="true" width="200" style="padding:2px;text-align:left">
|
||||
<f:facet name="header">
|
||||
<a:sortLink label="#{msg.title}" value="name" mode="case-insensitive" styleClass="header"/>
|
||||
</f:facet>
|
||||
<f:facet name="small-icon">
|
||||
<h:panelGroup>
|
||||
<a:actionLink value="#{r.name}" image="/images/icons/View_details.gif" showLink="false"
|
||||
actionListener="#{DialogManager.setupParameters}" action="dialog:manageWorkItem">
|
||||
<f:param name="id" value="#{r.id}" />
|
||||
</a:actionLink>
|
||||
</h:panelGroup>
|
||||
</f:facet>
|
||||
<a:actionLink value="#{r.name}" actionListener="#{DialogManager.setupParameters}"
|
||||
action="dialog:manageWorkItem">
|
||||
<f:param name="id" value="#{r.id}" />
|
||||
</a:actionLink>
|
||||
</a:column>
|
||||
|
||||
<%-- Description column --%>
|
||||
<a:column style="text-align:left">
|
||||
<f:facet name="header">
|
||||
<a:sortLink label="#{msg.id}" value="bpm:taskId" styleClass="header"/>
|
||||
</f:facet>
|
||||
<h:outputText value="#{r['bpm:taskId']}" />
|
||||
</a:column>
|
||||
|
||||
<%-- Type column --%>
|
||||
<a:column style="text-align:left">
|
||||
<f:facet name="header">
|
||||
<a:sortLink label="#{msg.type}" value="type" styleClass="header"/>
|
||||
</f:facet>
|
||||
<h:outputText value="#{r.type}" />
|
||||
</a:column>
|
||||
|
||||
<%-- Due date column --%>
|
||||
<a:column style="text-align:left">
|
||||
<f:facet name="header">
|
||||
<a:sortLink label="#{msg.due_date}" value="bpm:startDate" styleClass="header"/>
|
||||
</f:facet>
|
||||
<h:outputText value="#{r['bpm:dueDate']}">
|
||||
<a:convertXMLDate type="both" pattern="#{msg.date_pattern}" />
|
||||
</h:outputText>
|
||||
</a:column>
|
||||
|
||||
<%-- Status column --%>
|
||||
<a:column style="text-align:left">
|
||||
<f:facet name="header">
|
||||
<a:sortLink label="#{msg.status}" value="bpm:status" styleClass="header"/>
|
||||
</f:facet>
|
||||
<h:outputText value="#{r['bpm:status']}" />
|
||||
</a:column>
|
||||
|
||||
<%-- Actions column --%>
|
||||
<%--
|
||||
<a:column actions="true" style="text-align:left">
|
||||
<f:facet name="header">
|
||||
<h:outputText value="#{msg.actions}"/>
|
||||
</f:facet>
|
||||
<a:booleanEvaluator value="#{r.local}">
|
||||
<a:actionLink value="#{msg.delete}" image="/images/icons/delete.gif" showLink="false"
|
||||
styleClass="inlineAction"
|
||||
actionListener="#{RulesBean.setupRuleAction}" action="deleteRule">
|
||||
<f:param name="id" value="#{r.id}" />
|
||||
</a:actionLink>
|
||||
<a:actionLink value="#{msg.change_details}" image="/images/icons/change_rule.gif"
|
||||
showLink="false" styleClass="inlineAction"
|
||||
actionListener="#{RulesBean.setupRuleAction}" action="wizard:editRule">
|
||||
<f:param name="id" value="#{r.id}" />
|
||||
</a:actionLink>
|
||||
</a:booleanEvaluator>
|
||||
</a:column>
|
||||
--%>
|
||||
|
||||
<a:dataPager styleClass="pager" />
|
||||
</a:richList>
|
||||
|
||||
<h:message for="workt-items-list" styleClass="statusMessage" />
|
Reference in New Issue
Block a user