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

import com.fp.bpmlib.task.client.TaskUtil;
import com.fp.dto.rules.TransactionRule;
import com.fp.dto.save.SaveRequest;

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

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

    /**
     * Normal process.
     * 
     * @param pReq the req
     * @return save request
     * @throws Exception la exception
     */
    @Override
    public SaveRequest normalProcess(SaveRequest pReq) throws Exception {
        Long tid = pReq.getLong(TaskUtil.BPM_TID);
        TaskUtil t = new TaskUtil(tid);
        try {
            t.delegate(pReq.getUser());
        } finally {
            t.close();
        }
        return pReq;
    }

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

}
