/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.fp.general.templates.query;

import com.fp.dto.query.QueryRequest;
import com.fp.dto.rules.QueryRule;
import com.fp.persistence.commondb.PersistenceHelper;
import com.fp.persistence.pgeneral.message.TgeneMessageTemplatesDesc;
import com.fp.persistence.pgeneral.message.TgeneMessageTemplatesDescKey;

/**
 *
 * @author BPTWPA
 */
public class QueryTemplates extends QueryRule{

    @Override
    public QueryRequest process(QueryRequest pQueryRequest) throws Exception {
        Integer code = Integer.valueOf(pQueryRequest.getString("code"));
        String languaje=pQueryRequest.getString("languaje");
        TgeneMessageTemplatesDesc templates = TgeneMessageTemplatesDesc.find(PersistenceHelper.getEntityManager(), 
                (new TgeneMessageTemplatesDescKey(code, languaje)));
        pQueryRequest.getResponse().put("description", (templates==null)?"":templates.getDescription());
        pQueryRequest.getResponse().put("template", (templates==null)?"":templates.getTemplate());
        return pQueryRequest;
    }
}
