Adding workflow in Custom Portlet Module in Liferay DXP

Download Source code : WORKFLOW_IN_CUSTOM_ASSETS_IN_LIFERAY7.zip

Service.xml

<?xml version="1.0"?>

<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_0_0.dtd">

<service-builder package-path="com.feedbackservice">

<namespace>LS</namespace>

<!--<entity data-source="sampleDataSource" local-service="true" name="Foo" 

remote-service="false" session-factory="sampleSessionFactory" table="foo" 

tx-manager="sampleTransactionManager uuid="true""> -->

<entityname="Feedback"uuid="true"local-service="true"

remote-service="false">

<columnname="feedbackId"type="long"primary="true"/>

<columnname="feedbackDate"type="Date"/>

<columnname="feedbackText"type="String"/>

<columnname="feedbackSubject"type="String"/>

<columnname="feedBackStatus"type="int"/>

<columnname="statusByUserId"type="long"/>

<columnname="statusDate"type="Date"/>

<columnname="companyId"type="long"/>

<columnname="groupId"type="long"/>

<columnname="userId"type="long"/>

<order>

<order-columnname="feedbackId"order-by="asc"/>

<order-columnname="feedbackDate"order-by="desc"/>

</order>

<findername="GroupId"return-type="Collection">

<finder-columnname="groupId"/>

</finder>

<findername="CompanyId"return-type="Collection">

<finder-columnname="companyId"/>

</finder>

<findername="feedbackText"return-type="Collection">

<finder-columnname="feedbackText"/>

</finder>

<findername="G_S"return-type="Collection">

<finder-columnname="groupId"/>

<finder-columnname="feedBackStatus"/>

</finder>

<findername="G_S_U"return-type="Collection">

<finder-columnname="groupId"/>

<finder-columnname="feedBackStatus"/>

<finder-columnname="userId"/>

</finder>

<referencepackage-path="com.liferay.portal"entity="User"/>

<referencepackage-path="com.liferay.portlet.asset"entity="AssetEntry"/>

<referencepackage-path="com.liferay.portal"entity="WorkflowDefinitionLink"></reference>

<referencepackage-path="com.liferay.portal"entity="WorkflowInstanceLink"></reference>

</entity>

</service-builder>

init.jsp
</pre>

<!-- Code by Manish Kumar Jaiswal for Liferay DXP / Liferay 7 -->

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>

<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%><%@ taglib uri="http://liferay.com/tld/portlet"prefix="liferay-portlet"%><%@ taglib uri="http://liferay.com/tld/theme"prefix="liferay-theme"%><%@ taglib uri="http://liferay.com/tld/ui"prefix="liferay-ui"%>

<%@ taglib uri="http://liferay.com/tld/security" prefix="liferay-security"%>

<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util"%>

<%@ page import="javax.portlet.PortletPreferences"%>

<%@ page import="com.liferay.portal.kernel.util.Validator"%>

<%@ page import="com.liferay.portal.kernel.util.ParamUtil"%>

<%@ page import="com.liferay.portal.kernel.portlet.PortletPreferencesFactoryUtil"%>

<%@ page import="com.liferay.portal.kernel.util.PortalUtil"%>

<%@ page import="com.liferay.portal.kernel.dao.search.ResultRow"%>

<%@ page import="com.liferay.portal.kernel.util.ParamUtil"%>

<%@ page import="com.liferay.portal.kernel.util.WebKeys"%>

<%@ page import="com.liferay.portal.kernel.model.User"%>

<%@ page import="com.liferay.portal.kernel.service.UserLocalServiceUtil"%>

<%@ page import="javax.portlet.PortletURL"%>

<%@page import="javax.portlet.WindowState"%>

<%@page import="java.text.Format"%>

<%@page import="com.liferay.portal.kernel.util.FastDateFormatFactoryUtil"%>

<%@page import="com.liferay.portal.kernel.util.GetterUtil"%>

<%@page import="com.liferay.portal.kernel.util.StringPool"%>

<%@page import="java.util.*"%>

<%@page import="com.liferay.portal.kernel.util.OrderByComparator"%>
<liferay-theme:defineObjects />

<portlet:defineObjects />
<pre>
view.jsp
</pre>

<!--  Migrated to Liferay 7 / Liferay DXP by  Manish Kumar Jaiswal -->

<!--  ********Author Details******** -->

<!--  Manish Kumar Jaiswal -->

<!--  Email : [email protected] -->

<!--  Cell No:+919990866537 -->

<!--  ********Author Details******** -->

<%@ include file="init.jsp"%>

<% String tabs1 = ParamUtil.getString(request, "tabs1", "Aproved Feedback"); PortletURL portletURL = renderResponse.createRenderURL(); portletURL.setParameter("tabs1", tabs1); %>

<portlet:renderURL var="addFeedBackURL">

<portlet:paramname="mvcPath"value="/auto_feedback_form.jsp"/>

</portlet:renderURL>
<h4>Auto Feedback Workflow</h4>

<a href="<%=addFeedBackURL%>"

style="font-weight: bold; font-size: 18px;">Add New Auto FeedBack</a>
<liferay-ui:tabs names="Aproved Feedback,Pending Feedback"

portletURL="<%=portletURL%>"/>

<c:choose>

<c:whentest='<%=tabs1.equals("Pending Feedback")%>'>
<liferay-util:includepage="/auto_pending_feedback.jsp"

servletContext="<%=application%>"/>

</c:when>

<c:otherwise>
<liferay-util:includepage="/auto_approved_feedback.jsp"

servletContext="<%=application%>"/>

</c:otherwise>

</c:choose>
<pre>

auto_view_feedback.jsp

<!--  Migrated to Liferay 7 / Liferay DXP by  Manish Kumar Jaiswal -->

<!--  ********Author Details******** -->
<!--  Manish Kumar Jaiswal -->
<!--  Email : [email protected] -->
<!--  Cell No:+919990866537 -->
<!--  ********Author Details******** -->

<%@page import="com.feedbackservice.model.Feedback"%>
<%@page import="com.liferay.portal.kernel.workflow.WorkflowConstants"%>
<%@page import="com.feedbackservice.service.FeedbackLocalServiceUtil"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionMessages"%>
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="javax.portlet.ActionRequest"%>
<%@ include file="init.jsp"%>
<% Feedback feedback = null; if (request.getAttribute("feedBackObject") != null) feedback = (Feedback) request.getAttribute("feedBackObject"); %>
<c:if test='<%=feedback != null%>'>
	
<h2><%=feedback.getFeedbackSubject()%></h2>

	
Message:

<div>
		<%=feedback.getFeedbackText()%>
	</div>

</c:if>

auto_pending_feedback.jsp

<!--  Migrated to Liferay 7 / Liferay DXP by  Manish Kumar Jaiswal -->

<!--  ********Author Details******** -->
<!--  Manish Kumar Jaiswal -->
<!--  Email : [email protected] -->
<!--  Cell No:+919990866537 -->
<!--  ********Author Details******** -->

<%@page import="com.liferay.portal.kernel.workflow.WorkflowDefinitionManagerUtil"%>
<%@page import="com.liferay.portal.kernel.workflow.WorkflowHandlerRegistryUtil"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@page import="com.feedbackservice.model.Feedback"%>
<%@page import="com.feedbackservice.service.FeedbackLocalServiceUtil"%>
<%@page import="com.liferay.portal.kernel.workflow.WorkflowConstants"%>
<%@page import="javax.portlet.PortletURL"%>
<%@ include file="init.jsp"%>
<liferay-portlet:renderURL varImpl="iteratorURL">
	<portlet:param name="mvcPath" value="/view_pending_feedback.jsp" />
</liferay-portlet:renderURL>
<liferay-ui:search-container emptyResultsMessage="there-are-no-feedbacks"
	headerNames="FeedBack Subject,Message, Stauts"
	iteratorURL="<%=iteratorURL%>" delta="10" deltaConfigurable="true">
	<liferay-ui:search-container-results>
		<%
			List<Feedback> feedbackList = FeedbackLocalServiceUtil.findByG_S(themeDisplay.getScopeGroupId(),
							WorkflowConstants.STATUS_DRAFT);
// 		List<Feedback> feedbackList = FeedbackLocalServiceUtil.findByG_S_U(themeDisplay.getScopeGroupId(),
// 				WorkflowConstants.STATUS_DRAFT,themeDisplay.getUserId());
					results = ListUtil.subList(feedbackList, searchContainer.getStart(), searchContainer.getEnd());
					searchContainer.setTotal(feedbackList.size());
					searchContainer.setResults(results);
		%>
	</liferay-ui:search-container-results>
	<liferay-ui:search-container-row className="Feedback" keyProperty="feedbackId" modelVar="currentFeedback">
		<liferay-ui:search-container-column-text name="FeedBack Subject" property="feedbackSubject" />
		<liferay-ui:search-container-column-text name="Message" property="feedbackText" />
		<liferay-ui:search-container-column-text name="status"><%=WorkflowConstants.LABEL_PENDING%></liferay-ui:search-container-column-text>
	</liferay-ui:search-container-row>
	<liferay-ui:search-iterator searchContainer="<%=searchContainer%>" />
</liferay-ui:search-container>

auto_feedback_form.jsp

<!--  Migrated to Liferay 7 / Liferay DXP by  Manish Kumar Jaiswal -->

<!--  ********Author Details******** -->
<!--  Manish Kumar Jaiswal -->
<!--  Email : [email protected] -->
<!--  Cell No:+919990866537 -->
<!--  ********Author Details******** -->

<%@page import="com.liferay.portal.kernel.servlet.SessionErrors"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionMessages"%>
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="javax.portlet.ActionRequest"%>
<%@ include file="init.jsp"%>
<portlet:actionURL var="submitAutoFeedback"
	windowState="<%=LiferayWindowState.NORMAL.toString()%>"
	name="submitAutoFeedback">
</portlet:actionURL>
<a href="<portlet:renderURL />">«Home</a>

<div class="separator"></div>


<fieldset>

<legend>Auto Feedback Form</legend>

	<c:if
		test='<%=SessionMessages.contains(renderRequest, "feedback-submit-success")%>'>
		<liferay-ui:success key="feedback-submit-success" message="Feedback has been submited successfully." />
	</c:if>
	<c:if
		test='<%=SessionMessages.contains(renderRequest, "workflow-not-enabled")%>'>
		<liferay-ui:success key="workflow-not-enabled" message="Feedback not enabled with workflow please enable workflow." />
	</c:if>
	<c:if
		test='<%=SessionErrors.contains(renderRequest, "feedback-submit-failed")%>'>
		<liferay-ui:success key="feedback-submit-failed" message="There is problem of submit feedback please try again.." />
	</c:if>
	<aui:form action="<%=submitAutoFeedback%>" method="post"
		name="feedbackForm">

		<aui:input label="Feedback Subject" name="feedbackSubject" id="feedbackSubject" type="text" style="width:600px;height:50px;">
			<aui:validator name="required" />
		</aui:input>



		<aui:input name="feedbackMessage" id="feedbackMessage" label="Feedback Message" type="textarea" style="width:600px;height:100px;">
			<aui:validator name="required" />
		</aui:input>
		
		<span style="float: left;">Characters Left </span>
		

textCounter">

	
 

				<aui:button type="submit" value="Submit Feedback" name="submit"></aui:button>

	</aui:form>
</fieldset>

<aui:script>
	AUI().use('aui-char-counter', function(A) {
		new A.CharCounter({
			counter : '#<portlet:namespace/>textCounter',
			input : '#<portlet:namespace/>feedbackMessage',
			maxLength : 75,
			on : {
				maxLength : function(event) {
					alert('The max length limit was reached');
				}
			}
		});
	});
</aui:script>

auto_approved_feedback.jsp

<!--  Migrated to Liferay 7 / Liferay DXP by  Manish Kumar Jaiswal -->

<!--  ********Author Details******** -->
<!--  Manish Kumar Jaiswal -->
<!--  Email : [email protected] -->
<!--  Cell No:+919990866537 -->
<!--  ********Author Details******** -->

<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@page import="com.feedbackservice.model.Feedback"%>
<%@page import="com.liferay.portal.kernel.workflow.WorkflowConstants"%>
<%@page import="com.feedbackservice.service.FeedbackLocalServiceUtil"%>
<%@page import="javax.portlet.PortletURL"%>
<%@ include file="init.jsp"%>
<liferay-portlet:renderURL varImpl="iteratorURL">
	<portlet:param name="mvcPath" value="/view_approved_feedback.jsp" />
</liferay-portlet:renderURL>
<liferay-ui:search-container emptyResultsMessage="there-are-no-feedbacks"
	headerNames="FeedBack Subject,Message, Stauts"
	iteratorURL="<%=iteratorURL%>" delta="10" deltaConfigurable="true">
	<liferay-ui:search-container-results>
		<%
			List<Feedback> feedbackList = FeedbackLocalServiceUtil.findByG_S(themeDisplay.getScopeGroupId(),
							WorkflowConstants.STATUS_APPROVED);
					results = ListUtil.subList(feedbackList, searchContainer.getStart(), searchContainer.getEnd());
					searchContainer.setTotal(feedbackList.size());
					searchContainer.setResults(results);
		%>
	</liferay-ui:search-container-results>
	<liferay-ui:search-container-row className="Feedback" keyProperty="feedbackId" modelVar="currentFeedback">
		<liferay-ui:search-container-column-text name="FeedBack Subject" property="feedbackSubject" />
		<liferay-ui:search-container-column-text name="Message" property="feedbackText" />
		<liferay-ui:search-container-column-text name="status"><%=WorkflowConstants.LABEL_APPROVED%></liferay-ui:search-container-column-text>
	</liferay-ui:search-container-row>
	<liferay-ui:search-iterator searchContainer="<%=searchContainer%>" />
</liferay-ui:search-container>

AutoUserFeedbackPortlet.java

package com.feedback.portlet;

import com.feedbackservice.model.Feedback;
import com.feedbackservice.service.FeedbackLocalServiceUtil;
import com.liferay.asset.kernel.service.AssetEntryLocalServiceUtil;
import com.liferay.counter.kernel.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.NoSuchWorkflowDefinitionLinkException;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.model.WorkflowDefinitionLink;
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextFactory;
import com.liferay.portal.kernel.service.WorkflowDefinitionLinkLocalServiceUtil;
import com.liferay.portal.kernel.servlet.SessionErrors;
import com.liferay.portal.kernel.servlet.SessionMessages;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.kernel.workflow.WorkflowHandlerRegistryUtil;

import java.io.IOException;
import java.util.Date;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.Portlet;

import org.osgi.service.component.annotations.Component;

/**
 * Auto UserFeedback Module Migrated to Liferay 7 / Liferay DXP by  Manish Kumar Jaiswal
 * 
 * --------Author Details---------
 * Name:   Manish Kumar Jaiswal
 * Email : [email protected]
 * Cell No:+919990866537
 * --------Author Details---------
 * 
 */
@Component(immediate = true, property = { "com.liferay.portlet.display-category=category.sample",
		"com.liferay.portlet.instanceable=true", "javax.portlet.display-name=UserFeedback Portlet",
		"javax.portlet.init-param.template-path=/", "javax.portlet.init-param.view-template=/view.jsp",
		"javax.portlet.resource-bundle=content.Language",
		"javax.portlet.security-role-ref=power-user,user" }, service = Portlet.class)
public class AutoUserFeedbackPortlet extends MVCPortlet {

	public void submitAutoFeedback(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException,
			com.liferay.portal.kernel.exception.PortalException, com.liferay.portal.kernel.exception.SystemException {
System.out.println("**********************Into submitAutoFeedback***********************");
		ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
		String feedBackMessage = ParamUtil.getString(actionRequest, "feedbackMessage");
		String feedbackSubject = ParamUtil.getString(actionRequest, "feedbackSubject");
		ServiceContext serviceContext = ServiceContextFactory.getInstance(Feedback.class.getName(), actionRequest);
		try {
			// Add the feedback in database
			Feedback feedback = addFeedbackToDatabase(themeDisplay, feedBackMessage, feedbackSubject);
			WorkflowDefinitionLink workflowDefinitionLink = null;
			try {
				// This will provide you the default workflow associated with
				// the asset/portlet
				workflowDefinitionLink = WorkflowDefinitionLinkLocalServiceUtil
						.getDefaultWorkflowDefinitionLink(themeDisplay.getCompanyId(), Feedback.class.getName(), 0, 0);
			} catch (Exception e) {
				if (e instanceof NoSuchWorkflowDefinitionLinkException) {
					SessionMessages.add(actionRequest, "workflow-not-enabled");
				}
				e.printStackTrace();
			}
			// Now add the entry in assets in database and start the workflow
			addToAssetsAndStartWorkflowProcess(actionRequest, themeDisplay, serviceContext, feedback,
					workflowDefinitionLink);
		} catch (Exception e) {
			if (e instanceof NoSuchWorkflowDefinitionLinkException) {
				SessionMessages.add(actionRequest, "workflow-not-enabled");
			}
			e.printStackTrace();
		}
		actionResponse.setRenderParameter("mvcPath", "/auto_feedback_form.jsp");
	}

	private void addToAssetsAndStartWorkflowProcess(ActionRequest actionRequest, ThemeDisplay themeDisplay,
			ServiceContext serviceContext, Feedback feedback, WorkflowDefinitionLink workflowDefinitionLink)
			throws PortalException {
		// checking workflow defintion is enabled to feedback asset or not
		if (feedback != null && workflowDefinitionLink != null) {
			// add feedback asset entry in asset entry table
			AssetEntryLocalServiceUtil.updateEntry(themeDisplay.getUserId(), feedback.getGroupId(),
					Feedback.class.getName(), feedback.getFeedbackId(), serviceContext.getAssetCategoryIds(),
					serviceContext.getAssetTagNames());
			// This code will start workflow instance to feedback.
			WorkflowHandlerRegistryUtil.startWorkflowInstance(feedback.getCompanyId(), feedback.getGroupId(),
					themeDisplay.getUserId(), Feedback.class.getName(), feedback.getPrimaryKey(), feedback,
					serviceContext);
		}
		if (feedback == null) {
			SessionErrors.add(actionRequest, "feedback-submit-failed");
		} else {
			SessionMessages.add(actionRequest, "feedback-submit-success");
		}
	}

	private Feedback addFeedbackToDatabase(ThemeDisplay themeDisplay, String feedBackMessage, String feedbackSubject) {
		Feedback feedback = FeedbackLocalServiceUtil.createFeedback(CounterLocalServiceUtil.increment());
		feedback.setCompanyId(themeDisplay.getCompanyId());
		feedback.setGroupId(themeDisplay.getScopeGroupId());
		feedback.setFeedbackDate(new Date());
		feedback.setFeedbackText(feedBackMessage);
		feedback.setFeedbackSubject(feedbackSubject);
		feedback.setFeedBackStatus(WorkflowConstants.STATUS_DRAFT);
		feedback.setUserId(themeDisplay.getUserId());
		feedback.setStatusByUserId(themeDisplay.getUserId());
		// Adds the feedback to the database. Also notifies the appropriate
		// model listeners.
		feedback = FeedbackLocalServiceUtil.addFeedback(feedback);
		return feedback;
	}
}

FeedbackAssetRenderer.java

package com.feedback.portlet;

import java.util.Locale;

import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.feedbackservice.model.Feedback;
import com.liferay.asset.kernel.model.BaseAssetRenderer;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.service.UserLocalServiceUtil;

/**
 * Migrated to Liferay 7 / Liferay DXP by  Manish Kumar Jaiswal
 * 
 * --------Author Details---------
 * Name:   Manish Kumar Jaiswal
 * Email : [email protected]
 * Cell No:+919990866537
 * --------Author Details---------
 * 
 */
public class FeedbackAssetRenderer extends BaseAssetRenderer<Feedback> {

	private Feedback _feedback;

	public FeedbackAssetRenderer(Feedback feedback) {
		_feedback = feedback;
	}

	public long getClassPK() {
		return _feedback.getFeedbackId();
	}

	public long getGroupId() {
		return _feedback.getGroupId();
	}

	public String getSummary(Locale arg0) {
		return _feedback.getFeedbackText();
	}

	public String getTitle(Locale arg0) {
		return _feedback.getFeedbackSubject();
	}

	public long getUserId() {
		return _feedback.getUserId();
	}

	public String getUuid() {
		return _feedback.getUuid();
	}

	public String render(RenderRequest request, RenderResponse response, String template) throws Exception {
		if (template.equals(TEMPLATE_FULL_CONTENT)) {
			request.setAttribute("feedBackObject", _feedback);
			return "/auto_view_feedback.jsp";
		} else {
			return null;
		}
	}

	@Override
	public String getUserName() {
		// TODO Auto-generated method stub
		String userName = null;
		try {
			userName = UserLocalServiceUtil.getUser(_feedback.getUserId()).getFullName();
		} catch (PortalException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SystemException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return userName;
		}
		return userName;
	}

	@Override
	public String getClassName() {
		// TODO Auto-generated method stub
		return Feedback.class.getName();
	}

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

	@Override
	public String getSummary(PortletRequest portletRequest, PortletResponse portletResponse) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean include(HttpServletRequest request, HttpServletResponse response, String template) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}
}

FeedbackAssetRendererFactory.java

package com.feedback.portlet;

import org.osgi.service.component.annotations.Component;

import com.feedbackservice.model.Feedback;
import com.feedbackservice.service.FeedbackLocalServiceUtil;
import com.liferay.asset.kernel.model.AssetRenderer;
import com.liferay.asset.kernel.model.AssetRendererFactory;
import com.liferay.asset.kernel.model.BaseAssetRendererFactory;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;

/**
 * Migrated to Liferay 7 / Liferay DXP by  Manish Kumar Jaiswal
 * 
 * --------Author Details---------
 * Name:   Manish Kumar Jaiswal
 * Email : [email protected]
 * Cell No:+919990866537
 * --------Author Details---------
 * 
 */

@Component(immediate = true, property = {
		"javax.portlet.name=" + "com_feedback_portlet_UserFeedbackPortlet" }, service = AssetRendererFactory.class)
public class FeedbackAssetRendererFactory extends BaseAssetRendererFactory<Feedback> {
	@Override
	public AssetRenderer<Feedback> getAssetRenderer(long classPK, int type) throws PortalException, SystemException {
		Feedback feedback = FeedbackLocalServiceUtil.getFeedback(classPK);
		return new FeedbackAssetRenderer(feedback);
	}

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

	@Override
	public String getType() {
		return TYPE;
	}

	public static final String TYPE = "Feedback";
	public static final String CLASS_NAME = Feedback.class.getName();
}

FeedbackWorkflowHandler.java

package com.feedback.portlet;

import java.io.Serializable;
import java.util.Date;
import java.util.Locale;
import java.util.Map;

import org.osgi.service.component.annotations.Component;

import com.feedbackservice.model.Feedback;
import com.feedbackservice.service.FeedbackLocalServiceUtil;
import com.liferay.asset.kernel.service.AssetEntryLocalServiceUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.workflow.BaseWorkflowHandler;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.kernel.workflow.WorkflowHandler;
/**
 * Migrated to Liferay 7 / Liferay DXP by  Manish Kumar Jaiswal
 * 
 * --------Author Details---------
 * Name:   Manish Kumar Jaiswal
 * Email : [email protected]
 * Cell No:+919990866537
 * --------Author Details---------
 * 
 */


@Component(
property = {"model.class.name=com.feedbackservice.model.Feedback"},
service = WorkflowHandler.class
)
public class FeedbackWorkflowHandler extends BaseWorkflowHandler<Feedback>{
	 
    public String getClassName() {
        return CLASS_NAME;
    }
 
    public String getType(Locale locale) {
        return "Feedback";
    }
 
    public  Feedback updateStatus(int status,
            Map<String, Serializable> workflowContext) throws PortalException,
            SystemException {
        long userId = GetterUtil.getLong(workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
        long resourcePrimKey = GetterUtil.getLong(workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
        Feedback feedback = FeedbackLocalServiceUtil.getFeedback(resourcePrimKey);
        feedback.setFeedBackStatus(status);
        feedback.setStatusByUserId(userId);
        feedback.setStatusDate(new Date());
        feedback=FeedbackLocalServiceUtil.updateFeedback(feedback);
        if (status == WorkflowConstants.STATUS_APPROVED) {
            AssetEntryLocalServiceUtil.updateVisible(Feedback.class.getName(),
                    resourcePrimKey, true);
        } else {
        	AssetEntryLocalServiceUtil.updateVisible(Feedback.class.getName(),
                    resourcePrimKey, false);
        }
        return feedback;
    }
 
    public static final String CLASS_NAME = Feedback.class.getName();

}