org.opensubsystems.inventory.persist.db
Class CategoryDatabaseFactory

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.CategoryDatabaseFactory
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, CategoryFactory, org.opensubsystems.patterns.listdata.persist.db.ListDatabaseFactory, org.opensubsystems.patterns.listdata.persist.ListFactory

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

Data factory to retrieve and manipulate categories in persistence store.

Version:
$Id: CategoryDatabaseFactory.java,v 1.18 2007/01/28 06:54:43 bastafidli Exp $
Author:
Julian Legeny
Code reviewer:
Miro Halas
Code reviewed:
1.7 2006/02/21 06:02:01 bastafidli

Field Summary
protected  CategoryDatabaseSchema 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
CategoryDatabaseFactory()
          Default constructor.
 
Method Summary
 int create(java.util.Collection colDataObject)
          
 org.opensubsystems.core.data.DataObject create(org.opensubsystems.core.data.DataObject data)
          
 void delete(int iId, int iDomainId)
          
 int deleteRoot(int iId, org.opensubsystems.patterns.listdata.data.SimpleRule listSecurityData)
          Delete root category with all subcategories contained in this category.
 int deleteRoots(int[] arrIds, org.opensubsystems.patterns.listdata.data.SimpleRule listSecurityData)
          Delete all specified root categories with all its subcategories contained in.
 org.opensubsystems.core.data.DataObject get(int iId, int iDomainId)
          
 Category get(int iParentID, java.lang.String strCategoryName)
          Get category based on unique combination of name and parent id.
 int getActualCount(int[] arrIds)
          Get actual number of categories that still exists within the DB.
 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)
          
 org.opensubsystems.core.data.ModifiableDataObject save(org.opensubsystems.core.data.ModifiableDataObject data)
          
 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 verifyUniqueCategory(Category category)
          Get result for category existence.
 
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 CategoryDatabaseSchema m_schema
Schema to use to execute database dependent operations.

Constructor Detail

CategoryDatabaseFactory

public CategoryDatabaseFactory()
                        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

get

public Category get(int iParentID,
                    java.lang.String strCategoryName)
             throws org.opensubsystems.core.error.OSSException
Get category based on unique combination of name and parent id.

Specified by:
get in interface CategoryFactory
Parameters:
iParentID - - parent id of the category
strCategoryName - - name of the subcategory under given parent
Returns:
Category - category with specified parent id and name or null if not found
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

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 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

verifyUniqueCategory

public boolean verifyUniqueCategory(Category category)
                             throws org.opensubsystems.core.error.OSSException
Get result for category existence. This is used for manual unique constraint checking for attributes: DOMAIN_ID, INVENTORY_ID, PARENT_ID, NAME

Specified by:
verifyUniqueCategory in interface CategoryFactory
Parameters:
category - - Category object
Returns:
boolean - flag signaling if particular category already exists (manual check of unique constrain on 4 attributes)
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

deleteRoot

public int deleteRoot(int iId,
                      org.opensubsystems.patterns.listdata.data.SimpleRule listSecurityData)
               throws org.opensubsystems.core.error.OSSException
Delete root category with all subcategories contained in this category. The regular delete method deletes the category only if it is empty while this method will delete even non empty category by deleting all subcategories.

Specified by:
deleteRoot in interface CategoryFactory
Parameters:
iId - - id of category that has to be deleted
listSecurityData - - security data describing what data can be deleted
Returns:
int - number of deleted categories and subcategories
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

deleteRoots

public int deleteRoots(int[] arrIds,
                       org.opensubsystems.patterns.listdata.data.SimpleRule listSecurityData)
                throws org.opensubsystems.core.error.OSSException
Delete all specified root categories with all its subcategories contained in. The regular delete method deletes the category only if it is empty.

Specified by:
deleteRoots in interface CategoryFactory
Parameters:
arrIds - - array of category ids that has to be deleted
listSecurityData - - security data describing what data can be deleted
Returns:
int - number of deleted categories and subcategories
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured

getActualCount

public int getActualCount(int[] arrIds)
                   throws org.opensubsystems.core.error.OSSException
Get actual number of categories that still exists within the DB. This doesn't uses security because this method is used within the controller for checking of security of list of data to process.

Specified by:
getActualCount in interface CategoryFactory
Parameters:
arrIds - - array of category IDs that has to be counted
Returns:
int - number of existing categories
Throws:
org.opensubsystems.core.error.OSSException - - an error has occured


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