Advertisement
Guest User

triggerHelper

a guest
May 29th, 2018
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 48.92 KB | None | 0 0
  1. package logic;
  2.  
  3.  
  4. /*
  5.  __   _______     __  .___________. __     _______.        _______..___________. __    __  .______    __   _______     .______    __    __  .___________.    __  .___________.   ____    __    ____  ______   .______       __  ___      _______.      
  6. |  | |   ____|   |  | |           |(_ )   /       |       /       ||           ||  |  |  | |   _  \  |  | |       \    |   _  \  |  |  |  | |           |   |  | |           |   \   \  /  \  /   / /  __  \  |   _  \     |  |/  /     /       |      
  7. |  | |  |__      |  | `---|  |----` |/   |   (----`      |   (----``---|  |----`|  |  |  | |  |_)  | |  | |  .--.  |   |  |_)  | |  |  |  | `---|  |----`   |  | `---|  |----`    \   \/    \/   / |  |  |  | |  |_)  |    |  '  /     |   (----`      
  8. |  | |   __|     |  |     |  |            \   \           \   \        |  |     |  |  |  | |   ___/  |  | |  |  |  |   |   _  <  |  |  |  |     |  |        |  |     |  |          \            /  |  |  |  | |      /     |    <       \   \          
  9. |  | |  |        |  |     |  |        .----)   |      .----)   |       |  |     |  `--'  | |  |      |  | |  '--'  |   |  |_)  | |  `--'  |     |  |        |  |     |  |           \    /\    /   |  `--'  | |  |\  \----.|  .  \  .----)   |        
  10. |__| |__|        |__|     |__|        |_______/       |_______/        |__|      \______/  | _|      |__| |_______/    |______/   \______/      |__|        |__|     |__|            \__/  \__/     \______/  | _| `._____||__|\__\ |_______/          
  11.                                                                 __  .___________. __     _______.   .__   __.   ______   .___________.        _______..___________. __    __  .______    __   _______                                                  
  12.                                                                |  | |           |(_ )   /       |   |  \ |  |  /  __  \  |           |       /       ||           ||  |  |  | |   _  \  |  | |       \                                                
  13.                                                                |  | `---|  |----` |/   |   (----`   |   \|  | |  |  |  | `---|  |----`      |   (----``---|  |----`|  |  |  | |  |_)  | |  | |  .--.  |                                                
  14.                                                                |  |     |  |            \   \       |  . `  | |  |  |  |     |  |            \   \        |  |     |  |  |  | |   ___/  |  | |  |  |  |                                                
  15.                                                                |  |     |  |        .----)   |      |  |\   | |  `--'  |     |  |        .----)   |       |  |     |  `--'  | |  |      |  | |  '--'  |                                                
  16.                                                                |__|     |__|        |_______/       |__| \__|  \______/      |__|        |_______/        |__|      \______/  | _|      |__| |_______/      
  17.  
  18. */
  19. //import java.awt.List;
  20. import java.io.IOException;
  21. import java.lang.reflect.Array;
  22. import java.net.MalformedURLException;
  23. import java.net.URL;
  24. import java.util.ArrayList;
  25. import java.util.Arrays;
  26. import java.util.Collections;
  27. import java.util.HashMap;
  28. import java.util.Map;
  29. import java.util.concurrent.TimeUnit;
  30. import java.util.List;
  31.  
  32. import org.apache.xmlrpc.XmlRpcException;
  33. import org.apache.xmlrpc.client.XmlRpcClient;
  34. import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
  35. import org.codehaus.jettison.json.JSONException;
  36.  
  37. import com.thoughtworks.xstream.XStream;
  38.  
  39.  
  40. import messages.*;
  41. import rabbitMQ.Sender;
  42.  
  43. public class triggerHelper {       
  44.     static int userid = 142;
  45.     static String UUUID = "c5164143-b869-4afb-bfd1-1f96bd47ccfa"; //helper person not allowed
  46.     static int userID = 100; //helper person not allowed
  47.     static String namehelper = "test123654";
  48.     static int invoicehelper = 12;
  49.     static int productid =83;
  50.    
  51.  
  52. /* ************************************************************************************************************************************************************** */
  53.             public static void main(String[] args) throws Exception {
  54.                 // TODO Auto-generated method stub
  55.                 //newPersonFlow();
  56.                 //checkIfUUIDIsEmpty();
  57.                 //setPeronOnNotAllowedViaUserID(userID);
  58.                 //setPersonOnNotAllowedViaUserUUID(UUUID); // not working -> doesn't work with string inputs atm
  59.                 //setPersonOnNotAllowedViaUserName(namehelper);  // not working -> doesn't work with string inputs atm
  60.                 //createProduct();
  61.                 //invoicehelperfunction(0006);
  62.                 //getPayment();
  63.                 //newProduct();
  64.                 //getStartValuesForProducts();
  65.                 //getStartValuesForPersons();
  66.                 //newPersonFlow();
  67.             }
  68. /* ************************************************************************************************************************************************************** */
  69. //deze functie gaat het huidige producten aantal opzoeken
  70.  
  71. public static int getStartValuesForProducts() throws XmlRpcException, MalformedURLException {
  72.     //connection
  73.     final String url = "http://10.3.50.48:8069",
  74.             db = "KassaGroepC",
  75.             username ="ricardo.mayorga.mera@student.ehb.be",
  76.             password = "opiq188";
  77.             final XmlRpcClient client = new XmlRpcClient();
  78.             final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
  79.             common_config.setServerURL(
  80.             new URL(String.format("%s/xmlrpc/2/common", url)));
  81.             int uid =  (int) client.execute(common_config,"authenticate",Arrays.asList(db,username, password, Collections.emptyMap()));
  82.             final XmlRpcClient models = new XmlRpcClient() {
  83.                 {
  84.                 setConfig (new XmlRpcClientConfigImpl() {
  85.                     {
  86.                     setServerURL(new URL (String.format("%s/xmlrpc/2/object", url)));
  87.                     }
  88.                 });
  89.             }
  90.         }; 
  91.         //search ALL productid's
  92.         final java.util.List<Object> ids= Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  93.                 db, uid, password,
  94.                 "product.template", "search",
  95.                 Arrays.asList(Arrays.asList(
  96.                 )))));
  97.        
  98.         final java.util.List<Object> fields = Arrays.asList((Object[])models.execute
  99.                 ("execute_kw",Arrays.asList(db,uid,password,"product.template","read",Arrays.asList(ids),
  100.                 new HashMap()
  101.                 {{put("fields",Arrays.asList("id"));}})));
  102.                 //System.out.println(ids);
  103.                 List list = (List)ids;
  104.                
  105.                 int maxvaluefromproductlist = (int)Collections.max(list);
  106.                 //System.out.println(maxvaluefromproductlist);
  107.                 return maxvaluefromproductlist;
  108. }
  109.  
  110. public static int getStartValuesForPersons() throws XmlRpcException, MalformedURLException{
  111.     //connection
  112.         final String url = "http://10.3.50.48:8069",
  113.                 db = "KassaGroepC",
  114.                 username ="ricardo.mayorga.mera@student.ehb.be",
  115.                 password = "opiq188";
  116.                 final XmlRpcClient client = new XmlRpcClient();
  117.                 final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
  118.                 common_config.setServerURL(
  119.                 new URL(String.format("%s/xmlrpc/2/common", url)));
  120.                 int uid =  (int) client.execute(common_config,"authenticate",Arrays.asList(db,username, password, Collections.emptyMap()));
  121.                 final XmlRpcClient models = new XmlRpcClient() {
  122.                     {
  123.                     setConfig (new XmlRpcClientConfigImpl() {
  124.                         {
  125.                         setServerURL(new URL (String.format("%s/xmlrpc/2/object", url)));
  126.                         }
  127.                     });
  128.                 }
  129.             }; 
  130.            
  131.           //search ALL productid's
  132.             final java.util.List<Object> ids= Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  133.                     db, uid, password,
  134.                     "res.partner", "search",
  135.                     Arrays.asList(Arrays.asList(
  136.                     )))));
  137.            
  138.             final java.util.List<Object> fields = Arrays.asList((Object[])models.execute
  139.                     ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(ids),
  140.                     new HashMap()
  141.                     {{put("fields",Arrays.asList("id"));}})));
  142.                     //System.out.println(ids);
  143.                     List list = (List)ids;
  144.                    
  145.                     int maxvaluefrompersonlist = (int)Collections.max(list);
  146.                     //System.out.println(maxvaluefrompersonlist);
  147.                     return maxvaluefrompersonlist;
  148.            
  149.            
  150. }
  151.  
  152. public static void newPersonFlow() throws Exception {
  153.                 final String url = "http://10.3.50.48:8069",
  154.                 db = "KassaGroepC",
  155.                 username ="ricardo.mayorga.mera@student.ehb.be",
  156.                 password = "opiq188";
  157.                 final XmlRpcClient client = new XmlRpcClient();
  158.                 final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
  159.                 common_config.setServerURL(
  160.                 new URL(String.format("%s/xmlrpc/2/common", url)));
  161.                 int uid =  (int) client.execute(common_config,"authenticate",Arrays.asList(db,username, password, Collections.emptyMap()));
  162.                 final XmlRpcClient models = new XmlRpcClient() {
  163.                     {
  164.                     setConfig (new XmlRpcClientConfigImpl() {
  165.                         {
  166.                         setServerURL(new URL (String.format("%s/xmlrpc/2/object", url)));
  167.                         }
  168.                     });
  169.                 }
  170.             };     
  171.             //search and read      
  172.             //USER VOOR UPDATE
  173.             final java.util.List<Object> ids= Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  174.                         db, uid, password,
  175.                         "res.partner", "search",
  176.                         Arrays.asList(Arrays.asList(
  177.                         Arrays.asList("id", "=", userid))))));
  178.                         //System.out.println(ids);
  179.            
  180.             System.out.println("USER POLLING SYSTEM");
  181.            
  182.             if (ids != null && !ids.isEmpty()){
  183.                
  184.                     //System.out.print("userid: " + userid + " is not empty \n");
  185.                     int displayhelp = userid;
  186.                     System.out.println("Person found for userid: "  + displayhelp + ":");
  187.                    
  188.                     ///DONT TOUCH ABOVE
  189.                    
  190.                    
  191.                     models.execute("execute_kw", Arrays.asList(
  192.                             db, uid, password,
  193.                             "res.partner", "write",
  194.                             Arrays.asList(
  195.                                 Arrays.asList(userid),
  196.                                 new HashMap() {{     put("x_isallowed", true);
  197.                                               }}
  198.                             )
  199.                         ));
  200.                    
  201.                    
  202.                     //DONT TOUCH BELOW
  203.                     final java.util.List<Object> fields = Arrays.asList((Object[])models.execute
  204.                             ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(ids),
  205.                             new HashMap()
  206.                             {{put("fields",Arrays.asList("x_uuid","role","name","lastname","street","email","x_isactive","x_isallowed","x_isregistered","version","timestamp"));}})));
  207.                             System.out.println(fields);
  208.                            
  209.  
  210. final java.util.List<Object> uuids = Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  211.         db, uid, password,
  212.         "res.partner", "search",
  213.         Arrays.asList(Arrays.asList(
  214.         Arrays.asList("id", "=", userid),
  215.         Arrays.asList("x_uuid", "!=", false))))));
  216.        
  217.  
  218. if (ids != null && !uuids.isEmpty()){
  219.     int useridhelper = userid;
  220.     //System.out.print("UUID for userid: " + userid + " is not empty \n");
  221.     System.out.println("UUID for userid " + useridhelper + ": ");
  222.     final java.util.List<Object> fields1 = Arrays.asList((Object[])models.execute
  223.             ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(ids),
  224.             new HashMap()
  225.             {{put("fields",Arrays.asList("x_uuid"));}})));
  226.            System.out.println(fields1);
  227.            // System.out.print("looks for userid: " + "70" + " for the next search\n");
  228.    
  229. } else {
  230.     //USER WRD UPDATED HIER
  231.     System.out.println("THERE IS NO UUID YET FOR THIS PERSON\n");
  232.     System.out.println("FETCHING UUID FOR THIS PERSON\n");
  233.     //helper userid -> to string
  234.     String useridhelper = Integer.toString(userid);
  235.     //fetches UUID for userid
  236.     String n = UUIDHelper.createUUID(useridhelper);
  237.     //update the user and adds UUID
  238.     System.out.println(userid);
  239.     models.execute("execute_kw", Arrays.asList(
  240.             db, uid, password,
  241.             "res.partner", "write",
  242.             Arrays.asList(
  243.                 Arrays.asList(userid),
  244.                 new HashMap() {{ put("x_uuid", n);
  245.                                  put("x_isallowed", true);
  246.                                  put("x_isregistered", true);
  247.                                  put("x_isactive", true);
  248.                                  }}
  249.             )
  250.         ));
  251.    
  252.     //UPDATED USER MESSAGE
  253.     System.out.println("Person found for userid: "  + displayhelp + ":");
  254.     final java.util.List<Object> fields1 = Arrays.asList((Object[])models.execute
  255.             ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(ids),
  256.             new HashMap()
  257.             {{put("fields",Arrays.asList("x_uuid","role","name","lastname","street","email","x_isactive","x_isallowed","x_isregistered","version","timestamp"));}})));
  258.             System.out.println(fields1);
  259.             for (Object object : fields1) {
  260.             HashMap<String,Object> result = (HashMap) object;
  261.                            
  262.     System.out.println("UUID MADE FOR USERID: " + userid + " END OF FLOW\n\n" );
  263.     System.out.println("Building and sending message...\n\n");
  264.    
  265.     //newPerson messageuitsturen
  266.     message msg = new message();      
  267.      newPerson p = new newPerson(
  268.              result.get("x_uuid").toString(),
  269.              "visitor",
  270.              result.get("name").toString(),
  271.              "even een test achternaam",
  272.              result.get("street").toString(),
  273.              result.get("email").toString(),
  274.              //Boolean.valueOf(result.get("x_isactive").toString()),
  275.              true,
  276.              Boolean.valueOf(result.get("x_isallowed").toString()),
  277.              1,
  278.              UUIDHelper.getCurrentDate());
  279.      
  280.      XStream x = new XStream();
  281.      x.alias("message",message.class);
  282.      msg.setBody(p);
  283.      msg.setMessageType("newPerson");
  284.      x.alias("newPerson", newPerson.class);
  285.      String toSend=x.toXML(msg);
  286.      Sender.Send(toSend);  
  287.      
  288.     }
  289.    
  290.  
  291. }                                      
  292. userid++;              
  293.             } else {
  294.                 System.out.println("userid: " + userid + " is empty, trying again in 5 seconds...\n");
  295.                 //System.out.println("using userid: " + userid + " for the next search");
  296.             }    
  297.  
  298.             System.out.print("looks for userid: " + userid + " in the next search\n\n ________________________________________________________________________________________________________ \n\n");
  299.  
  300. }
  301.  
  302. public static void setPeronOnNotAllowedViaUserID(int userID) throws Exception{
  303.     //connection stuff
  304.     final String url = "http://10.3.50.48:8069",
  305.             db = "KassaGroepC",
  306.             username ="ricardo.mayorga.mera@student.ehb.be",
  307.             password = "opiq188";
  308.             final XmlRpcClient client = new XmlRpcClient();
  309.             final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
  310.             common_config.setServerURL(
  311.             new URL(String.format("%s/xmlrpc/2/common", url)));
  312.             int uid =  (int) client.execute(common_config,"authenticate",Arrays.asList(db,username, password, Collections.emptyMap()));
  313.             final XmlRpcClient models = new XmlRpcClient() {
  314.                 {
  315.                 setConfig (new XmlRpcClientConfigImpl() {
  316.                     {
  317.                     setServerURL(new URL (String.format("%s/xmlrpc/2/object", url)));
  318.                     }
  319.                 });
  320.             }
  321.             };   
  322.             //search and read      
  323.             final java.util.List<Object> ids= Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  324.                     db, uid, password,
  325.                     "res.partner", "search",
  326.                     Arrays.asList(Arrays.asList(
  327.                     Arrays.asList("id", "=", userID))))));
  328.             if (ids != null && !ids.isEmpty()){
  329.                 //System.out.print("userid: " + userid + " is not empty \n");
  330.                 int displayhelp = userID;
  331.                 System.out.println("Person found for userid: "  + displayhelp + ":");
  332.                 System.out.println("User before function: ");
  333.                 final java.util.List<Object> fields = Arrays.asList((Object[])models.execute
  334.                         ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(ids),
  335.                         new HashMap()
  336.                         {{put("fields",Arrays.asList("x_uuid","Bezoeker","name","street","email","x_isactive","x_isallowed","version","timestamp"));}})));
  337.                         System.out.println(fields);
  338.                         models.execute("execute_kw", Arrays.asList(
  339.                                 db, uid, password,
  340.                                 "res.partner", "write",
  341.                                 Arrays.asList(
  342.                                     Arrays.asList(userID),
  343.                                     new HashMap() {{ put("x_isallowed", false); }}
  344.                                 )
  345.                             ));
  346.                         System.out.println("set user to not allowed");
  347.                             // get record name after having changed it
  348.                             Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  349.                                 db, uid, password,
  350.                                 "res.partner", "name_get",
  351.                                 Arrays.asList(Arrays.asList(userID))
  352.                             )));
  353.                             final java.util.List<Object> fields1 = Arrays.asList((Object[])models.execute
  354.                                     ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(ids),
  355.                                     new HashMap()
  356.                                     {{put("fields",Arrays.asList("x_uuid","Bezoeker","name","street","email","x_isactive","x_isallowed","version","timestamp"));}})));
  357.                                     System.out.println(fields1);
  358.                                    
  359.                                    
  360.                                    
  361.                                     Odoo o = new Odoo();
  362.                                     List<Object> id1= Arrays.asList((Object[])o.models.execute("execute_kw", Arrays.asList(
  363.                                             o.db, o.uid, o.password,
  364.                                             "res.partner", "search",
  365.                                             Arrays.asList(Arrays.asList(
  366.                                             Arrays.asList("id", "=", userid))))));
  367.                                     List<Object> fields11 = Arrays.asList((Object[])o.models.execute("execute_kw",Arrays.asList(o.db,o.uid,o.password,"res.partner","read",
  368.                                             Arrays.asList(id1),
  369.                                             new HashMap() {{
  370.                                                 put("fields",Arrays.asList("name","x_uuid","street"));
  371.                                             }}
  372.                                             )));
  373.                                    
  374.                                     for (Object object : fields) {
  375.                                        HashMap<String,Object> result = (HashMap) object;
  376.                                      
  377.  
  378.                                      message msg = new message();
  379.                                      newPerson p = new newPerson(
  380.                                              result.get("x_uuid").toString(),
  381.                                              "visitor",
  382.                                              result.get("name").toString(),
  383.                                              "even een test achternaam",
  384.                                              result.get("street").toString(),
  385.                                              result.get("email").toString(),
  386.                                              //Boolean.valueOf(result.get("x_isactive").toString()),
  387.                                              false,
  388.                                              false,
  389.                                              //Boolean.valueOf(result.get("x_isallowed").toString()),
  390.                                              1,
  391.                                              UUIDHelper.getCurrentDate());
  392.                                      
  393.                                      XStream x = new XStream();
  394.                                      x.alias("message",message.class);
  395.                                      msg.setBody(p);
  396.                                      msg.setMessageType("newPerson");
  397.                                      x.alias("newPerson", newPerson.class);
  398.                                      String toSend=x.toXML(msg);
  399.                                      Sender.Send(toSend);
  400.                                    
  401.                                    
  402.             }
  403.             }
  404. }          
  405.  
  406. public static void setPersonOnNotAllowedViaUserUUID(String UUUID) throws Exception, XmlRpcException{
  407.             final String url = "http://10.3.50.48:8069",
  408.             db = "KassaGroepC",
  409.             username ="ricardo.mayorga.mera@student.ehb.be",
  410.             password = "opiq188";
  411.             final XmlRpcClient client = new XmlRpcClient();
  412.             final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
  413.             common_config.setServerURL(
  414.             new URL(String.format("%s/xmlrpc/2/common", url)));
  415.             int uid =  (int) client.execute(common_config,"authenticate",Arrays.asList(db,username, password, Collections.emptyMap()));
  416.             final XmlRpcClient models = new XmlRpcClient() {
  417.                 {
  418.                 setConfig (new XmlRpcClientConfigImpl() {
  419.                     {
  420.                     setServerURL(new URL (String.format("%s/xmlrpc/2/object", url)));
  421.                     }
  422.                 });
  423.             }
  424.             };   
  425.             //search and read      
  426.             final java.util.List<Object> xuuid= Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  427.                     db, uid, password,
  428.                     "res.partner", "search",
  429.                     Arrays.asList(Arrays.asList(
  430.                     Arrays.asList("x_uuid", "=", UUUID))))));
  431.             if (xuuid != null && !xuuid.isEmpty()){
  432.                 //System.out.print("userid: " + userid + " is not empty \n");
  433.                 System.out.println("Person found for UUID: "  + UUUID + ":");
  434.                 System.out.println("User before function: ");
  435.                 final java.util.List<Object> fields = Arrays.asList((Object[])models.execute
  436.                         ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(xuuid),
  437.                         new HashMap()
  438.                         {{put("fields",Arrays.asList("x_uuid","Bezoeker","name","street","email","x_isactive","x_isallowed","version","timestamp"));}})));
  439.                         System.out.println(fields);
  440.                         models.execute("execute_kw", Arrays.asList(
  441.                                 db, uid, password,
  442.                                 "res.partner", "write",
  443.                                 Arrays.asList(
  444.                                     Arrays.asList(UUUID),
  445.                                     new HashMap() {{ put("x_isallowed", false); }}
  446.                                 )
  447.                             ));
  448.                         System.out.println("set user to not allowed");
  449.                             // get record name after having changed it
  450.                             Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  451.                                 db, uid, password,
  452.                                 "res.partner", "name_get",
  453.                                 Arrays.asList(Arrays.asList(UUUID))
  454.                             )));
  455.                             final java.util.List<Object> fields1 = Arrays.asList((Object[])models.execute
  456.                                     ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(xuuid),
  457.                                     new HashMap()
  458.                                     {{put("fields",Arrays.asList("x_uuid","Bezoeker","name","street","email","x_isactive","x_isallowed","version","timestamp"));}})));
  459.                                     System.out.println(fields1);
  460.                                    
  461.                                    
  462.                                     message msg = new message();
  463.                                        //hier de message die moet doorgestuurd worden
  464.                                        //values van de persoon opvragen die zijn allowed op false moet gezet worden
  465.                                        //momenteel hardcoded message
  466.                                        newPerson p = new newPerson("x_uuid","Bezoeker","TESTMESSAGE " + userid  + " TEST","De program manager","zijn adress","testmail@verbeeck.be",true,false,1,UUIDHelper.getCurrentDate());
  467.                                        XStream x = new XStream();
  468.                                        x.alias("message",message.class);
  469.                                        msg.setBody(p);
  470.                                        msg.setMessageType("newPerson");
  471.                                        x.alias("newPerson", newPerson.class);
  472.                                        String toSend=x.toXML(msg);
  473.                                        Sender.Send(toSend);
  474.             }
  475.    
  476.    
  477. }
  478.  
  479. public static void setPersonOnNotAllowedViaUserName(String name) throws Exception{
  480.     //connection stuff
  481.         final String url = "http://10.3.50.48:8069",
  482.                 db = "KassaGroepC",
  483.                 username ="ricardo.mayorga.mera@student.ehb.be",
  484.                 password = "opiq188";
  485.                 final XmlRpcClient client = new XmlRpcClient();
  486.                 final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
  487.                 common_config.setServerURL(
  488.                 new URL(String.format("%s/xmlrpc/2/common", url)));
  489.                 int uid =  (int) client.execute(common_config,"authenticate",Arrays.asList(db,username, password, Collections.emptyMap()));
  490.                 final XmlRpcClient models = new XmlRpcClient() {
  491.                     {
  492.                     setConfig (new XmlRpcClientConfigImpl() {
  493.                         {
  494.                         setServerURL(new URL (String.format("%s/xmlrpc/2/object", url)));
  495.                         }
  496.                     });
  497.                 }
  498.                 };   
  499.                
  500.                 //search and read      
  501.                 final java.util.List<Object> ids= Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  502.                         db, uid, password,
  503.                         "res.partner", "search",
  504.                         Arrays.asList(Arrays.asList(
  505.                         Arrays.asList("name", "=", namehelper))))));
  506.                 if (ids != null && !ids.isEmpty()){
  507.                     //System.out.print("userid: " + userid + " is not empty \n");
  508.                     int displayhelp = userID;
  509.                     System.out.println("Person found with name: "  + namehelper + ":");
  510.                     System.out.println("User before function: ");
  511.                     final java.util.List<Object> fields = Arrays.asList((Object[])models.execute
  512.                             ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(ids),
  513.                             new HashMap()
  514.                             {{put("fields",Arrays.asList("x_uuid","Bezoeker","name","street","email","x_isactive","x_isallowed","version","timestamp"));}})));
  515.                             System.out.println(fields);
  516.                             models.execute("execute_kw", Arrays.asList(
  517.                                     db, uid, password,
  518.                                     "res.partner", "write",
  519.                                     Arrays.asList(
  520.                                         Arrays.asList(namehelper),
  521.                                         new HashMap() {{ put("x_isallowed", false); }}
  522.                                     )
  523.                                 ));
  524.                             System.out.println("set user to not allowed");
  525.                                 // get record name after having changed it
  526.                                 Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  527.                                     db, uid, password,
  528.                                     "res.partner", "name_get",
  529.                                     Arrays.asList(Arrays.asList(userID))
  530.                                 )));
  531.                                 final java.util.List<Object> fields1 = Arrays.asList((Object[])models.execute
  532.                                         ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(ids),
  533.                                         new HashMap()
  534.                                         {{put("fields",Arrays.asList("x_uuid","Bezoeker","name","street","email","x_isactive","x_isallowed","version","timestamp"));}})));
  535.                                         System.out.println(fields1);
  536.                                        
  537.                                         message msg = new message();
  538.                                            //hier de message die moet doorgestuurd worden
  539.                                            //values van de persoon opvragen die zijn allowed op false moet gezet worden
  540.                                            //momenteel hardcoded message
  541.                                            newPerson p = new newPerson("x_uuid","Bezoeker","TESTMESSAGE " + userid  + " TEST","De program manager","zijn adress","testmail@verbeeck.be",true,false,1,UUIDHelper.getCurrentDate());
  542.                                            XStream x = new XStream();
  543.                                            x.alias("message",message.class);
  544.                                            msg.setBody(p);
  545.                                            msg.setMessageType("newPerson");
  546.                                            x.alias("newPerson", newPerson.class);
  547.                                            String toSend=x.toXML(msg);
  548.                                            Sender.Send(toSend);
  549.                 }
  550. }
  551.  
  552. public static void  checkIfUUIDIsEmpty () throws XmlRpcException, IOException, JSONException {
  553.     final String url = "http://10.3.50.48:8069",
  554.             db = "KassaGroepC",
  555.             username ="ricardo.mayorga.mera@student.ehb.be",
  556.             password = "opiq188";
  557.     final XmlRpcClient client = new XmlRpcClient();
  558.     final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
  559.  
  560.     common_config.setServerURL(
  561.     new URL(String.format("%s/xmlrpc/2/common", url)));
  562.  
  563.     int uid =  (int) client.execute(common_config,"authenticate",Arrays.asList(db,username, password, Collections.emptyMap()));
  564.  
  565.     final XmlRpcClient models = new XmlRpcClient() {
  566.         {
  567.         setConfig (new XmlRpcClientConfigImpl() {
  568.             {
  569.             setServerURL(new URL (String.format("%s/xmlrpc/2/object", url)));
  570.             }
  571.         });
  572.     }
  573. };
  574. int heelper = userid -1;
  575.  
  576. final java.util.List<Object> ids= Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  577.         db, uid, password,
  578.         "res.partner", "search",
  579.         Arrays.asList(Arrays.asList(
  580.         Arrays.asList("id", "=", heelper),
  581.         Arrays.asList("x_uuid", "!=", false))))));
  582.  
  583. if (ids != null && !ids.isEmpty()){
  584.     //System.out.print("UUID for userid: " + userid + " is not empty \n");
  585.     System.out.println("UUID for userid " + heelper + ": ");
  586.     final java.util.List<Object> fields = Arrays.asList((Object[])models.execute
  587.             ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(ids),
  588.             new HashMap()
  589.             {{put("fields",Arrays.asList("x_uuid"));}})));
  590.            System.out.println(fields);
  591.            // System.out.print("looks for userid: " + "70" + " for the next search\n");
  592.    
  593. } else {
  594.     int helpuserid = userid -1;
  595.     System.out.println("THERE IS NO UUID YET FOR THIS PERSON\n");
  596.     System.out.println("FETCHING UUID FOR THIS PERSON\n");
  597.     //helper userid -> to string
  598.     String useridhelper = Integer.toString(helpuserid);
  599.     //fetches UUID for userid
  600.     String n = UUIDHelper.createUUID(useridhelper);
  601.     //update the user and adds UUID
  602.     System.out.println(helpuserid);
  603.     models.execute("execute_kw", Arrays.asList(
  604.             db, uid, password,
  605.             "res.partner", "write",
  606.             Arrays.asList(
  607.                 Arrays.asList(userid),
  608.                 new HashMap() {{ put("x_uuid", n); }}
  609.             )
  610.         ));
  611.     /*
  612.         // get record name after having changed it
  613.         Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  614.             db, uid, password,
  615.             "res.partner", "name_get",
  616.             Arrays.asList(Arrays.asList(userid))
  617.         )));
  618.     */
  619.  
  620.     System.out.println("UUID MADE FOR USERID" + helpuserid + "\n\n\n\n\n");
  621.    
  622. //System.out.println("UUID for userID: " + "70" + " is empty\n");
  623. //System.out.println("using userid: " + userid + " for the next search");
  624. }  
  625. }
  626.  
  627. public static void newProduct() throws Exception{
  628.     //CONNECTION
  629.     final String url = "http://10.3.50.48:8069",
  630.     db = "KassaGroepC",
  631.     username ="ricardo.mayorga.mera@student.ehb.be",
  632.     password = "opiq188";
  633.     final XmlRpcClient client = new XmlRpcClient();
  634.     final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
  635.     common_config.setServerURL(
  636.     new URL(String.format("%s/xmlrpc/2/common", url)));
  637.     int uid =  (int) client.execute(common_config,"authenticate",Arrays.asList(db,username, password, Collections.emptyMap()));
  638.     final XmlRpcClient models = new XmlRpcClient() {
  639.         {
  640.         setConfig (new XmlRpcClientConfigImpl() {
  641.             {
  642.             setServerURL(new URL (String.format("%s/xmlrpc/2/object", url)));
  643.             }
  644.         });
  645.     }
  646. };   
  647.  
  648.  
  649. //search and read      
  650. //USER VOOR UPDATE
  651. final java.util.List<Object> ids= Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  652.             db, uid, password,
  653.             "product.template", "search",
  654.             Arrays.asList(Arrays.asList(
  655.             Arrays.asList("id", "=", productid))))));
  656.             System.out.println("product POLLING SYSTEM");
  657.            
  658.             if (ids != null && !ids.isEmpty()){
  659.                 int displayhelp = productid;
  660.                 System.out.println("product found for productid: "  + displayhelp + ":");
  661.                
  662.                 final java.util.List<Object> productuuids = Arrays.asList((Object[])models.execute
  663.                 ("execute_kw",Arrays.asList(db,uid,password,"product.template","read",Arrays.asList(ids),
  664.                 new HashMap()
  665.                 {{put("fields",Arrays.asList("x_productuuid","id","display_name","name"));}})));
  666.                 System.out.println("BEFORE LOOP -- > ");
  667.                 System.out.println(productuuids.toString());
  668.                 for (Object object : productuuids) {
  669.                     HashMap<String,Object> result = (HashMap) object;
  670.                
  671.                     String uuidproducthelper = result.get("x_productuuid").toString();
  672.                     System.out.println(uuidproducthelper);
  673.                
  674.                 if (uuidproducthelper.isEmpty()) {
  675.                     //product already has a productuuid skips it
  676.                     final java.util.List<Object> fields2 = Arrays.asList((Object[])models.execute
  677.                             ("execute_kw",Arrays.asList(db,uid,password,"product.template","read",Arrays.asList(ids),
  678.                             new HashMap()
  679.                             {{put("fields",Arrays.asList("x_productuuid"));}})));
  680.                            System.out.println("UUID ALREADY EXISTS SKIP");
  681.                            
  682.                 }
  683.                  else {
  684.                     //product doesn't have a uuid yet + add a uuid
  685.                      System.out.println("THERE IS NO UUID YET FOR THIS Product\n");
  686.                         System.out.println("FETCHING UUID FOR THIS Product\n");
  687.                         //helper userid -> to string
  688.                         String productidhelper = Integer.toString(productid);
  689.                         //fetches UUID for userid
  690.                         String n = UUIDHelper.createUUID(productidhelper);
  691.                         System.out.println(n);
  692.                        
  693.                        
  694.                         System.out.println(productid);
  695.                         models.execute("execute_kw", Arrays.asList(
  696.                                 db, uid, password,
  697.                                 "product.template", "write",
  698.                                 Arrays.asList(
  699.                                     Arrays.asList(productid),
  700.                                     new HashMap() {{ put("x_productuuid", n);}}
  701.                                 )
  702.                             ));
  703.                        
  704.                        
  705.                         //UPDATED USER MESSAGE
  706.                         System.out.println("Product found for productid: "  + productid + ":");
  707.                         final java.util.List<Object> fields1 = Arrays.asList((Object[])models.execute
  708.                                 ("execute_kw",Arrays.asList(db,uid,password,"product.template","read",Arrays.asList(ids),
  709.                                 new HashMap()
  710.                                 {{put("fields",Arrays.asList("x_productuuid","id","display_name","name"));}})));
  711.                                 System.out.println(fields1);
  712.                                 for (Object objectuuid : fields1) {
  713.                                 HashMap<String,Object> resultuuid = (HashMap) objectuuid;
  714.                                
  715.                                          
  716.                         System.out.println("UUID MADE FOR PRODUCTID: " + productid + " END OF UUIDFLOW\n\n" );
  717.                         System.out.println("Building and sending message...\n\n"); 
  718.                         //BUILD MESSAGES
  719.                         message msg = new message();      
  720.                         newProduct k = new newProduct(
  721.                                 resultuuid.get("x_productuuid").toString(),     //uuid
  722.                                 resultuuid.get("display_name").toString(),      //name
  723.                                 resultuuid.get("name").toString(),              //descpription
  724.                                 1.0,
  725.                                 //(Double)resultuuid.get("price_unit"),                 //price
  726.                                  1,                                         //version
  727.                                  UUIDHelper.getCurrentDate()                //Date
  728.                        );
  729.                          
  730.                          XStream x = new XStream();
  731.                          x.alias("message",message.class);
  732.                          msg.setBody(k);
  733.                          msg.setMessageType("newProduct");
  734.                          x.alias("newProduct", newProduct.class);
  735.                          String toSend=x.toXML(msg);
  736.                          Sender.Send(toSend);
  737.                        
  738.                                 }
  739.                 }
  740.  
  741.                 }
  742.             productid++;
  743.             }
  744.             else
  745.             {
  746.     System.out.println("NO PRODUCT WAS FOUND");
  747.     System.out.println("LOOKING AGAIN IN 5 SECONDS");
  748.     System.out.println("looks for product id: " + productid);
  749. }
  750.  
  751.  
  752.  
  753.  
  754.  
  755. }
  756.  
  757. public static void createProduct() throws XmlRpcException, MalformedURLException {
  758.     //connection
  759.     final String url = "http://10.3.50.48:8069",
  760.             db = "KassaGroepC",
  761.             username ="ricardo.mayorga.mera@student.ehb.be",
  762.             password = "opiq188";
  763.             final XmlRpcClient client = new XmlRpcClient();
  764.             final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
  765.             common_config.setServerURL(
  766.             new URL(String.format("%s/xmlrpc/2/common", url)));
  767.             int uid =  (int) client.execute(common_config,"authenticate",Arrays.asList(db,username, password, Collections.emptyMap()));
  768.             final XmlRpcClient models = new XmlRpcClient() {
  769.                 {
  770.                 setConfig (new XmlRpcClientConfigImpl() {
  771.                     {
  772.                     setServerURL(new URL (String.format("%s/xmlrpc/2/object", url)));
  773.                     }
  774.                 });
  775.             }
  776.         };   
  777.         final Integer id = (Integer) models.execute("execute_kw",Arrays.asList(db,uid,password,"product.product","create",Arrays.asList(new HashMap() {{
  778.             put("name","productnametest");
  779.             put("list_price","1000000");
  780.             }
  781.         })));
  782.    
  783. }
  784.  
  785. public static String invoicehelperfunction(int invoicehelper) {
  786.     String nozero ="";
  787.     String onezero ="0";
  788.     String twozeroes ="00";
  789.     String threezeroes="000";
  790.     String zeroes;
  791.     if (invoicehelper > 9 && invoicehelper <= 99) {
  792.         return zeroes = twozeroes;
  793.     } if (invoicehelper > 99 && invoicehelper <= 999) {
  794.         return zeroes = onezero;
  795.     } if (invoicehelper >999)
  796.     {
  797.         return zeroes = nozero;
  798.     } else {
  799.         return zeroes = threezeroes;
  800.     }
  801. }
  802.  
  803. public static void getPayment() throws XmlRpcException, IOException, JSONException{
  804. //bevat een id
  805.     String invoicebase = "INV/2018/";
  806.     String zeroes = invoicehelperfunction(invoicehelper);
  807.     String fullinvoicepath = invoicebase + zeroes + invoicehelper;
  808.     System.out.println("INVOICE POLLING SYSTEM");
  809.     System.out.println("will search for: " + fullinvoicepath);
  810.     //connection
  811.     final String url = "http://10.3.50.48:8069",
  812.             db = "KassaGroepC",
  813.             username ="ricardo.mayorga.mera@student.ehb.be",
  814.             password = "opiq188";
  815.             final XmlRpcClient client = new XmlRpcClient();
  816.             final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
  817.             common_config.setServerURL(
  818.             new URL(String.format("%s/xmlrpc/2/common", url)));
  819.             int uid =  (int) client.execute(common_config,"authenticate",Arrays.asList(db,username, password, Collections.emptyMap()));
  820.             final XmlRpcClient models = new XmlRpcClient() {
  821.                 {
  822.                 setConfig (new XmlRpcClientConfigImpl() {
  823.                     {
  824.                     setServerURL(new URL (String.format("%s/xmlrpc/2/object", url)));
  825.                     }
  826.                 });
  827.             }
  828.         }; 
  829.    
  830.    
  831.     final java.util.List<Object> ids= Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  832.             db, uid, password,
  833.             "account.invoice", "search",
  834.             Arrays.asList(Arrays.asList(
  835.             Arrays.asList("number", "=", fullinvoicepath))))));
  836.     if (ids != null && !(ids.isEmpty())) {
  837.         final java.util.List<Object> fields1 = Arrays.asList((Object[])models.execute
  838.                 ("execute_kw",Arrays.asList(db,uid,password,"account.invoice","read",Arrays.asList(ids),
  839.                 new HashMap()
  840.                 {{put("fields",Arrays.asList("number","account_id","partner_id","amount_total","id","invoice_line_ids"));}})));
  841.                 System.out.println(fields1);
  842.                
  843.                 for (Object object : fields1) {
  844.                     HashMap<String,Object> result = (HashMap) object;
  845.                    
  846.                 List accountidhelper =  Arrays.asList((Object[])result.get("partner_id"));
  847.                 List invoicelineshelperprint = Arrays.asList((Object[])result.get("invoice_line_ids"));
  848.                
  849.                 System.out.println(accountidhelper);
  850.                 System.out.println(invoicelineshelperprint);
  851.                
  852.                 int idhelper = (int)result.get("id");
  853.                 System.out.println(idhelper);
  854.                
  855.                
  856.                 Integer startLoop = (Integer)invoicelineshelperprint.get(0);
  857.                 Integer endLoop = (Integer)invoicelineshelperprint.get(invoicelineshelperprint.size()-1);
  858.                
  859.                 System.out.println(startLoop);
  860.                 System.out.println(endLoop);
  861.                
  862.                
  863.                
  864.                
  865.                
  866.                 //foreach of the list here
  867.                 //hier haalt hij alle informatie uit de invoice
  868.                 for(int i=startLoop; i < endLoop; i++) {
  869.                 final java.util.List<Object> ids1= Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  870.                         db, uid, password,
  871.                         "account.invoice.line", "search",
  872.                         Arrays.asList(Arrays.asList(
  873.                         Arrays.asList("id", "=", i))))));
  874.                
  875.                 //name = description in odoo, display name = name
  876.                 final java.util.List<Object> fields11 = Arrays.asList((Object[])models.execute
  877.                         ("execute_kw",Arrays.asList(db,uid,password,"account.invoice.line","read",Arrays.asList(ids1),
  878.                         new HashMap()
  879.                         {{put("fields",Arrays.asList("id","price_unit","name","display_name","quantity","x_productuuid","product_id"));}})));
  880.                
  881.                 for (Object objectProd : fields11) {
  882.                     HashMap<String,Object> resultProd = (HashMap) objectProd;
  883.                         //System.out.println(fields11);
  884.                         List ProductenData = Arrays.asList((Object[])resultProd.get("product_id"));
  885.                         System.out.println("Product ID: "+Arrays.asList((Object[])resultProd.get("product_id")));
  886.                         String notallowedinteger = "71";
  887.                         System.out.println("RESULTPROD: " + resultProd.get("product_id"));
  888.                         Object prodhelperr = resultProd.get("product_id");
  889.                        // randomhelper = ((List<Object>) prodhelperr).get(0);
  890.                        // System.out.println("RANDOMHELPER: " + randomhelper);
  891.                         if (resultProd.get("product_id").toString() != notallowedinteger) {
  892.                            
  893.                             //continue the job as usual
  894.                         } else {
  895.                             //BAN THE USER
  896.                             //start newperson message flow
  897.                             System.out.println("ai ai ai BANHAMMER INC\n");
  898.                             //Set the user to not allowed in our system first
  899.                             //first we need the person his ID
  900.                             System.out.println("find the person his id!: \n");
  901.                            
  902.                             Integer useriid = (Integer)accountidhelper.get(0);
  903.                             System.out.println("USERIIIIIIIIIIIIIIIIIDDDDDDDDDDDD    " + useriid);
  904.                            
  905.                            
  906.                             /*
  907.                            
  908.                            
  909.                             //then we update the person
  910.                             System.out.println("it's update time!\n");
  911.                             models.execute("execute_kw", Arrays.asList(
  912.                                     db, uid, password,
  913.                                     "res.partner", "write",
  914.                                     Arrays.asList(
  915.                                         Arrays.asList(userid),
  916.                                         new HashMap() {{
  917.                                                          put("x_isallowed", false);
  918.                                                          put("x_isactive", false);
  919.                                                          }}
  920.                                     )
  921.                                 ));
  922.                             System.out.println("show me the user!!!!\n");
  923.                             final java.util.List<Object> uuids = Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  924.                                     db, uid, password,
  925.                                     "res.partner", "search",
  926.                                     Arrays.asList(Arrays.asList(
  927.                                     Arrays.asList("id", "=", userid),
  928.                                     Arrays.asList("x_uuid", "!=", false
  929.                                             ))))));
  930.                            
  931.                            
  932.                             //update the version
  933.                            
  934.                             //then send out the updated message with version
  935.                            
  936.                            
  937.                            
  938.                         }
  939.                         //System.out.println("product ID :" + resultProd.get("product_id"));
  940.                        
  941.                        
  942.                         /*
  943.                         for (Object object5 : fields11) {
  944.                             HashMap<String,Object> result10 = (HashMap) object5;
  945.                             List productuuidhelper;
  946.                             double quantity
  947.                             productuuidhelper = Arrays.asList((Object[])result10.get("product_id"));
  948.                             quantity = (double) result10.get("quantity");
  949.                             System.out.println(productuuidhelper);
  950.                             System.out.println(quantity);
  951.                            
  952.                             // uuid opvragen van de productuuidhelper
  953.                             final java.util.List<Object> fields9000 = Arrays.asList((Object[])models.execute
  954.                                     ("execute_kw",Arrays.asList(db,uid,password,"account.invoice.line","read",Arrays.asList(ids),
  955.                                     new HashMap()
  956.                                     {{put("fields9000",Arrays.asList("x_productuuid","name"));}})));
  957.                             for (Object object6 : fields9000) {
  958.                                 HashMap<String,Object> result11 = (HashMap) object6;
  959.                                
  960.                             String  productuuidhelperhelper = result11.get("x_productuuid").toString();
  961.                             System.out.println(productuuidhelperhelper);
  962.                             }  
  963.                             */
  964.                         }      
  965.                         //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  966.                 }
  967.                 }
  968.                
  969.                
  970.                
  971.                
  972.  
  973.                 Integer useriid = (Integer)accountidhelper.get(0);
  974.                 //ophalen van de UUID voor de persoon waarover het gaat
  975.                 final java.util.List<Object> ids11= Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  976.                         db, uid, password,
  977.                         "res.partner", "search",
  978.                         Arrays.asList(Arrays.asList(
  979.                                 //partneridhelper gelijk stellen aan de id uit de list partner_id
  980.                         Arrays.asList("id", "=", useriid/* partneridhelper */ ))))));
  981.                
  982.                 //name = description in odoo, display name = name
  983.                 final java.util.List<Object> fields111 = Arrays.asList((Object[])models.execute
  984.                         ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(ids11),
  985.                         new HashMap()
  986.                         {{put("fields",Arrays.asList("x_uuid"));}})));
  987.                         for (Object object2 : fields111) {
  988.                         HashMap<String,Object> results = (HashMap) object2;
  989.                         System.out.println(fields111);
  990.                         String uuidinvoicehelper = results.get("x_uuid").toString();
  991.                         System.out.println("zoekt naar uuid voor persoon met userid : " + useriid);
  992.                         System.out.println(uuidinvoicehelper);
  993.                         }      
  994.                 }            
  995.                 invoicehelper++;
  996.     } else {
  997.        
  998.         System.out.println("there is no invoice for this number, trying again in 5 seconds... \n");
  999.     }
  1000.     System.out.print("looks for invoicenumber: " + fullinvoicepath + " in the next search\n\n ________________________________________________________________________________________________________ \n\n");
  1001.                        
  1002. }
  1003.  
  1004. }
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020. /* ************************************************************************************************************************************************************** */
  1021. // create user 
  1022. /*
  1023. final Integer id = (Integer) models.execute("execute_kw",Arrays.asList(db,uid,password,"res.partner","create",Arrays.asList(new HashMap() {{
  1024.     put("name",userid);
  1025.     put("email","example@gmail.com");
  1026.     put("phone","5151516151");
  1027.     put("city","Brussels");
  1028.     put("zip","1000");
  1029.     put("street","Jan van Doorslaerlaan1");
  1030.     put("TaxId","161161884655");
  1031.     put("customer",true);
  1032.     put("employee",false);
  1033.     put("active",true);
  1034.     put("x_isRegistered",true);
  1035.     }
  1036. })));
  1037. */
  1038.  
  1039. /* ************************************************************************************************************************************************************** */
  1040. //Update
  1041. /*
  1042. models.execute("execute_kw", Arrays.asList(
  1043.     db, uid, password,
  1044.     "res.partner", "write",
  1045.     Arrays.asList(
  1046.         Arrays.asList(37),
  1047.         new HashMap() {{ put("x_isRegistered", false); }}
  1048.     )
  1049. ));
  1050. // get record name after having changed it
  1051. Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
  1052.     db, uid, password,
  1053.     "res.partner", "name_get",
  1054.     Arrays.asList(Arrays.asList(37))
  1055. )));
  1056. */
  1057. /* ******************************************************************************************************************************************************************* */  
  1058.    
  1059.  
  1060.  
  1061. /*
  1062. newPerson p = new newPerson(
  1063.          "x_uuid",
  1064.          "Bezoeker",
  1065.          "TESTMESSAGE " + userid  + " TEST",
  1066.          "De program manager",
  1067.          "zijn adress",
  1068.          "testmail@verbeeck.be",
  1069.          true,
  1070.          true,
  1071.          1,
  1072.          UUIDHelper.getCurrentDate());
  1073. */
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080. //List prodhelper = Arrays.asList((Object[])result.get("product_id"));
  1081.  
  1082. /*
  1083. final java.util.List<Object> fields11 = Arrays.asList((Object[])models.execute
  1084. ("execute_kw",Arrays.asList(db,uid,password,"account.invoice.report","read",Arrays.asList(ids),
  1085. new HashMap()
  1086. {{put("fields",Arrays.asList("number","display_name","account_line_id","account_id","partner_id","amount_total","id","invoice_line_ids","nbr","price_total","product_id","product_qty"));}})));
  1087. System.out.println(fields11);
  1088. List accountidhelper2 =  Arrays.asList((Object[])result.get("partner_id"));
  1089. List accountidhelper3 =  Arrays.asList((Object[])result.get("account_line_id"));
  1090. System.out.println(accountidhelper2);
  1091. System.out.println(accountidhelper3);
  1092. */
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099. /*
  1100. foreach (invoicelineshelperprint){
  1101.  
  1102. }
  1103. */
  1104. /*
  1105. int[] invoicelineidshelper =  {28,29,30,31,32};
  1106. for(int i=1; i<11; i++) {
  1107.  
  1108.  
  1109.    
  1110. }
  1111. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement