大家好我有一個自定義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工作流程
嗨感謝演示LiferayWorkFlowPortlet它與我的工作流程kaleo工作。在我的自定義portlet中執行相同的操作,但工作流任務中不顯示任何內容。數據submited立即顯示de view.jsp。 jsp視圖提供了一個從輸入oganizationTypeName並顯示插入的所有organizationTypeName的列表。在jsp視圖上顯示之前,我所提交的數據應該由工作流限定:這不是de case。在eclipse控制檯中沒有任何問題。請幫我調試我的項目 – 2014-10-29 10:43:42
一切正常問題出在addOrganizationType方法 – 2014-10-31 04:18:32