package br.mp.mprj.portal.portlet.gestaomensagens.service.service.impl;

import br.mp.mprj.portal.portlet.gestaomensagens.service.model.Mensagem;
import br.mp.mprj.portal.portlet.gestaomensagens.service.model.MensagemWorkflow;
import br.mp.mprj.portal.portlet.gestaomensagens.service.service.base.MensagemWorkflowLocalServiceBaseImpl;

import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;

/**
 * The implementation of the mensagem workflow local service.
 *
 * <p>
 * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link br.mp.mprj.portal.portlet.gestaomensagens.service.service.MensagemWorkflowLocalService} interface.
 *
 * <p>
 * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
 * </p>
 *
 * @author Henrique Simoes
 * @see br.mp.mprj.portal.portlet.gestaomensagens.service.service.base.MensagemWorkflowLocalServiceBaseImpl
 * @see br.mp.mprj.portal.portlet.gestaomensagens.service.service.MensagemWorkflowLocalServiceUtil
 */
public class MensagemWorkflowLocalServiceImpl
    extends MensagemWorkflowLocalServiceBaseImpl {

	
	public void gravarHistoricoWorkflow(Mensagem mensagem)
			throws PortalException, SystemException {
		MensagemWorkflow historico = mensagemWorkflowLocalService.createMensagemWorkflow(CounterLocalServiceUtil.increment());
		
		historico.setMensagemId(mensagem.getMensagemId());
		historico.setComentario(mensagem.getComentarioWorkflow());
		historico.setUserId(mensagem.getUserIdWorkflow());
		historico.setData(mensagem.getDataStatusWorkflow());
		historico.setStatus(mensagem.getStatusWorkflow());
		
		mensagemWorkflowPersistence.update(historico);
	}
}
