package com.fp.bpmlib.query.rules;

import java.util.List;

import com.fp.dto.rules.TransactionRule;
import com.fp.dto.save.SaveRequest;
import com.fp.persistence.pbpm.gene.TbpmRules;

/**
 * Clase que se encarga de refrescar la base de conocimiento dado un registro de tbpmrules.
 *
 * @author Jorge Vaca.
 * @version 2.1
 */
@SuppressWarnings("serial")
public class RefreshKnowledgeBase extends TransactionRule {

    @Override
    public SaveRequest normalProcess(SaveRequest pSaveRequest) throws Exception {
        if(pSaveRequest.get("refresh") == null){
            return pSaveRequest;
        }
        List<Object> ldata =  pSaveRequest.getSaveBeanModifiedRecords("TBPMRULES");
        TbpmRules obj = (TbpmRules)ldata.get(0);
        //KnowledgeBaseHelper kh = new KnowledgeBaseHelper();
        //kh.refreshKnowledgeBase(obj);
        pSaveRequest.remove("TBPMRULES");
        return pSaveRequest;
    }

    @Override
    public SaveRequest reverseProcess(SaveRequest pSaveRequest)	throws Exception {
        return pSaveRequest;
    }

}
