#! /bin/bash

# Copyright (c) 2000, 2004 IBM Corp. - All Rights Reserved.
# IBM makes no representations or warranties about the suitability of
# this program, either express or implied, including but not limited to
# the implied warranties of merchantability, fitness for a particular
# purpose, or non-infringement. 
  

# 
# # Copyright (c) 2000, 2004 IBM Corp. - All Rights Reserved.
# # IBM makes no representations or warranties about the suitability of
# # this program, either express or implied, including but not limited to
# # the implied warranties of merchantability, fitness for a particular
# # purpose, or non-infringement. 
# 
#


. ${TOP}/src/db/schema/util/set_db.sh

${ECHO}
${ECHO} ====================================================
${ECHO} Deleting old info for trigo
${ECHO} ====================================================
${ECHO}

. ${DB_DIR}/util/cleanup_cmp.sh --code=trigo --confirm_db=no

${ECHO}
${ECHO} ============================================================
${ECHO} Creating company and populating related info in db for trigo
${ECHO} ============================================================
${ECHO}

#${CCD_SQLPLUS} ${CONNECTION} <<EOF
#${DB_SQLFILE_EXECUTE} $DB_SCRIPTS/create_ccd_comp.sql
#EOF

. ${DB_DIR}/util/run_db_cmd.sh --file=$DB_SCRIPTS/create_ccd_comp.sql


${ECHO}
${ECHO} ====================================================================
${ECHO} Create basic role for Trigo users
${ECHO} ====================================================================
${ECHO}


. ${TOP}/src/db/schema/trigo/set_create_ccd.sh --confirm_db=no

CMP_DIR=$DB_DIR/cmp

BASIC_SCRIPT_SRC_FILE=${CMP_DIR}/basic_company_setup.script
BASIC_SCRIPT_FILE=${CMP_DIR}/basic_company_setup.script.tmp

${ECHO} ====================================================
${ECHO} Creating sql script for trigo
${ECHO} ====================================================

${CAT} ${BASIC_SCRIPT_SRC_FILE} \
    | ${SED} "s/%CMP_CODE%/trigo/g" \
    | ${SED} "s/%CMP_NAME%/Trigo/g" \
    > ${BASIC_SCRIPT_FILE}

${ECHO}
${ECHO} ====================================================
${ECHO} Building basic objects, users, roles for trigo
${ECHO} ====================================================
${ECHO}
${JAVA_RT} com.ibm.ccd.common.interpreter.test.TestScript --companycode="$CMP_CODE" \
                                              --username="trigo_root" \
                                              --scriptpath="${BASIC_SCRIPT_FILE}"


${RM} ${BASIC_SCRIPT_FILE}

${ECHO}
${ECHO} ====================================================
${ECHO} CREATE_COMPANY_INFO_LOAD_SCRIPT_SH 
${ECHO} ====================================================
${ECHO}

${JAVA_RT_NOOUT} com.ibm.ccd.docstore.util.DocLoader trigo Admin ${SCRIPTS_DIR}/common/ldap_scripts.xml Cp1252

