/**
 * OpenCPS is the open source Core Public Services software
 * Copyright (C) 2016-present OpenCPS community
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>
 */


package org.opencps.processmgt.util;

import java.util.ArrayList;
import java.util.List;

import javax.portlet.RenderRequest;

import org.opencps.processmgt.model.ProcessStep;
import org.opencps.processmgt.model.ServiceProcess;
import org.opencps.processmgt.service.ProcessStepLocalServiceUtil;
import org.opencps.processmgt.service.ServiceProcessLocalServiceUtil;

import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.Role;
import com.liferay.portal.model.RoleConstants;
import com.liferay.portal.service.RoleLocalServiceUtil;

/**
 * @author khoavd
 */
public class ProcessUtils {

	/**
	 * @param renderRequest
	 * @return
	 */
	public static List<Role> getRoles(RenderRequest renderRequest) {

		List<Role> roles = new ArrayList<Role>();
		try {
			roles =
			    RoleLocalServiceUtil.getTypeRoles(RoleConstants.TYPE_REGULAR);

		}
		catch (Exception e) {
			return new ArrayList<Role>();
		}

		return roles;
	}
	
	
	/**
	 * Get processName
	 * 
	 * @param serviceProcessId
	 * @return
	 */
	public static String getServiceProcessName(long serviceProcessId) {

		String processName = StringPool.BLANK;

		ServiceProcess process = null;

		try {
			process =
			    ServiceProcessLocalServiceUtil.fetchServiceProcess(serviceProcessId);
		}
		catch (Exception e) {
			return processName;
		}

		if (Validator.isNotNull(process)) {
			processName = process.getProcessName();
		}

		return processName;
	}
	

	/**
	 * @param processStepId
	 * @return
	 */
	public static String getProcessStepName(long processStepId) {

		String stepName = StringPool.BLANK;

		ProcessStep step = null;

		try {
			step = ProcessStepLocalServiceUtil.fetchProcessStep(processStepId);
		}
		catch (Exception e) {
			return stepName;
		}

		if (Validator.isNotNull(step)) {
			stepName = step.getStepName();
		}

		return stepName;
	}

}

@@ -759,17 +759,16 @@
 /%3E%0A */%0A%0A
-%0A
 package 
@@ -882,24 +882,148 @@
 erRequest;%0A%0A
+import org.opencps.dossiermgt.model.DossierTemplate;%0Aimport org.opencps.dossiermgt.service.DossierTemplateLocalServiceUtil;%0A
 import org.o
@@ -1493,62 +1493,733 @@
 il;%0A
-%0A/**%0A * @author khoavd%0A */%0Apublic class ProcessUtils %7B
+import com.liferay.portal.service.ServiceContext;%0Aimport com.liferay.portal.service.ServiceContextFactory;%0A%0A/**%0A * @author khoavd%0A */%0Apublic class ProcessUtils %7B%0A%09%0A%09/**%0A%09 * Get DossierTemplate by GroupId%0A%09 * %0A%09 * @param renderRequest%0A%09 * @return%0A%09 */%0A%09public static List%3CDossierTemplate%3E getDossierTemplate(%0A%09    RenderRequest renderRequest) %7B%0A%0A%09%09List%3CDossierTemplate%3E dossierTemplates =%0A%09%09    new ArrayList%3CDossierTemplate%3E();%0A%0A%09%09try %7B%0A%09%09%09ServiceContext context =%0A%09%09%09    ServiceContextFactory.getInstance(renderRequest);%0A%0A%09%09%09dossierTemplates = DossierTemplateLocalServiceUtil.getDossierTemplatesByGroupId(context.getScopeGroupId());%0A%0A%09%09%7D%0A%09%09catch (Exception e) %7B%0A%09%09%09return dossierTemplates;%0A%09%09%7D%0A%0A%09%09return dossierTemplates;%0A%09%7D
 %0A%0A%09/

Update ProcessUtil