com.konakartadmin.bl
Class AdminStoreMgr

java.lang.Object
  extended by com.konakartadmin.bl.AdminBaseMgr
      extended by com.konakartadmin.bl.AdminStoreMgr
All Implemented Interfaces:
AdminStoreMgrIf

public class AdminStoreMgr
extends AdminBaseMgr
implements AdminStoreMgrIf

The AdminStoreMgr - for Store-related functions of the Admin Application


Nested Class Summary
 
Nested classes/interfaces inherited from class com.konakartadmin.bl.AdminBaseMgr
AdminBaseMgr.StaticData
 
Field Summary
protected static int DEFAULT_ADMIN_ROLE_ID
           
protected static java.lang.String DEFAULT_ADMIN_USERNAME
          Default credentials for accessing the KonaKart Admin App
protected static java.lang.String DEFAULT_PASSWORD
          Default credentials for accessing the KonaKart Admin App
protected static int DEFAULT_SUPER_USER_ROLE_ID
           
protected static java.lang.String DEFAULT_SUPER_USERNAME
          Default credentials for accessing the KonaKart Admin App
protected static org.apache.commons.logging.Log log
          the log
 
Fields inherited from class com.konakartadmin.bl.AdminBaseMgr
adminEng, baseMgrMutex, baseStaticDataHM, cDataEnd, cDataStart, kkConf, kkInstanceId, mgrFactory, STORE_ID, templateBaseDir
 
Constructor Summary
AdminStoreMgr(KKAdminIf eng)
          Constructor
 
Method Summary
protected  void addStandardSelectColumns(com.konakart.bl.KKCriteria c)
           
protected  void addStatusSelectColumns(com.konakart.bl.KKCriteria c)
           
protected  void addStoreOrderBy(com.konakart.bl.KKCriteria c, AdminStoreSearch search)
           
protected  int addStoreSearchCriteria(com.konakart.bl.KKCriteria c, AdminStoreSearch search)
           
protected  void checkEngineMode(java.lang.String attempting)
           
protected  void checkValidStoreId(java.lang.String storeId)
           
protected  void cloneOrderStatuses(KKAdminIf targetEng, java.lang.String sessionId, java.lang.String sourceStoreId, java.lang.String targetStoreId)
           
 void cloneStore(AdminNewStoreOptions options, java.lang.String storeToCloneId, AdminStore newStore, int userId)
          Insert a new store into the mall by cloning a specified store.
protected  void cloneStoreData(KKAdminIf targetEng, java.lang.String sessionId, java.lang.String sourceStoreId, java.lang.String targetStoreId)
           
protected  void cloneStoreFiles(AdminStore newStore, AdminStore oldStore)
          Copy the reports and the template files from the original Store's mall file area to the new Store's mall file area
protected  void copyDirTree(java.lang.String sourceDir, java.lang.String targetDir)
          create the directory if it doesn't already exist
protected  void copyFile(java.io.File source, java.io.File target)
          File copying utility function
protected  KKAdminIf createAdminEngine(java.lang.String targetStoreId)
           
protected  void createDir(java.lang.String dir)
           
protected  java.lang.String createNewStore(AdminNewStoreOptions options, java.lang.String storeToCloneId, AdminStore newStore, int userId)
          Insert an AdminStore object
 void deleteStoreDB(java.lang.String storeId)
          Delete a Store from the Database
 boolean doesStoreExistDB(java.lang.String storeId)
          Return true if the store exists.
protected  void doInit(KKAdminIf eng)
           
protected  void executeStatement(java.lang.String sqlStatement)
          Execute statement that works for multi database testing
protected  AdminStoreIntegrationMgrInterface getAdminStoreIntegMgrInstanceByName(java.lang.String className)
          Called to instantiate an AdminStoreIntegrationMgr.
protected  AdminStoreIntegrationMgrInterface getAdminStoreIntegrationMgr()
          Used to get an instance of the AdminStoreIntegrationMgr
protected  java.lang.String getConfigValue(java.lang.String key)
           
protected  int getConfigValueAsInt(java.lang.String key, int def)
           
protected  int getCount(com.konakart.bl.KKCriteria c)
          Get the count of the number of rows returned by the KKCriteria (usually used for paging).
protected  XmlIoDataConfig getDataConfigForCloning(int direction)
          Creates a DataConfig object for cloning
 com.konakart.bl.KKCriteria getNewCriteria()
          Gets a new KKCriteria object from the super class then takes off the storeId as we never want to add a where storeId= constraint when looking up these stores.
protected  int getStoreCount(AdminStoreSearch search)
          Returns a count of the number of Zones with the specified search criteria
 AdminStore getStoreDBById(java.lang.String storeId)
          Return the AdminStore object from the database with the specified storeId
 AdminStore[] getStores(org.apache.commons.configuration.Configuration kkConfig)
          Get the stores supported by the server.
 AdminStore[] getStores(java.lang.String configFile)
          Get the stores supported by the server.
 AdminStoreSearchResult getStoresDB(AdminStoreSearch search, int offset, int size)
          Return the AdminStore objects defined by the search criteria.
protected  AdminStore[] getStoresPrivate()
          Just returns the default single store list.
 AdminStore getStoreStatusById(java.lang.String storeId)
          Return the status elements of the AdminStore object from the database with the specified storeId
protected  void insertRoleForUser(KKAdminIf eng, java.lang.String sessionId, int roleId, int userId)
           
 java.lang.String insertStore(AdminStore newStore, int userId)
          Insert an AdminStore object
protected  java.lang.String insertStoreDB(AdminStore insertObj)
          Insert an AdminStore object into the database
protected  void loadKonaKartNewStoreFile(AdminStore store, java.lang.String sourceStoreId)
          Copy the reference data from the source store to the target store.
protected  void loadNewStoreFile(java.lang.String filename, AdminStore store, java.lang.String sourceStoreId)
          Copy the reference data from the source store to the target store.
protected  void loadStoreData(AdminStore store, AdminNewStoreOptions options, java.lang.String sourceStoreId, int userId)
          Load the database for this new store
protected  void loadUserNewStoreFile(AdminStore store, java.lang.String sourceStoreId)
          Copy the reference data from the source store to the target store.
protected  java.lang.String loginToAdminEngine(KKAdminIf eng, java.lang.String userName, java.lang.String password)
           
protected  void modifyConfigValueForNewStore(KKAdminIf adEng, java.lang.String sessionId, java.lang.String key, java.lang.String targetStoreId, java.lang.String sourceStoreId)
           
protected  void setConfigsForNewStore(AdminStore store, KKAdminIf adminEng, java.lang.String sessionId, java.lang.String targetStoreId, java.lang.String sourceStoreId)
           
private  void setConfigValue(KKAdminIf adminEng, java.lang.String sessionId, java.lang.String key, java.lang.String value)
           
protected  void setLocal(AdminStore store)
          Set the local attribute on the store record to true or false as appropriate.
protected  boolean sqlLine(java.lang.String line)
           
 void updateStoreDB(AdminStore updateObj)
          Update an AdminStore object
 
Methods inherited from class com.konakartadmin.bl.AdminBaseMgr
addInsertAttr, addInsertAttr, checkIntIsSet, checkRequired, getAdminAddressMgr, getAdminAuditMgr, getAdminBillingMgr, getAdminBookableProductMgr, getAdminCatMgr, getAdminConfigMgr, getAdminCurrMgr, getAdminCustMgr, getAdminCustTagMgr, getAdminEmailMgr, getAdminEng, getAdminHtmlMgr, getAdminLanguageMgr, getAdminManuMgr, getAdminMessageMgr, getAdminMiscItemMgr, getAdminModulesMgr, getAdminMultiStoreMgr, getAdminOrderMgr, getAdminPdfMgr, getAdminProdAttrMgr, getAdminProdMgr, getAdminPromMgr, getAdminPublishProdMgr, getAdminReviewMgr, getAdminSearchRuleMgr, getAdminSecMgr, getAdminSolrMgr, getAdminStoreMgr, getAdminTagMgr, getAdminTaxMgr, getAdminValidationMgr, getAdminVelocityContextMgr, getAdminWishListMgr, getBooleanFromString, getExportXMLData, getIntFromString, getKkConfig, getKkInstanceId, getMode, getModeString, getMqMgr, getNewCriteria, getPostSearchText, getPreSearchText, getPropertyValue, getRecordCount, getRewardPointMgr, getSingleIntResult, getStoreId, getTemplate, getTemplateBase, getXml_io, init, isConfigSet, isEnterprise, isMultiStoreLanguagesShared, isMultiStoreMode, isMultiStoreShareCategories, isMultiStoreShareCustomers, isMultiStoreShareProducts, isMultiStoreSingleDBCSMode, isMultiStoreSingleDBMode, isMultiStoreSingleDBNonCSMode, manageException, refreshConfigs, removeCData, setAdminEng, setupWildCardRules, setWildCardAfter, setWildCardBefore, shutdownGracefully, shutdownGracefully, timestampStr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
the log


DEFAULT_ADMIN_ROLE_ID

protected static final int DEFAULT_ADMIN_ROLE_ID
See Also:
Constant Field Values

DEFAULT_SUPER_USER_ROLE_ID

protected static final int DEFAULT_SUPER_USER_ROLE_ID
See Also:
Constant Field Values

DEFAULT_ADMIN_USERNAME

protected static java.lang.String DEFAULT_ADMIN_USERNAME
Default credentials for accessing the KonaKart Admin App


DEFAULT_SUPER_USERNAME

protected static java.lang.String DEFAULT_SUPER_USERNAME
Default credentials for accessing the KonaKart Admin App


DEFAULT_PASSWORD

protected static java.lang.String DEFAULT_PASSWORD
Default credentials for accessing the KonaKart Admin App

Constructor Detail

AdminStoreMgr

public AdminStoreMgr(KKAdminIf eng)
              throws KKAdminException
Constructor

Parameters:
eng - KKAdminIf Admin Engine
Throws:
KKAdminException
Method Detail

doInit

protected void doInit(KKAdminIf eng)
               throws KKAdminException
Throws:
KKAdminException

getStores

public AdminStore[] getStores(java.lang.String configFile)
                       throws KKAdminException
Get the stores supported by the server.

Specified by:
getStores in interface AdminStoreMgrIf
Parameters:
configFile - the name of the properties file
Returns:
an array of AdminStore objects
Throws:
KKAdminException

getStores

public AdminStore[] getStores(org.apache.commons.configuration.Configuration kkConfig)
                       throws KKAdminException
Get the stores supported by the server. This version uses a KonaKart Configuration that has already been read rather than read a new one every time.

Specified by:
getStores in interface AdminStoreMgrIf
Parameters:
kkConfig - A configuration that has already been read
Returns:
an array of AdminStore objects
Throws:
KKAdminException

getStoresPrivate

protected AdminStore[] getStoresPrivate()
Just returns the default single store list.

Returns:
an array of AdminStore objects (actually the array always has just 1 element)

getStoresDB

public AdminStoreSearchResult getStoresDB(AdminStoreSearch search,
                                          int offset,
                                          int size)
                                   throws KKAdminException
Return the AdminStore objects defined by the search criteria.

Specified by:
getStoresDB in interface AdminStoreMgrIf
Parameters:
search - the Admin Store search object that defines the AdminStore objects to search for. If null we use the default AdminStoreSearch object.
offset - starting offset in database - so that you can page through results
size - size of the group that will be returned - the maximum number of records returned. If this is set to -1 (KonakartAdminConstants.NOT_SET) no limit is imposed.
Returns:
an AdminStoreSearchResult object
Throws:
KKAdminException

getStoreCount

protected int getStoreCount(AdminStoreSearch search)
                     throws org.apache.torque.TorqueException,
                            com.workingdogs.village.DataSetException
Returns a count of the number of Zones with the specified search criteria

Parameters:
search - Search criteria
Returns:
A count of the number of Zones with the specified search criteria
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getCount

protected int getCount(com.konakart.bl.KKCriteria c)
                throws org.apache.torque.TorqueException,
                       com.workingdogs.village.DataSetException
Get the count of the number of rows returned by the KKCriteria (usually used for paging).

Parameters:
c - the Criteria which contains a count()
Returns:
The number of records present in the database matching the given criteria
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getStoreStatusById

public AdminStore getStoreStatusById(java.lang.String storeId)
                              throws KKAdminException
Return the status elements of the AdminStore object from the database with the specified storeId

Specified by:
getStoreStatusById in interface AdminStoreMgrIf
Parameters:
storeId - the storeId of the AdminStore object to retrieve.
Returns:
a partly-filled AdminStore object or null if the store isn't found
Throws:
KKAdminException

getStoreDBById

public AdminStore getStoreDBById(java.lang.String storeId)
                          throws KKAdminException
Return the AdminStore object from the database with the specified storeId

Specified by:
getStoreDBById in interface AdminStoreMgrIf
Parameters:
storeId - the storeId of the AdminStore object to retrieve.
Returns:
an AdminStore object or null if the store isn't found
Throws:
KKAdminException

setLocal

protected void setLocal(AdminStore store)
                 throws KKAdminException
Set the local attribute on the store record to true or false as appropriate. We only set it to false if the store's store_home attribute is different to the KKInstance

Parameters:
store -
Throws:
KKAdminException

addStandardSelectColumns

protected void addStandardSelectColumns(com.konakart.bl.KKCriteria c)
Parameters:
c -

addStatusSelectColumns

protected void addStatusSelectColumns(com.konakart.bl.KKCriteria c)

addStoreSearchCriteria

protected int addStoreSearchCriteria(com.konakart.bl.KKCriteria c,
                                     AdminStoreSearch search)
Parameters:
c -
search -
Returns:
the number of constraints added

addStoreOrderBy

protected void addStoreOrderBy(com.konakart.bl.KKCriteria c,
                               AdminStoreSearch search)

deleteStoreDB

public void deleteStoreDB(java.lang.String storeId)
                   throws KKAdminException
Delete a Store from the Database

Specified by:
deleteStoreDB in interface AdminStoreMgrIf
Parameters:
storeId - A Store id
Throws:
KKAdminException

doesStoreExistDB

public boolean doesStoreExistDB(java.lang.String storeId)
                         throws KKAdminException,
                                org.apache.torque.TorqueException
Return true if the store exists.

Specified by:
doesStoreExistDB in interface AdminStoreMgrIf
Parameters:
storeId - store id
Returns:
True if the zone exists
Throws:
org.apache.torque.TorqueException
KKAdminException

checkEngineMode

protected void checkEngineMode(java.lang.String attempting)
                        throws KKAdminException
Parameters:
attempting -
Throws:
KKAdminException

insertStore

public java.lang.String insertStore(AdminStore newStore,
                                    int userId)
                             throws org.apache.torque.TorqueException,
                                    KKAdminException,
                                    java.lang.Exception
Insert an AdminStore object

Specified by:
insertStore in interface AdminStoreMgrIf
Parameters:
newStore - An AdminStore object to insert
userId - the user inserting the store
Returns:
returns the id of the inserted AdminStore object
Throws:
java.lang.Exception
KKAdminException
org.apache.torque.TorqueException

createNewStore

protected java.lang.String createNewStore(AdminNewStoreOptions options,
                                          java.lang.String storeToCloneId,
                                          AdminStore newStore,
                                          int userId)
                                   throws java.lang.Exception,
                                          KKAdminException
Insert an AdminStore object

Parameters:
options - Some options for defining how to execute the clone
storeToCloneId - the store the will be cloned to make the new store
newStore - the new store - all attributes should be filled in, including storeId
userId - the user inserting the store
Returns:
returns the id of the inserted AdminStore object
Throws:
java.lang.Exception
KKAdminException

checkValidStoreId

protected void checkValidStoreId(java.lang.String storeId)
                          throws KKAdminException
Parameters:
storeId -
Throws:
KKAdminException

insertStoreDB

protected java.lang.String insertStoreDB(AdminStore insertObj)
                                  throws KKAdminException
Insert an AdminStore object into the database

Parameters:
insertObj - An AdminStore object
Returns:
returns the id of the inserted AdminStore object
Throws:
KKAdminException

updateStoreDB

public void updateStoreDB(AdminStore updateObj)
                   throws KKAdminException
Update an AdminStore object

Specified by:
updateStoreDB in interface AdminStoreMgrIf
Parameters:
updateObj - An AdminStore object
Throws:
KKAdminException

getNewCriteria

public com.konakart.bl.KKCriteria getNewCriteria()
Gets a new KKCriteria object from the super class then takes off the storeId as we never want to add a where storeId= constraint when looking up these stores.

Specified by:
getNewCriteria in interface AdminStoreMgrIf
Overrides:
getNewCriteria in class AdminBaseMgr
Returns:
Returns a new KKCriteria object

cloneStore

public void cloneStore(AdminNewStoreOptions options,
                       java.lang.String storeToCloneId,
                       AdminStore newStore,
                       int userId)
                throws java.lang.Exception
Insert a new store into the mall by cloning a specified store. Multi-Store Single DB only

Specified by:
cloneStore in interface AdminStoreMgrIf
Parameters:
options - Some options for defining how to execute the clone
storeToCloneId - the store the will be cloned to make the new store
newStore - the new store - all attributes should be filled in, including storeId
userId -
Throws:
java.lang.Exception
org.apache.torque.TorqueException
KKAdminException

loadStoreData

protected void loadStoreData(AdminStore store,
                             AdminNewStoreOptions options,
                             java.lang.String sourceStoreId,
                             int userId)
                      throws java.lang.Exception
Load the database for this new store

Parameters:
options - Some options for defining how to execute the clone
Throws:
java.lang.Exception
org.apache.torque.TorqueException

cloneStoreData

protected void cloneStoreData(KKAdminIf targetEng,
                              java.lang.String sessionId,
                              java.lang.String sourceStoreId,
                              java.lang.String targetStoreId)

cloneOrderStatuses

protected void cloneOrderStatuses(KKAdminIf targetEng,
                                  java.lang.String sessionId,
                                  java.lang.String sourceStoreId,
                                  java.lang.String targetStoreId)
                           throws org.apache.torque.TorqueException,
                                  com.workingdogs.village.DataSetException,
                                  KKAdminException
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKAdminException

setConfigsForNewStore

protected void setConfigsForNewStore(AdminStore store,
                                     KKAdminIf adminEng,
                                     java.lang.String sessionId,
                                     java.lang.String targetStoreId,
                                     java.lang.String sourceStoreId)
                              throws org.apache.torque.TorqueException,
                                     com.workingdogs.village.DataSetException,
                                     java.lang.Exception
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
java.lang.Exception

modifyConfigValueForNewStore

protected void modifyConfigValueForNewStore(KKAdminIf adEng,
                                            java.lang.String sessionId,
                                            java.lang.String key,
                                            java.lang.String targetStoreId,
                                            java.lang.String sourceStoreId)
                                     throws KKAdminException
Throws:
KKAdminException

setConfigValue

private void setConfigValue(KKAdminIf adminEng,
                            java.lang.String sessionId,
                            java.lang.String key,
                            java.lang.String value)
                     throws KKAdminException
Throws:
KKAdminException

createAdminEngine

protected KKAdminIf createAdminEngine(java.lang.String targetStoreId)
                               throws KKAdminException
Parameters:
targetStoreId -
Returns:
return a KKAdmin engine
Throws:
KKAdminException

insertRoleForUser

protected void insertRoleForUser(KKAdminIf eng,
                                 java.lang.String sessionId,
                                 int roleId,
                                 int userId)
                          throws java.lang.Exception
Parameters:
eng -
sessionId -
roleId -
userId -
Throws:
java.lang.Exception

loginToAdminEngine

protected java.lang.String loginToAdminEngine(KKAdminIf eng,
                                              java.lang.String userName,
                                              java.lang.String password)
                                       throws com.konakart.app.KKException,
                                              KKAdminException
Parameters:
eng -
userName -
password -
Returns:
the sessionId if the login was successful otherwise an exception is thrown
Throws:
com.konakart.app.KKException
KKAdminException

getDataConfigForCloning

protected XmlIoDataConfig getDataConfigForCloning(int direction)
                                           throws KKAdminException
Creates a DataConfig object for cloning

Parameters:
direction - either KonakartAdminConstants.XML_IMPORT or KonakartAdminConstants.XML_EXPORT
Returns:
an XmlIoDataConfig object for cloning
Throws:
KKAdminException

loadUserNewStoreFile

protected void loadUserNewStoreFile(AdminStore store,
                                    java.lang.String sourceStoreId)
                             throws KKAdminException
Copy the reference data from the source store to the target store.

Throws:
KKAdminException
org.apache.torque.TorqueException

loadKonaKartNewStoreFile

protected void loadKonaKartNewStoreFile(AdminStore store,
                                        java.lang.String sourceStoreId)
                                 throws KKAdminException
Copy the reference data from the source store to the target store.

Parameters:
store - the the target store
sourceStoreId - the source store's storeId
Throws:
KKAdminException

getConfigValue

protected java.lang.String getConfigValue(java.lang.String key)
                                   throws KKAdminException
Parameters:
key -
Returns:
return the config value as a String
Throws:
KKAdminException

getConfigValueAsInt

protected int getConfigValueAsInt(java.lang.String key,
                                  int def)
                           throws KKAdminException
Parameters:
key -
def -
Returns:
the value of the configuration variable as an integer. If the configuration variable isn't present this returns the default provided.
Throws:
KKAdminException

loadNewStoreFile

protected void loadNewStoreFile(java.lang.String filename,
                                AdminStore store,
                                java.lang.String sourceStoreId)
                         throws KKAdminException
Copy the reference data from the source store to the target store.

Parameters:
filename -
store -
sourceStoreId -
Throws:
KKAdminException

sqlLine

protected boolean sqlLine(java.lang.String line)
Parameters:
line -
Returns:
true if it's an SQL statement

executeStatement

protected void executeStatement(java.lang.String sqlStatement)
                         throws org.apache.torque.TorqueException
Execute statement that works for multi database testing

Parameters:
sqlStatement -
Throws:
org.apache.torque.TorqueException

cloneStoreFiles

protected void cloneStoreFiles(AdminStore newStore,
                               AdminStore oldStore)
Copy the reports and the template files from the original Store's mall file area to the new Store's mall file area

Parameters:
newStore - the newly created store
oldStore - the source store

copyDirTree

protected void copyDirTree(java.lang.String sourceDir,
                           java.lang.String targetDir)
                    throws java.io.IOException
create the directory if it doesn't already exist

Parameters:
sourceDir -
targetDir -
Throws:
java.io.IOException

createDir

protected void createDir(java.lang.String dir)
Parameters:
dir -

copyFile

protected void copyFile(java.io.File source,
                        java.io.File target)
File copying utility function

Parameters:
source -
target -

getAdminStoreIntegrationMgr

protected AdminStoreIntegrationMgrInterface getAdminStoreIntegrationMgr()
Used to get an instance of the AdminStoreIntegrationMgr

Returns:
Returns an StoreIntegrationMgr Object

getAdminStoreIntegMgrInstanceByName

protected AdminStoreIntegrationMgrInterface getAdminStoreIntegMgrInstanceByName(java.lang.String className)
                                                                         throws java.lang.InstantiationException,
                                                                                java.lang.IllegalAccessException,
                                                                                java.lang.ClassNotFoundException,
                                                                                java.lang.IllegalArgumentException,
                                                                                java.lang.reflect.InvocationTargetException
Called to instantiate an AdminStoreIntegrationMgr. It determines whether the AdminStoreIntegrationMgr has a constructor where KKAdmin is passed in and if it does, then this constructor is used. Otherwise the empty constructor is used.

Parameters:
className -
Returns:
Returns an instantiated Module
Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.ClassNotFoundException
java.lang.reflect.InvocationTargetException
java.lang.IllegalArgumentException


Copyright © 2011 DS Data Systems UK Ltd.