73 lines
2.3 KiB
Java
73 lines
2.3 KiB
Java
package it.valueteam.gnp.obj;
|
|
|
|
import it.valueteam.gnp.dao.db.hb.GnpStatoCsNpg35;
|
|
import it.valueteam.gnp.dao.db.hb.GnpStatoCsNpg35DAO;
|
|
import it.valueteam.gnp.dao.db.hb.GnpStatoNpg35;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* Title: StatoRichiestaCSNPg35
|
|
* Description: Definisce gli stati di una richiesta nel processo DONOR
|
|
* Copyright: Copyright (c) 2010
|
|
* @author A. Caravaggi
|
|
* @version 1.0
|
|
* @version 1.1 Patched getStatoDescr() to prevent NullPointerException on unmapped status code
|
|
*/
|
|
public class StatoRichiestaCSNPg35 {
|
|
|
|
private static Map stateMap ;
|
|
private static final int STATO_FINALE=1;
|
|
@SuppressWarnings("unused")
|
|
private static final int STATO_NON_FINALE=0;
|
|
|
|
static void init(){
|
|
System.out.println("Inizio caricamento anagrafica Stato Richiesta Processo CS NPg35/NPg103");
|
|
stateMap = new HashMap();
|
|
GnpStatoCsNpg35DAO dao = new GnpStatoCsNpg35DAO();
|
|
List list = dao.findAll();
|
|
for(int i=0; i<list.size(); i++){
|
|
GnpStatoCsNpg35 statoCSNPg35 = (GnpStatoCsNpg35)list.get(i);
|
|
stateMap.put(statoCSNPg35.getIdStato(), statoCSNPg35);
|
|
}
|
|
System.out.println("Fine caricamento anagrafica Stato Richiesta Processo CS NPg35/NPg103");
|
|
|
|
}
|
|
|
|
public static final int ACQUISITA = 1;
|
|
public static final int PRESAINCARICO = 2;
|
|
public static final int ATTESAVERIFICA = 3;
|
|
public static final int RIFIUTATA = 4;
|
|
public static final int ESPLETATA = 5;
|
|
public static final int ANNULLATA = 8;
|
|
|
|
/**
|
|
* Return the description of the specified request status code.
|
|
* Patched to prevent NullPointerException on unmapped status code.
|
|
* @return error string "UNDEFINED_<status_code>" if not found.
|
|
*/
|
|
public static synchronized String getStatoDescr(int stato) {
|
|
if(null == stateMap){
|
|
init();
|
|
}
|
|
String defaultDescr = "UNDEFINED_" + String.valueOf(stato);
|
|
return ( null == stateMap.get(new Long(stato)) ? defaultDescr : ((GnpStatoCsNpg35)stateMap.get(new Long(stato))).getDescrStato() );
|
|
}
|
|
public static boolean isStatoFinale(Long stato){
|
|
if(stateMap==null){
|
|
init();
|
|
}
|
|
GnpStatoCsNpg35 rec = (GnpStatoCsNpg35)stateMap.get(stato);
|
|
if(STATO_FINALE==rec.getFinale().intValue()){
|
|
return true;
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|