com.konakartadmin.utils
Class SqlPopulator

java.lang.Object
  extended by com.konakartadmin.utils.SqlPopulator

public class SqlPopulator
extends java.lang.Object

Populates the db with standard data


Field Summary
(package private) static int addrFormatId
           
private static int adminRoleId
           
(package private) static int catCartoonId
           
(package private) static int catCdromId
           
(package private) static int catComedyId
           
(package private) static int catDramaId
           
(package private) static int catDvdActionId
           
(package private) static int catDvdId
           
(package private) static boolean categoriesShared
           
(package private) static int catGiftId
           
(package private) static int catGraphicsId
           
(package private) static int catHardwareId
           
(package private) static int catKeyboardId
           
(package private) static int catMemoryId
           
(package private) static int catMonitorId
           
(package private) static int catMouseId
           
(package private) static int catPrinterId
           
(package private) static int CatSciFiId
           
(package private) static int catSimulationId
           
(package private) static int catSoftActionId
           
(package private) static int catSoftwareId
           
(package private) static int catSpeakerId
           
(package private) static int catStrategyId
           
(package private) static int catTestCatId
           
(package private) static int catThrillerId
           
(package private) static int countryGbId
           
(package private) static int countryUsId
           
(package private) static boolean customersShared
           
(package private) static java.lang.String dbDirectory
           
(package private) static com.konakart.appif.DbPortabilityIf dbPort
           
(package private) static boolean debug
           
private static int DEFAULT_ADMIN_ROLE_ID
           
private static java.lang.String DEFAULT_HTTP_PORT
           
private static java.lang.String DEFAULT_HTTPS_PORT
           
private static java.lang.String DEFAULT_KONAKARTADMIN_PROPS_FILENAME
           
private static int DEFAULT_SUPER_USER_ID
           
private static int DEFAULT_SUPER_USER_ROLE_ID
           
private static java.lang.String DEFAULT_USERNAME
          Default credentials for accessing the KonaKart Admin App
(package private) static int engineMode
           
private static java.lang.String httpPort
           
private static java.lang.String httpsPort
           
(package private) static java.lang.String kkHome
           
(package private) static int langDeId
           
(package private) static int langEsId
           
(package private) static int langGbId
           
(package private) static int langPtId
           
static org.apache.commons.logging.Log log
          logger
(package private) static int manuCanon
           
(package private) static int manuDell
           
(package private) static int manuFox
           
(package private) static int manuGTInteractive
           
(package private) static int manuHP
           
(package private) static int manuKonaKart
           
(package private) static int manuLogitech
           
(package private) static int manuMatrox
           
(package private) static int manuMicrosoft
           
(package private) static int manuSierra
           
(package private) static int manuWarner
           
(package private) static boolean minimalStore
           
(package private) static org.apache.commons.configuration.Configuration miscConf
           
(package private) static java.lang.String miscPropsFileName
           
private static int newSuperUserId
           
(package private) static int optColorId
           
(package private) static int optMemoryId
           
(package private) static int optModelId
           
(package private) static int optSizeId
           
(package private) static int optTypeId
           
(package private) static int optVal16MbId
           
(package private) static int optVal32MbId
           
(package private) static int optVal4MbId
           
(package private) static int optVal8MbId
           
(package private) static int optValBronzeId
           
(package private) static int optValDeluxeId
           
(package private) static int optValGoldId
           
(package private) static int optValPremiumId
           
(package private) static int optValPs2Id
           
(package private) static int optValSilverId
           
(package private) static int optValUsbId
           
(package private) static int optValValueId
           
(package private) static int platform
           
(package private) static int PLATFORM_LINUX
           
(package private) static int PLATFORM_WINDOWS
           
(package private) static int prodSomeAbtMaryId
           
(package private) static boolean productsShared
           
(package private) static java.lang.String propsFileName
           
(package private) static int roleStoreAdministratorId
           
(package private) static int roleSuperUserId
           
(package private) static int stateFloridaId
           
(package private) static int stateTexasId
           
(package private) static java.lang.String storeId
           
(package private) static int storeNum
           
private static int superUserId
           
private static int superUserRoleId
           
(package private) static int taxClassId
           
(package private) static java.lang.String usage
           
(package private) static int userAdminId
           
(package private) static int userCatId
           
(package private) static int userOrderId
           
(package private) static int userRootId
           
 
Constructor Summary
SqlPopulator()
           
 
Method Summary
static void addRoleForNewSuperUser(KKAdminIf eng, java.lang.String sessionId)
          We assign the super user role to the new super user in the new store
static void derivePlatform()
          Derive the platform from the os.name
private static java.lang.String getAdminUserNameForStore(java.lang.String store)
           
private static KKAdminIf getAnEng(java.lang.String theStoreId)
           
private static int getCountryIdForISO3(KKAdminIf eng, java.lang.String iso3)
           
private static int getStoreNum()
           
private static int getTaxClassIdForTitle(KKAdminIf eng, java.lang.String title)
           
private static int getUserIdForEmail(KKAdminIf eng, java.lang.String sessionId, java.lang.String email)
           
private static int getZoneIdForCodeAndName(KKAdminIf eng, java.lang.String code, java.lang.String name)
           
static void insertAddressFormats(KKAdminIf eng, java.lang.String sessionId)
          Insert address formats and save an id to be used elsewhere
static void insertApiCalls(KKAdminIf eng, java.lang.String sessionId)
           
static void insertCategories(KKAdminIf eng, java.lang.String sessionId)
           
static void insertConfigurationGroups(KKAdminIf eng, java.lang.String sessionId)
           
static void insertConfigurations(KKAdminIf eng, java.lang.String sessionId)
           
static void insertCountries(KKAdminIf eng, java.lang.String sessionId)
          Populate the db with countries.
static void insertCurrencies(KKAdminIf eng, java.lang.String sessionId)
           
static void insertCustomers(KKAdminIf eng, java.lang.String sessionId)
           
static void insertCustomerTags(KKAdminIf eng, java.lang.String sessionId)
           
static void insertLanguages(KKAdminIf eng, java.lang.String sessionId)
           
static void insertManufacturers(KKAdminIf eng, java.lang.String sessionId)
           
static void insertOptions(KKAdminIf eng, java.lang.String sessionId)
           
static void insertOptionValues(KKAdminIf eng, java.lang.String sessionId)
           
static void insertOrderStatus(KKAdminIf eng, java.lang.String sessionId)
           
static void insertPanels(KKAdminIf eng, java.lang.String sessionId)
           
static void insertProducts(KKAdminIf eng, java.lang.String sessionId)
           
static void insertProductsToCategories(KKAdminIf eng, java.lang.String sessionId)
           
static void insertProductsToStores(KKAdminIf eng, java.lang.String sessionId)
           
static void insertReviews(KKAdminIf eng, java.lang.String sessionId)
           
static void insertRoles(KKAdminIf eng, java.lang.String sessionId)
           
static void insertRolesForSuperUser(KKAdminIf eng, java.lang.String sessionId)
          We assign the super user role to the super user in the new store
static void insertStoreAdminRole(KKAdminIf eng, java.lang.String sessionId)
          We assign the adminRoleId to the store admin user of our new store.
static int insertSuperUser(KKAdminIf eng, java.lang.String sessionId)
           
static void insertTaxData(KKAdminIf eng, java.lang.String sessionId)
           
static void insertUtility(KKAdminIf eng, java.lang.String sessionId)
          Insert the Utility Table values
static boolean isCategoriesShared()
           
static boolean isCustomersShared()
           
static boolean isLanguagesShared()
           
static boolean isMultiStoreSingleDB()
           
static boolean isProductsShared()
           
static java.lang.String login(java.lang.String user, KKAdminIf eng)
          Login customer so that a login can be performed.
static void main(java.lang.String[] args)
           
static int populate()
          Populate the store
static int populateStore(java.lang.String storeIdP, java.lang.String kkHomeP, int engineModeP, java.lang.String propsFileNameP, boolean customersSharedP, boolean productsSharedP, boolean categoriesSharedP, java.lang.String miscPropsFileNameP, boolean minimalStoreP, int adminRoleIdP, int superUserIdP, int superUserRoleIdP, boolean debugP, java.lang.String httpPortNumber, java.lang.String httpsPortNumber)
          Populate the store using the specified parameters.
static void removeStoreIdForTable(java.lang.String tableName)
          Set the store_id column to '' in the specified table
static void setCategoriesShared(boolean categoriesShared)
           
static void setCustomersShared(boolean customersShared)
           
static void setProductsShared(boolean productsShared)
           
private static void setUpMiscConfiguration()
           
private static void updateConfig(KKAdminIf eng, java.lang.String sessionId, java.lang.String key, int group, java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static org.apache.commons.logging.Log log
logger


usage

static final java.lang.String usage
See Also:
Constant Field Values

DEFAULT_KONAKARTADMIN_PROPS_FILENAME

private static final java.lang.String DEFAULT_KONAKARTADMIN_PROPS_FILENAME
See Also:
Constant Field Values

propsFileName

static java.lang.String propsFileName

miscPropsFileName

static java.lang.String miscPropsFileName

debug

static boolean debug

minimalStore

static boolean minimalStore

DEFAULT_ADMIN_ROLE_ID

private static final int DEFAULT_ADMIN_ROLE_ID
See Also:
Constant Field Values

adminRoleId

private static int adminRoleId

DEFAULT_SUPER_USER_ROLE_ID

private static final int DEFAULT_SUPER_USER_ROLE_ID
See Also:
Constant Field Values

superUserRoleId

private static int superUserRoleId

DEFAULT_SUPER_USER_ID

private static final int DEFAULT_SUPER_USER_ID
See Also:
Constant Field Values

superUserId

private static int superUserId

newSuperUserId

private static int newSuperUserId

userRootId

static int userRootId

userAdminId

static int userAdminId

userOrderId

static int userOrderId

userCatId

static int userCatId

roleSuperUserId

static int roleSuperUserId

roleStoreAdministratorId

static int roleStoreAdministratorId

addrFormatId

static int addrFormatId

catHardwareId

static int catHardwareId

catSoftwareId

static int catSoftwareId

catDvdId

static int catDvdId

catGraphicsId

static int catGraphicsId

catPrinterId

static int catPrinterId

catMonitorId

static int catMonitorId

catSpeakerId

static int catSpeakerId

catKeyboardId

static int catKeyboardId

catMouseId

static int catMouseId

catSoftActionId

static int catSoftActionId

CatSciFiId

static int CatSciFiId

catComedyId

static int catComedyId

catCartoonId

static int catCartoonId

catThrillerId

static int catThrillerId

catDramaId

static int catDramaId

catTestCatId

static int catTestCatId

catGiftId

static int catGiftId

catMemoryId

static int catMemoryId

catCdromId

static int catCdromId

catSimulationId

static int catSimulationId

catDvdActionId

static int catDvdActionId

catStrategyId

static int catStrategyId

manuMatrox

static int manuMatrox

manuMicrosoft

static int manuMicrosoft

manuDell

static int manuDell

manuWarner

static int manuWarner

manuFox

static int manuFox

manuLogitech

static int manuLogitech

manuCanon

static int manuCanon

manuSierra

static int manuSierra

manuGTInteractive

static int manuGTInteractive

manuHP

static int manuHP

manuKonaKart

static int manuKonaKart

langGbId

static int langGbId

langDeId

static int langDeId

langEsId

static int langEsId

langPtId

static int langPtId

countryUsId

static int countryUsId

countryGbId

static int countryGbId

stateFloridaId

static int stateFloridaId

stateTexasId

static int stateTexasId

taxClassId

static int taxClassId

optColorId

static int optColorId

optSizeId

static int optSizeId

optModelId

static int optModelId

optMemoryId

static int optMemoryId

optTypeId

static int optTypeId

optVal4MbId

static int optVal4MbId

optVal8MbId

static int optVal8MbId

optVal16MbId

static int optVal16MbId

optVal32MbId

static int optVal32MbId

optValValueId

static int optValValueId

optValPremiumId

static int optValPremiumId

optValDeluxeId

static int optValDeluxeId

optValPs2Id

static int optValPs2Id

optValUsbId

static int optValUsbId

optValBronzeId

static int optValBronzeId

optValSilverId

static int optValSilverId

optValGoldId

static int optValGoldId

prodSomeAbtMaryId

static int prodSomeAbtMaryId

storeId

static java.lang.String storeId

storeNum

static int storeNum

PLATFORM_LINUX

static final int PLATFORM_LINUX
See Also:
Constant Field Values

PLATFORM_WINDOWS

static final int PLATFORM_WINDOWS
See Also:
Constant Field Values

platform

static int platform

kkHome

static java.lang.String kkHome

dbDirectory

static java.lang.String dbDirectory

dbPort

static com.konakart.appif.DbPortabilityIf dbPort

engineMode

static int engineMode

customersShared

static boolean customersShared

productsShared

static boolean productsShared

categoriesShared

static boolean categoriesShared

miscConf

static org.apache.commons.configuration.Configuration miscConf

DEFAULT_HTTP_PORT

private static final java.lang.String DEFAULT_HTTP_PORT
See Also:
Constant Field Values

httpPort

private static java.lang.String httpPort

DEFAULT_HTTPS_PORT

private static final java.lang.String DEFAULT_HTTPS_PORT
See Also:
Constant Field Values

httpsPort

private static java.lang.String httpsPort

DEFAULT_USERNAME

private static java.lang.String DEFAULT_USERNAME
Default credentials for accessing the KonaKart Admin App

Constructor Detail

SqlPopulator

public SqlPopulator()
Method Detail

main

public static void main(java.lang.String[] args)
Parameters:
args -

derivePlatform

public static void derivePlatform()
Derive the platform from the os.name


populateStore

public static int populateStore(java.lang.String storeIdP,
                                java.lang.String kkHomeP,
                                int engineModeP,
                                java.lang.String propsFileNameP,
                                boolean customersSharedP,
                                boolean productsSharedP,
                                boolean categoriesSharedP,
                                java.lang.String miscPropsFileNameP,
                                boolean minimalStoreP,
                                int adminRoleIdP,
                                int superUserIdP,
                                int superUserRoleIdP,
                                boolean debugP,
                                java.lang.String httpPortNumber,
                                java.lang.String httpsPortNumber)
Populate the store using the specified parameters. This interface is used when calling this utility from another java program.

Parameters:
storeIdP -
kkHomeP -
engineModeP -
propsFileNameP -
customersSharedP -
productsSharedP -
categoriesSharedP -
miscPropsFileNameP - the name of a file containing Miscellaneous Property values
minimalStoreP - if true we create the smallest store we can (no products etc)
adminRoleIdP - the role id to give the admin user in the new store
superUserIdP -
superUserRoleIdP -
debugP - debug flag
httpPortNumber - HTTP port number
httpsPortNumber - HTTPS port number
Returns:
0 for success, otherwise 1n integer greater than 0

populate

public static int populate()
Populate the store

Returns:
0 for success, otherwise 1n integer greater than 0

getAdminUserNameForStore

private static java.lang.String getAdminUserNameForStore(java.lang.String store)

setUpMiscConfiguration

private static void setUpMiscConfiguration()

getAnEng

private static KKAdminIf getAnEng(java.lang.String theStoreId)
                           throws KKAdminException
Throws:
KKAdminException

getStoreNum

private static int getStoreNum()

login

public static java.lang.String login(java.lang.String user,
                                     KKAdminIf eng)
                              throws org.apache.torque.TorqueException,
                                     KKAdminException
Login customer so that a login can be performed. The method returns a sessionId.

Parameters:
user -
eng -
Returns:
Returns the sessionId
Throws:
org.apache.torque.TorqueException
KKAdminException

insertAddressFormats

public static void insertAddressFormats(KKAdminIf eng,
                                        java.lang.String sessionId)
                                 throws java.lang.Exception
Insert address formats and save an id to be used elsewhere

Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertCountries

public static void insertCountries(KKAdminIf eng,
                                   java.lang.String sessionId)
                            throws java.lang.Exception
Populate the db with countries. It must be called after insertAddressFormats() since it requires an addressFormatId.

Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

getZoneIdForCodeAndName

private static int getZoneIdForCodeAndName(KKAdminIf eng,
                                           java.lang.String code,
                                           java.lang.String name)
                                    throws KKAdminException
Throws:
KKAdminException

getTaxClassIdForTitle

private static int getTaxClassIdForTitle(KKAdminIf eng,
                                         java.lang.String title)
                                  throws KKAdminException
Throws:
KKAdminException

getCountryIdForISO3

private static int getCountryIdForISO3(KKAdminIf eng,
                                       java.lang.String iso3)
                                throws KKAdminException
Throws:
KKAdminException

getUserIdForEmail

private static int getUserIdForEmail(KKAdminIf eng,
                                     java.lang.String sessionId,
                                     java.lang.String email)
                              throws KKAdminException
Throws:
KKAdminException

insertLanguages

public static void insertLanguages(KKAdminIf eng,
                                   java.lang.String sessionId)
                            throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertCategories

public static void insertCategories(KKAdminIf eng,
                                    java.lang.String sessionId)
                             throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertConfigurationGroups

public static void insertConfigurationGroups(KKAdminIf eng,
                                             java.lang.String sessionId)
                                      throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertConfigurations

public static void insertConfigurations(KKAdminIf eng,
                                        java.lang.String sessionId)
                                 throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertCustomerTags

public static void insertCustomerTags(KKAdminIf eng,
                                      java.lang.String sessionId)
                               throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertManufacturers

public static void insertManufacturers(KKAdminIf eng,
                                       java.lang.String sessionId)
                                throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertOrderStatus

public static void insertOrderStatus(KKAdminIf eng,
                                     java.lang.String sessionId)
                              throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertTaxData

public static void insertTaxData(KKAdminIf eng,
                                 java.lang.String sessionId)
                          throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

removeStoreIdForTable

public static void removeStoreIdForTable(java.lang.String tableName)
                                  throws java.lang.Exception
Set the store_id column to '' in the specified table

Parameters:
tableName -
Throws:
java.lang.Exception

insertProductsToStores

public static void insertProductsToStores(KKAdminIf eng,
                                          java.lang.String sessionId)
                                   throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertProductsToCategories

public static void insertProductsToCategories(KKAdminIf eng,
                                              java.lang.String sessionId)
                                       throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertProducts

public static void insertProducts(KKAdminIf eng,
                                  java.lang.String sessionId)
                           throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertCurrencies

public static void insertCurrencies(KKAdminIf eng,
                                    java.lang.String sessionId)
                             throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertOptions

public static void insertOptions(KKAdminIf eng,
                                 java.lang.String sessionId)
                          throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertOptionValues

public static void insertOptionValues(KKAdminIf eng,
                                      java.lang.String sessionId)
                               throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertCustomers

public static void insertCustomers(KKAdminIf eng,
                                   java.lang.String sessionId)
                            throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertSuperUser

public static int insertSuperUser(KKAdminIf eng,
                                  java.lang.String sessionId)
                           throws java.lang.Exception
Parameters:
eng -
sessionId -
Returns:
the customerId of the newly created Super User
Throws:
java.lang.Exception

insertReviews

public static void insertReviews(KKAdminIf eng,
                                 java.lang.String sessionId)
                          throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertUtility

public static void insertUtility(KKAdminIf eng,
                                 java.lang.String sessionId)
                          throws java.lang.Exception
Insert the Utility Table values

Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertApiCalls

public static void insertApiCalls(KKAdminIf eng,
                                  java.lang.String sessionId)
                           throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertRoles

public static void insertRoles(KKAdminIf eng,
                               java.lang.String sessionId)
                        throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

updateConfig

private static void updateConfig(KKAdminIf eng,
                                 java.lang.String sessionId,
                                 java.lang.String key,
                                 int group,
                                 java.lang.String value)
                          throws java.lang.Exception
Throws:
java.lang.Exception

insertStoreAdminRole

public static void insertStoreAdminRole(KKAdminIf eng,
                                        java.lang.String sessionId)
                                 throws java.lang.Exception
We assign the adminRoleId to the store admin user of our new store.

Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertRolesForSuperUser

public static void insertRolesForSuperUser(KKAdminIf eng,
                                           java.lang.String sessionId)
                                    throws java.lang.Exception
We assign the super user role to the super user in the new store

Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

addRoleForNewSuperUser

public static void addRoleForNewSuperUser(KKAdminIf eng,
                                          java.lang.String sessionId)
                                   throws java.lang.Exception
We assign the super user role to the new super user in the new store

Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

insertPanels

public static void insertPanels(KKAdminIf eng,
                                java.lang.String sessionId)
                         throws java.lang.Exception
Parameters:
eng -
sessionId -
Throws:
java.lang.Exception

isLanguagesShared

public static boolean isLanguagesShared()
Returns:
true if the Languages are shared

isMultiStoreSingleDB

public static boolean isMultiStoreSingleDB()
Returns:
true if the mode is multi-store single DB

isCustomersShared

public static boolean isCustomersShared()
Returns:
the customersShared

setCustomersShared

public static void setCustomersShared(boolean customersShared)
Parameters:
customersShared - the customersShared to set

isProductsShared

public static boolean isProductsShared()
Returns:
the productsShared

setProductsShared

public static void setProductsShared(boolean productsShared)
Parameters:
productsShared - the productsShared to set

isCategoriesShared

public static boolean isCategoriesShared()
Returns:
the categoriesShared

setCategoriesShared

public static void setCategoriesShared(boolean categoriesShared)
Parameters:
categoriesShared - the categoriesShared to set


Copyright © 2011 DS Data Systems UK Ltd.