First Commit - Source Code from Reply
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
package xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mnp.xml.dao.msp.NotifyCreditTransferDonorESP;
|
||||
|
||||
import testUtil.TestProcessCache;
|
||||
|
||||
import db.ManagerDAO;
|
||||
|
||||
public class XMLNotificaMspCoopTcGenerator extends AbstractXmlGenerator {
|
||||
|
||||
protected TestProcessCache testProcessCache = TestProcessCache.getInstance();
|
||||
|
||||
public XMLNotificaMspCoopTcGenerator() {
|
||||
managerDAO = new ManagerDAO();
|
||||
}
|
||||
|
||||
/**
|
||||
* generateXml
|
||||
*
|
||||
* NOTIFICA TRASFERIMENTO CREDITO
|
||||
* args[0] selettore per il tipo di notifica da effettuare ('MSPCOOP_TC')
|
||||
* args[1] processType (tipo di processo: DON, DON_VIRT, REC_VIRT)
|
||||
* args[2] tipo evento (trasferimento = 01, sblocco credito anomalo = 02, sblocco importo = 03)
|
||||
* args[3] id richiesta (id della richiesta dbc associata)
|
||||
* args[4] credito residuo (xxxxx.xx)
|
||||
* args[5] verifica credito anomalo (flag Y|N)
|
||||
*
|
||||
* @return String
|
||||
* @throws Exception
|
||||
*/
|
||||
public String[] generateXml(String[] args) throws Exception {
|
||||
|
||||
if(args.length != 5)
|
||||
throw new Exception("Numero parametri errato!");
|
||||
|
||||
String records[] = null;
|
||||
String idRichiesta = args[1];
|
||||
String processType = args[2];
|
||||
String tipoEvento = args[3];
|
||||
String creditoResiduo = args[4];
|
||||
|
||||
checkFields(processType, tipoEvento, creditoResiduo);
|
||||
|
||||
List request = new ArrayList();
|
||||
|
||||
NotifyCreditTransferDonorESP richiestaTc = new NotifyCreditTransferDonorESP();
|
||||
if("NULL".equals(idRichiesta)){
|
||||
if(tipoEvento.equals("01")){
|
||||
request = managerDAO.getIdRichiestaMspCoop(processType);
|
||||
} else if(tipoEvento.equals("03")) {
|
||||
request = managerDAO.getIdRichiestaMspCoopByState(processType, tipoEvento);
|
||||
}
|
||||
//ciclo sulle coppie di id_richiesta/ business id acquisite
|
||||
if(request != null && request.size() > 0){
|
||||
records = new String[request.size()];
|
||||
for(int i = 0; i < request.size(); i++){
|
||||
richiestaTc.setID_RICHIESTA_DBC((String)request.get(i));
|
||||
richiestaTc.setIMPORTO_CREDITO_RESIDUO(creditoResiduo);
|
||||
richiestaTc.setTIPO_EVENTO(tipoEvento);
|
||||
records[i] = getXmlFromCastorObject(richiestaTc, false);
|
||||
}
|
||||
} else
|
||||
throw new Exception("NON SONO PRESENTI SUL DB DATI COMPATIBILI CON I PARAMETRI DI INPUT");
|
||||
} else {
|
||||
String businessId = managerDAO.verificaEsistenzaIdRichiestaMspCoop(processType, idRichiesta);
|
||||
// if(tipoEvento.equals("01")){
|
||||
// do nothing
|
||||
// } else
|
||||
if(tipoEvento.equals("03")) {
|
||||
request = managerDAO.verificaEsistenzaRichiestaTcMspCoop(processType, idRichiesta, tipoEvento);
|
||||
if(request == null || request.size() == 0)
|
||||
throw new Exception("SUL DB NON E' PRESENTE NESSUNA RICHIESTA DI TC AVENTE ID RICHIESTA = " + idRichiesta);
|
||||
}
|
||||
richiestaTc.setID_RICHIESTA_DBC(idRichiesta);
|
||||
richiestaTc.setIMPORTO_CREDITO_RESIDUO(creditoResiduo);
|
||||
richiestaTc.setTIPO_EVENTO(tipoEvento);
|
||||
records = new String[1];
|
||||
records[0] = getXmlFromCastorObject(richiestaTc, false);
|
||||
}
|
||||
|
||||
return records;
|
||||
}
|
||||
|
||||
private void checkFields(String processType, String tipoEvento, String creditoResiduo) throws Exception {
|
||||
if( !( processType.equals("DON") || processType.equals("DON_VIRT") || processType.equals("REC_VIRT") ) )
|
||||
throw new Exception("PROCESS TYPE ERRATO!");
|
||||
|
||||
if( !( tipoEvento.equals("01") || tipoEvento.equals("03") ) )
|
||||
throw new Exception("TIPO EVENTO ERRATO!");
|
||||
|
||||
String pattern = "[0-9]{1,5}[.][0-9]{2,2}";
|
||||
if(!creditoResiduo.matches(pattern))
|
||||
throw new Exception("VALORE CREDITO RESIDUO NON VALIDO!");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user