/*
 *
 */
package com.fp.bpmlib;

import com.fp.common.helper.Constant;
import com.fp.common.logger.APPLogger;
import com.fp.dto.save.SaveRequest;
import com.fp.persistence.commondb.PersistenceHelper;
import com.fp.persistence.commondb.helper.FormatDates;
import com.fp.persistence.pbpm.gene.TbpmProcessInstance;


/**
 * Class RegisterFlow encargada de.
 * 
 * @author jvaca
 * @version 2.1
 */
public class RegisterFlow  {


    /** El valor de process. */
    private Flujo flujo;

    /** El valor de request. */
    private SaveRequest request;


    /**
     * Crea una nueva instancia de register flow.
     * 
     * @param pProcess the process
     * @param pRequest the request
     * @param pCompany the company
     * @throws Exception la exception
     */
    public RegisterFlow(Flujo flujo, SaveRequest pRequest) throws Exception {
        this.flujo = flujo;
        this.request = pRequest;
    }



    /**
     * Register flow.
     * 
     * @throws Exception la exception
     */
    public void registerFlow() throws Exception {
        APPLogger.getLogger().info("registro Instancia de Flujo");
        TbpmProcessInstance pi = new TbpmProcessInstance(this.request.getJournalId(), this.flujo.getKiesession().getId(), FormatDates.getInstance()
                .getDataBaseDate());
        pi.setProcessid(this.flujo.getProcessInstance().getId());
        pi.setFinalized(Constant.STR_N);
        PersistenceHelper.persist(pi);
        APPLogger.getLogger().info("Graba Instancia de Flujo " + pi.getProcessid());

    }



}