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

import com.fp.common.helper.Constant;
import com.fp.dto.rules.TransactionRule;
import com.fp.dto.save.SaveRequest;
import com.fp.persistence.pgeneral.safe.TsafeUserDetail;

// TODO: Auto-generated Javadoc
/**
 * Class AddUsers encargada de.
 * 
 * @author gfiallos
 */
public class AddUsers extends TransactionRule {

    /** serialVersionUID. */
    private static final long serialVersionUID = 1L;

    /**
     * Normal process.
     * 
     * @param pSaveRequest the save request
     * @return save request
     * @throws Exception la exception
     */
    @Override
    public SaveRequest normalProcess(SaveRequest pSaveRequest) throws Exception {
        TsafeUserDetail tsafeUserDetail = (TsafeUserDetail) pSaveRequest.getSaveBeanModifiedObject("TSAFEUSERDETAIL");
        if (tsafeUserDetail == null) {
            tsafeUserDetail = (TsafeUserDetail) pSaveRequest.getSaveBeanModifiedObject("USERDETAIL");
        }
        if (tsafeUserDetail == null) {
            return pSaveRequest;
        }
        String isuserbpm = tsafeUserDetail.getIsuserbpm();
        if (Constant.ifYes(isuserbpm)) {
            try {
                //TaskServerSingleton.getInstance().getDaemon().addUser(tsafeUserDetail.getPk().getUsercode());
            } catch (Exception e) {
                //
            }
        }
        return pSaveRequest;
    }

    /**
     * Reverse process.
     * 
     * @param pSaveRequest the save request
     * @return save request
     * @throws Exception la exception
     */
    @Override
    public SaveRequest reverseProcess(SaveRequest pSaveRequest) throws Exception {

        return pSaveRequest;
    }

}
