Advertisement
AGihed

Untitled

Jul 12th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.62 KB | None | 0 0
  1. package com.Servlets.BIATNET_V1;
  2.  
  3. import java.io.IOException;
  4. import java.lang.reflect.Constructor;
  5. import java.lang.reflect.Field;
  6. import java.text.SimpleDateFormat;
  7. import java.util.ArrayList;
  8. import java.util.Calendar;
  9. import java.util.Iterator;
  10. import java.util.List;
  11.  
  12. import javax.servlet.Servlet;
  13. import javax.servlet.ServletException;
  14. import javax.servlet.ServletInputStream;
  15. import javax.servlet.http.HttpServlet;
  16. import javax.servlet.http.HttpServletRequest;
  17. import javax.servlet.http.HttpServletResponse;
  18. import com.Models.BIATNET_V1.Governor;
  19. import com.Utility.BIATNET_V1.InvocationSingleton;
  20.  
  21. import java.lang.reflect.Method;
  22. import java.net.SocketException;
  23. import java.lang.reflect.InvocationTargetException;
  24.  
  25. public class Mobile_Banking_Servlet extends HttpServlet implements Servlet
  26. {
  27. String Method_Name=null;
  28. String Class_Name=null;
  29. String Recived_Class=null;
  30. public static List<Governor> Governors=new ArrayList<Governor>();
  31. int i=0;
  32. public String Response_Caller="";
  33. private static final long serialVersionUID = 1L;
  34. public Mobile_Banking_Servlet() {
  35. super();
  36. }
  37.  
  38. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  39. {
  40. String timeStamp = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Calendar.getInstance().getTime());
  41. response.getOutputStream().println("Mobile Banking Servlet Has Been Called, And it's ready to Answer your needs : "+timeStamp);
  42. }
  43. protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  44. {
  45. response.setCharacterEncoding("utf-8");
  46. System.out.println("-------------------------Beging Of One Response-------------------");
  47. String Message_To_Sent_To_User="";
  48. try
  49. {
  50. try
  51. {
  52. Client_Response Client=new Client_Response();
  53. String Reading_Request_Resualt=Reading_Client_Message(request);
  54. Field Variable = Client.getClass().getField(Method_Name);
  55. Message_To_Sent_To_User=(String)Variable.get(Client);
  56. System.out.println("--------------------Beging Of First Message Sent to user---------------------------");
  57. response.getOutputStream().write(Message_To_Sent_To_User.getBytes());
  58. System.out.println("Message Sent to user :"+Message_To_Sent_To_User);
  59. System.out.println("--------------------------End Of First Message Sent to user------------------------");
  60. response.getOutputStream().flush();
  61. System.out.println("--------------------Beging Of Second Message Sent to user---------------------------");
  62. response.getOutputStream().write(Reading_Request_Resualt.getBytes());
  63. System.out.println("Message Sent to user :"+Reading_Request_Resualt);
  64. System.out.println("--------------------------End Of Second Message Sent to user------------------------");
  65. response.getOutputStream().flush();
  66. response.getOutputStream().close();
  67. }
  68. catch(IllegalAccessException|NoSuchFieldException|IllegalAccessError ex)
  69. {
  70. System.out.println(ex.toString());
  71. }
  72. }
  73. catch (IOException ex)
  74. {
  75. System.out.println("error : "+ex);
  76. }
  77. System.out.println("-------------------------End Of One Response-------------------");
  78. doGet(request, response);
  79.  
  80. }
  81. private String Reading_Client_Message(HttpServletRequest request) throws IOException
  82. {
  83. List<String> Parsed_Cliend_Request=new ArrayList<String>();
  84. int length = request.getContentLength();
  85. byte[] input = new byte[length];
  86. ServletInputStream sin = request.getInputStream();
  87. int c, count = 0 ;
  88. while ((c = sin.read(input, count, input.length-count)) != -1) {
  89. count +=c;
  90. }
  91. sin.close();
  92. String recievedString = new String(input);
  93. System.out.println("recivedString "+recievedString );
  94. String Recived_String="";
  95. for(int i=1;i<recievedString.length()-1;i++)
  96. {
  97. if(recievedString.charAt(i)!='"')
  98. {
  99. if(recievedString.charAt(i)!='\\')
  100. Recived_String=Recived_String+recievedString.charAt(i);
  101. }
  102. }
  103. System.out.println(Recived_String);
  104. String[] tokens=Recived_String.split("/");
  105. for (String t : tokens)
  106. {
  107. Parsed_Cliend_Request.add(t);
  108. }
  109. return Identifing_Client_Needs(Parsed_Cliend_Request);
  110. }
  111. private String Identifing_Client_Needs(List<String> Parsed_Client_Request)
  112. {
  113.  
  114. try
  115. {
  116. Recived_Class=null;
  117. int i=0;
  118. Iterator<String> Parsed_Client_Request_Iterator=Parsed_Client_Request.iterator();
  119. while(Parsed_Client_Request_Iterator.hasNext())
  120. {
  121. String Current_String=Parsed_Client_Request_Iterator.next();
  122. if(i==0)
  123. {
  124. if(Current_String.contains(","))
  125. {
  126. Recived_Class=Current_String.substring(0,Current_String.lastIndexOf(','));
  127. System.out.println("Recived_Class : "+Recived_Class);
  128. Class_Name=Current_String.substring(Current_String.lastIndexOf(',')+1,Current_String.length());
  129. System.out.println("Recived_Class : "+Class_Name);
  130. }
  131. else
  132. {
  133. Class_Name=Current_String;
  134. }
  135.  
  136. }
  137. else
  138. {
  139. Method_Name=Current_String;
  140. }
  141. i++;
  142. }
  143. if(Recived_Class==null)
  144. {
  145. Class<?> Called_Class = Class.forName(Class_Name);
  146. Constructor<?> Called_Class_Constructor = Called_Class.getConstructor();
  147. Object object = Called_Class_Constructor.newInstance();
  148. String Resualt=null;
  149. Method method = Called_Class.getDeclaredMethod (Method_Name);
  150. Resualt=(String)method.invoke(object);
  151. return Resualt;
  152. }
  153. else
  154. {
  155. Class<?> Called_Class = Class.forName(Class_Name);
  156. Constructor<?> Called_Class_Constructor = Called_Class.getConstructor();
  157. Object object = Called_Class_Constructor.newInstance();
  158. String Resualt=null;
  159. Method method = Called_Class.getDeclaredMethod (Method_Name,String.class);
  160. Resualt=(String)method.invoke(object,Recived_Class);
  161. return Resualt;
  162. }
  163. }
  164. catch(SecurityException|NoSuchMethodException|InvocationTargetException ex)
  165. {
  166. ex.printStackTrace();
  167. return null;
  168. }
  169. catch(IllegalAccessException|ClassNotFoundException|InstantiationException ex)
  170. {
  171. System.out.println("i'm the cause "+ex);
  172. return null;
  173. }
  174. }
  175. }
  176.  
  177. class Client_Response
  178. {
  179. public final String Preparing_Agencies_List_To_Send="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Agencies_List_Response\n";
  180. public final String Preparing_Dabs_List_To_Send="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Dabs_List_Response\n";
  181. public final String Preparing_Currency_List_To_Send="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Currency_List_Response\n";
  182. public final String Preparing_Customer_Info_To_Send="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Account_Info_Response\n";
  183. public final String Preparing_Check_Note_Creation="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Check_Book_Creation_Response\n";
  184. public final String Preparing_Withdrawal_History_To_Send="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Withdrawal_History_Response\n";
  185. public final String Preparing_Operation_History_To_Send="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Operation_History_Response\n";
  186. public final String Preparing_Add_Beneficiary_Request_To_Send="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Add_Beneficiary_Response\n";
  187. public final String Preparing_Remove_Beneficiary_Request_To_Send="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Remove_Beneficiary_Response\n";
  188. public final String Preparing_Beneficiary_List_Request_To_Send="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Beneficiary_List_Response\n";
  189. public final String Preparing_Transfer_Inter_Creation="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Transfer_Inter_Creation_Response\n";
  190. public final String Preparing_Transfer_Inter_Validation="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Transfer_Inter_Validation_Response\n";
  191. public final String Preparing_Transfer_Intra_Creation="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Transfer_Intra_Creation_Response\n";
  192. public final String Preparing_Transfer_Intra_Validation="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Transfer_Intra_Validation_Response\n";
  193. public final String Preparing_Transfer_History_To_Send="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Transfer_History_Response\n";
  194. public final String Preparing_Remboursement_Constant_Duree_To_Send="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Sim_Credit_Response\n";
  195. public final String Preparing_Remboursement_Constant_Montant_To_Send="com.app.taha.pfe.Server_Configuration.Server_Response_Manager/Sim_Credit_Response\n";
  196. }
  197. -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
  198.  
  199. package Response_Classes;
  200.  
  201. import java.lang.reflect.Type;
  202. import java.net.SocketException;
  203. import java.rmi.RemoteException;
  204. import java.util.ArrayList;
  205. import java.util.List;
  206.  
  207. import javax.xml.soap.MessageFactory;
  208. import javax.xml.soap.MimeHeaders;
  209. import javax.xml.soap.SOAPBody;
  210. import javax.xml.soap.SOAPElement;
  211. import javax.xml.soap.SOAPEnvelope;
  212. import javax.xml.soap.SOAPException;
  213. import javax.xml.soap.SOAPMessage;
  214. import javax.xml.soap.SOAPPart;
  215.  
  216. import com.Models.BIATNET_V1.Beneficiary;
  217. import com.Models.BIATNET_V1.Customer;
  218. import com.Models.BIATNET_V1.Governor;
  219. import com.Models.BIATNET_V1.Operation_History;
  220. import com.Models.BIATNET_V1.Loans;
  221. import com.Models.BIATNET_V1.Transfer;
  222. import com.Models.BIATNET_V1.Withdrawal_History;
  223. import com.Servlets.BIATNET_V1.Mobile_Banking_Servlet;
  224. import com.Utility.BIATNET_V1.Agency_Parser;
  225. import com.Utility.BIATNET_V1.Beneficiry_Parser;
  226. import com.Utility.BIATNET_V1.Currency_Parser;
  227. import com.Utility.BIATNET_V1.Distributor_Parser;
  228. import com.Utility.BIATNET_V1.Governors_Manager;
  229. import com.Utility.BIATNET_V1.InvocationSingleton;
  230. import com.Utility.BIATNET_V1.Operation_Parser;
  231. import com.Utility.BIATNET_V1.Transfer_History_Parser;
  232. import com.Utility.BIATNET_V1.User_Information_Parser;
  233. import com.Utility.BIATNET_V1.Web_Service;
  234. import com.Utility.BIATNET_V1.Withdrawal_Parser;
  235. import com.google.gson.Gson;
  236. import com.google.gson.JsonSyntaxException;
  237. import com.google.gson.reflect.TypeToken;
  238. import com.google.gson.stream.MalformedJsonException;
  239.  
  240. public class Client_Request_Manager
  241. {
  242. public Client_Request_Manager()
  243. {
  244. }
  245. public String Preparing_Agencies_List_To_Send()
  246. {
  247. InvocationSingleton Invocation;
  248. Invocation=new InvocationSingleton();
  249. try
  250. {
  251. Invocation.getOfsUserInfos("CHQ");
  252. Agency_Parser Parser=new Agency_Parser(Put_Server_Response_Into_List(Invocation.getListeAgences()));
  253. Governors_Manager Gov_Parser=new Governors_Manager();
  254. Gov_Parser.Sort_Governors();
  255. String json=new Gson().toJson(Mobile_Banking_Servlet.Governors);
  256. return json;
  257. }
  258. catch (RemoteException | NullPointerException e) {
  259. e.printStackTrace();
  260. return "Application internal Error";
  261. }
  262. }
  263. public String Preparing_Dabs_List_To_Send()
  264. {
  265. InvocationSingleton Invocation;
  266. Invocation=new InvocationSingleton();
  267. try
  268. {
  269. Invocation.getOfsUserInfos("CHQ");
  270. Distributor_Parser Parser=new Distributor_Parser(Put_Server_Response_Into_List(Invocation.getListeDAB()));
  271. Type listType = new TypeToken<List<Governor>>() {}.getType();
  272. Governors_Manager Gov_Parser=new Governors_Manager();
  273. Gov_Parser.Sort_Governors();
  274. String json=new Gson().toJson(Mobile_Banking_Servlet.Governors);
  275. return json;
  276. } catch (RemoteException | JsonSyntaxException | NullPointerException e) {
  277. e.printStackTrace();
  278. return "Application internal Error";
  279. }
  280.  
  281. }
  282. public String Preparing_Currency_List_To_Send()
  283. {
  284. InvocationSingleton Invocation;
  285. Invocation=new InvocationSingleton();
  286. try
  287. {
  288. Invocation.getOfsUserInfos("CHQ");
  289. Currency_Parser Parser=new Currency_Parser(Put_Server_Response_Into_List(Invocation.getDevisesTable()));
  290. String json=new Gson().toJson(Parser.Get_Currency_List());
  291. return json;
  292. }
  293. catch (RemoteException | NullPointerException e)
  294. {
  295. e.printStackTrace();
  296. return "Application internal Error";
  297. }
  298. }
  299. public String Preparing_Customer_Info_To_Send()
  300. {
  301. InvocationSingleton Invocation;
  302. Invocation=new InvocationSingleton();
  303. try
  304. {
  305. Invocation.getOfsUserInfos("CHQ");
  306. User_Information_Parser Parser=new User_Information_Parser(Put_Server_Response_Into_List(Invocation.getAccountIBInfos("IU1308852938")));
  307. String json=new Gson().toJson(Parser.Get_Gustomer());
  308. return json;
  309. }
  310. catch (RemoteException | NullPointerException e)
  311. {
  312. e.printStackTrace();
  313. return "Application internal Error";
  314. }
  315. }
  316. public String Preparing_Check_Note_Creation(String Param)throws MalformedJsonException
  317. {
  318. Type Type = new TypeToken<Customer>() {}.getType();
  319. Customer Current_Customer = new Gson().fromJson(Param, Type);
  320. InvocationSingleton Invocation;
  321. Invocation=new InvocationSingleton();
  322. try
  323. {
  324. Invocation.getOfsUserInfos("CHQ");
  325. String Barre=Current_Customer.Get_Accounts().get(0).Get_Check_Books().get(0).Get_Barred().toLowerCase();
  326. String firstLetter = Barre.substring(0,1).toUpperCase();
  327. String restLetters =Barre.substring(1).toLowerCase();
  328. Barre=firstLetter + restLetters;
  329. Current_Customer.Get_Accounts().get(0).Get_Check_Books().get(0).Set_Barred(Barre);
  330. String Check_Book_Creation_Response_Message= Invocation.CommandeChequier(Current_Customer.Get_Accounts().get(0).Get_Identifier(), String.valueOf(Current_Customer.Get_Accounts().get(0).Get_Check_Books().get(0).Get_Number_Of_Pages()), Current_Customer.Get_Accounts().get(0).Get_Check_Books().get(0).Get_Barred(), Current_Customer.Get_ID(), Current_Customer.Get_Unknown_ID());
  331. Type listType = new TypeToken<String>() {}.getType();
  332. String json=new Gson().toJson(Check_Book_Creation_Response_Message,listType);
  333. return json;
  334. }
  335. catch(RemoteException | JsonSyntaxException | NullPointerException e)
  336. {
  337. e.printStackTrace();
  338. return "Application internal Error";
  339. }
  340. }
  341. public String Preparing_Withdrawal_History_To_Send(String Param)throws MalformedJsonException
  342. {
  343. String Date=null;
  344. String Account=null;
  345. Type Type = new TypeToken<List<String>>() {}.getType();
  346. List<String> Recived_Param = new Gson().fromJson(Param, Type);
  347. Account=Recived_Param.get(0);
  348. Date=Recived_Param.get(1);
  349. InvocationSingleton Invocation;
  350. Invocation=new InvocationSingleton();
  351. try
  352. {
  353. Invocation.getOfsUserInfos("CHQ");
  354. Withdrawal_Parser Parser=new Withdrawal_Parser(Invocation.getExtraitCompte(Account, Date));
  355. Type listType = new TypeToken<Withdrawal_History>() {}.getType();
  356. String json=new Gson().toJson(Parser.Get_Withdrawal_History(),listType);
  357. return json;
  358. }
  359. catch(RemoteException | JsonSyntaxException | NullPointerException e)
  360. {
  361. e.printStackTrace();
  362. return "Application internal Error";
  363. }
  364. }
  365. public String Preparing_Operation_History_To_Send(String Param)throws MalformedJsonException
  366. {
  367. String Account=null;
  368. String Date_Debut=null;
  369. String Date_Debut_Max=null;
  370. String Min_Amount=null;
  371. String Max_Amount=null;
  372. String Sensop=null;
  373. String Refop=null;
  374. String Libop=null;
  375. Type Type = new TypeToken<List<String>>() {}.getType();
  376. List<String> Recived_Param = new Gson().fromJson(Param, Type);
  377. System.out.println(Recived_Param.toString());
  378. Account=Recived_Param.get(0);
  379. Date_Debut=Recived_Param.get(1);
  380. if(Recived_Param.get(2)==null)
  381. {
  382. Date_Debut_Max="";
  383. }
  384. else
  385. {
  386. Date_Debut_Max=Recived_Param.get(2);
  387. }
  388. if(Recived_Param.get(3)==null)
  389. {
  390. Min_Amount="";
  391. }
  392. else
  393. {
  394. Min_Amount=Recived_Param.get(3);
  395. }
  396. if(Recived_Param.get(4)==null)
  397. {
  398. Max_Amount="";
  399. }
  400. else
  401. {
  402. Max_Amount=Recived_Param.get(4);
  403. }
  404. if(Recived_Param.get(5)==null)
  405. {
  406. Sensop="";
  407. }
  408. else
  409. {
  410. Sensop=Recived_Param.get(5);
  411. }
  412. if(Recived_Param.get(6)==null)
  413. {
  414. Refop="";
  415. }
  416. else
  417. {
  418. Refop=Recived_Param.get(6);
  419. }
  420. if(Recived_Param.get(7)==null)
  421. {
  422. Libop="";
  423. }
  424. else
  425. {
  426. Libop=Recived_Param.get(7);
  427. }
  428. InvocationSingleton Invocation;
  429. Invocation=new InvocationSingleton();
  430. try
  431. {
  432. Invocation.getOfsUserInfos("CHQ");
  433. Operation_Parser Parser=new Operation_Parser(Invocation.getOperation(Account, Date_Debut,Date_Debut_Max,Min_Amount,Max_Amount,Sensop,Refop,Libop));
  434. Type listType = new TypeToken<Operation_History>() {}.getType();
  435. String json=new Gson().toJson(Parser.Get_Operation_History(),listType);
  436. return json;
  437. }
  438. catch(RemoteException | JsonSyntaxException | NullPointerException e)
  439. {
  440. e.printStackTrace();
  441. return "Application internal Error";
  442. }
  443. }
  444. public String Preparing_Add_Beneficiary_Request_To_Send(String Param)throws MalformedJsonException
  445. {
  446. try
  447. {
  448. Param=Param.replaceAll(",", "\",\"");
  449. Param=Param.replaceAll("\\{", "{\"");
  450. Param=Param.replaceAll("\\}", "\"}");
  451. Param=Param.replaceAll(":", "\":\"");
  452. Type Current_Type = new TypeToken<Beneficiary>() {}.getType();
  453. Beneficiary Current_Beneficiary = new Gson().fromJson(Param, Current_Type);
  454. InvocationSingleton Invocation;
  455. Invocation=new InvocationSingleton();
  456. String Add_Beneficiary_Response_Message=Invocation.addBeneficiary(Current_Beneficiary.Get_Useless(), Current_Beneficiary.Get_NickName(),Current_Beneficiary.Get_Note(),Current_Beneficiary.Get_Beneficiary_Account_Identifier(),Current_Beneficiary.Get_BIATNet_Customer_ID());
  457. Type listType = new TypeToken<String>() {}.getType();
  458. String json=new Gson().toJson(Add_Beneficiary_Response_Message,listType);
  459. return json;
  460. }
  461. catch(RemoteException | JsonSyntaxException | NullPointerException e)
  462. {
  463. e.printStackTrace();
  464. return "Application internal Error";
  465. }
  466. }
  467. public String Preparing_Remove_Beneficiary_Request_To_Send(String Param)throws MalformedJsonException
  468. {
  469. InvocationSingleton Invocation;
  470. try
  471. {
  472. Invocation=new InvocationSingleton();
  473. Type Type = new TypeToken<String>() {}.getType();
  474. String Current_Beneficiary_ID = new Gson().fromJson(Param, Type);
  475. return Invocation.removeBeneficiary(Current_Beneficiary_ID);
  476. }
  477. catch(RemoteException | JsonSyntaxException | NullPointerException e)
  478. {
  479. e.printStackTrace();
  480. return "Application internal Error";
  481. }
  482. }
  483. public String Preparing_Beneficiary_List_Request_To_Send(String Param)throws MalformedJsonException
  484. {
  485.  
  486. Type Type = new TypeToken<String>() {}.getType();
  487. String Client_ID = new Gson().fromJson(Param, Type);
  488. InvocationSingleton Invocation;
  489. Invocation=new InvocationSingleton();
  490. try
  491. {
  492. Invocation.getOfsUserInfos("CHQ");
  493. Beneficiry_Parser Parser=new Beneficiry_Parser(Invocation.getListeBenefIB(Client_ID));
  494. Type listType = new TypeToken<List<Beneficiary>>() {}.getType();
  495. String json=new Gson().toJson(Parser.Get_Beneficiaries_List(),listType);
  496. return json;
  497. }
  498. catch(RemoteException | JsonSyntaxException | NullPointerException e)
  499. {
  500. e.printStackTrace();
  501. return "Application internal Error";
  502. }
  503. }
  504. public String Preparing_Transfer_Inter_Creation(String Param)throws MalformedJsonException
  505. {
  506. Type Type = new TypeToken<Transfer>() {}.getType();
  507. Transfer Current_Transfer = new Gson().fromJson(Param, Type);
  508. InvocationSingleton Invocation;
  509. Invocation=new InvocationSingleton();
  510. try
  511. {
  512. Invocation.getOfsUserInfos("CHQ");
  513. String Virement_Inter1_Response=Invocation.virementInter1
  514. (
  515. Current_Transfer.Get_Sender_Account_ID(),
  516. Current_Transfer.Get_Reciver_Account_ID(),
  517. Current_Transfer.Get_Amount(),
  518. Current_Transfer.Get_Currency(),
  519. Current_Transfer.Get_Password(),
  520. Current_Transfer.Get_Phone_Number(),
  521. Current_Transfer.Get_BIATNet_Account_ID(),
  522. Current_Transfer.Get_Status()
  523. );
  524.  
  525. String[] Tokens=Virement_Inter1_Response.split("/");
  526. String Transfer_ID=Tokens[0].substring(Tokens[0].indexOf(86));
  527. Current_Transfer.Set_Transfer_ID(Transfer_ID);
  528. Type listType = new TypeToken<Transfer>() {}.getType();
  529. String json=new Gson().toJson(Current_Transfer,listType);
  530. return json;
  531. }
  532. catch(RemoteException | JsonSyntaxException | NullPointerException e)
  533. {
  534. e.printStackTrace();
  535. return "Application internal Error";
  536. }
  537. }
  538. public String Preparing_Transfer_Inter_Validation(String Param)throws MalformedJsonException
  539. {
  540. Type Type = new TypeToken<Transfer>() {}.getType();
  541. Transfer Current_Transfer = new Gson().fromJson(Param, Type);
  542. InvocationSingleton Invocation;
  543. Invocation=new InvocationSingleton();
  544. try
  545. {
  546. Invocation.getOfsUserInfos("CHQ");
  547. String Virement_Inter_Request=Invocation.virementInter
  548. (
  549. Current_Transfer.Get_Sender_Account_ID(),
  550. Current_Transfer.Get_Reciver_Account_ID(),
  551. Current_Transfer.Get_Amount(),
  552. Current_Transfer.Get_Currency(),
  553. Current_Transfer.Get_Password(),
  554. Current_Transfer.Get_Phone_Number(),
  555. Current_Transfer.Get_BIATNet_Account_ID(),
  556. "ATTENTE",
  557. Current_Transfer.Get_Transfer_ID(),
  558. Current_Transfer.Get_User_Code_Validation()
  559. );
  560. Type listType = new TypeToken<String>() {}.getType();
  561. String json=new Gson().toJson(Virement_Inter_Request,listType);
  562. return json;
  563. }
  564. catch(RemoteException | JsonSyntaxException | NullPointerException e)
  565. {
  566. e.printStackTrace();
  567. return "Application internal Error";
  568. }
  569. }
  570. public String Preparing_Transfer_Intra_Creation(String Param)throws MalformedJsonException
  571. {
  572. Type Type = new TypeToken<Transfer>() {}.getType();
  573. Transfer Current_Transfer = new Gson().fromJson(Param, Type);
  574. System.out.println("Recived param For Transfer Creation :");
  575. System.out.println(Current_Transfer.toString());
  576. InvocationSingleton Invocation;
  577. Invocation=new InvocationSingleton();
  578. try
  579. {
  580. Invocation.getOfsUserInfos("CHQ");
  581. String Virement_Intra_Response=Invocation.virementIntra1
  582. (
  583. Current_Transfer.Get_Sender_Account_ID(),
  584. Current_Transfer.Get_Reciver_Account_ID(),
  585. Current_Transfer.Get_Amount(),
  586. Current_Transfer.Get_Currency(),
  587. Current_Transfer.Get_Password(),
  588. Current_Transfer.Get_Phone_Number(),
  589. Current_Transfer.Get_BIATNet_Account_ID(),
  590. "NONE"
  591. );
  592.  
  593. String[] Tokens=Virement_Intra_Response.split("/");
  594. String Transfer_ID=Tokens[0].substring(Tokens[0].indexOf(86));
  595. Current_Transfer.Set_Transfer_ID(Transfer_ID);
  596. Type listType = new TypeToken<Transfer>() {}.getType();
  597. String json=new Gson().toJson(Current_Transfer,listType);
  598. return json;
  599. }
  600. catch(RemoteException | JsonSyntaxException | NullPointerException e)
  601. {
  602. e.printStackTrace();
  603. return "Application internal Error";
  604. }
  605. }
  606. public String Preparing_Transfer_Intra_Validation(String Param)throws MalformedJsonException
  607. {
  608. Type Type = new TypeToken<Transfer>() {}.getType();
  609. Transfer Current_Transfer = new Gson().fromJson(Param, Type);
  610. InvocationSingleton Invocation;
  611. System.out.println("Recived param For Transfer Validation :");
  612. System.out.println(Current_Transfer.toString());
  613. Invocation=new InvocationSingleton();
  614. try
  615. {
  616. Invocation.getOfsUserInfos("CHQ");
  617. String Virement_Intra_Request=Invocation.virementIntra
  618. (
  619. Current_Transfer.Get_Sender_Account_ID(),
  620. Current_Transfer.Get_Reciver_Account_ID(),
  621. Current_Transfer.Get_Amount(),
  622. Current_Transfer.Get_Currency(),
  623. Current_Transfer.Get_Password(),
  624. Current_Transfer.Get_Phone_Number(),
  625. Current_Transfer.Get_BIATNet_Account_ID(),
  626. Current_Transfer.Get_User_Code_Validation(),
  627. "ATTENTE",
  628. Current_Transfer.Get_Transfer_ID()
  629. );
  630. Type listType = new TypeToken<String>() {}.getType();
  631. String json=new Gson().toJson(Virement_Intra_Request,listType);
  632. return json;
  633. }
  634. catch(RemoteException | JsonSyntaxException | NullPointerException e)
  635. {
  636. e.printStackTrace();
  637. return "Application internal Error";
  638. }
  639. }
  640.  
  641. public String Preparing_Transfer_History_To_Send(String Param)throws MalformedJsonException
  642. {
  643. Type Type = new TypeToken<String>() {}.getType();
  644. String Client_ID = new Gson().fromJson(Param, Type);
  645. InvocationSingleton Invocation;
  646. Invocation=new InvocationSingleton();
  647. try
  648. {
  649. Invocation.getOfsUserInfos("CHQ");
  650. Transfer_History_Parser Parser=new Transfer_History_Parser(Put_Server_Response_Into_List(Invocation.SuiviVirements(Client_ID)));
  651. String json=new Gson().toJson(Parser.Get_Transfer_History_List());
  652. return json;
  653. }
  654. catch (RemoteException | JsonSyntaxException | NullPointerException e) {
  655. e.printStackTrace();
  656. return "Application internal Error";
  657. }
  658. }
  659. public String Preparing_Remboursement_Degressif_Montant_To_Send(String Param)throws MalformedJsonException
  660. {
  661. try
  662. {
  663. Type Type = new TypeToken<Loans>() {}.getType();
  664. Loans Simulation_Param = new Gson().fromJson(Param, Type);
  665.  
  666. MessageFactory messageFactory = MessageFactory.newInstance();
  667. SOAPMessage Soap_Message = messageFactory.createMessage();
  668. SOAPPart soapPart = Soap_Message.getSOAPPart();
  669.  
  670. String serverURI = "http://BIATSI/SI_SERVICES/Credit/";
  671.  
  672. // SOAP Envelope
  673. SOAPEnvelope envelope = soapPart.getEnvelope();
  674. envelope.addNamespaceDeclaration("",serverURI);
  675.  
  676. // SOAP Body
  677. //SOAPBody soapBody = envelope.getBody();
  678. SOAPBody soapBody = envelope.getBody();
  679. SOAPElement Remboursement_Degressif_Montant = soapBody.addChildElement("RemboursementDegressifMontant","","http://BIATSI/SI_SERVICES/Credit");
  680.  
  681. SOAPElement Montant_de_la_tranche = Remboursement_Degressif_Montant.addChildElement("Montant_de_la_tranche","","http://BIATSI/SI_SERVICES/Credit");
  682. Montant_de_la_tranche.addTextNode(Simulation_Param.Get_Montant_de_la_tranche());
  683.  
  684. SOAPElement Montant_Remboursement = Remboursement_Degressif_Montant.addChildElement("Montant_Remboursement","","http://BIATSI/SI_SERVICES/Credit");
  685. Montant_Remboursement.addTextNode(Simulation_Param.Get_Montant_Remboursement());
  686.  
  687. SOAPElement Taux = Remboursement_Degressif_Montant.addChildElement("Taux","","http://BIATSI/SI_SERVICES/Credit");
  688. Taux.addTextNode(Simulation_Param.Get_Taux());
  689.  
  690. SOAPElement Periodicite_Principal= Remboursement_Degressif_Montant.addChildElement("Periodicite_Principal","","http://BIATSI/SI_SERVICES/Credit");
  691. Periodicite_Principal.addTextNode(Simulation_Param.Get_Periodicite_Principal());
  692.  
  693. SOAPElement Periodicite_Interets = Remboursement_Degressif_Montant.addChildElement("Periodicite_Interets","","http://BIATSI/SI_SERVICES/Credit");
  694. Periodicite_Interets.addTextNode(Simulation_Param.Get_Periodicite_Interets());
  695.  
  696. SOAPElement DateDeblocage = Remboursement_Degressif_Montant.addChildElement("DateDeblocage","","http://BIATSI/SI_SERVICES/Credit");
  697. DateDeblocage.addTextNode(Simulation_Param.Get_DateDeblocage());
  698.  
  699. SOAPElement PremiereEcheancePrincipal = Remboursement_Degressif_Montant.addChildElement("PremiereEcheancePrincipal","","http://BIATSI/SI_SERVICES/Credit");
  700. PremiereEcheancePrincipal.addTextNode(Simulation_Param.Get_PremiereEcheancePrincipal());
  701.  
  702. SOAPElement PremiereEcheanceInterets = Remboursement_Degressif_Montant.addChildElement("PremiereEcheanceInterets","","http://BIATSI/SI_SERVICES/Credit");
  703. PremiereEcheanceInterets.addTextNode(Simulation_Param.Get_PremiereEcheanceInterets());
  704.  
  705. MimeHeaders headers = Soap_Message.getMimeHeaders();
  706. headers.addHeader("SOAPAction", serverURI + "RemboursementDegressifMontant");
  707. Soap_Message.saveChanges();
  708. Web_Service Web_Service_Caller=new Web_Service(Soap_Message);
  709. String json=new Gson().toJson(Web_Service_Caller.Get_Web_Service_Response_List());
  710. return json;
  711. }
  712. catch (SOAPException | JsonSyntaxException | NullPointerException e)
  713. {
  714. e.printStackTrace();
  715. return "Application internal Error";
  716. }
  717. }
  718. public String Preparing_Remboursement_Constant_Montant_To_Send(String Param)throws MalformedJsonException
  719. {
  720. try
  721. {
  722. Type Type = new TypeToken<Loans>() {}.getType();
  723. Loans Simulation_Param = new Gson().fromJson(Param, Type);
  724.  
  725. MessageFactory messageFactory = MessageFactory.newInstance();
  726. SOAPMessage Soap_Message = messageFactory.createMessage();
  727. SOAPPart soapPart = Soap_Message.getSOAPPart();
  728.  
  729. String serverURI = "http://BIATSI/SI_SERVICES/Credit/";
  730.  
  731. // SOAP Envelope
  732. SOAPEnvelope envelope = soapPart.getEnvelope();
  733. envelope.addNamespaceDeclaration("",serverURI);
  734.  
  735. // SOAP Body
  736. //SOAPBody soapBody = envelope.getBody();
  737. SOAPBody soapBody = envelope.getBody();
  738. SOAPElement Remboursement_Constant_Montant = soapBody.addChildElement("RemboursementConstantMontant","","http://BIATSI/SI_SERVICES/Credit");
  739.  
  740. SOAPElement Montant_de_la_tranche = Remboursement_Constant_Montant.addChildElement("Montant_de_la_tranche","","http://BIATSI/SI_SERVICES/Credit");
  741. Montant_de_la_tranche.addTextNode(Simulation_Param.Get_Montant_de_la_tranche());
  742.  
  743. SOAPElement Montant_Remboursement = Remboursement_Constant_Montant.addChildElement("Montant_Remboursement","","http://BIATSI/SI_SERVICES/Credit");
  744. Montant_Remboursement.addTextNode(Simulation_Param.Get_Montant_Remboursement());
  745.  
  746. SOAPElement Taux = Remboursement_Constant_Montant.addChildElement("Taux","","http://BIATSI/SI_SERVICES/Credit");
  747. Taux.addTextNode(Simulation_Param.Get_Taux());
  748.  
  749. SOAPElement Periodicite_Principal= Remboursement_Constant_Montant.addChildElement("Periodicite_Principal","","http://BIATSI/SI_SERVICES/Credit");
  750. Periodicite_Principal.addTextNode(Simulation_Param.Get_Periodicite_Principal());
  751.  
  752. SOAPElement Periodicite_Interets = Remboursement_Constant_Montant.addChildElement("Periodicite_Interets","","http://BIATSI/SI_SERVICES/Credit");
  753. Periodicite_Interets.addTextNode(Simulation_Param.Get_Periodicite_Interets());
  754.  
  755. SOAPElement DateDeblocage = Remboursement_Constant_Montant.addChildElement("DateDeblocage","","http://BIATSI/SI_SERVICES/Credit");
  756. DateDeblocage.addTextNode(Simulation_Param.Get_DateDeblocage());
  757.  
  758. SOAPElement PremiereEcheancePrincipal = Remboursement_Constant_Montant.addChildElement("PremiereEcheancePrincipal","","http://BIATSI/SI_SERVICES/Credit");
  759. PremiereEcheancePrincipal.addTextNode(Simulation_Param.Get_PremiereEcheancePrincipal());
  760.  
  761. SOAPElement PremiereEcheanceInterets = Remboursement_Constant_Montant.addChildElement("PremiereEcheanceInterets","","http://BIATSI/SI_SERVICES/Credit");
  762. PremiereEcheanceInterets.addTextNode(Simulation_Param.Get_PremiereEcheanceInterets());
  763.  
  764. MimeHeaders headers = Soap_Message.getMimeHeaders();
  765. headers.addHeader("SOAPAction", serverURI + "RemboursementConstantMontant");
  766. Soap_Message.saveChanges();
  767. System.out.println(Soap_Message.toString());
  768. Web_Service Web_Service_Caller=new Web_Service(Soap_Message);
  769. String json=new Gson().toJson(Web_Service_Caller.Get_Web_Service_Response_List());
  770. return json;
  771. }
  772. catch (SOAPException | JsonSyntaxException | NullPointerException e)
  773. {
  774. e.printStackTrace();
  775. return "Application internal Error";
  776. }
  777. }
  778. public String Preparing_Remboursement_Degressif_Duree_To_Send(String Param)throws MalformedJsonException
  779. {
  780. try
  781. {
  782. Type Type = new TypeToken<Loans>() {}.getType();
  783. Loans Simulation_Param = new Gson().fromJson(Param, Type);
  784.  
  785. MessageFactory messageFactory = MessageFactory.newInstance();
  786. SOAPMessage Soap_Message = messageFactory.createMessage();
  787. SOAPPart soapPart = Soap_Message.getSOAPPart();
  788.  
  789. String serverURI = "http://BIATSI/SI_SERVICES/Credit/";
  790.  
  791. // SOAP Envelope
  792. SOAPEnvelope envelope = soapPart.getEnvelope();
  793. envelope.addNamespaceDeclaration("",serverURI);
  794.  
  795. // SOAP Body
  796. //SOAPBody soapBody = envelope.getBody();
  797. SOAPBody soapBody = envelope.getBody();
  798. SOAPElement Remboursement_Degressif_Duree = soapBody.addChildElement("RemboursementDegressifDuree","","http://BIATSI/SI_SERVICES/Credit");
  799.  
  800. SOAPElement Montant_de_la_tranche = Remboursement_Degressif_Duree.addChildElement("Montant_de_la_tranche","","http://BIATSI/SI_SERVICES/Credit");
  801. Montant_de_la_tranche.addTextNode(Simulation_Param.Get_Montant_de_la_tranche());
  802.  
  803. SOAPElement Duree_Tranche = Remboursement_Degressif_Duree.addChildElement("Duree_Tranche","","http://BIATSI/SI_SERVICES/Credit");
  804. Duree_Tranche.addTextNode(Simulation_Param.Get_Duree_Tranche());
  805.  
  806. SOAPElement Taux = Remboursement_Degressif_Duree.addChildElement("Taux","","http://BIATSI/SI_SERVICES/Credit");
  807. Taux.addTextNode(Simulation_Param.Get_Taux());
  808.  
  809. SOAPElement Periodicite_Principal= Remboursement_Degressif_Duree.addChildElement("Periodicite_Principal","","http://BIATSI/SI_SERVICES/Credit");
  810. Periodicite_Principal.addTextNode(Simulation_Param.Get_Periodicite_Principal());
  811.  
  812. SOAPElement Periodicite_Interets = Remboursement_Degressif_Duree.addChildElement("Periodicite_Interets","","http://BIATSI/SI_SERVICES/Credit");
  813. Periodicite_Interets.addTextNode(Simulation_Param.Get_Periodicite_Interets());
  814.  
  815. SOAPElement DateDeblocage = Remboursement_Degressif_Duree.addChildElement("DateDeblocage","","http://BIATSI/SI_SERVICES/Credit");
  816. DateDeblocage.addTextNode(Simulation_Param.Get_DateDeblocage());
  817.  
  818. SOAPElement PremiereEcheancePrincipal = Remboursement_Degressif_Duree.addChildElement("PremiereEcheancePrincipal","","http://BIATSI/SI_SERVICES/Credit");
  819. PremiereEcheancePrincipal.addTextNode(Simulation_Param.Get_PremiereEcheancePrincipal());
  820.  
  821. SOAPElement PremiereEcheanceInterets = Remboursement_Degressif_Duree.addChildElement("PremiereEcheanceInterets","","http://BIATSI/SI_SERVICES/Credit");
  822. PremiereEcheanceInterets.addTextNode(Simulation_Param.Get_PremiereEcheanceInterets());
  823.  
  824. MimeHeaders headers = Soap_Message.getMimeHeaders();
  825. headers.addHeader("SOAPAction", serverURI + "RemboursementDegressifDuree");
  826. Soap_Message.saveChanges();
  827. System.out.println(Soap_Message.toString());
  828. Web_Service Web_Service_Caller=new Web_Service(Soap_Message);
  829. String json=new Gson().toJson(Web_Service_Caller.Get_Web_Service_Response_List());
  830. return json;
  831. }
  832. catch (SOAPException | JsonSyntaxException | NullPointerException e)
  833. {
  834. e.printStackTrace();
  835. return "Application internal Error";
  836. }
  837. }
  838. public String Preparing_Remboursement_Constant_Duree_To_Send(String Param)throws MalformedJsonException
  839. {
  840.  
  841. try
  842. {
  843. Type Type = new TypeToken<Loans>() {}.getType();
  844. Loans Simulation_Param = new Gson().fromJson(Param, Type);
  845.  
  846. MessageFactory messageFactory = MessageFactory.newInstance();
  847. SOAPMessage Soap_Message = messageFactory.createMessage();
  848. SOAPPart soapPart = Soap_Message.getSOAPPart();
  849.  
  850. String serverURI = "http://BIATSI/SI_SERVICES/Credit/";
  851. // SOAP Envelope
  852. SOAPEnvelope envelope = soapPart.getEnvelope();
  853. envelope.addNamespaceDeclaration("",serverURI);
  854.  
  855. // SOAP Body
  856. //SOAPBody soapBody = envelope.getBody();
  857. SOAPBody soapBody = envelope.getBody();
  858. SOAPElement Remboursement_Constant_Duree = soapBody.addChildElement("RemboursementConstantDuree","","http://BIATSI/SI_SERVICES/Credit");
  859.  
  860. SOAPElement Montant_de_la_tranche = Remboursement_Constant_Duree.addChildElement("Montant_de_la_tranche","","http://BIATSI/SI_SERVICES/Credit");
  861. Montant_de_la_tranche.addTextNode(Simulation_Param.Get_Montant_de_la_tranche());
  862.  
  863. SOAPElement Duree = Remboursement_Constant_Duree.addChildElement("Duree","","http://BIATSI/SI_SERVICES/Credit");
  864. Duree.addTextNode(Simulation_Param.Get_Duree());
  865.  
  866. SOAPElement Taux = Remboursement_Constant_Duree.addChildElement("Taux","","http://BIATSI/SI_SERVICES/Credit");
  867. Taux.addTextNode(Simulation_Param.Get_Taux());
  868.  
  869. SOAPElement Periodicite= Remboursement_Constant_Duree.addChildElement("Periodicite","","http://BIATSI/SI_SERVICES/Credit");
  870. Periodicite.addTextNode(Simulation_Param.Get_Periodicite());
  871.  
  872. SOAPElement DateDeblocage = Remboursement_Constant_Duree.addChildElement("DateDeblocage","","http://BIATSI/SI_SERVICES/Credit");
  873. DateDeblocage.addTextNode(Simulation_Param.Get_DateDeblocage());
  874.  
  875. SOAPElement PremiereEcheance = Remboursement_Constant_Duree.addChildElement("PremiereEcheance","","http://BIATSI/SI_SERVICES/Credit");
  876. PremiereEcheance.addTextNode(Simulation_Param.Get_PremiereEcheance());
  877.  
  878. MimeHeaders headers = Soap_Message.getMimeHeaders();
  879. headers.addHeader("SOAPAction", serverURI + "RemboursementConstantDuree");
  880. Soap_Message.saveChanges();
  881.  
  882.  
  883. Web_Service Web_Service_Caller=new Web_Service(Soap_Message);
  884. String json=new Gson().toJson(Web_Service_Caller.Get_Web_Service_Response_List());
  885. return json;
  886. }
  887. catch (SOAPException | JsonSyntaxException | NullPointerException e)
  888. {
  889. e.printStackTrace();
  890. return "Application internal Error";
  891. }
  892. }
  893.  
  894. private String Remove_Server_Response_Header(String Server_Response)
  895. {
  896. int i=0;
  897. int j=0;
  898. while(j!=2)
  899. {
  900. if(Server_Response.charAt(i)==44)
  901. {
  902. j++;
  903. }
  904. i++;
  905. }
  906. Server_Response=Server_Response.substring(i-1,Server_Response.length());
  907. return Server_Response;
  908. }
  909. private List<String> Put_Server_Response_Into_List(String Server_Response)
  910. {
  911. int i=0;
  912. List<String>Request_Resualt_List=new ArrayList<String>();
  913. String[] Tokens=Remove_Server_Response_Header(Server_Response).split(",\"");
  914. for (String One_Line : Tokens)
  915. {
  916. if(i>0)
  917. {
  918. One_Line="\""+One_Line;
  919. Request_Resualt_List.add(One_Line);
  920. }
  921. i++;
  922. }
  923. return Request_Resualt_List;
  924. }
  925. }
  926. ---------------------------------------------------------------------------------------------------------------------------------------------
  927. package com.Utility.BIATNET_V1;
  928.  
  929. import java.rmi.RemoteException;
  930. import java.util.ArrayList;
  931. import java.util.Iterator;
  932. import java.util.List;
  933. import java.util.NoSuchElementException;
  934. import java.util.regex.Matcher;
  935. import java.util.regex.Pattern;
  936. import com.Models.BIATNET_V1.Account;
  937. import com.Models.BIATNET_V1.Card;
  938. import com.Models.BIATNET_V1.Check_Book;
  939. import com.Models.BIATNET_V1.Customer;
  940. import com.Models.BIATNET_V1.Transfer_History;
  941.  
  942. public class User_Information_Parser
  943. {
  944. private Customer Current_Customer;
  945. public User_Information_Parser(List<String> Server_Response)
  946. {
  947. Current_Customer=new Customer();
  948. Create_Customer(Server_Response);
  949. }
  950. private String Remove_Server_Response_Header(String Server_Response)
  951. {
  952. try
  953. {
  954. int i=0;
  955. int j=0;
  956. while(j!=2)
  957. {
  958. if(Server_Response.charAt(i)==44)
  959. {
  960. j++;
  961. }
  962. i++;
  963. }
  964. Server_Response=Server_Response.substring(i-1,Server_Response.length());
  965. return Server_Response;
  966. }
  967. catch (NoSuchElementException e)
  968. {
  969. return null;
  970. }
  971. }
  972. private List<String> Put_Server_Response_Into_List(String Server_Response)
  973. {
  974. try
  975. {
  976. int i=0;
  977. List<String>Request_Resualt_List=new ArrayList<String>();
  978. String[] Tokens=Remove_Server_Response_Header(Server_Response).split(",\"");
  979. for (String One_Line : Tokens)
  980. {
  981. if(i>0)
  982. {
  983. One_Line="\""+One_Line;
  984. Request_Resualt_List.add(One_Line);
  985. }
  986. i++;
  987. }
  988. return Request_Resualt_List;
  989. }
  990. catch (NoSuchElementException e)
  991. {
  992. return null;
  993. }
  994. }
  995. private Customer Create_Customer(List<String> Server_Response)
  996. {
  997. List<Account> Current_Customer_Accounts=new ArrayList<Account>();
  998. try
  999. {
  1000.  
  1001. Account Current_Account;
  1002. int i=0;
  1003. Iterator<String> Cleaned_Server_Response_Iterator=Server_Response.iterator();
  1004. while(Cleaned_Server_Response_Iterator.hasNext())
  1005. {
  1006. if(i==0)
  1007. {
  1008. Current_Account=new Account();
  1009. String Current_Server_Response_Line=Cleaned_Server_Response_Iterator.next();
  1010. Iterator<String> Individual_Data_Iterator=Extract_Individual_Data(Current_Server_Response_Line).iterator();
  1011.  
  1012. Current_Customer.Set_ID(Individual_Data_Iterator.next().trim());
  1013. Current_Customer.Set_Phone_Number(Individual_Data_Iterator.next().trim());
  1014.  
  1015. Current_Account.Set_Identifier(Individual_Data_Iterator.next().trim());
  1016. Current_Account=Extract_Account_Balance(Current_Account);
  1017. Current_Account.Set_Check_Books(Extract_Check_Book_History(Current_Account.Get_Identifier()));
  1018. Current_Customer.Set_Status(Individual_Data_Iterator.next().trim());
  1019. Current_Customer.Set_Password(Individual_Data_Iterator.next().trim());
  1020. Current_Customer.Set_Full_Name(Individual_Data_Iterator.next().trim());
  1021. Current_Account.Set_Fonction(Individual_Data_Iterator.next().trim());
  1022.  
  1023. Current_Customer.Set_Unknown_ID(Individual_Data_Iterator.next().trim());
  1024. Current_Customer.Set_Cards(Extract_Customer_Cards_List(Current_Customer.Get_Unknown_ID()));
  1025. Current_Account.Set_Account_CTOS(Individual_Data_Iterator.next().trim());
  1026. String Options=Individual_Data_Iterator.next().trim();
  1027. Current_Customer.Set_Transfers_History(Extract_Transfer_History_Data(Current_Customer.Get_Unknown_ID()));
  1028. if(Options.indexOf("2") >= 0)
  1029. {
  1030. Current_Customer.Set_Virement(1);
  1031. }
  1032. else
  1033. {
  1034. Current_Customer.Set_Virement(0);
  1035. }
  1036. if(Options.indexOf("1") >= 0)
  1037. {
  1038. Current_Customer.Set_Download(1);
  1039. }
  1040. else
  1041. {
  1042. Current_Customer.Set_Download(0);
  1043. }
  1044. Current_Account.Set_Owner(Individual_Data_Iterator.next().trim());
  1045. Current_Customer_Accounts.add(Current_Account);
  1046. i++;
  1047. }
  1048. else
  1049. {
  1050. Current_Account=new Account();
  1051. String Current_Server_Response_Line=Cleaned_Server_Response_Iterator.next();
  1052. Iterator<String> Individual_Data_Iterator=Extract_Individual_Data(Current_Server_Response_Line).iterator();
  1053.  
  1054. Individual_Data_Iterator.next();
  1055. Individual_Data_Iterator.next();
  1056.  
  1057. Current_Account.Set_Identifier(Individual_Data_Iterator.next().trim());
  1058.  
  1059. Current_Account=Extract_Account_Balance(Current_Account);
  1060. Current_Account.Set_Check_Books(Extract_Check_Book_History(Current_Account.Get_Identifier()));
  1061.  
  1062. Individual_Data_Iterator.next();
  1063. Individual_Data_Iterator.next();
  1064. Individual_Data_Iterator.next();
  1065.  
  1066. Current_Account.Set_Fonction(Individual_Data_Iterator.next().trim());
  1067.  
  1068. Individual_Data_Iterator.next();
  1069.  
  1070. Current_Account.Set_Account_CTOS(Individual_Data_Iterator.next().trim());
  1071.  
  1072. Individual_Data_Iterator.next();
  1073.  
  1074. Current_Account.Set_Owner(Individual_Data_Iterator.next().trim());
  1075.  
  1076. Current_Customer_Accounts.add(Current_Account);
  1077. }
  1078. }
  1079. Current_Customer.Set_Accounts(Current_Customer_Accounts);
  1080. return Current_Customer;
  1081. } catch (NoSuchElementException e)
  1082. {
  1083. return null;
  1084. }
  1085. }
  1086. private List<String> Extract_Individual_Data(String Current_Line)
  1087. {
  1088. try {
  1089. Matcher matcher=null;
  1090. ArrayList<String> Individual_Data = new ArrayList<>();
  1091. Pattern regex = Pattern.compile("\"([^\"]*)\"");
  1092. matcher = regex.matcher(Current_Line);
  1093. try
  1094. {
  1095. while(matcher.find())
  1096. {
  1097. Individual_Data.add(matcher.group(1));
  1098. }
  1099. }
  1100. catch(NullPointerException ex)
  1101. {
  1102. System.out.println("Empty String");
  1103. }
  1104. return Individual_Data;
  1105. } catch (NoSuchElementException e)
  1106. {
  1107. return null;
  1108. }
  1109. }
  1110. private Account Extract_Account_Balance(Account Current_Account)
  1111. {
  1112. Account Current_Account1;
  1113. Current_Account1=Current_Account;
  1114. InvocationSingleton Invocation=new InvocationSingleton();
  1115. String Request_Response=null;
  1116. try
  1117. {
  1118. Invocation.getOfsUserInfos("CHQ");
  1119. Request_Response = Invocation.getSoldeComptes(Current_Account1.Get_Identifier());
  1120. Iterator<String> Balance_Server_Response_Iterator=Put_Server_Response_Into_List(Request_Response).iterator();
  1121. Iterator<String> Current_Balance_Iterator=Extract_Individual_Data(Balance_Server_Response_Iterator.next()).iterator();
  1122. Current_Balance_Iterator.next();
  1123. Current_Balance_Iterator.next();
  1124. Current_Account1.Set_Last_Operation_Date(Current_Balance_Iterator.next().trim());
  1125. Current_Account1.Set_Countable_Balance(Current_Balance_Iterator.next().trim());
  1126. Current_Account1.Set_Available_Balance(Current_Balance_Iterator.next().trim());
  1127. Current_Account1.Set_Devise(Current_Balance_Iterator.next().trim());
  1128. return Current_Account1;
  1129. }
  1130. catch (RemoteException | NoSuchElementException e)
  1131. {
  1132. e.printStackTrace();
  1133. return null;
  1134. }
  1135. }
  1136. private List<Check_Book> Extract_Check_Book_History(String Identifier)
  1137. {
  1138. List<Check_Book> Current_Account_Check_Book_List=new ArrayList<Check_Book>();
  1139. Check_Book Current_Check_Book;
  1140. InvocationSingleton Invocation=new InvocationSingleton();
  1141. String Request_Response=null;
  1142. try
  1143. {
  1144. Invocation.getOfsUserInfos("CHQ");
  1145. Request_Response=Invocation.SuiviCommandeChequier(Identifier);
  1146. Iterator<String> Request_Response_Iterator=Put_Server_Response_Into_List(Request_Response).iterator();
  1147. while(Request_Response_Iterator.hasNext())
  1148. {
  1149. Current_Check_Book=new Check_Book();
  1150. String Current_Line=Request_Response_Iterator.next();
  1151. List<String> Current_Data=Extract_Individual_Data(Current_Line);
  1152. if(Current_Data.size()==1)
  1153. {
  1154. Current_Check_Book.Set_Status("Aucune demande en cours");
  1155. }
  1156. else
  1157. {
  1158. Iterator<String> Current_Data_Iterator=Current_Data.iterator();
  1159. Current_Check_Book.Set_ID(Current_Data_Iterator.next().trim());
  1160. Current_Data_Iterator.next();
  1161. Current_Check_Book.Set_Date_Request(Current_Data_Iterator.next().trim());
  1162. Current_Check_Book.Set_Number_Of_Pages(Integer.parseInt(Current_Data_Iterator.next().trim()));
  1163. Current_Check_Book.Set_Barred(Current_Data_Iterator.next().trim());
  1164. Current_Check_Book.Set_Status(Current_Data_Iterator.next().trim());
  1165. }
  1166. Current_Account_Check_Book_List.add(Current_Check_Book);
  1167. }
  1168. return Current_Account_Check_Book_List;
  1169. }
  1170. catch(RemoteException | NoSuchElementException e)
  1171. {
  1172. e.printStackTrace();
  1173. return null;
  1174. }
  1175.  
  1176. }
  1177. private List<Card> Extract_Customer_Cards_List(String Unknown_ID)
  1178. {
  1179. InvocationSingleton Invocation=new InvocationSingleton();
  1180. List<Card> Current_Customuer_Cards_List=new ArrayList<Card>();
  1181. Card Current_Card;
  1182. String Request_Response=null;
  1183. try
  1184. {
  1185. Invocation.getOfsUserInfos("CHQ");
  1186. Request_Response=Invocation.getListecartes(Unknown_ID);
  1187. Iterator<String> Request_Response_Iterator=Put_Server_Response_Into_List(Request_Response).iterator();
  1188. //Iterator<String> Request_Response_Iterator=Put_Server_Response_Into_List(List_Carte_Server_Response).iterator();
  1189. while(Request_Response_Iterator.hasNext())
  1190. {
  1191. try
  1192. {
  1193. Current_Card=new Card();
  1194. Iterator<String> Current_Card_Data_Iterator=Extract_Individual_Data(Request_Response_Iterator.next()).iterator();
  1195. Current_Card.Set_Number(Current_Card_Data_Iterator.next().trim());
  1196. Current_Card.Set_Owner(Current_Card_Data_Iterator.next().trim());
  1197. Current_Card.Set_Type(Current_Card_Data_Iterator.next().trim());
  1198. Current_Card.Set_ID_Cout(Current_Card_Data_Iterator.next().trim());
  1199. Current_Customuer_Cards_List.add(Current_Card);
  1200. }
  1201. catch (NoSuchElementException e)
  1202. {
  1203. Current_Card=new Card();
  1204. }
  1205. }
  1206. return Current_Customuer_Cards_List;
  1207. }
  1208. catch(RemoteException | NoSuchElementException e)
  1209. {
  1210. e.printStackTrace();
  1211. return null;
  1212. }
  1213. }
  1214. private List<Transfer_History> Extract_Transfer_History_Data(String Unknown_ID)
  1215. {
  1216. InvocationSingleton Invocation;
  1217. Invocation=new InvocationSingleton();
  1218. try
  1219. {
  1220. Invocation.getOfsUserInfos("CHQ");
  1221. Transfer_History_Parser Parser=new Transfer_History_Parser(Put_Server_Response_Into_List(Invocation.SuiviVirements(Unknown_ID)));
  1222. return Parser.Get_Transfer_History_List();
  1223. }
  1224. catch (RemoteException e) {
  1225. e.printStackTrace();
  1226. return null;
  1227. }
  1228. }
  1229. public Customer Get_Gustomer()
  1230. {
  1231. return Current_Customer;
  1232. }
  1233. }
  1234. ---------------------------------------------------------------------------------------------------------------
  1235. package com.Models.BIATNET_V1;
  1236.  
  1237. import java.util.ArrayList;
  1238. import java.util.List;
  1239.  
  1240. public class Customer
  1241. {
  1242. private String ID,Unknown_ID,Phone_Number,status,Password,Full_Name;
  1243. private int Virement,Download;
  1244. private List<Account> Accounts=new ArrayList<Account>();
  1245. private List<Card> Cards=new ArrayList<Card>();
  1246. private List<Transfer_History> Transfers_History=new ArrayList<Transfer_History>();
  1247.  
  1248. public String Get_ID() {
  1249. return ID;
  1250. }
  1251.  
  1252. public void Set_ID(String ID) {
  1253. this.ID = ID;
  1254. }
  1255.  
  1256. public String Get_Unknown_ID() {
  1257. return Unknown_ID;
  1258. }
  1259.  
  1260. public void Set_Unknown_ID(String Unknown_ID) {
  1261. this.Unknown_ID = Unknown_ID;
  1262. }
  1263.  
  1264. public String Get_Phone_Number() {
  1265. return Phone_Number;
  1266. }
  1267.  
  1268. public void Set_Phone_Number(String Phone_Number) {
  1269. this.Phone_Number = Phone_Number;
  1270. }
  1271.  
  1272. public String Get_Status() {
  1273. return status;
  1274. }
  1275.  
  1276. public void Set_Status(String status) {
  1277. this.status = status;
  1278. }
  1279.  
  1280. public String Get_Password() {
  1281. return Password;
  1282. }
  1283.  
  1284. public void Set_Password(String Password) {
  1285. this.Password = Password;
  1286. }
  1287.  
  1288. public String Get_Full_Name() {
  1289. return Full_Name;
  1290. }
  1291.  
  1292. public void Set_Full_Name(String Full_Name) {
  1293. this.Full_Name = Full_Name;
  1294. }
  1295.  
  1296. public int Get_Virement() {
  1297. return Virement;
  1298. }
  1299.  
  1300. public void Set_Virement(int Virement) {
  1301. this.Virement = Virement;
  1302. }
  1303.  
  1304. public int Get_Download() {
  1305. return Download;
  1306. }
  1307.  
  1308. public void Set_Download(int Download) {
  1309. this.Download = Download;
  1310. }
  1311.  
  1312. public List<Account> Get_Accounts() {
  1313. return Accounts;
  1314. }
  1315.  
  1316. public void Set_Accounts(List<Account> Accounts) {
  1317. this.Accounts = Accounts;
  1318. }
  1319.  
  1320. public List<Card> Get_Cards() {
  1321. return Cards;
  1322. }
  1323.  
  1324. public void Set_Cards(List<Card> Cards) {
  1325. this.Cards = Cards;
  1326. }
  1327. public void Set_Transfers_History(List<Transfer_History> Transfers_History)
  1328. {
  1329. this.Transfers_History=Transfers_History;
  1330. }
  1331. public List<Transfer_History> Get_Transfers_History()
  1332. {
  1333. return this.Transfers_History;
  1334. }
  1335.  
  1336.  
  1337. @Override
  1338. public String toString() {
  1339. return "Customer [ID=" + ID + ", Unknown_ID=" + Unknown_ID + ", Phone_Number=" + Phone_Number + ", status="
  1340. + status + ", Password=" + Password + ", Full_Name=" + Full_Name + ", Virement=" + Virement
  1341. + ", Download=" + Download + ", Accounts=" + Accounts + ", Cards=" + Cards + "]";
  1342. }
  1343.  
  1344. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement