First Commit - Source Code from Reply
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package xml;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import mnp.database.dao.HZGestioneRichiestaDAO;
|
||||
import mnp.utility.DateUtils;
|
||||
import mnp.xml.dao.dbcfx.notifica.NotificaHZFromDBCFX;
|
||||
import testUtil.TestProcessCache;
|
||||
|
||||
public class XMLDbcfxGenerator
|
||||
extends AbstractXmlGenerator {
|
||||
|
||||
HZGestioneRichiestaDAO dao = null;
|
||||
protected TestProcessCache testProcessCache = TestProcessCache.getInstance();
|
||||
public XMLDbcfxGenerator() {
|
||||
dao = new HZGestioneRichiestaDAO();
|
||||
}
|
||||
|
||||
/**
|
||||
* generateXml
|
||||
*
|
||||
* @param args String[] - 0 - TIPO SISTEMA, 1 - TIPO OPERAZIONE - 2 DET -
|
||||
* 3 NUMERO RICHIESTE
|
||||
* @return String
|
||||
* @throws Exception
|
||||
*/
|
||||
public String[] generateXml(String[] args) throws Exception {
|
||||
int numRichieste = Integer.parseInt(args[2]);
|
||||
String[] records = new String[numRichieste];
|
||||
String data="";
|
||||
System.out.println("args.length " + args.length);
|
||||
|
||||
if (args.length != 3) {
|
||||
throw new IllegalArgumentException("Numero di parametri insufficienti");
|
||||
}
|
||||
NotificaHZFromDBCFX notifica = new NotificaHZFromDBCFX();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
System.out.println("parametro xml " + i + ": " + args[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < numRichieste; i++) {
|
||||
if ("S".equalsIgnoreCase(args[1])){
|
||||
// MI COSTRUISCO UNA STRINGA CONTENENTE UNA DATA NEL FORMATO:
|
||||
//det = DateUtils.toDateFormat(DateUtils.getCurrentStringDate(), "DD-MM-yyyy HH:MM:SS");
|
||||
data = DateUtils.toString(new Date(), "dd-MM-yyyy HH:MM:SS");
|
||||
data= data.substring(0,19);
|
||||
notifica.setDET(data);
|
||||
|
||||
}else {
|
||||
notifica.setDET(args[1]);
|
||||
}
|
||||
|
||||
notifica.setTIPO_OPERAZIONE(Integer.parseInt(args[0]));
|
||||
notifica.setDIRECTORY_NUMBER(getIdRisorsa());
|
||||
|
||||
records[i] = getXmlFromCastorObject(notifica, false);
|
||||
//test automatici
|
||||
testProcessCache.addItem(TestProcessCache.HZ,notifica);
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
|
||||
private String getIdRisorsa(){
|
||||
|
||||
String[] cifre = {"1","2","3","4","5","6","7","8","9","0"};
|
||||
String[] prefix ={"06","02","0763","0131","0764","0776","0773"};
|
||||
|
||||
String appNumero[] = new String[8];
|
||||
String appPrefisso[] = new String[1];
|
||||
String msisdn = "";
|
||||
String prefisso = "";
|
||||
|
||||
appPrefisso[0] = prefix[(int) (Math.random()*7)];
|
||||
prefisso = prefisso + appPrefisso[0];
|
||||
for (int i=0; i<8; i++){
|
||||
appNumero[i]= cifre[(int)(Math.random()*9)];
|
||||
msisdn= msisdn + appNumero[i];
|
||||
}
|
||||
|
||||
return prefisso+msisdn;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user