Steps to create kaleo workflow in custom portlet Liferay 6.1.1 GA2.
Hi,
I am new to liferay. I am using Liferay 6.1.1 GA2 version. Can somebody please provide me the steps to create workflow in custom portlets with some workable samples.
Thanks in advance.
Add entity in service.xml regarding your workflow portlet.
i.e
<entity name="XXWorkflow" local-service="true" remote-service="false">
<!-- PK fields -->
<column name="workflowId" type="long" primary="true" />
<!-- Foreign key columns -->
<column name="XXd" type="long" />
<column name="companyId" type="long" />
<column name="groupId" type="long" />
<column name="userId" type="long"/>
<!-- Workflow fields -->
<!-- Resource -->
<column name="resourcePrimKey" type="long"></column>
<column name="title" type="String"></column>
<column name="status" type="int"></column>
<column name="statusByUserId" type="long"></column>
<column name="statusByUserName" type="String"></column>
<column name="statusDate" type="Date"></column>
<!-- Finder methods -->
<finder name="ResourcePrimKey" return-type="RfpWorkflow">
<finder-column name="resourcePrimKey"></finder-column>
</finder>
<finder name="Status" return-type="Collection">
<finder-column name="status"></finder-column>
</finder>
<finder name="R_S" return-type="RfpWorkflow">
<finder-column name="resourcePrimKey"></finder-column>
<finder-column name="status"></finder-column>
</finder>
<!-- end of workflow columns and finders -->
<finder return-type="Collection" name="XXId">
<finder-column name="XXId"></finder-column>
</finder>
<reference package-path="com.liferay.portal" entity="WorkflowInstanceLink"></reference>
<reference package-path="com.liferay.portlet.asset" entity="AssetEntry"></reference>
<reference package-path="com.liferay.portlet.social" entity="SocialActivity"></reference>
</entity>
your jsp file:-
submit button action url = "processAction"
Controller
public void processAction(ActionRequest request, ActionResponse response)
throws Exception {
//do your required stuff
workflowInitiation(request,response,XX.getXXId(),XX.getXXName());
}
public void workflowInitiation(ActionRequest actionRequest,
ActionResponse actionResponse,long XXId,String XXName) throws IOException, PortletException {
// TODO Auto-generated method stub
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest
.getAttribute(WebKeys.THEME_DISPLAY);
System.out.println("Title : " + XXName);
XXWorkflowImpl xxWorkflow = new XXWorkflowImpl();
XXWorkflow.setTitle(xxName);
XXWorkflow.setxxId(xxpId);
XXWorkflow.setCompanyId(themeDisplay.getCompanyId());
XXWorkflow.setGroupId(themeDisplay.getScopeGroupId());
ThemeDisplay themeDisplay1 = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
ServiceContext serviceContext;
try {
serviceContext = ServiceContextFactory.getInstance(XXPortlet.class.getName(), actionRequest);
XXWorkflowLocalServiceUtil.addXXWorkflow(XXWorkflow,serviceContext, themeDisplay1.getUserId());
} catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
}
}
Hanlder Class
public class XXWorkflowHandler extends BaseWorkflowHandler {
public static final String CLASS_NAME = XXWorkflow.class.getName();
public String getClassName() {
return CLASS_NAME;
}
public String getType(Locale locale) {
return LanguageUtil.get(locale, "model.resource." + CLASS_NAME);
}
public Object updateStatus(int status,Map<String, Serializable> workflowContext) throws PortalException,
SystemException {
long userId = GetterUtil.getLong((String) workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
long resourcePrimKey = GetterUtil.getLong((String) workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
ServiceContext serviceContext = (ServiceContext) workflowContext.get("serviceContext");
return RfpWorkflowLocalServiceUtil.updateStatus(userId, resourcePrimKey,status, serviceContext);
}
}
Add in your liferay-portlet.xml after portlet-name
<workflow-handler>com.xx.RFPWorkflowHandler</workflow-handler>
HTH
You can find code for Kaleo workflow in custom portlet here for Liferay 6.2
https://drive.google.com/file/d/0B9B1NsG0lyx6ZmE0UWJCdjk0Mmc/view?usp=sharing
You can find code for Kaleo workflow in custom portlet here for Liferay 6.1
http://sourceforge.net/projects/meeralferay/files/LiferayWorkFlowPortlet/
You can find more specific example for Kaleo workflow in custom portlet which will show only approved feedback list.
https://drive.google.com/file/d/0B9B1NsG0lyx6a3ctUERFNENDTUU/view?usp=sharing