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


import com.fp.bpmlib.ProcessUtil;
import com.fp.bpmlib.flow.Monitor;
import com.fp.dto.Response;
import com.fp.dto.query.QueryRequest;
import com.fp.dto.rules.QueryRule;


/**
 * Class TaskHistory encargada de.
 * 
 * @author gfiallos
 */
public class TaskHistory extends QueryRule {

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

    /**
     * Process.
     * 
     * @param pQueryRequest the query request
     * @return query request
     * @throws Exception la exception
     */
    @Override
    public QueryRequest process(QueryRequest pQueryRequest) throws Exception {
        QueryRequest request = pQueryRequest;
        Long pid = pQueryRequest.getLong("PID");
        Long spid = pid;
        try {
            spid = pQueryRequest.getLong("SPID");
        } catch (Exception e) {
            //
        }
        String name = pQueryRequest.getString("NAME");
        Response response = request.getResponse();
        Monitor monitor = new Monitor(pid);
        response.put("DATA",  ProcessUtil.getDoneTaskMetaData(monitor, name));
        return pQueryRequest;
    }

}
