org.opensubsystems.inventory.persist.db
Class IdentificationDatabaseFactory

java.lang.Object
  extended by org.opensubsystems.core.persist.db.DatabaseFactoryImpl
      extended by org.opensubsystems.patterns.listdata.persist.db.impl.ListDatabaseFactoryImpl
          extended by org.opensubsystems.inventory.persist.db.IdentificationDatabaseFactory
All Implemented Interfaces:
org.opensubsystems.core.persist.BasicDataFactory, org.opensubsystems.core.persist.DataFactory, org.opensubsystems.core.persist.db.BasicDatabaseFactory, org.opensubsystems.core.persist.db.DatabaseFactory, org.opensubsystems.core.persist.db.ModifiableDatabaseFactory, org.opensubsystems.core.persist.ModifiableDataFactory, IdentificationFactory, org.opensubsystems.patterns.listdata.persist.db.ListDatabaseFactory, org.opensubsystems.patterns.listdata.persist.ListFactory

public class IdentificationDatabaseFactory
extends org.opensubsystems.patterns.listdata.persist.db.impl.ListDatabaseFactoryImpl
implements IdentificationFactory, org.opensubsystems.core.persist.db.ModifiableDatabaseFactory

Data factory to retrieve and manipulate identifications in persistence store.

Version:
$Id: IdentificationDatabaseFactory.java,v 1.22 2007/01/28 06:54:43 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
1.8 2006/02/21 06:02:01 bastafidli

Field Summary
protected  IdentificationDatabaseSchema m_schema
          Schema to use to execute database dependent operations.
 
Fields inherited from class org.opensubsystems.patterns.listdata.persist.db.impl.ListDatabaseFactoryImpl
m_arrOrderColumnCodes, m_arrOrderDirections, m_arrShowColumnCodes, m_listSchema
 
Fields inherited from class org.opensubsystems.core.persist.db.DatabaseFactoryImpl
m_connectionFactory, m_iConcurrencySelectListResultSet, m_iDataType, m_iTypeSelectListResultSet, m_transactionFactory
 
Constructor Summary
IdentificationDatabaseFactory()
          Default constructor.
 
Method Summary
 int create(java.util.Collection colDataObject)
          
 org.opensubsystems.core.data.DataObject create(org.opensubsystems.core.data.DataObject data)
          
 Identification create(Identification identification, boolean bCheckName)
          Create Identification in the persistance store.
 void create(java.util.List lstIdentifications, boolean bCheckUnique)
          Create list of Identifications in the persistance store.
 void delete(int iId, int iDomainId)
          
 org.opensubsystems.core.data.DataObject get(int iId, int iDomainId)
          
 Identification get(int iInventoryId, java.lang.String strInternalNumber)
          Get specific identification identified by the number assigned to it by user, which should be unique in the inventory.
 java.util.Set getAllExternalNumbers(int iInventoryId)
          Get all manufacturer specified external numbers in inventory.
 java.util.Set getAllInternalNumbers(int iInventoryId)
          Get all user specified internal numbers for particular inventory.
protected  java.util.Map getDataWithExistingSerialNumbers(java.util.List lstSerialNumbers, int iInventoryId)
          Get all existing serial numbers and belonging IDs for specified inventory
 java.lang.String getExtNumberUniqueException(boolean bIsInsert, boolean bIsList)
          Method constructs and returns unique constraint exception for created or modified identifications
 java.util.List getForItem(int iItemId)
          Get list with all identifications for specified item.
 java.lang.String getInternalNumberForExternalNumber(int iInventoryId, java.lang.String strExternalNumber)
          Get internal numbers for external number in inventory.
 java.lang.String getInternalNumberForNotUniquelyTracked(int iItemId)
          Return unique internal number associated with this non uniquely tracked item.
 java.lang.String getNextInternalNumber(int iInventoryId)
          Try to get the next internal number for particular inventory.
 org.opensubsystems.core.data.DataObject load(java.sql.ResultSet rsQueryResults, int initialIndex)
          
 org.opensubsystems.core.data.DataObject load(java.sql.ResultSet rsQueryResults, int[] selectedColumns, int initialIndex)
          
 int save(java.util.Collection colDataObject)
          Update collection of Identifications
 Identification save(Identification identification, boolean bCheckName)
          Updates Identification in the persistence store.
 void save(java.util.List lstIdentifications, boolean bCheckUnique)
          Update list of Identifications in the persistance store.
 org.opensubsystems.core.data.ModifiableDataObject save(org.opensubsystems.core.data.ModifiableDataObject data)
          
 void setAllRetired(int iInventoryId)
          Set all identifications in the inventory as retired since they should not be used anymore.
 void setRetired(java.util.Set idList)
          Set all identifications in the specified list as retired since they should not be used anymore.
 int setValuesForInsert(java.sql.PreparedStatement insertStatement, org.opensubsystems.core.data.DataObject data, int iIndex)
          
 int setValuesForUpdate(java.sql.PreparedStatement updateStatement, org.opensubsystems.core.data.DataObject data, int iIndex)
          
 boolean verifyUniqueExternalNumber(Identification data, boolean checkName)
          Check external number, inventory, manufacturer is not used yet
 
Methods inherited from class org.opensubsystems.patterns.listdata.persist.db.impl.ListDatabaseFactoryImpl
get, getDefaultListDefinition, getListDatabaseSchema
 
Methods inherited from class org.opensubsystems.core.persist.db.DatabaseFactoryImpl
getConcurrencySelectListResultSet, getDataType, getTypeSelectListResultSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opensubsystems.core.persist.DataFactory
getDataType
 
Methods inherited from interface org.opensubsystems.patterns.listdata.persist.ListFactory
get, getDefaultListDefinition
 

Field Detail

m_schema

protected IdentificationDatabaseSchema m_schema
Schema to use to execute database dependent operations.

Constructor Detail

IdentificationDatabaseFactory

public IdentificationDatabaseFactory()
                              throws org.opensubsystems.core.error.OSSException
Default constructor.

Throws:
org.opensubsystems.core.error.OSSException - - an error has occured
Method Detail

load

public org.opensubsystems.core.data.DataObject load(java.sql.ResultSet rsQueryResults,
                                                    int[] selectedColumns,
                                                    int initialIndex)
                                             throws org.opensubsystems.core.error.OSSDatabaseAccessException

Specified by:
load in interface org.opensubsystems.patterns.listdata.persist.db.ListDatabaseFactory
Throws:
org.opensubsystems.core.error.OSSDatabaseAccessException

setValuesForInsert

public int setValuesForInsert(java.sql.PreparedStatement insertStatement,
                              org.opensubsystems.core.data.DataObject data,
                              int iIndex)
                       throws org.opensubsystems.core.error.OSSException,
                              java.sql.SQLException

Specified by:
setValuesForInsert in interface org.opensubsystems.core.persist.db.BasicDatabaseFactory
Throws:
org.opensubsystems.core.error.OSSException
java.sql.SQLException

setValuesForUpdate

public int setValuesForUpdate(java.sql.PreparedStatement updateStatement,
                              org.opensubsystems.core.data.DataObject data,
                              int iIndex)
                       throws org.opensubsystems.core.error.OSSException,
                              java.sql.SQLException

Specified by:
setValuesForUpdate in interface org.opensubsystems.core.persist.db.ModifiableDatabaseFactory
Throws:
org.opensubsystems.core.error.OSSException
java.sql.SQLException

get

public org.opensubsystems.core.data.DataObject get(int iId,
                                                   int iDomainId)
                                            throws org.opensubsystems.core.error.OSSException

Specified by:
get in interface org.opensubsystems.core.persist.DataFactory
Throws:
org.opensubsystems.core.error.OSSException

load

public org.opensubsystems.core.data.DataObject load(java.sql.ResultSet rsQueryResults,
                                                    int initialIndex)
                                             throws org.opensubsystems.core.error.OSSDatabaseAccessException

Specified by:
load in interface org.opensubsystems.core.persist.db.DatabaseFactory
Throws:
org.opensubsystems.core.error.OSSDatabaseAccessException

create

public org.opensubsystems.core.data.DataObject create(org.opensubsystems.core.data.DataObject data)
                                               throws org.opensubsystems.core.error.OSSException

Specified by:
create in interface org.opensubsystems.core.persist.BasicDataFactory
Throws:
org.opensubsystems.core.error.OSSException

create

public Identification create(Identification identification,
                             boolean bCheckName)
                      throws org.opensubsystems.core.error.OSSException
Create Identification in the persistance store.

Specified by:
create in interface IdentificationFactory
Parameters:
identification - - item number item to create
bCheckName - - if true external number has to be unique in the inventory
Returns:
Identification - newly created Identification
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

create

public int create(java.util.Collection colDataObject)
           throws org.opensubsystems.core.error.OSSException

Specified by:
create in interface org.opensubsystems.core.persist.BasicDataFactory
Throws:
org.opensubsystems.core.error.OSSException

delete

public void delete(int iId,
                   int iDomainId)
            throws org.opensubsystems.core.error.OSSException

Specified by:
delete in interface org.opensubsystems.core.persist.BasicDataFactory
Throws:
org.opensubsystems.core.error.OSSException

save

public org.opensubsystems.core.data.ModifiableDataObject save(org.opensubsystems.core.data.ModifiableDataObject data)
                                                       throws org.opensubsystems.core.error.OSSException

Specified by:
save in interface org.opensubsystems.core.persist.ModifiableDataFactory
Throws:
org.opensubsystems.core.error.OSSException

save

public Identification save(Identification identification,
                           boolean bCheckName)
                    throws org.opensubsystems.core.error.OSSException
Updates Identification in the persistence store.

Specified by:
save in interface IdentificationFactory
Parameters:
identification - - Identification item to create
bCheckName - - if true external number has to be unique in the inventory
Returns:
Identification - newly created Identification
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

save

public int save(java.util.Collection colDataObject)
         throws org.opensubsystems.core.error.OSSException
Update collection of Identifications

Specified by:
save in interface IdentificationFactory
Parameters:
colDataObject - - collection of identifications that have to be updated
Returns:
int - number of updated records
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

create

public void create(java.util.List lstIdentifications,
                   boolean bCheckUnique)
            throws org.opensubsystems.core.error.OSSException
Create list of Identifications in the persistance store.

Specified by:
create in interface IdentificationFactory
Parameters:
lstIdentifications - - list of Identification items to create
bCheckUnique - - if true external number has to be unique in the inventory
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

save

public void save(java.util.List lstIdentifications,
                 boolean bCheckUnique)
          throws org.opensubsystems.core.error.OSSException
Update list of Identifications in the persistance store.

Specified by:
save in interface IdentificationFactory
Parameters:
lstIdentifications - - list of Identification items to update
bCheckUnique - - if true external number has to be unique in the inventory
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

verifyUniqueExternalNumber

public boolean verifyUniqueExternalNumber(Identification data,
                                          boolean checkName)
                                   throws org.opensubsystems.core.error.OSSException
Check external number, inventory, manufacturer is not used yet

Specified by:
verifyUniqueExternalNumber in interface IdentificationFactory
Parameters:
data - - data to check
checkName - - if true name have to be unique
Returns:
boolean - true if external number, inventory, manufacturer is already used
Throws:
org.opensubsystems.core.error.OSSException - - an error occured

getInternalNumberForNotUniquelyTracked

public java.lang.String getInternalNumberForNotUniquelyTracked(int iItemId)
                                                        throws org.opensubsystems.core.error.OSSException
Return unique internal number associated with this non uniquely tracked item. Non uniquely tracked items are items, which cannot be distinguished from each other and therefore each individual item does not have specific internal number which identifies it. The whole group of items represented by this item have one number which can identify all and every one of them. This internal number is from Identification object for particular Item "found holder" Unit. Each item without external numbers (not uniquely tracked) have one and only one found holder unit with one Identification

Specified by:
getInternalNumberForNotUniquelyTracked in interface IdentificationFactory
Parameters:
iItemId - - item id
Returns:
String - internal number or null if the item is uniquelly tracked
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

get

public Identification get(int iInventoryId,
                          java.lang.String strInternalNumber)
                   throws org.opensubsystems.core.error.OSSException
Get specific identification identified by the number assigned to it by user, which should be unique in the inventory.

Specified by:
get in interface IdentificationFactory
Parameters:
iInventoryId - - id of inventory to get the identification from TODO: Improve: Why are we saying it should be unique? Why we do not enforce the uniqueness
strInternalNumber - - internal number assigned to it by user which should be unique in the inventory
Returns:
ItemNumber - specified identification or null if it cannot be found
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getNextInternalNumber

public java.lang.String getNextInternalNumber(int iInventoryId)
                                       throws org.opensubsystems.core.error.OSSException
Try to get the next internal number for particular inventory. Function at first finds record with latest creation date in the specified inventory, then get its internal number. If the internal number is numeric (can be converted to number), return string with value equal to number + 1 otherwise return only string.

Specified by:
getNextInternalNumber in interface IdentificationFactory
Parameters:
iInventoryId - - inventory id to get the next internal number from
Returns:
String - next number or string
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getForItem

public java.util.List getForItem(int iItemId)
                          throws org.opensubsystems.core.error.OSSException
Get list with all identifications for specified item.

Specified by:
getForItem in interface IdentificationFactory
Parameters:
iItemId - - item id to get identification for
Returns:
List - list with Identification objects
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getAllInternalNumbers

public java.util.Set getAllInternalNumbers(int iInventoryId)
                                    throws org.opensubsystems.core.error.OSSException
Get all user specified internal numbers for particular inventory.

Specified by:
getAllInternalNumbers in interface IdentificationFactory
Parameters:
iInventoryId - - inventory id to get the internal numbers for
Returns:
Set - set with all user specified internal numbers in the specified inventory
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getAllExternalNumbers

public java.util.Set getAllExternalNumbers(int iInventoryId)
                                    throws org.opensubsystems.core.error.OSSException
Get all manufacturer specified external numbers in inventory.

Specified by:
getAllExternalNumbers in interface IdentificationFactory
Parameters:
iInventoryId - - inventory id to get the external numbers from
Returns:
Set - set with external numbers from the in the specified inventory
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getInternalNumberForExternalNumber

public java.lang.String getInternalNumberForExternalNumber(int iInventoryId,
                                                           java.lang.String strExternalNumber)
                                                    throws org.opensubsystems.core.error.OSSException
Get internal numbers for external number in inventory.

Specified by:
getInternalNumberForExternalNumber in interface IdentificationFactory
Parameters:
iInventoryId - - inventory id
strExternalNumber - - external number
Returns:
String - internal number for external number or null if not found
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

setAllRetired

public void setAllRetired(int iInventoryId)
                   throws org.opensubsystems.core.error.OSSException
Set all identifications in the inventory as retired since they should not be used anymore.

Specified by:
setAllRetired in interface IdentificationFactory
Parameters:
iInventoryId - - id of inventory for Identifications
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

setRetired

public void setRetired(java.util.Set idList)
                throws org.opensubsystems.core.error.OSSException
Set all identifications in the specified list as retired since they should not be used anymore.

Specified by:
setRetired in interface IdentificationFactory
Parameters:
idList - - set with ids of Identification to set as retired
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getDataWithExistingSerialNumbers

protected java.util.Map getDataWithExistingSerialNumbers(java.util.List lstSerialNumbers,
                                                         int iInventoryId)
                                                  throws org.opensubsystems.core.error.OSSException
Get all existing serial numbers and belonging IDs for specified inventory

Parameters:
lstSerialNumbers - - list of external numbers
iInventoryId - - inventory ID the external numbers will be checked for
Returns:
Map - map of data with serial numbers. There will be returned hash map of records - the KEY is ID and the VALUE is external number
Throws:
org.opensubsystems.core.error.OSSException - - error occured while getting data

getExtNumberUniqueException

public java.lang.String getExtNumberUniqueException(boolean bIsInsert,
                                                    boolean bIsList)
Method constructs and returns unique constraint exception for created or modified identifications

Parameters:
bIsInsert - - flag signaling if there is processed insert or update - true = insert identification is processed - false = update identification is processed
bIsList - - flag signaling if there is iserted/updated just 1 record or list of records - true = just 1 identification is inserted/updated - false = list of identifications is inserted/updated
Returns:
String - constructed external number unique exception


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