/*
 *
 */
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 TaskComplete encargada de completar tareas.
 * 
 * @author gfiallos
 */
public class TaskComments extends TransactionRule {

    /** 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 {
        if (pReq.get(TaskUtil.BPM_TID) == null) {
            return pReq;
        }
        long tid = pReq.getLong(TaskUtil.BPM_TID);
        TaskUtil util = new TaskUtil(tid);
        // util
        try {
            util.comment(pReq.getUser(), pReq.getString(TaskUtil.BPM_OBS));
        } finally {
            util.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;
    }

}
