mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -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
|
||||
*/
|
||||
@@ -143,7 +145,7 @@ public class CreateFormWizard
|
||||
private String formName = null;
|
||||
private String formTitle = null;
|
||||
private String formDescription = null;
|
||||
private String defaultWorkflowId = null;
|
||||
private String defaultWorkflowName = null;
|
||||
private RenderingEngine renderingEngine = null;
|
||||
protected ContentService contentService;
|
||||
protected MimetypeService mimetypeService;
|
||||
@@ -197,9 +199,9 @@ public class CreateFormWizard
|
||||
this.getSchemaRootElementName());
|
||||
props.put(WCMModel.PROP_OUTPUT_PATH_PATTERN_FOR_FORM_INSTANCE_DATA,
|
||||
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);
|
||||
|
||||
@@ -282,7 +284,7 @@ public class CreateFormWizard
|
||||
this.outputPathPatternForFormInstanceData = null;
|
||||
this.outputPathPatternForRendition = null;
|
||||
this.mimetypeForRendition = null;
|
||||
this.defaultWorkflowId = null;
|
||||
this.defaultWorkflowName = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -710,27 +712,27 @@ public class CreateFormWizard
|
||||
return this.formDescription;
|
||||
}
|
||||
|
||||
public void setDefaultWorkflowId(final String[] defaultWorkflowId)
|
||||
public void setDefaultWorkflowName(final String[] defaultWorkflowName)
|
||||
{
|
||||
assert defaultWorkflowId.length == 1;
|
||||
this.defaultWorkflowId = ("no_default_workflow_selected".equals(defaultWorkflowId[0])
|
||||
assert defaultWorkflowName.length == 1;
|
||||
this.defaultWorkflowName = (NO_DEFAULT_WORKFLOW_SELECTED.equals(defaultWorkflowName[0])
|
||||
? null
|
||||
: defaultWorkflowId[0]);
|
||||
: defaultWorkflowName[0]);
|
||||
}
|
||||
|
||||
public WorkflowDefinition getDefaultWorkflowDefinition()
|
||||
{
|
||||
return (this.defaultWorkflowId == null
|
||||
return (this.defaultWorkflowName == null
|
||||
? null
|
||||
: this.workflowService.getDefinitionById(this.defaultWorkflowId));
|
||||
: this.workflowService.getDefinitionByName("jbpm$" + this.defaultWorkflowName));
|
||||
}
|
||||
|
||||
public String[] getDefaultWorkflowId()
|
||||
public String[] getDefaultWorkflowName()
|
||||
{
|
||||
return new String[] {
|
||||
(this.defaultWorkflowId == null
|
||||
? "no_default_workflow_selected"
|
||||
: this.defaultWorkflowId)
|
||||
(this.defaultWorkflowName == null
|
||||
? NO_DEFAULT_WORKFLOW_SELECTED
|
||||
: this.defaultWorkflowName)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -745,16 +747,15 @@ public class CreateFormWizard
|
||||
final List<UIListItem> result = new ArrayList<UIListItem>(workflowDefs.size() + 1);
|
||||
|
||||
UIListItem item = new UIListItem();
|
||||
item.setValue("no_default_workflow_selected");
|
||||
item.setValue(NO_DEFAULT_WORKFLOW_SELECTED);
|
||||
item.setLabel("None");
|
||||
item.setDescription("");
|
||||
item.setImage(WebResources.IMAGE_WORKFLOW_32);
|
||||
result.add(item);
|
||||
|
||||
for (WorkflowDefinition workflowDef : workflowDefs)
|
||||
{
|
||||
item = new UIListItem();
|
||||
item.setValue(workflowDef.getId());
|
||||
item.setValue(workflowDef.getName());
|
||||
item.setLabel(workflowDef.getTitle());
|
||||
item.setDescription(workflowDef.getDescription());
|
||||
item.setImage(WebResources.IMAGE_WORKFLOW_32);
|
||||
|
@@ -203,14 +203,13 @@ public class CreateWebContentWizard extends BaseContentWizard
|
||||
}
|
||||
|
||||
final NodeRef workflowRef = workflowRefs.get(0).getChildRef();
|
||||
final String workflowId = (String)
|
||||
this.nodeService.getProperty(workflowRef, ContentModel.PROP_WORKFLOW_ID);
|
||||
if (workflowId == null)
|
||||
final String workflowName = (String)this.nodeService.getProperty(workflowRef, ContentModel.PROP_WORKFLOW_NAME);
|
||||
if (workflowName == null)
|
||||
{
|
||||
throw new RuntimeException("no workflow found for form " + formName);
|
||||
}
|
||||
System.err.println("using workflow " + workflowId + " for form " + formName);
|
||||
wd = this.workflowService.getDefinitionById(workflowId);
|
||||
System.err.println("using workflow " + workflowName + " for form " + formName);
|
||||
wd = this.workflowService.getDefinitionByName("jbpm$" + workflowName);
|
||||
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final ContentReader cr = this.contentService.getReader(workflowRef, ContentModel.PROP_WORKFLOWDEFAULTS);
|
||||
|
@@ -237,7 +237,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
|
||||
{
|
||||
WorkflowWrapper workflow = form.getWorkflow();
|
||||
props.clear();
|
||||
props.put(ContentModel.PROP_WORKFLOW_ID, workflow.getId());
|
||||
props.put(ContentModel.PROP_WORKFLOW_NAME, workflow.getName());
|
||||
NodeRef workflowRef = this.nodeService.createNode(formRef,
|
||||
ContentModel.ASSOC_WORKFLOWDEFAULTS,
|
||||
ContentModel.ASSOC_WORKFLOWDEFAULTS,
|
||||
@@ -276,7 +276,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
|
||||
for (WorkflowWrapper workflow : this.workflows)
|
||||
{
|
||||
props.clear();
|
||||
props.put(ContentModel.PROP_NAME, workflow.getId());
|
||||
props.put(ContentModel.PROP_NAME, workflow.getName());
|
||||
NodeRef workflowRef = this.nodeService.createNode(nodeRef,
|
||||
ContentModel.ASSOC_WEBWORKFLOWDEFAULTS,
|
||||
ContentModel.ASSOC_WEBWORKFLOWDEFAULTS,
|
||||
@@ -653,7 +653,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
|
||||
if (index != -1)
|
||||
{
|
||||
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();
|
||||
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;
|
||||
}
|
||||
@@ -918,35 +918,27 @@ public class CreateWebsiteWizard extends BaseWizardBean
|
||||
*/
|
||||
public static class WorkflowWrapper
|
||||
{
|
||||
private String id;
|
||||
private String name;
|
||||
private String title;
|
||||
private String filenamePattern;
|
||||
private QName type;
|
||||
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.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.
|
||||
*/
|
||||
|
@@ -169,7 +169,7 @@ public class FormDetailsDialog extends BaseDialogBean
|
||||
WorkflowWrapper workflow = getActionForm().getWorkflow();
|
||||
if (workflow != null)
|
||||
{
|
||||
this.workflowSelectedValue = new String[] {workflow.getId()};
|
||||
this.workflowSelectedValue = new String[] {workflow.getName()};
|
||||
}
|
||||
}
|
||||
return this.workflowSelectedValue;
|
||||
@@ -231,8 +231,8 @@ public class FormDetailsDialog extends BaseDialogBean
|
||||
}
|
||||
if (this.workflowSelectedValue != null && this.workflowSelectedValue.length != 0)
|
||||
{
|
||||
WorkflowDefinition def = this.workflowService.getDefinitionById(this.workflowSelectedValue[0]);
|
||||
form.setWorkflow(new CreateWebsiteWizard.WorkflowWrapper(def.getId(), def.getTitle()));
|
||||
WorkflowDefinition def = this.workflowService.getDefinitionByName("jbpm$" + this.workflowSelectedValue[0]);
|
||||
form.setWorkflow(new CreateWebsiteWizard.WorkflowWrapper(def.getName(), def.getTitle()));
|
||||
}
|
||||
return outcome;
|
||||
}
|
||||
|
@@ -122,7 +122,7 @@ public class FormWorkflowDialog extends BaseDialogBean
|
||||
if (this.workflowNode == null)
|
||||
{
|
||||
// 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())
|
||||
logger.debug("Selected workflow: "+ flowDef);
|
||||
|
@@ -100,11 +100,11 @@ class FormImpl
|
||||
public WorkflowDefinition getDefaultWorkflow()
|
||||
{
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
final String defaultWorkflowId = (String)nodeService.getProperty(this.folderNodeRef,
|
||||
WCMModel.PROP_DEFAULT_WORKFLOW_ID);
|
||||
final String defaultWorkflowName = (String)nodeService.getProperty(this.folderNodeRef,
|
||||
WCMModel.PROP_DEFAULT_WORKFLOW_NAME);
|
||||
final WorkflowService workflowService = this.getServiceRegistry().getWorkflowService();
|
||||
return (defaultWorkflowId != null
|
||||
? workflowService.getDefinitionById(defaultWorkflowId)
|
||||
return (defaultWorkflowName != null
|
||||
? workflowService.getDefinitionByName("jbpm$" + defaultWorkflowName)
|
||||
: null);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user