/** * */ package it.valueteam.gnp.dao; import it.valueteam.gnp.dao.db.hb.*; import it.valueteam.gnp.helper.MultiLineaHelper; import it.valueteam.gnp.obj.ApplicationCostants; import it.valueteam.gnp.obj.ProcessMapper; import it.valueteam.gnp.obj.StatoRichiestaDoppioDonating; import it.valueteam.gnp.obj.StatoRichiestaRec; import it.valueteam.gnp.utility.DateUtils; import it.valueteam.gnp.utility.Resources; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; /** * Description: La classe consente di ricercare un insieme di richieste da * DB secondo parametri definiti. * @author pocciac * */ public class RichiestaRecipientLoader { private RichiestaRecipientLoader() {}; /** * Ritorna la lista dei DTO secondo i parametri passati * @param states * @param daInviare * @param cow * @return */ public static List getRequestByCriteria(List states, Long daInviare, String cow ) { List dtoList = null; //creo la lista dei criteri di ricerca ArrayList criterion = new ArrayList(); criterion.add(Restrictions.in(GnpRichiesteRecDAO.HIB_PROP_STATO, states)); criterion.add(Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, daInviare)); criterion.add(Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_COW, cow)); GnpRichiesteRecDAO dao = new GnpRichiesteRecDAO(); dtoList = dao.findByCriteria(criterion); return dtoList; } /** * Ritorna la lista dei DTO secondo i parametri passati * @param states * @param daInviare * @param cow * @return */ public static List getRequestByCriteria(List states, String codiceCorrelazione, boolean isPrjMlMs ) { List dtoList = null; //creo la lista dei criteri di ricerca ArrayList criterion = new ArrayList(); criterion.add(Restrictions.in(GnpRichiesteRecDAO.HIB_PROP_STATO, states)); criterion.add(Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_COD_CORRELAZIONE, codiceCorrelazione)); criterion.add(Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PRJ_ML_MS, new Long(isPrjMlMs ? 1 : 0))); GnpRichiesteRecDAO dao = new GnpRichiesteRecDAO(); dtoList = dao.findByCriteria(criterion); return dtoList; } /** * Ritorna la lista dei DTO secondo i parametri passati * @param states * @param daInviare * @param cow * @return * @throws Exception */ public static List getRequestFineWaitOLOStandard() throws Exception { List dtoList = null; GnpRichiesteRecDAO dao = new GnpRichiesteRecDAO(); //creo la lista dei criteri di ricerca ArrayList criterion = new ArrayList(); boolean activeA375 = Resources.isActiveValidazionePitagoraA375(); // Criterio 1. Tutte le richieste in stato ACCETTATA con DFW scaduta e non multilinea/multisede Criterion standardRequestCrit1 = Restrictions.and( Restrictions.and( Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO,new Long(StatoRichiestaRec.ACCETTATA)), Restrictions.lt(GnpRichiesteRecDAO.HIB_PROP_DWF, DateUtils.troncaOra(new Date()))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PRJ_ML_MS, new Long(0))); Criterion standardRequestCrit2 = null; if(activeA375) { // Criterio 2. Tutte le richieste in stato VALIDATA_OLO con VERIFICATA_A375 = 1 e non multilinea/multisede standardRequestCrit2 = Restrictions.and( Restrictions.and( Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, new Long(StatoRichiestaRec.VALIDATA_OLO)), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PRJ_ML_MS, new Long(0))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_VALIDATA_A375, "1")); } else { // Criterio 2. Tutte le richieste in stato VALIDATA_OLO e non multilinea/multisede standardRequestCrit2 = Restrictions.and( Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, new Long(StatoRichiestaRec.VALIDATA_OLO)), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PRJ_ML_MS, new Long(0))); } // Criterio 3. Tutte le richieste in stato VALIDATA_OLO con VERIFICATA_A375 = 0 (o NULL), con DFW scaduta e non multilinea/multisede Criterion standardRequestCrit3 = Restrictions.and( Restrictions.and( Restrictions.and( Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO,new Long(StatoRichiestaRec.VALIDATA_OLO)), Restrictions.lt(GnpRichiesteRecDAO.HIB_PROP_DWF, DateUtils.troncaOra(new Date()))), Restrictions.or( Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_VALIDATA_A375, "0"), Restrictions.isNull(GnpRichiesteRecDAO.HIB_PROP_VALIDATA_A375))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PRJ_ML_MS, new Long(0))); Criterion totalCrit = Restrictions.or(Restrictions.or(standardRequestCrit1, standardRequestCrit2), standardRequestCrit3); criterion.add(totalCrit); dtoList = dao.findByCriteria(criterion); return dtoList; } public static List getStandardRequestToSendOLO() throws Exception{ List resultList = null; List processList = new ArrayList(); processList.add(ProcessMapper.proc_RIENTRO_ADSL); processList.add(ProcessMapper.proc_RIENTRO_FONIA); processList.add(ProcessMapper.proc_RIENTRO_NAKED); List processListAgg = new ArrayList(); processListAgg.add(ProcessMapper.proc_RIENTRO_FONIA); processListAgg.add(ProcessMapper.proc_RIENTRO_NAKED); GnpRichiesteRecDAO dao = new GnpRichiesteRecDAO(); //creo la lista dei criteri di ricerca ArrayList criterion = new ArrayList(); boolean activeA375 = Resources.isActiveValidazionePitagoraA375(); Criterion acquisiteCrit = null; Criterion acquisiteCritNoAgg = null; Criterion attesaReinvioCrit = null; if( activeA375 ) { acquisiteCrit = Restrictions.and(Restrictions.and(Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, //MR 10X07 new Long(StatoRichiestaRec.VERIFICATAOK)), new Long(StatoRichiestaRec.VERIFICATAOK_DEFINITIVO)), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE))), Restrictions.in(GnpRichiesteRecDAO.HIB_PROP_PROCESSO, processListAgg)); acquisiteCritNoAgg = Restrictions.and(Restrictions.and(Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, new Long(StatoRichiestaRec.VERIFICATAOK)), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PROCESSO, ProcessMapper.proc_RIENTRO_ADSL)); // Se è attiva la gestione della delibera A375 le multilinea/multisede vanno come le standard attesaReinvioCrit = Restrictions.and(Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE)), Restrictions.and(Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, new Long(StatoRichiestaRec.ATTESAREINVIO)), Restrictions.le(GnpRichiesteRecDAO.HIB_PROP_DATA_REINVIO_OLO, DateUtils.troncaOra(new java.util.Date())))); } else { acquisiteCrit = Restrictions.and(Restrictions.and(Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, //MR 10X07 new Long(StatoRichiestaRec.VERIFICATAOK)), new Long(StatoRichiestaRec.VERIFICATAOK_DEFINITIVO)), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE))), Restrictions.in(GnpRichiesteRecDAO.HIB_PROP_PROCESSO, processListAgg)); acquisiteCritNoAgg = Restrictions.and(Restrictions.and(Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, new Long(StatoRichiestaRec.VERIFICATAOK)), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PROCESSO, ProcessMapper.proc_RIENTRO_ADSL)); attesaReinvioCrit = Restrictions.and(Restrictions.and(Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE)), Restrictions.and(Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, new Long(StatoRichiestaRec.ATTESAREINVIO)), Restrictions.le(GnpRichiesteRecDAO.HIB_PROP_DATA_REINVIO_OLO, DateUtils.troncaOra(new java.util.Date())))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PRJ_ML_MS, new Long(0))); } Criterion totalCrit = null; totalCrit = Restrictions.or(Restrictions.or(acquisiteCrit, attesaReinvioCrit), acquisiteCritNoAgg); criterion.add(totalCrit); resultList = dao.findByCriteria(criterion); //posso fare direttamente addAll perchè hibernate eventualmente non trovi // nessuna richiesta crea una List vuota ma istanziata // resultList.addAll(richiesteDaInviareOloMultilinea); //ordino per data ricezione richiesta Collections.sort(resultList, new DataRicezioneComparator()); return resultList; } public static List getRichiesteDoppioDonatingToSendOLO() throws Exception{ List resultList = null; List processList = new ArrayList(); GnpDoppioDonatingOloBridgeDAO dao = new GnpDoppioDonatingOloBridgeDAO(); processList.add(ProcessMapper.proc_RIENTRO_DOPPIO_DONATING); //creo la lista dei criteri di ricerca ArrayList criterion = new ArrayList(); Criterion acquisiteCrit = null; acquisiteCrit =Restrictions.or( Restrictions.and( Restrictions.eq(GnpDoppioDonatingOloBridgeDAO.HIB_PROP_STATO, new Long(StatoRichiestaDoppioDonating.DA_INVIARE)), Restrictions.eq(GnpDoppioDonatingOloBridgeDAO.HIB_PROP_DA_INVIARE, new Long(ApplicationCostants.REQUEST_DOPPIO_DONATING_DA_INVIARE))), Restrictions.and( Restrictions.and( Restrictions.eq(GnpDoppioDonatingOloBridgeDAO.HIB_PROP_STATO,new Long(StatoRichiestaDoppioDonating.DA_REINVIARE)), Restrictions.eq(GnpDoppioDonatingOloBridgeDAO.HIB_PROP_DA_INVIARE, new Long(ApplicationCostants.REQUEST_DOPPIO_DONATING_DA_INVIARE))), Restrictions.le(GnpDoppioDonatingOloBridgeDAO.HIB_PROP_DATA_REINVIO_OLO,DateUtils.troncaOra(new java.util.Date())))); criterion.add(acquisiteCrit); resultList = dao.findByCriteria(criterion); Collections.sort(resultList, new DataRicezioneComparatorDD()); return resultList; } public static List getStandardRequestToSendPitagoraReg(boolean isActiveBlackListManage) throws Exception{ List resultList = null; ArrayList criterion = new ArrayList(); GnpRichiesteRecDAO dao = new GnpRichiesteRecDAO(); Criterion totalCrit = null; boolean flagA375 = Resources.isActiveValidazionePitagoraA375(); // Per i processi blacklist e NPg lo stato di partenza da considerare cambia a seconda che // sia attiva o meno la gestione della delibera A375 Long statoPartenzaBKL_NPG = flagA375 ? new Long(StatoRichiestaRec.VERIFICATAOK) : new Long(StatoRichiestaRec.ACQUISITA); Long statoPartenzaNPG = flagA375 ? new Long(StatoRichiestaRec.VERIFICATAOK_DEFINITIVO) : new Long(StatoRichiestaRec.ACQUISITA); Criterion criterionValidatingStandard = Restrictions.and(Restrictions.and(Restrictions.and(Restrictions.and( Restrictions.in(GnpRichiesteRecDAO.HIB_PROP_PROCESSO, new String[]{ProcessMapper.proc_RIENTRO_FONIA, ProcessMapper.proc_RIENTRO_FONIA_BKL, ProcessMapper.proc_RIENTRO_NPg, ProcessMapper.proc_RIENTRO_DOPPIO_DONATING, ProcessMapper.proc_RIENTRO_DOPPIO_DONATING_BKL}), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, new Long(StatoRichiestaRec.VALIDATING))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PRJ_ML_MS, new Long(0))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_FLAG_VERTICALIZZATO, "N")); Criterion acquisiteBlackListStandard = Restrictions.and(Restrictions.and(Restrictions.and(Restrictions.and( Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PROCESSO, ProcessMapper.proc_RIENTRO_DOPPIO_DONATING_BKL), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, statoPartenzaBKL_NPG)), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PRJ_ML_MS, new Long(0))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_FLAG_VERTICALIZZATO, "N")); Criterion acquisiteNPg = Restrictions.and(Restrictions.and(Restrictions.and( Restrictions.in(GnpRichiesteRecDAO.HIB_PROP_PROCESSO, new String[]{ProcessMapper.proc_RIENTRO_FONIA_BKL, ProcessMapper.proc_RIENTRO_NPg}), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, statoPartenzaNPG)), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_FLAG_VERTICALIZZATO, "N")); Criterion acquisiteNPg_StopPitagora = Restrictions.and(Restrictions.and(Restrictions.and( Restrictions.in(GnpRichiesteRecDAO.HIB_PROP_PROCESSO, new String[]{ProcessMapper.proc_RIENTRO_FONIA_BKL, ProcessMapper.proc_RIENTRO_NPg}), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, statoPartenzaNPG) ), Restrictions.and( Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE)), Restrictions.isNull(GnpRichiesteRecDAO.HIB_PROP_STOP_NPG))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_FLAG_VERTICALIZZATO, "N")); if(isActiveBlackListManage){ if(Resources.isActivePitagoraRegolatiorioNpg()){ totalCrit = Restrictions.or(Restrictions.or(criterionValidatingStandard, acquisiteBlackListStandard),acquisiteNPg); } else { totalCrit = Restrictions.or(Restrictions.or(criterionValidatingStandard, acquisiteBlackListStandard),acquisiteNPg_StopPitagora); } }else{ if(Resources.isActivePitagoraRegolatiorioNpg()){ totalCrit = Restrictions.or(criterionValidatingStandard,acquisiteNPg); } else { totalCrit = Restrictions.or(criterionValidatingStandard,acquisiteNPg_StopPitagora); } } criterion.add(totalCrit); resultList = dao.findByCriteria(criterion); return resultList; } public static List getStandardRequestToSendPitagoraXdsl(boolean isActiveBlackListManage) throws Exception{ List resultList = null; ArrayList criterion = new ArrayList(); GnpRichiesteRecDAO dao = new GnpRichiesteRecDAO(); Criterion totalCrit = null; boolean flagA375 = Resources.isActiveValidazionePitagoraA375(); // Per i processi blacklist lo stato di partenza da considerare cambia a seconda che // sia attiva o meno la gestione della delibera A375 Long statoPartenzaBKL = new Long(StatoRichiestaRec.VERIFICATAOK); Criterion criterionValidating = Restrictions.and( Restrictions.and(Restrictions.and(Restrictions.and( Restrictions.in(GnpRichiesteRecDAO.HIB_PROP_PROCESSO, new String[]{ProcessMapper.proc_RIENTRO_ADSL, ProcessMapper.proc_RIENTRO_ADSL_BKL, ProcessMapper.proc_RIENTRO_NAKED, ProcessMapper.proc_RIENTRO_NAKED_BKL}), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, new Long(StatoRichiestaRec.VALIDATING))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PRJ_ML_MS, new Long(0))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_FLAG_VERTICALIZZATO, "N")); Criterion acquisiteBlackListStandard = Restrictions.and(Restrictions.and(Restrictions.and(Restrictions.and( Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PROCESSO, ProcessMapper.proc_RIENTRO_ADSL_BKL), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, statoPartenzaBKL)), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PRJ_ML_MS, new Long(0))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_FLAG_VERTICALIZZATO, "N")); Criterion acquisiteBlackListAggStandard = Restrictions.and(Restrictions.and(Restrictions.and(Restrictions.and( Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PROCESSO, ProcessMapper.proc_RIENTRO_NAKED_BKL), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_STATO, new Long(StatoRichiestaRec.VERIFICATAOK_DEFINITIVO))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_DAINVIARE, new Long(ApplicationCostants.REQUEST_DA_INVIARE))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_PRJ_ML_MS, new Long(0))), Restrictions.eq(GnpRichiesteRecDAO.HIB_PROP_FLAG_VERTICALIZZATO, "N")); if(isActiveBlackListManage){ totalCrit = Restrictions.or(Restrictions.or(criterionValidating, acquisiteBlackListStandard), acquisiteBlackListAggStandard); }else{ totalCrit = criterionValidating; } criterion.add(totalCrit); resultList = dao.findByCriteria(criterion); return resultList; } public static Map getMultilineaRequestToSend(List gnpMLineaMSedeDaInviare, int stato) throws Exception{ Map map = new HashMap(); List resultList = null; GnpRichiesteRecDAO dao = new GnpRichiesteRecDAO(); for(int i=0; i0){ map.put(mLineaMsedeDto, resultList); } } return map; } public static Map getMultilineaRequestToSendNPG35(List gnpMLineaMSedeDaInviare, int stato) throws Exception{ Map map = new HashMap(); List resultList = null; GnpRichiesteRecDAO dao = new GnpRichiesteRecDAO(); for(int i=0; i0){ map.put(mLineaMsedeDto, resultList); } } return map; } public static Map getMultilineaRequestToSendNPG103(List gnpMLineaMSedeDaInviare, int stato) throws Exception{ Map map = new HashMap(); List resultList = null; GnpRichiesteRecDAO dao = new GnpRichiesteRecDAO(); for(int i=0; i0){ map.put(mLineaMsedeDto, resultList); } } return map; } // public static Map getMultilineaRequestToSendPitagora(String processo, int stato, List gnpMLineaMSedeDaInviare) throws Exception{ // List resultList = null; // GnpRichiesteRecDAO dao = new GnpRichiesteRecDAO(); // Map map = new HashMap(); // for(int i=0; i0){ // map.put(mLineaMsedeDto, resultList); // } // } // return map; // } public static Map getMultilineaRequestToSendPitagora(boolean isBlackList, List gnpMLineaMSedeDaInviare) throws Exception{ List resultList = null; GnpRichiesteRecDAO dao = new GnpRichiesteRecDAO(); Map map = new HashMap(); for(int i=0; i0){ map.put(mLineaMsedeDto, resultList); } } return map; } /** * Ritorna la lista dei DTO secondo i parametri passati * @param states * @param daInviare * @param cow * @return * @throws Exception */ public static Map getRequestFineWaitOLOMultilinea() throws Exception { List resultList = null; GnpRichiesteRecDAO dao = new GnpRichiesteRecDAO(); MultiLineaHelper helper = new MultiLineaHelper(); List gnpMsedeMlineaList = helper.getMultilineaDtoFineWaitOLO(); Map map = new HashMap(); for(int i=0; i0){ map.put(mLineaMsedeDto, resultList); } } return map; } } class DataRicezioneComparator implements Comparator{ public int compare(Object arg0, Object arg1) { GnpRichiesteRec richiesta1 = (GnpRichiesteRec) arg0; GnpRichiesteRec richiesta2 = (GnpRichiesteRec) arg1; if(richiesta1.getDataRicezioneRichiesta().after(richiesta2.getDataRicezioneRichiesta())){ return 1; }else if (richiesta1.getDataRicezioneRichiesta().before(richiesta2.getDataRicezioneRichiesta())){ return -1; }else return 0; } } /* Per Doppio Donating */ class DataRicezioneComparatorDD implements Comparator{ public int compare(Object arg0, Object arg1) { GnpDoppioDonatingOloBridge richiesta1 = (GnpDoppioDonatingOloBridge) arg0; GnpDoppioDonatingOloBridge richiesta2 = (GnpDoppioDonatingOloBridge) arg1; if(richiesta1.getDataCreazione().after(richiesta2.getDataCreazione())){ return 1; }else if (richiesta1.getDataCreazione().before(richiesta2.getDataCreazione())){ return -1; }else return 0; } }