. Files in the submit dialog list are now matched against the regular expressions provided for web project workflow definitions

. Configuring the workflow file match regular expression has been moved into the Configure Workflow screen

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4569 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-12-11 16:07:10 +00:00
parent c102cc20d6
commit bedaafd781
6 changed files with 133 additions and 8 deletions

View File

@@ -863,6 +863,8 @@ edit_website_title=Edit Web Project Wizard
edit_website_desc=This wizard helps you modify the settings for a web project space. edit_website_desc=This wizard helps you modify the settings for a web project space.
edit_website_finish_instruction=To close this wizard and save the modified settings for your web project space click Finish. To review or change your selections click Back. edit_website_finish_instruction=To close this wizard and save the modified settings for your web project space click Finish. To review or change your selections click Back.
edit_website=Edit Web Project Settings edit_website=Edit Web Project Settings
workflow_settings=Workflow Settings
error_filename_pattern=Error with workflow filename pattern: {0}
# Invite web users wizard messages # Invite web users wizard messages
invite_website_users=Invite Web Project Users invite_website_users=Invite Web Project Users

View File

@@ -63,14 +63,17 @@ import org.apache.commons.logging.LogFactory;
*/ */
public class CreateWebsiteWizard extends BaseWizardBean public class CreateWebsiteWizard extends BaseWizardBean
{ {
private static final String COMPONENT_FORMLIST = "form-list";
private static final String COMPONENT_WORKFLOWLIST = "workflow-list";
private static final String MSG_DESCRIPTION = "description"; private static final String MSG_DESCRIPTION = "description";
private static final String MSG_NAME = "name"; private static final String MSG_NAME = "name";
private static final String MSG_USERROLES = "create_website_summary_users"; private static final String MSG_USERROLES = "create_website_summary_users";
private static final String MSG_FORM_SUMMARY = "website_form_summary"; private static final String MSG_FORM_SUMMARY = "website_form_summary";
private static final String MSG_NONE = "value_not_set"; private static final String MSG_NONE = "value_not_set";
private static final String COMPONENT_FORMLIST = "form-list";
private static final String COMPONENT_WORKFLOWLIST = "workflow-list";
private static final String MATCH_DEFAULT = ".*";
private static final String WEBAPP_DEFAULT = "ROOT"; private static final String WEBAPP_DEFAULT = "ROOT";
private static Log logger = LogFactory.getLog(CreateWebsiteWizard.class); private static Log logger = LogFactory.getLog(CreateWebsiteWizard.class);
@@ -661,7 +664,8 @@ public class CreateWebsiteWizard extends BaseWizardBean
if (index != -1) if (index != -1)
{ {
WorkflowDefinition workflow = (WorkflowDefinition)this.workflowsList.get(index).getValue(); WorkflowDefinition workflow = (WorkflowDefinition)this.workflowsList.get(index).getValue();
this.workflows.add(new WorkflowWrapper(workflow.getName(), workflow.getTitle(), workflow.getDescription())); this.workflows.add(new WorkflowWrapper(
workflow.getName(), workflow.getTitle(), workflow.getDescription(), MATCH_DEFAULT));
} }
} }
@@ -946,6 +950,13 @@ public class CreateWebsiteWizard extends BaseWizardBean
private Map<QName, Serializable> params; private Map<QName, Serializable> params;
public WorkflowWrapper(String name, String title, String description) public WorkflowWrapper(String name, String title, String description)
{
this.name = name;
this.title = title;
this.description = description;
}
public WorkflowWrapper(String name, String title, String description, String filenamePattern)
{ {
this.name = name; this.name = name;
this.title = title; this.title = title;

View File

@@ -16,13 +16,18 @@
*/ */
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.text.MessageFormat;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.workflow.WorkflowDefinition; import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.cmr.workflow.WorkflowTaskDefinition; import org.alfresco.service.cmr.workflow.WorkflowTaskDefinition;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.dialog.BaseDialogBean; import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.TransientNode; import org.alfresco.web.bean.repository.TransientNode;
@@ -39,8 +44,12 @@ import org.apache.commons.logging.LogFactory;
*/ */
public class FormWorkflowDialog extends BaseDialogBean public class FormWorkflowDialog extends BaseDialogBean
{ {
private static final String MSG_ERROR_FILENAME_PATTERN = "error_filename_pattern";
private static final Log logger = LogFactory.getLog(FormWorkflowDialog.class); private static final Log logger = LogFactory.getLog(FormWorkflowDialog.class);
private String filenamePattern;
protected WorkflowService workflowService; protected WorkflowService workflowService;
protected CreateWebsiteWizard websiteWizard; protected CreateWebsiteWizard websiteWizard;
protected TransientNode workflowNode; protected TransientNode workflowNode;
@@ -62,6 +71,29 @@ public class FormWorkflowDialog extends BaseDialogBean
this.websiteWizard = wizard; this.websiteWizard = wizard;
} }
/**
* @return Returns the filename pattern.
*/
public String getFilenamePattern()
{
if (this.filenamePattern == null)
{
this.filenamePattern = getActionWorkflow().getFilenamePattern();
}
return this.filenamePattern;
}
/**
* @param filenamePattern The filename pattern to set.
*/
public void setFilenamePattern(String filenamePattern)
{
if (this.filenamePattern != null && this.filenamePattern.length() != 0)
{
this.filenamePattern = filenamePattern;
}
}
/** /**
* @see org.alfresco.web.bean.dialog.BaseDialogBean#init(java.util.Map) * @see org.alfresco.web.bean.dialog.BaseDialogBean#init(java.util.Map)
*/ */
@@ -70,6 +102,7 @@ public class FormWorkflowDialog extends BaseDialogBean
{ {
super.init(parameters); super.init(parameters);
this.filenamePattern = null;
this.workflowNode = null; this.workflowNode = null;
WorkflowWrapper workflow = getActionWorkflow(); WorkflowWrapper workflow = getActionWorkflow();
if (workflow != null && workflow.getParams() != null) if (workflow != null && workflow.getParams() != null)
@@ -86,11 +119,29 @@ public class FormWorkflowDialog extends BaseDialogBean
@Override @Override
protected String finishImpl(FacesContext context, String outcome) throws Exception protected String finishImpl(FacesContext context, String outcome) throws Exception
{ {
// push serialized params back into workflow object
if (this.workflowNode != null) if (this.workflowNode != null)
{ {
getActionWorkflow().setParams( WorkflowUtil.prepareTaskParams(this.workflowNode) ); // push serialized params back into workflow object
getActionWorkflow().setType(this.workflowNode.getType()); WorkflowWrapper wf = getActionWorkflow();
wf.setParams(WorkflowUtil.prepareTaskParams(this.workflowNode));
wf.setType(this.workflowNode.getType());
if (this.filenamePattern != null && this.filenamePattern.length() != 0)
{
// check the filename pattern compiles and display an error if a problem occurs
try
{
Pattern.compile(this.filenamePattern);
}
catch (PatternSyntaxException pax)
{
throw new AlfrescoRuntimeException(
MessageFormat.format(
Application.getMessage(FacesContext.getCurrentInstance(), MSG_ERROR_FILENAME_PATTERN),
pax.getMessage()), pax);
}
wf.setFilenamePattern(this.filenamePattern);
}
} }
return outcome; return outcome;
} }

View File

@@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
@@ -287,13 +288,38 @@ public class SubmitDialog extends BaseDialogBean
NodeRef websiteRef = this.avmBrowseBean.getWebsite().getNodeRef(); NodeRef websiteRef = this.avmBrowseBean.getWebsite().getNodeRef();
List<ChildAssociationRef> webWorkflowRefs = this.nodeService.getChildAssocs( List<ChildAssociationRef> webWorkflowRefs = this.nodeService.getChildAssocs(
websiteRef, WCMAppModel.ASSOC_WEBWORKFLOWDEFAULTS, RegexQNamePattern.MATCH_ALL); websiteRef, WCMAppModel.ASSOC_WEBWORKFLOWDEFAULTS, RegexQNamePattern.MATCH_ALL);
List<FormWorkflowWrapper> workflowMatchers = new ArrayList<FormWorkflowWrapper>(webWorkflowRefs.size());
for (ChildAssociationRef ref : webWorkflowRefs) for (ChildAssociationRef ref : webWorkflowRefs)
{ {
NodeRef wfDefaultsRef = ref.getChildRef(); NodeRef wfDefaultsRef = ref.getChildRef();
String wfName = (String)this.nodeService.getProperty(wfDefaultsRef, WCMAppModel.PROP_WORKFLOW_NAME); String wfName = (String)this.nodeService.getProperty(wfDefaultsRef, WCMAppModel.PROP_WORKFLOW_NAME);
Map<QName, Serializable> params = (Map<QName, Serializable>)AVMWorkflowUtil.deserializeWorkflowParams( Map<QName, Serializable> params = (Map<QName, Serializable>)AVMWorkflowUtil.deserializeWorkflowParams(
wfDefaultsRef); wfDefaultsRef);
this.workflows.add(new FormWorkflowWrapper(wfName, params)); String matchPattern = (String)this.nodeService.getProperty(
wfDefaultsRef, WCMAppModel.PROP_FILENAMEPATTERN);
if (matchPattern != null)
{
// add to temp list with the file name pattern
workflowMatchers.add(new FormWorkflowWrapper(wfName, params, matchPattern));
}
}
// perform match on each submitted file against available workflows
for (ItemWrapper wrapper : this.submitItems)
{
String path = wrapper.getPath();
for (int i=0; i<workflowMatchers.size(); i++)
{
// see if the file path matches this workflow path pattern
if (workflowMatchers.get(i).matchesPath(path) == true)
{
// found a match - remove the workflow from the list of ones to check
this.workflows.add(workflowMatchers.get(i));
workflowMatchers.remove(i);
}
}
// if all workflows are matched, there is no need to continue looping
if (workflowMatchers.size() == 0) break;
} }
// build a UI item for each available workflow // build a UI item for each available workflow
@@ -531,6 +557,7 @@ public class SubmitDialog extends BaseDialogBean
{ {
public String Name; public String Name;
public Map<QName, Serializable> Params; public Map<QName, Serializable> Params;
private Pattern filenamePattern;
FormWorkflowWrapper(String name, Map<QName, Serializable> params) FormWorkflowWrapper(String name, Map<QName, Serializable> params)
{ {
@@ -538,6 +565,28 @@ public class SubmitDialog extends BaseDialogBean
this.Params = params; this.Params = params;
} }
FormWorkflowWrapper(String name, Map<QName, Serializable> params, String filenamePattern)
{
this.Name = name;
this.Params = params;
if (filenamePattern != null)
{
this.filenamePattern = Pattern.compile(filenamePattern);
}
}
boolean matchesPath(String path)
{
if (filenamePattern != null)
{
return filenamePattern.matcher(path).matches();
}
else
{
return false;
}
}
@Override @Override
public int hashCode() public int hashCode()
{ {

View File

@@ -26,3 +26,15 @@
<r:propertySheetGrid id="task-props" value="#{DialogManager.bean.workflowMetadataNode}" <r:propertySheetGrid id="task-props" value="#{DialogManager.bean.workflowMetadataNode}"
var="taskProps" columns="1" externalConfig="true" /> var="taskProps" columns="1" externalConfig="true" />
</h:panelGrid> </h:panelGrid>
<h:panelGroup rendered="#{DialogManager.bean.filenamePattern != null}">
<h:panelGrid columns="1" cellpadding="2" style="padding-top:4px;padding-bottom:4px;"
width="100%" rowClasses="wizardSectionHeading">
<h:outputText value="&nbsp;#{msg.workflow_settings}" escape="false" />
</h:panelGrid>
<h:panelGrid columns="2" cellpadding="2" cellspacing="2" style="margin-left:16px">
<h:outputText value="&nbsp;#{msg.website_filename_match}" escape="false" />
<h:inputText value="#{DialogManager.bean.filenamePattern}" />
</h:panelGrid>
</h:panelGroup>

View File

@@ -53,7 +53,7 @@
<h:outputText value="#{msg.configure}" /> <h:outputText value="#{msg.configure}" />
</f:facet> </f:facet>
<h:outputText value="#{msg.website_filename_match}:" style="padding-right:4px" /> <h:outputText value="#{msg.website_filename_match}:" style="padding-right:4px" />
<h:inputText value="#{row.filenamePattern}" /> <h:outputText value="#{row.filenamePattern}" />
<h:commandButton id="cmd-1" rendered="#{WizardManager.bean.editMode == false}" value="#{msg.form_template_conf_workflow}" style="margin-left:4px" styleClass="dialogControls" action="dialog:formTemplateWorkflow" actionListener="#{WizardManager.bean.setupWorkflowAction}" /> <h:commandButton id="cmd-1" rendered="#{WizardManager.bean.editMode == false}" value="#{msg.form_template_conf_workflow}" style="margin-left:4px" styleClass="dialogControls" action="dialog:formTemplateWorkflow" actionListener="#{WizardManager.bean.setupWorkflowAction}" />
<h:commandButton id="cmd-2" rendered="#{WizardManager.bean.editMode == true}" value="#{msg.form_template_conf_workflow}" style="margin-left:4px" styleClass="dialogControls" action="dialog:editFormTemplateWorkflow" actionListener="#{WizardManager.bean.setupWorkflowAction}" /> <h:commandButton id="cmd-2" rendered="#{WizardManager.bean.editMode == true}" value="#{msg.form_template_conf_workflow}" style="margin-left:4px" styleClass="dialogControls" action="dialog:editFormTemplateWorkflow" actionListener="#{WizardManager.bean.setupWorkflowAction}" />
</h:column> </h:column>