Advertisement
Aleksandr37rus

Untitled

Oct 8th, 2022
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.54 KB | None | 0 0
  1. import org.apache.commons.lang.StringUtils;
  2.  
  3. import java.io.Serializable;
  4. import java.sql.SQLData;
  5. import java.sql.SQLException;
  6. import java.sql.SQLInput;
  7. import java.sql.SQLOutput;
  8.  
  9. public class PositionEntryItem implements Serializable, SQLData {
  10.     private static final long serialVersionUID = -773499731171578088L;
  11.  
  12.     private Integer numberRow;
  13.     private String code;
  14.     private Integer id;
  15.     private String clientCode;
  16.     private String vendorCode;
  17.     private String etmCode;
  18.     private String selectedUomCode;
  19.     private int quantity = 1;
  20.     private boolean hasError;
  21.     private String errorMsg;
  22.  
  23.     public Integer getId() {
  24.         return id;
  25.     }
  26.  
  27.     public void setId(final Integer id) {
  28.         this.id = id;
  29.     }
  30.  
  31.     public boolean isHasError() {
  32.         return hasError;
  33.     }
  34.  
  35.     public void setHasError(final boolean hasError) {
  36.         this.hasError = hasError;
  37.     }
  38.  
  39.     public String getErrorMsg() {
  40.         return errorMsg;
  41.     }
  42.  
  43.     public void setErrorMsg(final String errorMsg) {
  44.         this.errorMsg = errorMsg;
  45.     }
  46.  
  47.     public Integer getNumberRow() {
  48.         return numberRow;
  49.     }
  50.  
  51.     public void setNumberRow(final Integer numberRow) {
  52.         this.numberRow = numberRow;
  53.     }
  54.  
  55.     public String getCode() {
  56.         return code;
  57.     }
  58.  
  59.     public void setCode(final String code) {
  60.         this.code = code;
  61.     }
  62.  
  63.     public String getClientCode() {
  64.         return clientCode;
  65.     }
  66.  
  67.     public void setClientCode(final String clientCode) {
  68.         this.clientCode = clientCode;
  69.     }
  70.  
  71.     public String getVendorCode() {
  72.         return vendorCode;
  73.     }
  74.  
  75.     public void setVendorCode(final String vendorCode) {
  76.         this.vendorCode = vendorCode;
  77.     }
  78.  
  79.     public String getEtmCode() {
  80.         return etmCode;
  81.     }
  82.  
  83.     public void setEtmCode(final String etmCode) {
  84.         this.etmCode = etmCode;
  85.     }
  86.  
  87.     public String getSelectedUomCode() {
  88.         return selectedUomCode;
  89.     }
  90.  
  91.     public void setSelectedUomCode(final String selectedUomCode) {
  92.         this.selectedUomCode = selectedUomCode;
  93.     }
  94.  
  95.     public int getQuantity() {
  96.         return quantity;
  97.     }
  98.  
  99.     public void setQuantity(final int quantity) {
  100.         if (quantity <= 0) {
  101.             this.quantity = 1;
  102.         } else {
  103.             this.quantity = quantity;
  104.         }
  105.     }
  106.  
  107.     @Override
  108.     public String toString() {
  109.         return "PositionEntryItem{" +
  110.                 "numberRow=" + numberRow +
  111.                 ", code='" + code + '\'' +
  112.                 ", id=" + id +
  113.                 ", clientCode='" + clientCode + '\'' +
  114.                 ", vendorCode='" + vendorCode + '\'' +
  115.                 ", etmCode='" + etmCode + '\'' +
  116.                 ", selectedUomCode='" + selectedUomCode + '\'' +
  117.                 ", quantity=" + quantity +
  118.                 ", hasError=" + hasError +
  119.                 ", errorMsg='" + errorMsg + '\'' +
  120.                 '}';
  121.     }
  122.  
  123.     @Override
  124.     public String getSQLTypeName() throws SQLException {
  125.         return "XXRSV_PE_ITEM_REC";
  126.     }
  127.  
  128.     @Override
  129.     public void readSQL(final SQLInput stream, final String typeName) throws SQLException {
  130.         this.numberRow = stream.readInt();
  131.         this.code = stream.readString();
  132.         this.clientCode = stream.readString();
  133.         this.vendorCode = stream.readString();
  134.         this.etmCode = stream.readString();
  135.         this.selectedUomCode = stream.readString();
  136.         this.quantity = stream.readInt();
  137.     }
  138.  
  139.     @Override
  140.     public void writeSQL(final SQLOutput stream) throws SQLException {
  141.             stream.writeInt(this.numberRow);
  142.             stream.writeString(this.code);
  143.             stream.writeString(this.clientCode);
  144.             stream.writeString(this.vendorCode);
  145.             stream.writeString(validateEtmCode(this.etmCode));
  146.             stream.writeString(this.selectedUomCode);
  147.             stream.writeInt(this.quantity);
  148.     }
  149.  
  150.     private String validateEtmCode(final String value) {
  151.         if (StringUtils.isNotEmpty(value)) {
  152.             return etmCode.replaceAll("[^\\p{Digit}]", "").trim();
  153.         }
  154.         return value;
  155.     }
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement