2014-10-28 106 views
1

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

有添加自定义代码,但是当我运行一个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> 

接下来是我俗organizationImpl类

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

} 

终于在这里是一块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工作流程

回答

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

+0

嗨感谢演示LiferayWorkFlowPortlet它与我的工作流程kaleo工作。在我的自定义portlet中执行相同的操作,但工作流任务中不显示任何内容。数据submited立即显示de view.jsp。 jsp视图提供了一个从输入oganizationTypeName并显示插入的所有organizationTypeName的列表。在jsp视图上显示之前,我所提交的数据应该由工作流限定:这不是de case。在eclipse控制台中没有任何问题。请帮我调试我的项目 – 2014-10-29 10:43:42

+0

一切正常问题出在addOrganizationType方法 – 2014-10-31 04:18:32