package com.fp.armas.mail;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fp.simple.maia.MailRecipient;

/**
 * Clase que se encarga de objener el email de una persona.
 * 
 * @version 2.1
 */
public class SolicitanteDireccion extends MailRecipient {

    /*
     * (non-Javadoc)
     * 
     * @see com.fp.simple.maia.MailRecipient#getEmailAddress(java.lang.Object)
     */
    @SuppressWarnings("unchecked")
    @Override
    public Map<String, Object> getEmailAddress(Object pParam) throws Exception {
        List<String> lemail = new ArrayList<String>();
        Map<String, Object> mresp = new HashMap<String, Object>();
//        HashMap<String, Object> m = (HashMap<String, Object>) pParam;
//        Map<String, Object> mrequest = (Map<String, Object>) m.get("request");
//        if (mrequest.get("csolicitud") == null) {
//            return mresp;
//        }
//        String solicitud = (String) mrequest.get("csolicitud");
//        TarmSolicitud tarmsolicitud=PersistenceHelper.getEntityManager()
//        		.createQuery("select o from TarmSolicitud o where o.pk=:solicitud",TarmSolicitud.class).setParameter("solicitud", solicitud).getSingleResult();
//       // TcustPersonAddressKey
//        List<TcustPersonAddress> lpersonadress= PersistenceHelper.getEntityManager().createQuery("select o from TcustPersonAddress o where o.pk.personcode=:personcode "
//        											+ " and o.addresstypecatalog=3"
//        											+ " and  o.pk.dateto=(select max(dt.pk.dateto) from TcustPersonAddress dt where dt.pk.personcode=:personcode2)",TcustPersonAddress.class)
//        											.setParameter("personcode", tarmsolicitud.getPersoncode())
//        											.setParameter("personcode2", tarmsolicitud.getPersoncode()).getResultList();
//        
//        // adiciona email.
//        for(TcustPersonAddress addres:lpersonadress){
//        	lemail.add(addres.getAddress());
//        }
        lemail.add("fpazmino@bupartech.com");
        mresp.put("lemail", lemail);
        return mresp; 
    }
}
