Advertisement
Guest User

Class NewPayment / Class Message / Class MessageBody

a guest
May 26th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.40 KB | None | 0 0
  1. ----------------------------------------------- Class NewPayment
  2. package messages;
  3.  
  4. import java.util.Date;
  5.  
  6. public class newPayment implements MessageBody{
  7.     private String userUUID;
  8.     private String invoiceUUID;
  9.     private String productUUID;
  10.     private Integer quantity;
  11.     private Double price;
  12.     private Double totalAmountOpen;
  13.     private Double totalAmountPaid;
  14.     private Boolean isPaid;
  15.     private Integer version;
  16.     private String timestamp;
  17.  
  18.     public newPayment(String userUUID, String invoiceUUID, String productUUID, Integer quantity, Double price,
  19.             Double totalAmountOpen, Double totalAmountPaid, Boolean isPaid, String timestamp, Integer version) {
  20.         super();
  21.         this.userUUID = userUUID;
  22.         this.invoiceUUID = invoiceUUID;
  23.         this.productUUID = productUUID;
  24.         this.quantity = quantity;
  25.         this.price = price;
  26.         this.totalAmountOpen = totalAmountOpen;
  27.         this.totalAmountPaid = totalAmountPaid;
  28.         this.isPaid = isPaid;
  29.         this.version = version;
  30.         this.timestamp = timestamp;
  31.     }
  32.  
  33.     public String getUserUUID() {
  34.         return userUUID;
  35.     }
  36.  
  37.     public void setUserUUID(String userUUID) {
  38.         this.userUUID = userUUID;
  39.     }
  40.  
  41.     public String getInvoiceUUID() {
  42.         return invoiceUUID;
  43.     }
  44.  
  45.     public void setInvoiceUUID(String invoiceUUID) {
  46.         this.invoiceUUID = invoiceUUID;
  47.     }
  48.  
  49.     public String getProductUUID() {
  50.         return productUUID;
  51.     }
  52.  
  53.     public void setProductUUID(String productUUID) {
  54.         this.productUUID = productUUID;
  55.     }
  56.  
  57.     public Integer getQuantity() {
  58.         return quantity;
  59.     }
  60.  
  61.     public void setQuantity(Integer quantity) {
  62.         this.quantity = quantity;
  63.     }
  64.  
  65.     public Double getPrice() {
  66.         return price;
  67.     }
  68.  
  69.     public void setPrice(Double price) {
  70.         this.price = price;
  71.     }
  72.  
  73.     public Double getTotalAmountOpen() {
  74.         return totalAmountOpen;
  75.     }
  76.  
  77.     public void setTotalAmountOpen(Double totalAmountOpen) {
  78.         this.totalAmountOpen = totalAmountOpen;
  79.     }
  80.  
  81.     public Double getTotalAmountPaid() {
  82.         return totalAmountPaid;
  83.     }
  84.  
  85.     public void setTotalAmountPaid(Double totalAmountPaid) {
  86.         this.totalAmountPaid = totalAmountPaid;
  87.     }
  88.  
  89.     public Boolean getIsPaid() {
  90.         return isPaid;
  91.     }
  92.  
  93.     public void setIsPaid(Boolean isPaid) {
  94.         this.isPaid = isPaid;
  95.     }
  96.  
  97.     public Integer getVersion() {
  98.         return version;
  99.     }
  100.  
  101.     public void setVersion(Integer version) {
  102.         this.version = version;
  103.     }
  104.  
  105.     public String getTimeStamp() {
  106.         return timestamp;
  107.     }
  108.  
  109.     public void setTimeStamp(String timestamp) {
  110.         this.timestamp = timestamp;
  111.     }
  112.  
  113.     public newPayment() {
  114.         super();
  115.     }
  116.    
  117.    
  118.    
  119. }
  120. -------------------------------------------------- Class Message
  121. package messages;
  122.  
  123. import java.util.Arrays;
  124. import java.util.HashMap;
  125.  
  126. import logic.Odoo;
  127. import logic.UUIDHelper;
  128.  
  129. public class message {
  130.     private String messageType;
  131.     private MessageBody body;
  132.     public String getMessageType() {
  133.         return messageType;
  134.     }
  135.     public void setMessageType(String messageType) {
  136.         this.messageType = messageType;
  137.     }
  138.     public MessageBody getBody() {
  139.         return body;
  140.     }
  141.     public void setBody(MessageBody body) {
  142.         this.body = body;
  143.     }
  144.     public message() {
  145.         super();
  146.     }
  147.     public message(String messageType, MessageBody body) {
  148.         super();
  149.         this.messageType = messageType;
  150.         this.body = body;
  151.     }
  152.     public boolean processMessage() throws Exception {
  153.         Odoo o = new Odoo();
  154.         switch (messageType) {
  155.         case "newPerson":
  156.             newPerson p = (newPerson)body;
  157.             Integer id = (Integer) o.models.execute("execute_kw",Arrays.asList(o.db,o.uid,o.password,"res.partner","create",Arrays.asList(new HashMap() {{
  158.                 put("name",p.getFirstName()+" "+p.getLastName());
  159.                 put("email",p.getEmail());
  160.                 put("phone","0480090900");
  161.                 put("city","Brussels");
  162.                 put("zip","1000");
  163.                 put("street",p.getAddress());
  164.                 put("TaxId","123456789");
  165.                 put("customer",true);
  166.                 put("employee",false);
  167.                 put("x_isRegistered",true);
  168.                 put("active",true);}})));
  169.            o.models.execute("execute_kw",Arrays.asList(o.db,o.uid,o.password,"res.partner","write",Arrays.asList(Arrays.asList(id),new HashMap() {{
  170.                put("x_UUID",p.getUUID());
  171.            }})));
  172.                 return true;
  173.         case "newPayment":
  174.             //o.models.execute("execute_kw",Arrays.asList(o.db,o.uid,o.password,"res.partner","write",));
  175.            
  176.            
  177.         default:
  178.             break;
  179.         }
  180.         return false;
  181.        
  182.     }
  183. }
  184. -------------------Interface MessageBody
  185. package messages;
  186.  
  187. public interface MessageBody {
  188.  
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement