- Added workflow history to the manage task dialog

- Moved wcm workflow model constants to separate class to be consistent

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5761 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2007-05-23 14:48:07 +00:00
parent 7644596c74
commit 3530184871
12 changed files with 425 additions and 17 deletions

View File

@@ -1330,6 +1330,7 @@ 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
task=Task
id=Id
status=Status
completed=Completed
@@ -1354,6 +1355,8 @@ reassign_task_desc=This dialog allows you to reassign a task.
reassign_select_user=Select the user to assign the task to, then press OK.
error_reassign_task=Unable to reassign the task due to system error:
part_of_workflow=Part of Workflow
workflow_history=Workflow History
no_workflow_history=This workflow does not have any history
workflow_outline=Workflow Outline
initiated_by=Initiated by
started_on=Started on
@@ -1365,6 +1368,7 @@ no_tasks=No tasks found.
no_resources=No resources found.
in_progress=In Progress
by=by
assignee=Assignee
# Workflow Definitions
wf_review_options=Review Options

View File

@@ -78,13 +78,6 @@ public class AVMWorkflowUtil extends WorkflowUtil
{
private static final Log logger = LogFactory.getLog(AVMWorkflowUtil.class);
// Common workflow definitions
private static final String WCM_WORKFLOW_MODEL_1_0_URI = "http://www.alfresco.org/model/wcmworkflow/1.0";
public static final QName PROP_FROM_PATH = QName.createQName(WCM_WORKFLOW_MODEL_1_0_URI, "fromPath");
public static final QName PROP_LABEL = QName.createQName(WCM_WORKFLOW_MODEL_1_0_URI, "label");
public static final QName PROP_LAUNCH_DATE = QName.createQName(WCM_WORKFLOW_MODEL_1_0_URI, "launchDate");
public static final QName ASSOC_WEBPROJECT = QName.createQName(WCM_WORKFLOW_MODEL_1_0_URI, "webproject");
// cached configured lists
private static List<WorkflowDefinition> configuredWorkflowDefs = null;

View File

@@ -45,6 +45,7 @@ import org.alfresco.config.ConfigService;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.model.WCMWorkflowModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.wf.AVMSubmittedAspect;
import org.alfresco.repo.content.MimetypeMap;
@@ -405,11 +406,11 @@ public class CreateWebContentWizard extends BaseContentWizard
parameters.put(WorkflowModel.ASSOC_PACKAGE, packageNodeRef);
// TODO: capture label and comment?
parameters.put(AVMWorkflowUtil.PROP_LABEL,
parameters.put(WCMWorkflowModel.PROP_LABEL,
MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null
? this.formInstanceData.getName()
: this.getFileName());
parameters.put(AVMWorkflowUtil.PROP_FROM_PATH, AVMUtil.buildStoreRootPath(sandboxName));
parameters.put(WCMWorkflowModel.PROP_FROM_PATH, AVMUtil.buildStoreRootPath(sandboxName));
// update start task with submit parameters
this.workflowService.updateTask(startTask.id, parameters, null, null);

View File

@@ -42,6 +42,7 @@ import javax.transaction.UserTransaction;
import org.alfresco.config.JNDIConstants;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.model.WCMWorkflowModel;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.wf.AVMSubmittedAspect;
@@ -325,11 +326,11 @@ public class SubmitDialog extends BaseDialogBean
// add submission parameters
params.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, getComment());
params.put(AVMWorkflowUtil.PROP_LABEL, getLabel());
params.put(AVMWorkflowUtil.PROP_FROM_PATH,
params.put(WCMWorkflowModel.PROP_LABEL, getLabel());
params.put(WCMWorkflowModel.PROP_FROM_PATH,
AVMUtil.buildStoreRootPath(this.avmBrowseBean.getSandbox()));
params.put(AVMWorkflowUtil.PROP_LAUNCH_DATE, this.launchDate);
params.put(AVMWorkflowUtil.ASSOC_WEBPROJECT,
params.put(WCMWorkflowModel.PROP_LAUNCH_DATE, this.launchDate);
params.put(WCMWorkflowModel.ASSOC_WEBPROJECT,
this.avmBrowseBean.getWebsite().getNodeRef());
// update start task with submit parameters

View File

@@ -0,0 +1,250 @@
/*
* 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"
*/
package org.alfresco.web.ui.repo.component;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.ResourceBundle;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.cmr.workflow.WorkflowInstance;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.service.cmr.workflow.WorkflowTaskQuery;
import org.alfresco.service.cmr.workflow.WorkflowTaskState;
import org.alfresco.service.cmr.workflow.WorkflowTransition;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.SelfRenderingComponent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* JSF component that displays historic information about a workflow.
*
* @author gavinc
*/
public class UIWorkflowHistory extends SelfRenderingComponent
{
protected WorkflowInstance value = null;
private static final Log logger = LogFactory.getLog(UIWorkflowHistory.class);
private static final String MSG_DESCRIPTION = "description";
private static final String MSG_TASK = "task_type";
private static final String MSG_ID = "id";
private static final String MSG_CREATED = "created";
private static final String MSG_ASSIGNEE = "assignee";
private static final String MSG_DATE_COMPLETED = "completed_on";
private static final String MSG_OUTCOME = "outcome";
private static final String MSG_NO_HISTORY = "no_workflow_history";
// ------------------------------------------------------------------------------
// Component Impl
@Override
public String getFamily()
{
return "org.alfresco.faces.WorkflowHistory";
}
@Override
public void restoreState(FacesContext context, Object state)
{
Object values[] = (Object[])state;
// standard component attributes are restored by the super class
super.restoreState(context, values[0]);
this.value = (WorkflowInstance)values[1];
}
@Override
public Object saveState(FacesContext context)
{
Object values[] = new Object[8];
// standard component attributes are saved by the super class
values[0] = super.saveState(context);
values[1] = this.value;
return values;
}
@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException
{
if (!isRendered()) return;
WorkflowInstance wi = getValue();
if (wi != null)
{
ResponseWriter out = context.getResponseWriter();
ResourceBundle bundle = Application.getBundle(context);
if (logger.isDebugEnabled())
logger.debug("Retrieving workflow history for workflow instance: " + wi);
WorkflowTaskQuery query = new WorkflowTaskQuery();
query.setProcessId(wi.id);
query.setTaskState(WorkflowTaskState.COMPLETED);
query.setOrderBy(new WorkflowTaskQuery.OrderBy[] {
WorkflowTaskQuery.OrderBy.TaskCreated_Desc,
WorkflowTaskQuery.OrderBy.TaskActor_Asc });
List<WorkflowTask> tasks = Repository.getServiceRegistry(context).
getWorkflowService().queryTasks(query);
// output surrounding table and style if necessary
out.write("<table cellspacing='2' cellpadding='1' border='0' width='100%'");
if (this.getAttributes().get("style") != null)
{
out.write(" style=\"");
out.write((String)this.getAttributes().get("style"));
out.write("\"");
}
if (this.getAttributes().get("styleClass") != null)
{
out.write(" class=\"");
out.write((String)this.getAttributes().get("styleClass"));
out.write("\"");
}
out.write(">");
if (tasks.size() == 0)
{
out.write("<div style='margin-left:18px;margin-top: 6px;'>");
out.write(bundle.getString(MSG_NO_HISTORY));
out.write("</div>");
}
else
{
// output a header row
out.write("<tr align=left><th>");
out.write(bundle.getString(MSG_DESCRIPTION));
out.write("</th><th>");
out.write(bundle.getString(MSG_TASK));
out.write("</th><th>");
out.write(bundle.getString(MSG_ID));
out.write("</th><th>");
out.write(bundle.getString(MSG_CREATED));
out.write("</th><th>");
out.write(bundle.getString(MSG_ASSIGNEE));
out.write("</th><th>");
out.write(bundle.getString(MSG_DATE_COMPLETED));
out.write("</th><th>");
out.write(bundle.getString(MSG_OUTCOME));
out.write("</th></tr>");
// output a row for each previous completed task
for (WorkflowTask task : tasks)
{
Long id = (Long)task.properties.get(WorkflowModel.PROP_TASK_ID);
String desc = (String)task.properties.get(WorkflowModel.PROP_DESCRIPTION);
Date createdDate = (Date)task.properties.get(ContentModel.PROP_CREATED);
String owner = (String)task.properties.get(ContentModel.PROP_OWNER);
Date completedDate = (Date)task.properties.get(WorkflowModel.PROP_COMPLETION_DATE);
String transition = (String)task.properties.get(WorkflowModel.PROP_OUTCOME);
String outcome = "";
if (transition != null)
{
WorkflowTransition[] transitions = task.definition.node.transitions;
for (WorkflowTransition trans : transitions)
{
if (trans.id.equals(transition))
{
outcome = trans.title;
break;
}
}
}
out.write("<tr><td>");
out.write(desc == null ? "" : desc);
out.write("</td><td>");
out.write(task.title);
out.write("</td><td>");
out.write(id.toString());
out.write("</td><td>");
out.write(Utils.getDateTimeFormat(context).format(createdDate));
out.write("</td><td>");
out.write(owner);
out.write("</td><td>");
out.write(Utils.getDateTimeFormat(context).format(completedDate));
out.write("</td><td>");
out.write(outcome);
out.write("</td></tr>");
}
}
// output the end of the table
out.write("</table>");
}
}
@Override
public void encodeEnd(FacesContext context) throws IOException
{
if (!isRendered()) return;
}
@Override
public boolean getRendersChildren()
{
return false;
}
// ------------------------------------------------------------------------------
// Strongly typed component property accessors
/**
* Returns the workflow instance this component is showing information on
*
* @return The workflow instance
*/
public WorkflowInstance getValue()
{
ValueBinding vb = getValueBinding("value");
if (vb != null)
{
this.value = (WorkflowInstance)vb.getValue(getFacesContext());
}
return this.value;
}
/**
* Sets the workflow instance to show the summary for
*
* @param value The workflow instance
*/
public void setValue(WorkflowInstance value)
{
this.value = value;
}
}

View File

@@ -0,0 +1,85 @@
/*
* 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"
*/
package org.alfresco.web.ui.repo.tag;
import javax.faces.component.UIComponent;
import org.alfresco.web.ui.common.tag.HtmlComponentTag;
/**
* Tag that allows the workflow history component to be placed on a JSP page
*
* @author gavinc
*/
public class WorkflowHistoryTag extends HtmlComponentTag
{
/**
* @see javax.faces.webapp.UIComponentTag#getComponentType()
*/
public String getComponentType()
{
return "org.alfresco.faces.WorkflowHistory";
}
/**
* @see javax.faces.webapp.UIComponentTag#getRendererType()
*/
public String getRendererType()
{
return null;
}
/**
* @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
*/
protected void setProperties(UIComponent component)
{
super.setProperties(component);
setStringProperty(component, "value", this.value);
}
/**
* @see org.alfresco.web.ui.common.tag.HtmlComponentTag#release()
*/
public void release()
{
super.release();
this.value = null;
}
/**
* Set the value (binding to the list of user/group data)
*
* @param value the value
*/
public void setValue(String value)
{
this.value = value;
}
/** the value (binding to the workflow instance) */
private String value;
}

View File

@@ -39,6 +39,7 @@ import javax.faces.el.ValueBinding;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMWorkflowModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.workflow.WorkflowModel;
@@ -181,7 +182,7 @@ public class UIPendingSubmissions extends SelfRenderingComponent
"submitpendingTask"));
query.setTaskState(WorkflowTaskState.IN_PROGRESS);
Map<QName, Object> processProps = new HashMap<QName, Object>();
processProps.put(AVMWorkflowUtil.ASSOC_WEBPROJECT, webProject);
processProps.put(WCMWorkflowModel.ASSOC_WEBPROJECT, webProject);
query.setProcessCustomProps(processProps);
query.setOrderBy(new WorkflowTaskQuery.OrderBy[] {
WorkflowTaskQuery.OrderBy.TaskDue_Desc,
@@ -226,11 +227,11 @@ public class UIPendingSubmissions extends SelfRenderingComponent
for (WorkflowTask task : pendingTasks)
{
String desc = (String)task.properties.get(WorkflowModel.PROP_DESCRIPTION);
String label = (String)task.properties.get(AVMWorkflowUtil.PROP_LABEL);
String label = (String)task.properties.get(WCMWorkflowModel.PROP_LABEL);
String submitted = Utils.getDateTimeFormat(context).format(task.path.instance.startDate);
String username = (String)Repository.getServiceRegistry(context).getNodeService().
getProperty(task.path.instance.initiator, ContentModel.PROP_USERNAME);
Date launchDate = (Date)task.properties.get(AVMWorkflowUtil.PROP_LAUNCH_DATE);
Date launchDate = (Date)task.properties.get(WCMWorkflowModel.PROP_LAUNCH_DATE);
String launch = Utils.getDateTimeFormat(context).format(launchDate);
out.write("<tr><td>");

View File

@@ -169,6 +169,11 @@
<component-class>org.alfresco.web.ui.repo.component.UIWorkflowSummary</component-class>
</component>
<component>
<component-type>org.alfresco.faces.WorkflowHistory</component-type>
<component-class>org.alfresco.web.ui.repo.component.UIWorkflowHistory</component-class>
</component>
<component>
<component-type>org.alfresco.faces.NodeWorkflowInfo</component-type>
<component-class>org.alfresco.web.ui.repo.component.UINodeWorkflowInfo</component-class>

View File

@@ -1913,6 +1913,52 @@
</attribute>
</tag>
<tag>
<name>workflowHistory</name>
<tag-class>org.alfresco.web.ui.repo.tag.WorkflowHistoryTag</tag-class>
<body-content>JSP</body-content>
<description>
Shows history information of a workflow instance.
</description>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>binding</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>rendered</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>style</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>styleClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>sidebar</name>
<tag-class>org.alfresco.web.ui.repo.tag.SidebarTag</tag-class>

View File

@@ -588,6 +588,16 @@ a.topToolbarLinkHighlight, a.topToolbarLinkHighlight:link, a.topToolbarLinkHighl
border-color: #DDDDDD;
}
.workflowHistoryList
{
margin-left: 18px;
margin-top: 6px;
background-color: #f5f5f5;
border-width: 1px;
border-style: solid;
border-color: #DDDDDD;
}
#pluginBox
{
border: 1px solid #babfc5;

View File

@@ -154,6 +154,12 @@
<r:workflowSummary id="workflow-summary" value="#{DialogManager.bean.workflowInstance}" styleClass="workflowSummary" />
<f:verbatim><div style="padding-left:9px;padding-top:8px;padding-bottom:4px"></f:verbatim>
<a:panel id="pending-submission-panel" label="#{msg.workflow_history}" progressive="true"
expanded="false" styleClass="mainSubTitle">
<r:workflowHistory id="workflow-history" value="#{DialogManager.bean.workflowInstance}" styleClass="workflowHistoryList" />
</a:panel>
<f:verbatim></div></f:verbatim>
</a:panel>
<h:outputText id="padding4" styleClass="paddingRow" value="&nbsp;" escape="false" />

View File

@@ -144,6 +144,12 @@
<r:workflowSummary id="workflow-summary" value="#{DialogManager.bean.workflowInstance}" styleClass="workflowSummary" />
<f:verbatim><div style="padding-left:9px;padding-top:8px;padding-bottom:4px"></f:verbatim>
<a:panel id="pending-submission-panel" label="#{msg.workflow_history}" progressive="true"
expanded="false" styleClass="mainSubTitle">
<r:workflowHistory id="workflow-history" value="#{DialogManager.bean.workflowInstance}" styleClass="workflowHistoryList" />
</a:panel>
<f:verbatim></div></f:verbatim>
</a:panel>
<h:outputText id="padding4" styleClass="paddingRow" value="&nbsp;" escape="false" />