04-30-2013 08:52 AM
04-30-2013 08:33 PM
<aspect name="myr:approvable">
<properties>
<property name="myr:workflowName">
<title>Approval Workflow Name</title>
<type>d:text</type>
<default>activiti$myPieceApproval</default>
</property>
<property name="myr:approverAuthority">
<title>Approver Authority</title>
<type>d:text</type>
<default>GROUP_APPROVERS</default>
</property>
</properties>
</aspect>
protected void executeImpl(Action action, NodeRef nodeRef) {
NodeService nodeService = serviceRegistry.getNodeService();
if (nodeService.hasAspect(nodeRef, MyriadModel.ASPECT_APPROVABLE)) {
String workflowName = (String)nodeService.getProperty(nodeRef, MyriadModel.PROP_WORKFLOW_NAME);
// TODO check if group or individual
String groupName = (String)nodeService.getProperty(nodeRef, MyriadModel.PROP_APPROVER_AUTHORITY);
NodeRef approverAuthority = serviceRegistry.getAuthorityService().getAuthorityNodeRef(groupName);
WorkflowService workflowService = serviceRegistry.getWorkflowService();
NodeRef workflowPackage = workflowService.createPackage(null);
QName qname = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
QName.createValidLocalName((String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME)));
nodeService.addChild(workflowPackage, nodeRef, ContentModel.ASSOC_CONTAINS, qname);
Map<QName,Serializable> params = new HashMap<QName,Serializable>();
params.put(WorkflowModel.ASSOC_PACKAGE, workflowPackage);
params.put(WorkflowModel.ASSOC_GROUP_ASSIGNEE, approverAuthority);
params.put(WorkflowModel.PROP_SEND_EMAIL_NOTIFICATIONS, Boolean.TRUE);
params.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "Approval Request: '" + nodeService.getProperty(nodeRef, ContentModel.PROP_NAME) + "'");
params.put(MyriadModel.PROP_SUBMITTER_COMMENTS, action.getParameterValue(PARAM_COMMENTS));
if (action.getParameterValue(PARAM_DUEDATE) != null) {
params.put(WorkflowModel.PROP_WORKFLOW_DUE_DATE, action.getParameterValue(PARAM_DUEDATE));
}
WorkflowDefinition workflowDef = workflowService.getDefinitionByName(workflowName);
workflowService.startWorkflow(workflowDef.getId(), params);
// Now we need to disable the edit and move actions.
// TODO: externalize this to allow for per-client customization of this behavior.
if (nodeService.hasAspect(nodeRef, MyriadModel.ASPECT_DOCUMENT_ACTIONS)) {
nodeService.setProperty(nodeRef, MyriadModel.PROP_HASACTION_EDITCUSTOMIZABLE, Boolean.FALSE);
nodeService.setProperty(nodeRef, MyriadModel.PROP_HASACTION_EDITCUSTOMIZABLE, Boolean.FALSE);
}
}
}
05-02-2013 09:44 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.