Package com.commander4j.tablemodel

Source Code of com.commander4j.tablemodel.JDBProcessOrderTableModel

package com.commander4j.tablemodel;

import java.sql.ResultSet;
import java.util.HashMap;

import javax.swing.table.AbstractTableModel;

import com.commander4j.db.JDBProcessOrder;
import com.commander4j.sys.Common;

public class JDBProcessOrderTableModel extends AbstractTableModel
{
  private static final long serialVersionUID = 1;
  public static final int Process_Order_Col = 0;
  public static final int Process_Order_Material_Col = 1;
  public static final int Process_Order_Description_Col = 2;
  public static final int Process_Order_Status_Col = 3;
  public static final int Process_Order_Location_Col = 4;
  public static final int Process_Order_Due_Date_Col = 5;
  public static final int Process_Order_Recipe_Col = 6;
  public static final int Process_Order_Required_Quantity_Col = 7;
  public static final int Process_Order_Required_Uom_Col = 8;
  public static final int Process_Order_DefaultBatchStatus_Col = 9;
  public static final int Process_Order_Required_Resource_Col = 10;
  public static final int Process_Order_Customer_Col = 11;
 
  private String[] mcolNames = { "Process Order", "Material", "Description", "Status", "Location ID", "Due Date", "Recipe ID", "Quantity", "Uom", "Default Pallet Status", "Resource","Customer" };
  private ResultSet mResultSet;
  private int prowCount = -1;
  private HashMap<Integer,JDBProcessOrder> cache = new HashMap<Integer,JDBProcessOrder>();

  public JDBProcessOrderTableModel()
  {

  }

  public JDBProcessOrderTableModel(ResultSet rs)
  {
    super();
    prowCount = -1;
    mResultSet = rs;
  }

  public int getColumnCount() {
    return mcolNames.length;
  }

  public String getColumnName(int col) {
    return mcolNames[col];
  }

  public int getRowCount() {
    try
    {
      if (prowCount <= 0)
      {
        mResultSet.last();
        prowCount = mResultSet.getRow();
        mResultSet.beforeFirst();
      }
      return prowCount;

    }
    catch (Exception e)
    {
      return 0;
    }
  }

  public Object getValueAt(int row, int col) {

    try
    {
      if (cache.containsKey(row)==false)
      {
        mResultSet.absolute(row + 1);
        final JDBProcessOrder prow = new JDBProcessOrder(Common.selectedHostID, Common.sessionID);
        prow.getPropertiesfromResultSet(mResultSet);
        cache.put(row, prow);
      }
     
      switch (col)
      {
      case Process_Order_Col:
        return cache.get(row).getProcessOrder();
      case Process_Order_Material_Col:
        return cache.get(row).getMaterial();
      case Process_Order_Description_Col:
        return cache.get(row).getDescription();
      case Process_Order_Status_Col:
        return cache.get(row).getStatus();
      case Process_Order_Location_Col:
        return cache.get(row).getLocation();
      case Process_Order_Due_Date_Col:
        return cache.get(row).getDueDate().toString().substring(0, 16);
      case Process_Order_Required_Quantity_Col:
        return cache.get(row).getRequiredQuantity();
      case Process_Order_Required_Uom_Col:
        return cache.get(row).getRequiredUom();
      case Process_Order_Recipe_Col:
        return cache.get(row).getRecipe();
      case Process_Order_DefaultBatchStatus_Col:
        return cache.get(row).getDefaultPalletStatus();
      case Process_Order_Required_Resource_Col:
        return cache.get(row).getRequiredResource();
      case Process_Order_Customer_Col:
        return cache.get(row).getCustomerID();       
      }
    }
    catch (Exception ex)
    {
      return "Error";
    }

    return new String();
  }

  public void setValueAt(Object value, int row, int col) {

  }
}
TOP

Related Classes of com.commander4j.tablemodel.JDBProcessOrderTableModel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.