Refactored wcm client workflow models to use workflow 'name' not 'id'

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4435 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-11-23 18:02:21 +00:00
parent 5d18c75e08
commit e58bf45b96
8 changed files with 43 additions and 51 deletions

View File

@@ -70,6 +70,8 @@ public class CreateFormWizard
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
private static final String NO_DEFAULT_WORKFLOW_SELECTED = "no_default_workflow_selected";
/** /**
* Simple wrapper class to represent a form data renderer * Simple wrapper class to represent a form data renderer
*/ */
@@ -143,7 +145,7 @@ public class CreateFormWizard
private String formName = null; private String formName = null;
private String formTitle = null; private String formTitle = null;
private String formDescription = null; private String formDescription = null;
private String defaultWorkflowId = null; private String defaultWorkflowName = null;
private RenderingEngine renderingEngine = null; private RenderingEngine renderingEngine = null;
protected ContentService contentService; protected ContentService contentService;
protected MimetypeService mimetypeService; protected MimetypeService mimetypeService;
@@ -197,9 +199,9 @@ public class CreateFormWizard
this.getSchemaRootElementName()); this.getSchemaRootElementName());
props.put(WCMModel.PROP_OUTPUT_PATH_PATTERN_FOR_FORM_INSTANCE_DATA, props.put(WCMModel.PROP_OUTPUT_PATH_PATTERN_FOR_FORM_INSTANCE_DATA,
this.getOutputPathPatternForFormInstanceData()); this.getOutputPathPatternForFormInstanceData());
if (this.defaultWorkflowId != null) if (this.defaultWorkflowName != null)
{ {
props.put(WCMModel.PROP_DEFAULT_WORKFLOW_ID, this.defaultWorkflowId); props.put(WCMModel.PROP_DEFAULT_WORKFLOW_NAME, this.defaultWorkflowName);
} }
this.nodeService.addAspect(folderInfo.getNodeRef(), WCMModel.ASPECT_FORM, props); this.nodeService.addAspect(folderInfo.getNodeRef(), WCMModel.ASPECT_FORM, props);
@@ -282,7 +284,7 @@ public class CreateFormWizard
this.outputPathPatternForFormInstanceData = null; this.outputPathPatternForFormInstanceData = null;
this.outputPathPatternForRendition = null; this.outputPathPatternForRendition = null;
this.mimetypeForRendition = null; this.mimetypeForRendition = null;
this.defaultWorkflowId = null; this.defaultWorkflowName = null;
} }
@Override @Override
@@ -710,27 +712,27 @@ public class CreateFormWizard
return this.formDescription; return this.formDescription;
} }
public void setDefaultWorkflowId(final String[] defaultWorkflowId) public void setDefaultWorkflowName(final String[] defaultWorkflowName)
{ {
assert defaultWorkflowId.length == 1; assert defaultWorkflowName.length == 1;
this.defaultWorkflowId = ("no_default_workflow_selected".equals(defaultWorkflowId[0]) this.defaultWorkflowName = (NO_DEFAULT_WORKFLOW_SELECTED.equals(defaultWorkflowName[0])
? null ? null
: defaultWorkflowId[0]); : defaultWorkflowName[0]);
} }
public WorkflowDefinition getDefaultWorkflowDefinition() public WorkflowDefinition getDefaultWorkflowDefinition()
{ {
return (this.defaultWorkflowId == null return (this.defaultWorkflowName == null
? null ? null
: this.workflowService.getDefinitionById(this.defaultWorkflowId)); : this.workflowService.getDefinitionByName("jbpm$" + this.defaultWorkflowName));
} }
public String[] getDefaultWorkflowId() public String[] getDefaultWorkflowName()
{ {
return new String[] { return new String[] {
(this.defaultWorkflowId == null (this.defaultWorkflowName == null
? "no_default_workflow_selected" ? NO_DEFAULT_WORKFLOW_SELECTED
: this.defaultWorkflowId) : this.defaultWorkflowName)
}; };
} }
@@ -745,16 +747,15 @@ public class CreateFormWizard
final List<UIListItem> result = new ArrayList<UIListItem>(workflowDefs.size() + 1); final List<UIListItem> result = new ArrayList<UIListItem>(workflowDefs.size() + 1);
UIListItem item = new UIListItem(); UIListItem item = new UIListItem();
item.setValue("no_default_workflow_selected"); item.setValue(NO_DEFAULT_WORKFLOW_SELECTED);
item.setLabel("None"); item.setLabel("None");
item.setDescription("");
item.setImage(WebResources.IMAGE_WORKFLOW_32); item.setImage(WebResources.IMAGE_WORKFLOW_32);
result.add(item); result.add(item);
for (WorkflowDefinition workflowDef : workflowDefs) for (WorkflowDefinition workflowDef : workflowDefs)
{ {
item = new UIListItem(); item = new UIListItem();
item.setValue(workflowDef.getId()); item.setValue(workflowDef.getName());
item.setLabel(workflowDef.getTitle()); item.setLabel(workflowDef.getTitle());
item.setDescription(workflowDef.getDescription()); item.setDescription(workflowDef.getDescription());
item.setImage(WebResources.IMAGE_WORKFLOW_32); item.setImage(WebResources.IMAGE_WORKFLOW_32);

View File

@@ -203,14 +203,13 @@ public class CreateWebContentWizard extends BaseContentWizard
} }
final NodeRef workflowRef = workflowRefs.get(0).getChildRef(); final NodeRef workflowRef = workflowRefs.get(0).getChildRef();
final String workflowId = (String) final String workflowName = (String)this.nodeService.getProperty(workflowRef, ContentModel.PROP_WORKFLOW_NAME);
this.nodeService.getProperty(workflowRef, ContentModel.PROP_WORKFLOW_ID); if (workflowName == null)
if (workflowId == null)
{ {
throw new RuntimeException("no workflow found for form " + formName); throw new RuntimeException("no workflow found for form " + formName);
} }
System.err.println("using workflow " + workflowId + " for form " + formName); System.err.println("using workflow " + workflowName + " for form " + formName);
wd = this.workflowService.getDefinitionById(workflowId); wd = this.workflowService.getDefinitionByName("jbpm$" + workflowName);
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ContentReader cr = this.contentService.getReader(workflowRef, ContentModel.PROP_WORKFLOWDEFAULTS); final ContentReader cr = this.contentService.getReader(workflowRef, ContentModel.PROP_WORKFLOWDEFAULTS);

View File

@@ -237,7 +237,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
{ {
WorkflowWrapper workflow = form.getWorkflow(); WorkflowWrapper workflow = form.getWorkflow();
props.clear(); props.clear();
props.put(ContentModel.PROP_WORKFLOW_ID, workflow.getId()); props.put(ContentModel.PROP_WORKFLOW_NAME, workflow.getName());
NodeRef workflowRef = this.nodeService.createNode(formRef, NodeRef workflowRef = this.nodeService.createNode(formRef,
ContentModel.ASSOC_WORKFLOWDEFAULTS, ContentModel.ASSOC_WORKFLOWDEFAULTS,
ContentModel.ASSOC_WORKFLOWDEFAULTS, ContentModel.ASSOC_WORKFLOWDEFAULTS,
@@ -276,7 +276,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
for (WorkflowWrapper workflow : this.workflows) for (WorkflowWrapper workflow : this.workflows)
{ {
props.clear(); props.clear();
props.put(ContentModel.PROP_NAME, workflow.getId()); props.put(ContentModel.PROP_NAME, workflow.getName());
NodeRef workflowRef = this.nodeService.createNode(nodeRef, NodeRef workflowRef = this.nodeService.createNode(nodeRef,
ContentModel.ASSOC_WEBWORKFLOWDEFAULTS, ContentModel.ASSOC_WEBWORKFLOWDEFAULTS,
ContentModel.ASSOC_WEBWORKFLOWDEFAULTS, ContentModel.ASSOC_WEBWORKFLOWDEFAULTS,
@@ -653,7 +653,7 @@ 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.getId(), workflow.getTitle())); this.workflows.add(new WorkflowWrapper(workflow.getName(), workflow.getTitle()));
} }
} }
@@ -777,7 +777,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
WorkflowDefinition wf = this.form.getDefaultWorkflow(); WorkflowDefinition wf = this.form.getDefaultWorkflow();
if (this.workflow == null && wf != null) if (this.workflow == null && wf != null)
{ {
this.workflow = new WorkflowWrapper(wf.id, wf.getTitle()); this.workflow = new WorkflowWrapper(wf.name, wf.getTitle());
} }
return this.workflow; return this.workflow;
} }
@@ -918,35 +918,27 @@ public class CreateWebsiteWizard extends BaseWizardBean
*/ */
public static class WorkflowWrapper public static class WorkflowWrapper
{ {
private String id; private String name;
private String title; private String title;
private String filenamePattern; private String filenamePattern;
private QName type; private QName type;
private Map<QName, Serializable> params; private Map<QName, Serializable> params;
public WorkflowWrapper(String id, String title) public WorkflowWrapper(String name, String title)
{ {
this.id = id; this.name = name;
this.title = title; this.title = title;
this.filenamePattern = filenamePattern; this.filenamePattern = filenamePattern;
} }
/** /**
* @return Returns the id of the workflow. * @return Returns the name key of the workflow.
*/ */
public String getId() public String getName()
{ {
return this.id; return this.name;
} }
/**
* @return Returns the name of the workflow.
*/
//public String getName()
//{
// return workflowService.getDefinitionById(this.getId()).getName();
//}
/** /**
* @return the display label of the workflow. * @return the display label of the workflow.
*/ */

View File

@@ -169,7 +169,7 @@ public class FormDetailsDialog extends BaseDialogBean
WorkflowWrapper workflow = getActionForm().getWorkflow(); WorkflowWrapper workflow = getActionForm().getWorkflow();
if (workflow != null) if (workflow != null)
{ {
this.workflowSelectedValue = new String[] {workflow.getId()}; this.workflowSelectedValue = new String[] {workflow.getName()};
} }
} }
return this.workflowSelectedValue; return this.workflowSelectedValue;
@@ -231,8 +231,8 @@ public class FormDetailsDialog extends BaseDialogBean
} }
if (this.workflowSelectedValue != null && this.workflowSelectedValue.length != 0) if (this.workflowSelectedValue != null && this.workflowSelectedValue.length != 0)
{ {
WorkflowDefinition def = this.workflowService.getDefinitionById(this.workflowSelectedValue[0]); WorkflowDefinition def = this.workflowService.getDefinitionByName("jbpm$" + this.workflowSelectedValue[0]);
form.setWorkflow(new CreateWebsiteWizard.WorkflowWrapper(def.getId(), def.getTitle())); form.setWorkflow(new CreateWebsiteWizard.WorkflowWrapper(def.getName(), def.getTitle()));
} }
return outcome; return outcome;
} }

View File

@@ -122,7 +122,7 @@ public class FormWorkflowDialog extends BaseDialogBean
if (this.workflowNode == null) if (this.workflowNode == null)
{ {
// TODO: remove the 'jbpm$' prefix once bug fix to WorkflowService has been merged across! // TODO: remove the 'jbpm$' prefix once bug fix to WorkflowService has been merged across!
WorkflowDefinition flowDef = this.workflowService.getDefinitionById(getActionWorkflow().getId()); WorkflowDefinition flowDef = this.workflowService.getDefinitionByName("jbpm$" + getActionWorkflow().getName());
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Selected workflow: "+ flowDef); logger.debug("Selected workflow: "+ flowDef);

View File

@@ -100,11 +100,11 @@ class FormImpl
public WorkflowDefinition getDefaultWorkflow() public WorkflowDefinition getDefaultWorkflow()
{ {
final NodeService nodeService = this.getServiceRegistry().getNodeService(); final NodeService nodeService = this.getServiceRegistry().getNodeService();
final String defaultWorkflowId = (String)nodeService.getProperty(this.folderNodeRef, final String defaultWorkflowName = (String)nodeService.getProperty(this.folderNodeRef,
WCMModel.PROP_DEFAULT_WORKFLOW_ID); WCMModel.PROP_DEFAULT_WORKFLOW_NAME);
final WorkflowService workflowService = this.getServiceRegistry().getWorkflowService(); final WorkflowService workflowService = this.getServiceRegistry().getWorkflowService();
return (defaultWorkflowId != null return (defaultWorkflowName != null
? workflowService.getDefinitionById(defaultWorkflowId) ? workflowService.getDefinitionByName("jbpm$" + defaultWorkflowName)
: null); : null);
} }

View File

@@ -22,7 +22,7 @@
<h:panelGroup> <h:panelGroup>
<f:verbatim><div style="height:108px;*height:112px;width:300px;overflow:auto" class="selectListTable"></f:verbatim> <f:verbatim><div style="height:108px;*height:112px;width:300px;overflow:auto" class="selectListTable"></f:verbatim>
<a:selectList id="workflow-list" multiSelect="false" style="width:276px" itemStyleClass="selectListItem" <a:selectList id="workflow-list" multiSelect="false" style="width:276px" itemStyleClass="selectListItem"
value="#{WizardManager.bean.defaultWorkflowId}"> value="#{WizardManager.bean.defaultWorkflowName}">
<a:listItems value="#{WizardManager.bean.defaultWorkflowChoices}" /> <a:listItems value="#{WizardManager.bean.defaultWorkflowChoices}" />
</a:selectList> </a:selectList>
<f:verbatim></div></f:verbatim> <f:verbatim></div></f:verbatim>

View File

@@ -72,14 +72,14 @@
<h:panelGrid columns="2" cellpadding="3" cellspacing="3" border="0"> <h:panelGrid columns="2" cellpadding="3" cellspacing="3" border="0">
<h:outputText value="#{msg.apply_default_workflow}:"/> <h:outputText value="#{msg.apply_default_workflow}:"/>
<c:choose> <c:choose>
<c:when test="${WizardManager.bean.defaultWorkflowId != null}"> <c:when test="${WizardManager.bean.defaultWorkflowName != null}">
<h:outputText value="#{msg.yes}"/> <h:outputText value="#{msg.yes}"/>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<h:outputText value="#{msg.no}"/> <h:outputText value="#{msg.no}"/>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
<c:if test="${WizardManager.bean.defaultWorkflowId != null}"> <c:if test="${WizardManager.bean.defaultWorkflowName != null}">
<h:outputText value="#{msg.name}:"/> <h:outputText value="#{msg.name}:"/>
<h:outputText value="#{WizardManager.bean.defaultWorkflowDefinition.name}"/> <h:outputText value="#{WizardManager.bean.defaultWorkflowDefinition.name}"/>
<h:outputText value="#{msg.description}:"/> <h:outputText value="#{msg.description}:"/>