org.opensubsystems.inventory.persist
Interface UnitFactory

All Superinterfaces:
org.opensubsystems.core.persist.BasicDataFactory, org.opensubsystems.core.persist.DataFactory, org.opensubsystems.patterns.listdata.persist.ListFactory, org.opensubsystems.core.persist.ModifiableDataFactory
All Known Implementing Classes:
UnitDatabaseFactory

public interface UnitFactory
extends org.opensubsystems.core.persist.ModifiableDataFactory, org.opensubsystems.patterns.listdata.persist.ListFactory

Methods to create, retrieve and manipulate units in the persistence store.

Version:
$Id: UnitFactory.java,v 1.3 2007/01/07 06:14:31 bastafidli Exp $
Author:
Martin Cerba
Code reviewer:
TODO: Review this code
Code reviewed:
Initial revision

Method Summary
 boolean changeAvailableCount(int iUnitId, int iValue)
          Change the available count for specified unit by specified relative value.
 boolean changeAvailableCount(java.util.List lstChanges)
          Change the available count for specified unit by specified relative values.
 boolean changeShippedAndAvailableCount(int iUnitId, int iValue)
          Change the shipped and available count for specified unit by specified relative value.
 boolean changeShippedAndAvailableCountSecure(int iUnitId, int iValue)
          Change the shipped and available count for specified unit by specified relative value.
 Unit get(int iItemId, double cost)
          Get unit based on the item it belongs to and cost of this unit.
 java.util.List getAvailableItems(int iItemId)
          This method returnd ids of all units for specified item which are available (that is the available count > 0)
 java.util.List getExceptFoundHolder(int iItemId)
          Get all units for specified item except the "found holder" (if any exists).
 Unit getFoundHolderItem(int iItemId)
          Get unit which is marked as "found holder".
 int resetCounts(int iInventoryId)
          Reset all counts of all items in the inventory to 0.
 int save(java.util.Collection colUnits)
          Update collection of Units
 
Methods inherited from interface org.opensubsystems.core.persist.ModifiableDataFactory
save
 
Methods inherited from interface org.opensubsystems.core.persist.BasicDataFactory
create, create, delete
 
Methods inherited from interface org.opensubsystems.core.persist.DataFactory
get, getDataType
 
Methods inherited from interface org.opensubsystems.patterns.listdata.persist.ListFactory
get, getDefaultListDefinition
 

Method Detail

save

int save(java.util.Collection colUnits)
         throws org.opensubsystems.core.error.OSSException
Update collection of Units

Parameters:
colUnits - - collection of units that have to be updated
Returns:
int - number of updated records
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

get

Unit get(int iItemId,
         double cost)
         throws org.opensubsystems.core.error.OSSException
Get unit based on the item it belongs to and cost of this unit. TODO: For Miro: Here we have assumption that units are unique for a given item based on their cost. I am not sure what was the original design thought. Review this.

Parameters:
iItemId - - id of item to get unit for
cost - - cost of unit to get
Returns:
Unit - specified Unit or null if not found.
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getFoundHolderItem

Unit getFoundHolderItem(int iItemId)
                        throws org.opensubsystems.core.error.OSSException
Get unit which is marked as "found holder". Found holder is used to track information such as counts for all found items that is items we cannot otherwise decide what unit they belong to. There can be only one such item per item.

Parameters:
iItemId - - id of item to get found holder unit for
Returns:
Unit - specified Unit or null if not found.
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getExceptFoundHolder

java.util.List getExceptFoundHolder(int iItemId)
                                    throws org.opensubsystems.core.error.OSSException
Get all units for specified item except the "found holder" (if any exists).

Parameters:
iItemId - - id of item to get units for
Returns:
List - list of units
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getAvailableItems

java.util.List getAvailableItems(int iItemId)
                                 throws org.opensubsystems.core.error.OSSException
This method returnd ids of all units for specified item which are available (that is the available count > 0)

Parameters:
iItemId - - item id to get the units for
Returns:
List - list of Unit objects
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

changeAvailableCount

boolean changeAvailableCount(int iUnitId,
                             int iValue)
                             throws org.opensubsystems.core.error.OSSException
Change the available count for specified unit by specified relative value. If the value is positive the available item count will be increased otherwise it will be decreased. The sum of these values is cached in the Item and these has to always be in sync.

Parameters:
iUnitId - - unit id to change the available count for
iValue - - value to add (if positive) or remove (if negative)
Returns:
boolean - sucess flag
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

changeShippedAndAvailableCount

boolean changeShippedAndAvailableCount(int iUnitId,
                                       int iValue)
                                       throws org.opensubsystems.core.error.OSSException
Change the shipped and available count for specified unit by specified relative value. If the value is positive the available item count will be increased otherwise it will be decreased. The sum of these values is cached in the Item and these has to always be in sync.

Parameters:
iUnitId - - unit id to change the available count for
iValue - - value to add (if positive) or remove (if negative)
Returns:
boolean - sucess flag
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

changeShippedAndAvailableCountSecure

boolean changeShippedAndAvailableCountSecure(int iUnitId,
                                             int iValue)
                                             throws org.opensubsystems.core.error.OSSException
Change the shipped and available count for specified unit by specified relative value. If the value is positive the available item count will be increased otherwise it will be decreased. The sum of these values is cached in the ItemType and these has to always be in sync. Because shipped have to be always >= 0 and availble can be < 0 only in foud holder this function remove max shipped and available from item

Parameters:
iUnitId - - Unit id
iValue - - value to add ( have to be >= 0 )
Returns:
boolean - sucess flag
Throws:
org.opensubsystems.core.error.OSSException - - error in database

changeAvailableCount

boolean changeAvailableCount(java.util.List lstChanges)
                             throws org.opensubsystems.core.error.OSSException
Change the available count for specified unit by specified relative values. If the value is positive the available item count will be increased otherwise it will be decreased. The sum of these values is cached in the Item and these has to always be in sync.

Parameters:
lstChanges - - list of TwoIntStructs where the first int is the unit id and the second int is the integer value (positive or negative to change the count by)
Returns:
boolean - sucess flag
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

resetCounts

int resetCounts(int iInventoryId)
                throws org.opensubsystems.core.error.OSSException
Reset all counts of all items in the inventory to 0. The sum of these values is cached in the Item and these has to always be in sync therefore those counts needs to be reset as well.

Parameters:
iInventoryId - - inventory id where to reset count of items
Returns:
int - number of updated items
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured


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