自定义portlet中的Kaleo工作流程

时间:2013-07-25 08:54:23

标签: workflow liferay portlet

在自定义portlet Liferay 6.1.1 GA2中创建kaleo工作流程的步骤。

您好, 我是liferay的新手。我正在使用Liferay 6.1.1 GA2版本。有人可以请我提供在自定义portlet中创建工作流程的步骤,其中包含一些可行的示例。

提前致谢。

2 个答案:

答案 0 :(得分:9)

service.xml 中添加有关工作流程portlet的实体。

<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>

你的jsp文件: -

submit button action url = "processAction"

<强>控制器

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);

    }

}

在portlet-name

之后添加liferay-portlet.xml
<workflow-handler>com.xx.RFPWorkflowHandler</workflow-handler>

HTH

答案 1 :(得分:1)

您可以在Liferay 6.2的自定义portlet中找到Kaleo工作流程的代码

https://drive.google.com/file/d/0B9B1NsG0lyx6ZmE0UWJCdjk0Mmc/view?usp=sharing

您可以在Liferay 6.1中找到自定义portlet中Kaleo工作流的代码 http://sourceforge.net/projects/meeralferay/files/LiferayWorkFlowPortlet/

您可以在自定义portlet中找到更具体的Kaleo工作流示例,该示例仅显示已批准的反馈列表。 https://drive.google.com/file/d/0B9B1NsG0lyx6a3ctUERFNENDTUU/view?usp=sharing