org.opensubsystems.inventory.data
Class Unit

java.lang.Object
  extended by org.opensubsystems.core.data.DataObject
      extended by org.opensubsystems.core.data.BasicDataObject
          extended by org.opensubsystems.core.data.ModifiableDataObject
              extended by org.opensubsystems.inventory.data.Unit
All Implemented Interfaces:
java.io.Serializable

public class Unit
extends org.opensubsystems.core.data.ModifiableDataObject

Unit represents group of items of the same type with certain cost which are present in the inventory. All items of the same type with the same cost share the same record. This allows us to track group of items which may have been added to the inventory at different times and therefore can have different cost but otherwise they the same items.

Version:
$Id: Unit.java,v 1.10 2007/01/28 06:54:39 bastafidli Exp $
Author:
Martin Cerba
See Also:
Serialized Form
Code reviewer:
Miro Halas
Code reviewed:
1.4 2006/02/18 05:31:32 bastafidli

Field Summary
static int[] ALL_FILTER_COLUMNS
          Static variable for array of all filter columns codes.
static int[] ALL_UNIT_COLUMNS
          Static variable for array of all columns codes.
static int COL_UNIT_AVAILABLE_COUNT
          Code for table column.
static int COL_UNIT_COST
          Code for table column.
static java.lang.Integer COL_UNIT_COST_OBJ
          Code for table column.
static int COL_UNIT_CREATION_DATE
          Code for table column.
static int COL_UNIT_DOMAIN_ID
          Code for table column.
static int COL_UNIT_FOUND_HOLDER
          Code for table column.
static int COL_UNIT_ID
          Code for table column.
static int COL_UNIT_INVENTORY_ID
          Code for table column.
static int COL_UNIT_ITEM_ID
          Code for table column.
static int COL_UNIT_MODIFICATION_DATE
          Code for table column.
static int COL_UNIT_SHIPPED_COUNT
          Code for table column.
static int[] DEFAULT_LIST_COLUMNS
          Default columns to retrieve when asked for list of objects.
static int[] DEFAULT_LIST_SORT_COLUMNS
          Default columns to sort by when asked for list of objects.
static java.lang.String[] DEFAULT_LIST_SORT_ORDER
          Default order in which the columns will be sorted.
protected  boolean m_bFoundHolder
          If this is true then this instance is used to track found units we don't know where they came from or what instance of unit for this item they belong to.
protected  double m_dCost
          Cost of individual unit.
protected  int m_iAvailableCount
          This has to be nonnegative number less or equal to shipped count for all units except for unit flagged as the "found holder" since for all normal units we cannot issue more than we have available.
protected  int m_iInventoryId
          ID of the inventory the unit belongs to.
protected  int m_iItemId
          Id of the item represented by this unit
protected  int m_iShippedCount
          How many units were shipped (delivered) to the inventory.
 
Fields inherited from class org.opensubsystems.core.data.ModifiableDataObject
m_modificationTimestamp
 
Fields inherited from class org.opensubsystems.core.data.BasicDataObject
m_creationTimestamp, m_iDomainId
 
Fields inherited from class org.opensubsystems.core.data.DataObject
NEW_ID, NEW_ID_OBJ, NEW_ID_STR
 
Constructor Summary
Unit(int iDomainId)
          Empty constructor
Unit(int iDomainId, int iInventoryId, int iItemId, int iShippedCount, int iAvailableCount, double dCost, boolean bFoundHolder)
          Full constructor to create new unit
Unit(int iUnitId, int iDomainId, int iInventoryId, int iItemId, int iShippedCount, int iAvailableCount, double dCost, boolean bFoundHolder, java.sql.Timestamp creationDate, java.sql.Timestamp modificationDate)
          Full constructor to create new unit.
 
Method Summary
 int getAvailableCount()
           
 double getCost()
           
 int getInventoryId()
           
 int getItemId()
           
 int getShippedCount()
           
 boolean isFoundHolder()
           
 boolean isSame(java.lang.Object oObject)
          
 void setAvailableCount(int value)
          Change available count.
 void setCost(double dCost)
           
 void setInventoryId(int iInventoryId)
           
 void setItemId(int iItemId)
           
 void setShippedCount(int iShippedCount)
           
 
Methods inherited from class org.opensubsystems.core.data.ModifiableDataObject
equals, getModificationTimestamp, hashCode, restore, setModificationTimestamp
 
Methods inherited from class org.opensubsystems.core.data.BasicDataObject
getCreationTimestamp, getDomainId, getId, getIdAsObject, restore, setCreationTimestamp, setId
 
Methods inherited from class org.opensubsystems.core.data.DataObject
isFromPersistenceStore, setFromPersistenceStore
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COL_UNIT_ID

public static final int COL_UNIT_ID
Code for table column.

See Also:
Constant Field Values

COL_UNIT_DOMAIN_ID

public static final int COL_UNIT_DOMAIN_ID
Code for table column.

See Also:
Constant Field Values

COL_UNIT_INVENTORY_ID

public static final int COL_UNIT_INVENTORY_ID
Code for table column.

See Also:
Constant Field Values

COL_UNIT_ITEM_ID

public static final int COL_UNIT_ITEM_ID
Code for table column.

See Also:
Constant Field Values

COL_UNIT_SHIPPED_COUNT

public static final int COL_UNIT_SHIPPED_COUNT
Code for table column.

See Also:
Constant Field Values

COL_UNIT_AVAILABLE_COUNT

public static final int COL_UNIT_AVAILABLE_COUNT
Code for table column.

See Also:
Constant Field Values

COL_UNIT_COST

public static final int COL_UNIT_COST
Code for table column.

See Also:
Constant Field Values

COL_UNIT_COST_OBJ

public static final java.lang.Integer COL_UNIT_COST_OBJ
Code for table column.


COL_UNIT_FOUND_HOLDER

public static final int COL_UNIT_FOUND_HOLDER
Code for table column.

See Also:
Constant Field Values

COL_UNIT_CREATION_DATE

public static final int COL_UNIT_CREATION_DATE
Code for table column.

See Also:
Constant Field Values

COL_UNIT_MODIFICATION_DATE

public static final int COL_UNIT_MODIFICATION_DATE
Code for table column.

See Also:
Constant Field Values

ALL_UNIT_COLUMNS

public static final int[] ALL_UNIT_COLUMNS
Static variable for array of all columns codes. The order is important since it is used to retrieve all data from the persistence store efficiently so do not modify it unless you make changes to other places as well.


ALL_FILTER_COLUMNS

public static final int[] ALL_FILTER_COLUMNS
Static variable for array of all filter columns codes. TODO: For Miro: This is not used for now so either we implement filters for it and then remove this to do or remove this attribute.


DEFAULT_LIST_COLUMNS

public static final int[] DEFAULT_LIST_COLUMNS
Default columns to retrieve when asked for list of objects. These should be only columns visible to user on the screen and not any internal columns. Also the columns should be retrievable efficiently so that the default view is very quick.


DEFAULT_LIST_SORT_COLUMNS

public static final int[] DEFAULT_LIST_SORT_COLUMNS
Default columns to sort by when asked for list of objects.


DEFAULT_LIST_SORT_ORDER

public static final java.lang.String[] DEFAULT_LIST_SORT_ORDER
Default order in which the columns will be sorted.


m_iInventoryId

protected int m_iInventoryId
ID of the inventory the unit belongs to.


m_iItemId

protected int m_iItemId
Id of the item represented by this unit


m_iShippedCount

protected int m_iShippedCount
How many units were shipped (delivered) to the inventory. This is here for bookkeeping purposes since this is the total number of units which should be still in the inventory or issued. Sum of these values for one item is cached in the Item class.


m_iAvailableCount

protected int m_iAvailableCount
This has to be nonnegative number less or equal to shipped count for all units except for unit flagged as the "found holder" since for all normal units we cannot issue more than we have available. For "found holder" though we can issue more units then we have available therefore for found holder this can be negative. Also the sum of all available counts of units of the same item is cached in Item class. Available count encompasses all units which were never issued + all units which were returned + all items which were found + all items which needs repair.


m_dCost

protected double m_dCost
Cost of individual unit. Combination of item and cost should be unique (that is units represents how many of the same items in the inventory share the same cost). Average cost is cached in the Item.


m_bFoundHolder

protected boolean m_bFoundHolder
If this is true then this instance is used to track found units we don't know where they came from or what instance of unit for this item they belong to. There could be only one such found holder for an item. If this is false then this is just a regular unit which was supplied to the inventory. Found holder unit is also used when we are issuing more units than we have available, since apparently in the inventory there were some units "found" (units we don't know anything about).

Constructor Detail

Unit

public Unit(int iDomainId)
Empty constructor

Parameters:
iDomainId - - domain id this unit belongs to

Unit

public Unit(int iDomainId,
            int iInventoryId,
            int iItemId,
            int iShippedCount,
            int iAvailableCount,
            double dCost,
            boolean bFoundHolder)
Full constructor to create new unit

Parameters:
iDomainId - - domain id this unit belongs to
iInventoryId - - id of inventory this unit belongs to
iItemId - - id of the item this unit represents
iShippedCount - - originally shipped count, how many units were supplied to the inventory with a given cost
iAvailableCount - - available count - how many units are available in the inventory
dCost - - cost of the unit
bFoundHolder - - If this is true then this instance is used to track found units we don't know where they came from or what instance of unit for this item they belong to. There could be only one such found holder for an item. If this is false then this is just a regular unit which was supplied to the inventory. Found holder unit is also used when we are issuing more units than we have available, since apparently in the inventory there were some units "found" (units we don't know anything about).

Unit

public Unit(int iUnitId,
            int iDomainId,
            int iInventoryId,
            int iItemId,
            int iShippedCount,
            int iAvailableCount,
            double dCost,
            boolean bFoundHolder,
            java.sql.Timestamp creationDate,
            java.sql.Timestamp modificationDate)
Full constructor to create new unit.

Parameters:
iUnitId - - id of this unit
iDomainId - - domain id this unit belongs to
iInventoryId - - id of inventory this unit belongs to
iItemId - - id of the item this unit represents
iShippedCount - - originally shipped count, how many units were supplied to the inventory with a given cost
iAvailableCount - - available count - how many units are available in the inventory
dCost - - cost of the units
bFoundHolder - - If this is true then this instance is used to track found units we don't know where they came from or what instance of unit for this item they belong to. There could be only one such found holder for an item. If this is false then this is just a regular unit which was supplied to the inventory. Found holder unit is also used when we are issuing more units than we have available, since apparently in the inventory there were some units "found" (units we don't know anything about).
modificationDate - - Unit modification date
creationDate - - Unit creation date
Method Detail

getItemId

public int getItemId()
Returns:
int - id of the item this unit represent

setItemId

public void setItemId(int iItemId)
Parameters:
iItemId - - what item this identification represents

getAvailableCount

public int getAvailableCount()
Returns:
int - how many units are available in the inventory

getCost

public double getCost()
Returns:
double - cost of the units

getInventoryId

public int getInventoryId()
Returns:
int - id of inventory this unit belongs to

setInventoryId

public void setInventoryId(int iInventoryId)
Parameters:
iInventoryId - - what inventory this unit belongs to

setAvailableCount

public void setAvailableCount(int value)
Change available count.

Parameters:
value - - new available count value

isFoundHolder

public boolean isFoundHolder()
Returns:
boolean - If this is true then this instance is used to track found units we don't know where they came from or what instance of unit for this item they belong to. There could be only one such found holder for an item. If this is false then this is just a regular unit which was supplied to the inventory. Found holder unit is also used when we are issuing more units than we have available, since apparently in the inventory there were some units "found" (units we don't know anything about).

getShippedCount

public int getShippedCount()
Returns:
int - originally shipped count, how many units were supplied to the inventory with a given cost

setShippedCount

public void setShippedCount(int iShippedCount)
Parameters:
iShippedCount - - originally shipped count, how many units were supplied to the inventory with a given cost

setCost

public void setCost(double dCost)
Parameters:
dCost - - Cost of individual item. Combination of item and cost should be unique. Average cost is cached in the Item.

isSame

public boolean isSame(java.lang.Object oObject)

Specified by:
isSame in class org.opensubsystems.core.data.DataObject


Copyright © 2003 - 2006 OpenSubsystems s.r.o.