集成工作流在liferay自定义portlet中不起作用

时间:2014-10-28 10:34:10

标签: model-view-controller liferay workflow portlet

大家好,我在服务构建器中提供了一个带有单个表的自定义portlet。我想整合工作流程,以便在表格中插入行应该通过kaleo工作流程,所以我没有找到一个清晰的教程,除了一个http://liferayzone.wordpress.com/2013/11/29/kaleo-workflow-configuration-for-custom-portlet-in-liferay-6-1/

添加了自定义代码但是当我运行一个instert项目时,它会显示在一个jsp上,列出所有插入的项目。工作流程集成没有在我的工作流程任务中显示任何内容。在此之前,我在控制面板中为已部署的portlet启用了Workflow。

这是我的服务构建器实体

<author>Cooder</author>
    <namespace>sem</namespace>
    <entity name="OrganizationType" local-service="true" uuid="true">
        <column name="organizationTypeId" primary="true" type="long"></column>
        <column name="organizationTypeName" type="String"></column>
        <column name="userId" type="long"></column>
        <column name="companyId" type="long"></column>
        <column name="groupId" type="long"></column>
        <column name="createDate" type="Date"></column>
        <column name="modifiedDate" type="Date"></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>
        <order by="asc">
            <order-column name="createDate" order-by="desc"></order-column>
        </order>
        <finder name="OrganizationTypeName" return-type="Collection">
            <finder-column name="organizationTypeName"></finder-column>
        </finder>
        <finder name="GroupId" return-type="Collection">
            <finder-column name="groupId"></finder-column>
        </finder>
        <finder name="CompanyId" return-type="Collection">
            <finder-column name="companyId"></finder-column>
        </finder>
        <finder name="G_S" return-type="Collection">
            <finder-column name="groupId"></finder-column>
            <finder-column name="status"></finder-column>
        </finder>
        <reference package-path="com.liferay.portal" entity="User"></reference>
        <reference package-path="com.liferay.portlet.asset" entity="AssetEntry"></reference>
    </entity>

接下来是我的custum organizationImpl class

public class OrganizationTypeLocalServiceImpl
    extends OrganizationTypeLocalServiceBaseImpl {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never reference this interface directly. Always use {@link sem.service.service.OrganizationTypeLocalServiceUtil} to access the organization type local service.
     */

    public OrganizationType addOrganizationType(long userId, String organizationTypeName, ServiceContext serviceContext) throws PortalException, SystemException{
        User user = userPersistence.findByPrimaryKey(userId);
        long organizationTypeId = counterLocalService.increment(OrganizationType.class.getName());
        OrganizationType organizationType = organizationTypePersistence.create(organizationTypeId);
        Date now = new Date();

        organizationType.setGroupId(user.getGroupId());
        organizationType.setCompanyId(user.getCompanyId());
        organizationType.setUserId(user.getUserId());
        organizationType.setStatus(WorkflowConstants.STATUS_DRAFT);
        organizationType.setCreateDate(serviceContext.getCreateDate(now));
        //organizationType.setModifiedDate(serviceContext.getModifiedDate(now));

        organizationType.setOrganizationTypeName(organizationTypeName);

        //super.addOrganizationType(organizationType);
        organizationTypePersistence.update(organizationType, false);

        assetEntryLocalService.updateEntry(
                serviceContext.getUserId(), 
                serviceContext.getScopeGroupId(),
                OrganizationType.class.getName(),
                organizationType.getOrganizationTypeId(),
                serviceContext.getAssetCategoryIds(),
                serviceContext.getAssetTagNames());

        WorkflowHandlerRegistryUtil.startWorkflowInstance(
                organizationType.getCompanyId(),
                organizationType.getGroupId(),
                organizationType.getUserId(), 
                OrganizationType.class.getName(),
                organizationType.getPrimaryKey(),
                organizationType, serviceContext);

        /*resourceLocalService.addResources(organizationType.getCompanyId(), 
                organizationType.getGroupId(),
                organizationType.getUserId(),
                OrganizationType.class.getName(),
                organizationType.getOrganizationTypeId(),
                false,
                true,
                true);*/

        return organizationType;
    }

    public OrganizationType updateMyOrganizationType(long userId, long organizationTypeId, String organizationTypeName, ServiceContext serviceContext) throws PortalException, SystemException{

        User user = userPersistence.findByPrimaryKey(userId);
        Date now = new Date();

        OrganizationType orgType = OrganizationTypeLocalServiceUtil.fetchOrganizationType(organizationTypeId);

        orgType.setModifiedDate(serviceContext.getModifiedDate(now));
        orgType.setGroupId(user.getGroupId());
        orgType.setCompanyId(user.getCompanyId());
        orgType.setUserId(user.getUserId());
        orgType.setOrganizationTypeName(organizationTypeName);

        super.updateOrganizationType(orgType);

        return orgType;
    }

    public OrganizationType getOrganizationType(long organizationTypeId) throws PortalException, SystemException{
        return organizationTypePersistence.findByPrimaryKey(organizationTypeId);
    }
    public List<OrganizationType> getOrganizationTypeAll() throws SystemException{
        return organizationTypePersistence.findAll();
    }

    public OrganizationType deleteOrganizationType(OrganizationType organizationType) throws SystemException, PortalException{
        assetEntryLocalService.deleteEntry(OrganizationType.class.getName(), organizationType.getOrganizationTypeId());
        return organizationTypePersistence.remove(organizationType);
    }

    public OrganizationType deleteOrganizationType(long organizationTypeId) throws PortalException, SystemException{
        OrganizationType orgType = organizationTypePersistence.findByPrimaryKey(organizationTypeId);
        return deleteOrganizationType(orgType);
    }

    public OrganizationType updateStatus(
            long userId,
            long resourcePrimKey,
            int status,
            ServiceContext serviceContext) throws SystemException, PortalException{
        User user = UserLocalServiceUtil.getUser(userId);
        OrganizationType orgType = OrganizationTypeLocalServiceUtil.getOrganizationType(resourcePrimKey);
        orgType.setStatus(status);
        orgType.setStatusByUserId(userId);
        orgType.setStatusByUserName(user.getFullName());
        orgType.setStatusDate(serviceContext.getModifiedDate());
        organizationTypePersistence.update(orgType, false);
        if(status == WorkflowConstants.STATUS_APPROVED){
            assetEntryLocalService.updateVisible(OrganizationType.class.getName(), resourcePrimKey, true);
        }
        else{
            assetEntryLocalService.updateVisible(OrganizationType.class.getName(), resourcePrimKey, true);
        }
        return orgType;
    }
}

接下来是我的AssetRendererFactory

public class RendererFactoryOrganizationTypeAsset extends BaseAssetRendererFactory{

    @Override
    public AssetRenderer getAssetRenderer(long classPK, int type)
            throws PortalException, SystemException {
        OrganizationType organizationType = OrganizationTypeLocalServiceUtil.getOrganizationType(classPK);
        return new AssetRendererOrganizationType(organizationType);
    }

    @Override
    public String getClassName() {
        return OrganizationType.class.getName();
    }

    @Override
    public String getType() {
        return "article";
    }

}

接下来是我的AssetRenderer

public class AssetRendererOrganizationType extends BaseAssetRenderer{

    private OrganizationType _organizationType;
    @Override
    public long getClassPK() {
        return _organizationType.getOrganizationTypeId();
    }

    @Override
    public long getGroupId() {
        return _organizationType.getGroupId();
    }

    @Override
    public String getSummary(Locale arg0) {
        return _organizationType.getOrganizationTypeName();
    }

    @Override
    public String getTitle(Locale arg0) {
        return "Organization type context entry";
    }

    @Override
    public long getUserId() {
        return _organizationType.getUserId();
    }

    @Override
    public String getUserName() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String getUuid() {
        return _organizationType.getUuid();
    }

    @Override
    public String render(RenderRequest request, RenderResponse response, String template)
            throws Exception {
        if (template.equals(TEMPLATE_FULL_CONTENT)) {
            return "/html/organizationType.jsp";
        }
        else
        {
            return null;
        }
    }

    public AssetRendererOrganizationType(OrganizationType _organizationType) {
        super();
        this._organizationType = _organizationType;
    }

}

接下来是我的WorkflowHandler

public class WorkflowHandlerOrganizationType extends BaseWorkflowHandler{

    public static final String CLASS_NAME = OrganizationType.class.getName();

    @Override
    public String getClassName() {
        return CLASS_NAME;
    }

    @Override
    public String getType(Locale locale) {
        return LanguageUtil.get(locale, "model.resource.", CLASS_NAME);
    }

    @Override
    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 OrganizationTypeLocalServiceUtil.updateStatus(userId, resourcePrimKey, status, serviceContext);
    }

}

finally这是liferay-portlet部署描述符

<portlet>
        <portlet-name>SearchEngineManager</portlet-name>
        <icon>/icon.png</icon>
        <asset-renderer-factory>sem.RendererFactoryOrganizationTypeAsset</asset-renderer-factory>
        <workflow-handler>sem.WorkflowHandlerOrganizationType</workflow-handler>
        <header-portlet-css>/css/main.css</header-portlet-css>
        <footer-portlet-javascript>
            /js/main.js
        </footer-portlet-javascript>
        <css-class-wrapper>
            searchenginemanager-portlet
        </css-class-wrapper>
    </portlet>

请帮我弄清楚缺少什么。我在liferay 6.1 GA3中使用MVCPorltet和Kaleo工作流程

1 个答案:

答案 0 :(得分:0)

您没有添加任何错误日志,因此很难找到错误。你为什么不尝试这两个链接

http://www.cignex.com/articles/applying-advanced-workflow-custom-assets-liferay-6 https://www.liferay.com/community/forums/-/message_boards/message/11117796

你也可以在这里找到一个示例项目。

https://sourceforge.net/projects/meeralferay/files/LiferayWorkFlowPortlet/

您希望使用工作流处理组织实体。但是您已经在cm.egov.cameroon.sem.service.service.impl.OrganizationTypeLocalServiceImpl.addOrganizationType(long, String, ServiceContext

中实现了工作流级服务

取代

cm.egov.cameroon.sem.service.service.impl.OrganizationLocalServiceImpl.addOrganization(String, String, long, ServiceContext).