diff --git a/.github/workflows/sync-to-azure-boards.yml b/.github/workflows/sync-to-azure-boards.yml index daa35fe..3902e74 100644 --- a/.github/workflows/sync-to-azure-boards.yml +++ b/.github/workflows/sync-to-azure-boards.yml @@ -15,7 +15,7 @@ jobs: github_token: "${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}" ado_organization: "intershop-com" ado_project: "Products" - ado_area_path: "Products\\Intershop Order Management\\Blueprint Projekt" + ado_area_path: "Products\\Intershop Order Management\\Blueprint Project" ado_iteration_path: "Products\\Domain Order Management" ado_wit: "Task" ado_new_state: "New" diff --git a/.gitignore b/.gitignore index 596c878..ed7742e 100644 --- a/.gitignore +++ b/.gitignore @@ -61,4 +61,5 @@ devenv-share/ filebeat-kubernetes.yaml .idea/ *.iml -devenv.user.properties \ No newline at end of file +devenv.user.properties +testframework-config.user.yaml \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6fad081..9f78903 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -18,8 +18,8 @@ extends: parameters: agentPool: ubuntu-20.4-DS4_v2-adopt-adoptium-jdk-ora artifactsFeed: order-iom-releases - dockerRepoIOMServiceConnection: order-iom-docker.intershop.de.dockerhub - dockerRepoIOM: docker.intershop.de/intershophub + dockerRepoIOMServiceConnection: order-iom-docker.tools.intershop.com + dockerRepoIOM: docker.tools.intershop.com/iom/intershophub acrServiceConnection: order-iomInternalACR-ISH-ENG-IOM acr: iominternalacr.azurecr.io projectEnvName: dev diff --git a/devenv-4-iom/README.md b/devenv-4-iom/README.md index e660e58..af906d4 100644 --- a/devenv-4-iom/README.md +++ b/devenv-4-iom/README.md @@ -16,6 +16,43 @@ If _devenv-4-iom_ is already installed and you are looking for a short overview ``` devenv-cli.sh -h ``` +# Release Information 2.2.0 + +## Compatibility + +At the time of release of _devenv-4-iom_, it is compatible with the latest version of IOM. As long as there is no new release of _devenv-4-iom_, it is ensured, that new releases of IOM are compatible with _devenv-4-iom_. If a new version of IOM requires an update of _devenev-4-iom_, the release notes of IOM will contain an according statement. + +At the time of writing, _devenv-4-iom 2.2.0_ is compatible with all IOM versions between 3.0 and 4.1 (inclusive). + +## New Features + +### Documentation, Comments and Default Values were adapted for new Intershop Docker Registry + +Intershop provides Docker images of their products now on _docker.tools.intershop.com_. All documentation, comments and default values were changed to use this new server. + +## Migration Notes + +### Default value of _DB_ACCOUNT_IMAGE_ was changed + +The Docker repository, that is used by the default value of DB_ACCOUNT_IMAGE was changed to _docker.tools.intershop.com_. Since this repository requires authorization to access its images, a new Pull-Secret has to be created (see chapter [Accessing in Private Docker Registry](docs/04_development_process.md#accessing-a-private-docker-registry)). + +# Release Information 2.1.0 + +## Compatibility + +At the time of release of _devenv-4-iom_, it is compatible with the latest version of IOM. As long as there is no new release of _devenv-4-iom_, it is ensured, that new releases of IOM are compatible with _devenv-4-iom_. If a new version of IOM requires an update of _devenev-4-iom_, the release notes of IOM will contain an according statement. + +At the time of writing, _devenv-4-iom 2.1.0_ is compatible with all IOM versions between 3.0 and 4.1 (inclusive). + +## New Features + +### Support for bash completion + +_devenv-4-iom_ now supports bash completion. In order to use this new feature, the according completion script has to be installed, see [documentation of installation](doc/00_installation.md). + +### Support for IOM Test-Framework + +When starting the IOM application server (`create iom`), a file _testframework-config.user.yaml_ is created within the project root directory, containing all necessary information to run local tests based on [IOM Test-Framework](https://github.com/intershop/iom-test-framework). Along with support for this file, one new configuration properties was added: _CREATE_TEST_CONFIG_, which controls the creation of the configuration file. # Release Information 2.0.5 diff --git a/devenv-4-iom/bin/devenv-cli-completion.sh b/devenv-4-iom/bin/devenv-cli-completion.sh new file mode 100644 index 0000000..a07f44f --- /dev/null +++ b/devenv-4-iom/bin/devenv-cli-completion.sh @@ -0,0 +1,256 @@ +# returns $command if $input is somewhere between $prefix and $command, otherwise false is returned. +_devenv_is_command() { + local input prefix command + # remove everything from $input, that cannot be accepted + input=$(echo "$1" | sed 's/[^a-zA-Z-]//g') + prefix="$2" + command="$3" + + if echo "$input" | grep -qi "^$prefix" && echo "$command" | grep -qi "^$input"; then + echo "$command" + else + false + fi +} + +_devenv_dirs() { + ls -d "$1"* 2> /dev/null | while read LINE; do + if file "$LINE" | grep -q 'directory$'; then + echo -n "$LINE/ " + fi + done +} + +_devenv_cli() { + local cur prev property_file cmd sub_cmd + + # Array variable storing the possible completions. + COMPREPLY=() + + cur=${COMP_WORDS[$COMP_CWORD]} + prev=${COMP_WORDS[$(($COMP_CWORD - 1))]} + + #--------------------------------------------------------------------------- + # investigate arguments, that are already present at the command line + #--------------------------------------------------------------------------- + + # according to devenv-cli.sh, the first arg is assumed to be a property file, if a local + # file with that name exists. + if [ "$COMP_CWORD" -gt 1 -a -f "${COMP_WORDS[1]}" ]; then + property_file="${COMP_WORDS[1]}" + fi + + # determine $cmd + if [ -z "$property_file" -a "$COMP_CWORD" -gt 1 ]; then + cmd="${COMP_WORDS[1]}" + elif [ ! -z "$property_file" -a "$COMP_CWORD" -gt 2 ]; then + cmd="${COMP_WORDS[2]}" + fi + + # expand $cmd (user might have entered an abbrevation) + if [ ! -z "$cmd" ]; then + cmd=$(_devenv_is_command $cmd i info || + _devenv_is_command $cmd c create || + _devenv_is_command $cmd de delete || + _devenv_is_command $cmd a apply || + _devenv_is_command $cmd du dump || + _devenv_is_command $cmd g get || + _devenv_is_command $cmd l log) + fi + + # determine $sub_cmd + if [ -z "$property_file" -a "$COMP_CWORD" -gt 2 ]; then + sub_cmd="${COMP_WORDS[2]}" + elif [ ! -z "$property_file" -a "$COMP_CWORD" -gt 3 ]; then + sub_cmd="${COMP_WORDS[3]}" + fi + + # expand $sub_cmd (user might have entered an abbrevation) + if [ ! -z "$sub_cmd" ]; then + case "$cmd" in + info) + sub_cmd=$(_devenv_is_command $sub_cmd i iom || + _devenv_is_command $sub_cmd p postgres || + _devenv_is_command $sub_cmd m mailserver || + _devenv_is_command $sub_cmd s storage || + _devenv_is_command $sub_cmd cl cluster || + _devenv_is_command $sub_cmd co config) + ;; + create) + sub_cmd=$(_devenv_is_command $sub_cmd s storage || + _devenv_is_command $sub_cmd n namespace || + _devenv_is_command $sub_cmd m mailserver || + _devenv_is_command $sub_cmd p postgres || + _devenv_is_command $sub_cmd i iom || + _devenv_is_command $sub_cmd c cluster) + ;; + delete) + sub_cmd=$(_devenv_is_command $sub_cmd s storage || + _devenv_is_command $sub_cmd n namespace || + _devenv_is_command $sub_cmd m mailserver || + _devenv_is_command $sub_cmd p postgres || + _devenv_is_command $sub_cmd i iom || + _devenv_is_command $sub_cmd c cluster) + ;; + apply) + sub_cmd=$(_devenv_is_command $sub_cmd de deployment || + _devenv_is_command $sub_cmd m mail-templates || + _devenv_is_command $sub_cmd x xsl-templates || + _devenv_is_command $sub_cmd sql-s sql-scripts || + _devenv_is_command $sub_cmd sql-c sql-config || + _devenv_is_command $sub_cmd j json-config || + _devenv_is_command $sub_cmd db dbmigrate) + ;; + dump) + sub_cmd=$(_devenv_is_command $sub_cmd c create || + _devenv_is_command $sub_cmd l load) + ;; + get) + sub_cmd=$(_devenv_is_command $sub_cmd c config || + _devenv_is_command $sub_cmd g geb-props || + _devenv_is_command $sub_cmd w ws-props || + _devenv_is_command $sub_cmd s soap-props || + _devenv_is_command $sub_cmd b bash-completion) + ;; + log) + sub_cmd=$(_devenv_is_command $sub_cmd d dbaccount || + _devenv_is_command $sub_cmd c config || + _devenv_is_command $sub_cmd i iom || + _devenv_is_command $sub_cmd ap app || + _devenv_is_command $sub_cmd ac access) + ;; + esac + fi + + #--------------------------------------------------------------------------- + # provide COMPREPLY for current input + #--------------------------------------------------------------------------- + + # First argument might be the name of a property file or the top-level command + if [ "$COMP_CWORD" -eq 1 ]; then + COMPREPLY=( $(compgen -W "info create delete apply dump get log -h --help" -G "$cur*.properties" -- $cur) ) + + + # If the first argument is the name of a property file, the second argument has to + # be the top-level command. + elif [ "$COMP_CWORD" -eq 2 -a ! -z "$property_file" ]; then + COMPREPLY=( $(compgen -W "info create delete apply dump get log -h --help" -- $cur) ) + + + # If no property file was passed, sub-cmd is expected on second position. + # OR + # If a property file was passed, sub-cmd is expeceted on third position. + elif [ \( "$COMP_CWORD" -eq 2 -a -z "$property_file" \) -o \ + \( "$COMP_CWORD" -eq 3 -a ! -z "$property_file" \) ]; then + case "$cmd" in + get) + COMPREPLY=( $(compgen -W 'config geb-probs ws-probs soap-probs bash-completion -h --help' -- $cur) ) + ;; + info) + COMPREPLY=( $(compgen -W 'iom postgres mailserver storage cluster config -h --help' -- $cur) ) + ;; + create) + COMPREPLY=( $(compgen -W 'storage namespace mailserver postgres iom cluster -h --help' -- $cur) ) + ;; + delete) + COMPREPLY=( $(compgen -W 'storage namespace mailserver postgres iom cluster -h --help' -- $cur) ) + ;; + apply) + COMPREPLY=( $(compgen -W 'deployment mail-templates xsl-templates sql-scripts sql-config json-config dbmigrate -h --help' -- $cur) ) + ;; + dump) + COMPREPLY=( $(compgen -W 'create load -h --help' -- $cur) ) + ;; + log) + COMPREPLY=( $(compgen -W 'dbaccount config iom app access -h --help' -- $cur) ) + ;; + -h|--help) + ;; + esac + + + # If no property file was passed, first argument for sub-command is expected on third position. + # OR + # If a property file was passed, first argument for sub-command is expected on 4th position. + elif [ \( "$COMP_CWORD" -eq 3 -a -z "$property_file" \) -o \ + \( "$COMP_CWORD" -eq 4 -a ! -z "$property_file" \) ]; then + case "$cmd" in + apply) + case "$sub_cmd" in + sql-scripts) + # "apply sql-scripts" requires sql-file or directory as argument + COMPREPLY=( $(compgen -W '-h --help' -- $cur) $(compgen -G "$cur*.sql" -- $cur) $(_devenv_dirs "$cur") ) + ;; + deployment) + COMPREPLY=( $(compgen -W '-h --help ' -- $cur) ) + ;; + *) + COMPREPLY=( $(compgen -W '-h --help' -- $cur) ) + esac + ;; + get) + case "$sub_cmd" in + config) + COMPREPLY=( $(compgen -W '-h --help --skip-config --skip-user-config' -- $cur) ) + ;; + *) + COMPREPLY=( $(compgen -W '-h --help' -- $cur) ) + ;; + esac + ;; + log) + case "$sub_cmd" in + dbaccount|config|iom|app) + COMPREPLY=( $(compgen -W '-h --help -f fatal error warn info debug trace' -- $cur) ) + ;; + access) + COMPREPLY=( $(compgen -W '-h --help -f error all' -- $cur) ) + ;; + *) + COMPREPLY=( $(compgen -W '-h --help' -- $cur) ) + esac + ;; + *) + COMPREPLY=( $(compgen -W '-h --help' -- $cur) ) + ;; + + esac + + + # If no property file was passed, second argument for sub-command is expected on 4th position. + # OR + # If a property file was passed, second argument for sub-command is expected on 5th position. + elif [ \( "$COMP_CWORD" -eq 4 -a -z "$property_file" \) -o \ + \( "$COMP_CWORD" -eq 5 -a ! -z "$property_file" \) ]; then + case "$cmd" in + log) + case "$sub_cmd" in + dbaccount|config|iom|app) + case "$prev" in + -f) + COMPREPLY=( $(compgen -W 'fatal error warn info debug trace' -- $cur) ) + ;; + *) + COMPREPLY=( $(compgen -W '-f' -- $cur) ) + esac + ;; + access) + case "$prev" in + -f) + COMPREPLY=( $(compgen -W 'error all' -- $cur) ) + ;; + *) + COMPREPLY=( $(compgen -W '-f' -- $cur) ) + ;; + esac + ;; + esac + ;; + esac + fi + + return 0 +} + + +complete -F _devenv_cli devenv-cli.sh diff --git a/devenv-4-iom/bin/devenv-cli.sh b/devenv-4-iom/bin/devenv-cli.sh index d24c70f..c004b47 100755 --- a/devenv-4-iom/bin/devenv-cli.sh +++ b/devenv-4-iom/bin/devenv-cli.sh @@ -1219,10 +1219,11 @@ CONFIG-FILE $(msg_config_file 4) RESOURCE - config|co* get configuration file + config|c* get configuration file ws-props|w* get ws properties geb-props|g* get geb properties soap-props|s* get soap properties + bash-completion|b* get bash completion script Run '$ME [CONFIG-FILE] get RESOURCE --help|-h' for more information on a command. EOF @@ -1340,6 +1341,33 @@ BACKGROUND EOF } +#------------------------------------------------------------------------------- +help-get-bash-completion() { + ME=$(basename "$0") + cat <: true|false +#------------------------------------------------------------------------------- +kube_pod_started() ( + APP_NAME=$1 + + PODS=( $(kubectl get pods --namespace $EnvId --context="$KUBERNETES_CONTEXT" -l app=$APP_NAME -o jsonpath='{.items[*].metadata.name}' 2> /dev/null) ) + + for POD in ${PODS[@]}; do + # array with Phase at position 0 and deletionTimestamp at position 1 + POD_STATUS=( $(kubectl get pod $POD --namespace $EnvId --context="$KUBERNETES_CONTEXT" -o jsonpath='{.status.phase} {.metadata.deletionTimestamp}' 2> /dev/null) ) + PHASE=${POD_STATUS[0]} + DELETION_TIMESTAMP=${POD_STATUS[1]} + if [ "$PHASE" = 'Running' -o "$PHASE" = 'Pending' ] && [ -z "$DELETION_TIMESTAMP" ]; then + STATUS='Started' + break + fi + done + [ "$STATUS" = 'Started' ] +) + #------------------------------------------------------------------------------- # $1: timestamp # -> seconds @@ -2192,7 +2246,7 @@ create-mailserver() { if [ -z "$CONFIG_FILES" ]; then log_msg ERROR "create-mailserver: no config-file given!" < /dev/null SUCCESS=false - else + elif ! kube_pod_started mailhog; then "$DEVENV_DIR/bin/template_engine.sh" \ --template="$DEVENV_DIR/templates/mailhog.yml.template" \ --config="$CONFIG_FILES" \ @@ -2236,7 +2290,7 @@ create-postgres() { log_msg INFO "create-postges: no need to link docker volume to dabase storage" < /dev/null fi if [ "$SUCCESS" = 'true' ]; then - if ! kube_resource_exists pods postgres || ! kube_resource_exists services postgres-service; then + if ! kube_pod_started postgres; then # start postgres pod/service "$DEVENV_DIR/bin/template_engine.sh" \ --template="$DEVENV_DIR/templates/postgres.yml.template" \ @@ -2249,7 +2303,7 @@ create-postgres() { log_msg INFO "create-postgres: successfully created postgres" < "$TMP_OUT" fi else - log_msg INFO "create-postgres: pod and service already exist" < /dev/null + log_msg INFO "create-postgres: nothing to do" < /dev/null fi fi else @@ -2282,16 +2336,34 @@ create-iom() { log_msg INFO "create-iom: successfully copied secret $IMAGE_PULL_SECRET from default namespace" < "$TMP_OUT" fi fi + # create IOM deployment if [ "$SUCCESS" = 'true' ]; then + if ! kube_pod_started iom; then + "$DEVENV_DIR/bin/template_engine.sh" \ + --template="$DEVENV_DIR/templates/$IomTemplate" \ + --config="$CONFIG_FILES" \ + --project-dir="$PROJECT_DIR" | kubectl apply --namespace $EnvId --context="$KUBERNETES_CONTEXT" -f - 2> "$TMP_ERR" > "$TMP_OUT" + if [ $? -ne 0 ]; then + log_msg ERROR "create-iom: error creating iom" < "$TMP_ERR" + SUCCESS=false + else + log_msg INFO "create-iom: successfully created iom" < "$TMP_OUT" + fi + else + log_msg INFO "create-iom: nothing to do" < /dev/null + fi + fi + # create file testframework-config.user.yaml + if [ "$SUCCESS" = 'true' -a "$CREATE_TEST_CONFIG" = 'true' ]; then "$DEVENV_DIR/bin/template_engine.sh" \ - --template="$DEVENV_DIR/templates/$IomTemplate" \ + --template="$DEVENV_DIR/templates/testframework-config.user.yaml.template" \ --config="$CONFIG_FILES" \ - --project-dir="$PROJECT_DIR" | kubectl apply --namespace $EnvId --context="$KUBERNETES_CONTEXT" -f - 2> "$TMP_ERR" > "$TMP_OUT" + --project-dir="$PROJECT_DIR" > "$PROJECT_DIR/testframework-config.user.yaml" 2> "$TMP_ERR" if [ $? -ne 0 ]; then - log_msg ERROR "create-iom: error creating iom" < "$TMP_ERR" + log_msg ERROR "create-iom: error creating file $PROJECT_DIR/testframework-config.user.yaml" < "$TMP_ERROR" SUCCESS=false else - log_msg INFO "create-iom: successfully created iom" < "$TMP_OUT" + log_msg INFO "create-iom: successfully created file $PROJECT_DIR/testframework-config.user.yaml" < /dev/null fi fi fi @@ -2463,7 +2535,7 @@ delete-iom() { else log_msg INFO "delete-iom: nothing to do" < /dev/null fi - rm -f "$TMP_ERR" "$TMP_OUT" + rm -f "$TMP_ERR" "$TMP_OUT" "$PROJECT_DIR/testframework-config.user.yaml" [ "$SUCCESS" = 'true' ] } @@ -3190,6 +3262,13 @@ get-soap-props() { [ "$SUCCESS" = 'true' ] } +#------------------------------------------------------------------------------- +# get bash completion script +#------------------------------------------------------------------------------- +get-bash-completion() { + cat "$DEVENV_DIR/bin/devenv-cli-completion.sh" +} + ################################################################################ # functions, implementing the log handler ################################################################################ @@ -3796,10 +3875,11 @@ elif [ "$LEVEL0" = "dump" ]; then exit 1 fi elif [ "$LEVEL0" = 'get' ]; then - LEVEL1=$(isCommand "$1" co config || - isCommand "$1" g geb-props || - isCommand "$1" w ws-props || - isCommand "$1" s soap-props) || + LEVEL1=$(isCommand "$1" c config || + isCommand "$1" g geb-props || + isCommand "$1" w ws-props || + isCommand "$1" s soap-props || + isCommand "$1" b bash-completion) || if [ "$1" = '--help' -o "$1" = '-h' ]; then help-get exit 0 diff --git a/devenv-4-iom/bin/template-variables b/devenv-4-iom/bin/template-variables index 454c23d..a226e8c 100644 --- a/devenv-4-iom/bin/template-variables +++ b/devenv-4-iom/bin/template-variables @@ -1,4 +1,4 @@ -DEVENV4IOM_VERSION=2.0.5 +DEVENV4IOM_VERSION=2.2.0 ################################################################################ # Defaults @@ -355,7 +355,7 @@ TIMEZONE="${TIMEZONE:-Europe/Berlin}" # images DOCKER_DB_IMAGE="${DOCKER_DB_IMAGE:-postgres:12}" MAILHOG_IMAGE="${MAILHOG_IMAGE:-mailhog/mailhog}" -IOM_DBACCOUNT_IMAGE="${IOM_DBACCOUNT_IMAGE:-docker.intershop.de/intershophub/iom-dbaccount:1.3.0.0}" +IOM_DBACCOUNT_IMAGE="${IOM_DBACCOUNT_IMAGE:-docker.tools.intershop.com/iom/intershophub/iom-dbaccount:1.5.0}" IOM_CONFIG_IMAGE="${IOM_CONFIG_IMAGE}" IOM_APP_IMAGE="${IOM_APP_IMAGE}" IOM_IMAGE="${IOM_IMAGE}" @@ -399,3 +399,5 @@ OMS_LOGLEVEL_CUSTOMIZATION=${OMS_LOGLEVEL_CUSTOMIZATION:-WARN} OMS_LOGLEVEL_SCRIPTS=${OMS_LOGLEVEL_SCRIPTS:-INFO} OMS_LOGLEVEL_DEVENV=${OMS_LOGLEVEL_DEVENV:-INFO} OMS_LOG_REST_IDS=${OMS_LOG_REST_IDS} + +CREATE_TEST_CONFIG="${CREATE_TEST_CONFIG:-true}" \ No newline at end of file diff --git a/devenv-4-iom/doc/00_installation.md b/devenv-4-iom/doc/00_installation.md index 310a259..626ab1f 100644 --- a/devenv-4-iom/doc/00_installation.md +++ b/devenv-4-iom/doc/00_installation.md @@ -70,5 +70,15 @@ To become able to use _devenv-cli.sh_ without the need to call it with its absol export PATH="$PATH:/DirnameToBeAdapted/devenv-4-iom/bin" ``` +To enable bash-completion, add the following line to `~/.bashrc`: +```sh +source <(devenv-cli.sh get bash-completion) +``` + +This method is not working on Mac OS X, alternatively the following command can be used: +```sh +eval "$(devenv-cli.sh get bash-completion)" +``` + --- [^ Index](../README.md) | [First Steps >](01_first_steps.md) diff --git a/devenv-4-iom/doc/01_first_steps.md b/devenv-4-iom/doc/01_first_steps.md index 3f38791..9e3da96 100644 --- a/devenv-4-iom/doc/01_first_steps.md +++ b/devenv-4-iom/doc/01_first_steps.md @@ -27,7 +27,7 @@ There are some values in _devenv.project.properties_ that have to be set afterwa * `ID`: Every developer instance of IOM, hence every configuration file, needs to have a unique value for ID. Once you have set the `ID` and started the according IOM, you must not change it anymore. Otherwise you will loose the ability to access/control the resources associated with the IOM installation. * `IMAGE_PULL_POLICY`: The value of this property has to be set to `IfNotPresent`. This makes it easier to get through the _first steps_ example. The [_operations_ part of the documentation](03_operations.md) shows a more sustainable approach to [access a private Docker registry](03_operations.md#private_docker_registry). -* `IOM_IMAGE`: You need to define the IOM image, that has to be used for the _first steps_ example. If you use IOM version 4.0.0, then the according image name is `docker.intershop.de/intershophub/iom:4.0.0`. The `IOM_IMAGE` property is one of the most important settings, since it defines what will be executed by _devenv-4-iom_. By defining the image, you can control that a specific project, a standard IOM product without any customizations or an image of the IOM project, you have created locally, will run in your development environment. +* `IOM_IMAGE`: You need to define the IOM image, that has to be used for the _first steps_ example. If you use IOM version 4.1.0, then the according image name is `docker.tools.intershop.com/iom/intershophub/iom:4.1.0`. The `IOM_IMAGE` property is one of the most important settings, since it defines what will be executed by _devenv-4-iom_. By defining the image, you can control that a specific project, a standard IOM product without any customizations or an image of the IOM project, you have created locally, will run in your development environment. Now set the new values for `ID`, `IMAGE_PULL_POLICY` and `IOM_IMAGE`. Please make sure that you do NOT add any spaces around the '='! @@ -41,14 +41,14 @@ The Docker registry, we selected for our example, requires authentication. Hence Open the newly created config-file _devenv.project.properties_ and use the values of the `*_IMAGE` properties to pull the Docker images manually, just as shown in the box below: # login into Docker registry - # you need to have valid credentials for docker.intershop.de - docker login docker.intershop.de + # you need to have valid credentials for docker.tools.intershop.com + docker login docker.tools.intershop.com # pull images from registry docker pull postgres:12 docker pull mailhog/mailhog - docker pull docker.intershop.de/intershophub/iom-dbaccount:1.4.0 - docker pull docker.intershop.de/intershophub/iom:4.0.0 + docker pull docker.tools.intershop.com/iom/intershophub/iom-dbaccount:1.5.0 + docker pull docker.tools.intershop.com/iom/intershophub/iom:4.1.0 Before using _devenv-cli.sh_ to manage your IOM developer instance, you need to know how the configuration file will be passed to the script. There are some different ways, which are explained in detail in [Configuration | General Concept](02_configuration.md#concept_config). For our _first steps_ example you will use the mechanism, that `devenv.project.properties` will be automatically used, if it is located at the current directory. Hence, you only have to take care, to run `devenv-cli.sh` always from the directory, which contains the properties file. @@ -76,10 +76,10 @@ Due to the quite complex configuration of _devenv-4-iom_, see [Configuration | G IMAGE_PULL_SECRET= DOCKER_DB_IMAGE=postgres:12 MAILHOG_IMAGE=mailhog/mailhog - IOM_DBACCOUNT_IMAGE=docker.intershop.de/intershophub/iom-dbaccount:1.4.0 + IOM_DBACCOUNT_IMAGE=docker.tools.intershop.com/iom/intershophub/iom-dbaccount:1.5.0 IOM_CONFIG_IMAGE= IOM_APP_IMAGE= - IOM_IMAGE=docker.intershop.de/intershophub/iom:4.0.0 + IOM_IMAGE=docker.tools.intershop.com/iom/intershophub/iom:4.1.0 ... -------------------------------------------------------------------------------- @@ -177,7 +177,7 @@ IOM is now running and we are able to use it in the browser. It is time to learn "environment": "first steps", "logHost": "iom-567c64d69c-59jzd", "logVersion": "1.0", - "appVersion": "4.0.0", + "appVersion": "4.1.0", "appName": "iom", "logType": "access", "configName": "", @@ -195,7 +195,7 @@ IOM is now running and we are able to use it in the browser. It is time to learn "requestHeaderX-Real-IP": null, "requestHeaderX-Forwarded-Host": null, "requestHeaderX-Forwarded-Proto": null, - "requestLine": "GET /omt/static/css/application-styles.css?version=4.0.0 HTTP/1.1", + "requestLine": "GET /omt/static/css/application-styles.css?version=4.1.0 HTTP/1.1", "requestProtocol": "HTTP/1.1", "requestScheme": "http", "responseCode": 304, @@ -210,7 +210,7 @@ IOM is now running and we are able to use it in the browser. It is time to learn "environment": "first steps", "logHost": "iom-567c64d69c-59jzd", "logVersion": "1.0", - "appVersion": "4.0.0", + "appVersion": "4.1.0", "appName": "iom", "logType": "access", "configName": "", @@ -252,9 +252,9 @@ The following box shows an example where the file is named _test.sql_. If you ha 2021-12-20T10:49:57Z INFO apply-sql-scripts: job successfully started job.batch/apply-sql-job created - {"tenant":"Intershop","environment":"first steps","logHost":"apply-sql-job-sp8tr","logVersion":"1.0","appName":"iom","appVersion":"4.0.0","logType":"script","timestamp":"2021-12-20T10:49:57+00:00","level":"INFO","processName":"apply_sql.sh","message":"Properties","configName":null,"additionalInfo":"--src=/tmp/sql-dir-volume/test.sql\nOMS_DB_HOST=postgres-service\nOMS_DB_PORT=5432\nOMS_DB_NAME=oms_db\nOMS_DB_USER=oms_user\nOMS_DB_USER_CONNECTION_SUFFIX=\nOMS_DB_CONNECT_TIMEOUT=10\nOMS_LOGLEVEL_SCRIPTS=INFO\nTENANT=Intershop\nENVIRONMENT=first steps"} - {"tenant":"Intershop","environment":"first steps","logHost":"apply-sql-job-sp8tr","logVersion":"1.0","appName":"iom","appVersion":"4.0.0","logType":"script","timestamp":"2021-12-20T10:49:58+00:00","level":"INFO","processName":"apply_sql.sh","message":"processing file '/tmp/sql-dir-volume/test.sql'","configName":null} - {"tenant":"Intershop","environment":"first steps","logHost":"apply-sql-job-sp8tr","logVersion":"1.0","appName":"iom","appVersion":"4.0.0","logType":"script","timestamp":"2021-12-20T10:49:58+00:00","level":"INFO","processName":"apply_sql.sh","message":"success","configName":null} + {"tenant":"Intershop","environment":"first steps","logHost":"apply-sql-job-sp8tr","logVersion":"1.0","appName":"iom","appVersion":"4.1.0","logType":"script","timestamp":"2021-12-20T10:49:57+00:00","level":"INFO","processName":"apply_sql.sh","message":"Properties","configName":null,"additionalInfo":"--src=/tmp/sql-dir-volume/test.sql\nOMS_DB_HOST=postgres-service\nOMS_DB_PORT=5432\nOMS_DB_NAME=oms_db\nOMS_DB_USER=oms_user\nOMS_DB_USER_CONNECTION_SUFFIX=\nOMS_DB_CONNECT_TIMEOUT=10\nOMS_LOGLEVEL_SCRIPTS=INFO\nTENANT=Intershop\nENVIRONMENT=first steps"} + {"tenant":"Intershop","environment":"first steps","logHost":"apply-sql-job-sp8tr","logVersion":"1.0","appName":"iom","appVersion":"4.1.0","logType":"script","timestamp":"2021-12-20T10:49:58+00:00","level":"INFO","processName":"apply_sql.sh","message":"processing file '/tmp/sql-dir-volume/test.sql'","configName":null} + {"tenant":"Intershop","environment":"first steps","logHost":"apply-sql-job-sp8tr","logVersion":"1.0","appName":"iom","appVersion":"4.1.0","logType":"script","timestamp":"2021-12-20T10:49:58+00:00","level":"INFO","processName":"apply_sql.sh","message":"success","configName":null} 2021-12-20T10:50:02Z INFO apply-sql-scripts: successfully deleted job job.batch "apply-sql-job" deleted diff --git a/devenv-4-iom/doc/03_operations.md b/devenv-4-iom/doc/03_operations.md index d91692a..7719d4e 100644 --- a/devenv-4-iom/doc/03_operations.md +++ b/devenv-4-iom/doc/03_operations.md @@ -7,15 +7,15 @@ _devenv-4-iom_ does not manage the _Kubernetes_ secret in any way. The user is The document [Pull an Image from a Private Registry](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) from the _Kubernetes_ documentation explains how to create _Kubernetes_ secret objects in general, suitable to authenticate at a private _Docker_ registry. [Pull images from an Azure container registry to a _Kubernetes_ cluster](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auth-kubernetes) from the Microsoft Azure documentation explains how to apply this concept to private Azure Container Registries. -The following example shows how to create a _Kubernetes_ secret to be used to access the private _Docker_ Registry _docker.intershop.de_ within the default namespace. The name of the newly created secret is `intershop-pull-secret`, which has to be set as value of the variable `IMAGE_PULL_SECRET`. +The following example shows how to create a _Kubernetes_ secret to be used to access the private _Docker_ Registry _docker.tools.intershop.com_ within the default namespace. The name of the newly created secret is `intershop-pull-secret`, which has to be set as value of the variable `IMAGE_PULL_SECRET`. kubectl create secret docker-registry intershop-pull-secret \ --context="docker-desktop" \ - --docker-server=docker.intershop.de \ + --docker-server=docker.tools.intershop.com \ --docker-username='' \ --docker-password='' -If the secret is created and the variable `IMAGE_PULL_SECRET` is set in a user-specific configuration file (see [General Concept of Configuration](02_configuration.md#concept_config)), _devenv-4-iom_ can now authenticate at the _Docker_ Registry _docker.intershop.de_. +If the secret is created and the variable `IMAGE_PULL_SECRET` is set in a user-specific configuration file (see [General Concept of Configuration](02_configuration.md#concept_config)), _devenv-4-iom_ can now authenticate at the _Docker_ Registry _docker.tools.intershop.com_. When accessing a private Azure Container Registry (ACR), the same mechanism can be used. In this case the value of _service principal ID_ has to be set at `docker-username` and the value of _service principal password_ for `docker-password`. diff --git a/devenv-4-iom/doc/04_development_process.md b/devenv-4-iom/doc/04_development_process.md index 2e4bb60..1c8b8c1 100644 --- a/devenv-4-iom/doc/04_development_process.md +++ b/devenv-4-iom/doc/04_development_process.md @@ -145,28 +145,28 @@ Before creating a new project image, the properties and _Wildfly-CLI_ scripts ha # determine command, how to access jboss-cli.sh in running IOM pod devenv-cli.sh info iom ... - jboss-cli: kubectl exec --namespace customerprojectiom400 --context="docker-desktop" iom-7b99d8c9df-trctc -c iom -it -- /opt/jboss/wildfly/bin/jboss-cli.sh -c + jboss-cli: kubectl exec --namespace customerprojectiom410 --context="docker-desktop" iom-7b99d8c9df-trctc -c iom -it -- /opt/jboss/wildfly/bin/jboss-cli.sh -c ... # execute jboss-cli.sh in running IOM pod - kubectl exec --namespace customerprojectiom400 --context="docker-desktop" iom-7b99d8c9df-trctc -c iom -it -- /opt/jboss/wildfly/bin/jboss-cli.sh -c + kubectl exec --namespace customerprojectiom410 --context="docker-desktop" iom-7b99d8c9df-trctc -c iom -it -- /opt/jboss/wildfly/bin/jboss-cli.sh -c # test your CLI commands [standalone@localhost:9990 /] ls -l /deployment - bakery.base-app-4.0.0.ear - bakery.communication-app-4.0.0.ear - bakery.control-app-4.0.0.war - bakery.impex-app-4.0.0.war - bakery.omt-app-4.0.0.war - gdpr-app-4.0.0.war - oms.monitoring-app-4.0.0.war - oms.rest.communication-app-4.0.0.war - order-state-app-4.0.0.war + bakery.base-app-4.1.0.ear + bakery.communication-app-4.1.0.ear + bakery.control-app-4.1.0.war + bakery.impex-app-4.1.0.war + bakery.omt-app-4.1.0.war + gdpr-app-4.1.0.war + oms.monitoring-app-4.1.0.war + oms.rest.communication-app-4.1.0.war + order-state-app-4.1.0.war postgresql-jdbc4 - process-app-4.0.0.ear - rma-app-4.0.0.war - schedule-app-4.0.0.war - transmission-app-4.0.0.war + process-app-4.1.0.ear + rma-app-4.1.0.war + schedule-app-4.1.0.war + transmission-app-4.1.0.war ## Load Custom Dump @@ -221,6 +221,12 @@ PDF documents are stored within the shared file system of IOM. To get easy acces After that, you will have direct access to IOMs shared file system through the directory you have set for `CUSTOM_SHARE_DIR`. +## Testing in Context of IOM Project Development + +Projects, that are based on [IOM Project Archetype](https://github.com/intershop/iom-project-archetype), are providing a very good intergration of [IOM Test-Framework](https://github.com/intershop/iom-test-framework). This test-framework provides automatic testing of REST APIs. + +In order to pass all required information for [IOM Test-Framework](https://github.com/intershop/iom-test-framework), _devenv-4-iom_ creates a file _testframework-config.user.yaml_ whenever the IOM application server is started (`create iom`). This configuration file provides information how to connect the IOM application server and the according PostgreSQL database. + ## Testing in Context of IOM Product Development The processes described in this section are specific for IOM product development. Nevertheless, the concept can be adapted in context of projects as well. The tasks of _devenv-4-iom_ in context of testing are very simple: diff --git a/devenv-4-iom/doc/05_log_messages.md b/devenv-4-iom/doc/05_log_messages.md index da1f608..db21b80 100644 --- a/devenv-4-iom/doc/05_log_messages.md +++ b/devenv-4-iom/doc/05_log_messages.md @@ -9,8 +9,8 @@ The most important features used in context of _devenv-4-iom_ are formatting and # Print raw JSON messages cmd_producing_json ... - {"tenant":"Intershop","environment":"first steps","logHost":"iom-5948d556fd-h8wq8","logVersion":"1.0","appName":"iom","appVersion":"4.0.0","logType":"script","timestamp":"2021-12-21T11:48:19+00:00","level":"INFO","processName":"dbmigrate-kubernetes.sh","message":"processing directory '/opt/oms/stored_procedures'","configName":null} - {"tenant":"Intershop","environment":"first steps","logHost":"iom-5948d556fd-h8wq8","logVersion":"1.0","appName":"iom","appVersion":"4.0.0","logType":"script","timestamp":"2021-12-21T11:48:19+00:00","level":"INFO","processName":"dbmigrate-kubernetes.sh","message":"processing file '/opt/oms/stored_procedures/./admin/add_communication_partner.sql'","configName":null} + {"tenant":"Intershop","environment":"first steps","logHost":"iom-5948d556fd-h8wq8","logVersion":"1.0","appName":"iom","appVersion":"4.1.0","logType":"script","timestamp":"2021-12-21T11:48:19+00:00","level":"INFO","processName":"dbmigrate-kubernetes.sh","message":"processing directory '/opt/oms/stored_procedures'","configName":null} + {"tenant":"Intershop","environment":"first steps","logHost":"iom-5948d556fd-h8wq8","logVersion":"1.0","appName":"iom","appVersion":"4.1.0","logType":"script","timestamp":"2021-12-21T11:48:19+00:00","level":"INFO","processName":"dbmigrate-kubernetes.sh","message":"processing file '/opt/oms/stored_procedures/./admin/add_communication_partner.sql'","configName":null} ... # Print formatted JSON messages @@ -21,7 +21,7 @@ The most important features used in context of _devenv-4-iom_ are formatting and "logHost": "iom-5948d556fd-h8wq8", "logVersion": "1.0", "appName": "iom", - "appVersion": "4.0.0", + "appVersion": "4.1.0", "logType": "script", "timestamp": "2021-12-21T11:48:19+00:00", "level": "INFO", @@ -35,7 +35,7 @@ The most important features used in context of _devenv-4-iom_ are formatting and "logHost": "iom-5948d556fd-h8wq8", "logVersion": "1.0", "appName": "iom", - "appVersion": "4.0.0", + "appVersion": "4.1.0", "logType": "script", "timestamp": "2021-12-21T11:48:19+00:00", "level": "INFO", @@ -62,18 +62,18 @@ The most important features used in context of _devenv-4-iom_ are formatting and "hostName": "iom-5948d556fd-h8wq8", "processName": "jboss-modules.jar", "processId": 12621, - "stackTrace": ": com.intershop.oms.rolemgmt.capi.OMSLogicalException: Object not found for given ID '100' while 'get user for management'.\n\tat deployment.bakery.base-app-4.0.0.ear.oms.rolemgmt-internal-4.0.0.jar//com.intershop.oms.rolemgmt.internal.security.user.UserSecurityBean.checkForNull(UserSecurityBean.java:87)\n\t...", + "stackTrace": ": com.intershop.oms.rolemgmt.capi.OMSLogicalException: Object not found for given ID '100' while 'get user for management'.\n\tat deployment.bakery.base-app-4.1.0.ear.oms.rolemgmt-internal-4.1.0.jar//com.intershop.oms.rolemgmt.internal.security.user.UserSecurityBean.checkForNull(UserSecurityBean.java:87)\n\t...", "sourceClassName": "com.intershop.oms.rolemgmt.internal.connector.BackendAdminConnector", "sourceFileName": "BackendAdminConnector.java", "sourceMethodName": "handleException", "sourceLineNumber": 140, - "sourceModuleName": "deployment.bakery.base-app-4.0.0.ear.oms.rolemgmt-internal-4.0.0.jar", + "sourceModuleName": "deployment.bakery.base-app-4.1.0.ear.oms.rolemgmt-internal-4.1.0.jar", "sourceModuleVersion": null, "tenant": "Intershop", "environment": "first steps", "logHost": "iom-5948d556fd-h8wq8", "logVersion": "1.0", - "appVersion": "4.0.0", + "appVersion": "4.1.0", "appName": "iom", "logType": "message", "configName": null @@ -97,18 +97,18 @@ The most important features used in context of _devenv-4-iom_ are formatting and "hostName": "iom-5948d556fd-h8wq8", "processName": "jboss-modules.jar", "processId": 12621, - "stackTrace": ": com.intershop.oms.rolemgmt.capi.OMSLogicalException: Object not found for given ID '100' while 'get user for management'.\n\tat deployment.bakery.base-app-4.0.0.ear.oms.rolemgmt-internal-4.0.0.jar//com.intershop.oms.rolemgmt.internal.security.user.UserSecurityBean.checkForNull(UserSecurityBean.java:87)\n\t...", + "stackTrace": ": com.intershop.oms.rolemgmt.capi.OMSLogicalException: Object not found for given ID '100' while 'get user for management'.\n\tat deployment.bakery.base-app-4.1.0.ear.oms.rolemgmt-internal-4.1.0.jar//com.intershop.oms.rolemgmt.internal.security.user.UserSecurityBean.checkForNull(UserSecurityBean.java:87)\n\t...", "sourceClassName": "com.intershop.oms.rolemgmt.internal.connector.BackendAdminConnector", "sourceFileName": "BackendAdminConnector.java", "sourceMethodName": "handleException", "sourceLineNumber": 140, - "sourceModuleName": "deployment.bakery.base-app-4.0.0.ear.oms.rolemgmt-internal-4.0.0.jar", + "sourceModuleName": "deployment.bakery.base-app-4.1.0.ear.oms.rolemgmt-internal-4.1.0.jar", "sourceModuleVersion": null, "tenant": "Intershop", "environment": "first steps", "logHost": "iom-5948d556fd-h8wq8", "logVersion": "1.0", - "appVersion": "4.0.0", + "appVersion": "4.1.0", "appName": "iom", "logType": "message", "configName": null diff --git a/devenv-4-iom/doc/06_troubleshooting.md b/devenv-4-iom/doc/06_troubleshooting.md index 12dc193..ffc952f 100644 --- a/devenv-4-iom/doc/06_troubleshooting.md +++ b/devenv-4-iom/doc/06_troubleshooting.md @@ -211,16 +211,16 @@ According to section [Delete a Configuration](02_configuration.md#delete_config ### Search and Delete Orphaned _Kubernetes_ Namespaces -All _Kubernetes_ resources, belonging to a configuration, are assigned to one _Kubernetes_ namespace. The name of this namespace is derived from the `ID` defined in the configuration file. To create a valid name for the namespace, all non-alphanumerical characters are stripped from the `ID` and the remaining characters are transformed to lowercase. E.g., if you had used _CustomerProject IOM 4.0.0_ as `ID`, the derived namespace is _customerprojectiom400_. +All _Kubernetes_ resources, belonging to a configuration, are assigned to one _Kubernetes_ namespace. The name of this namespace is derived from the `ID` defined in the configuration file. To create a valid name for the namespace, all non-alphanumerical characters are stripped from the `ID` and the remaining characters are transformed to lowercase. E.g., if you had used _CustomerProject IOM 4.1.0_ as `ID`, the derived namespace is _customerprojectiom410_. _Kubernetes_ uses namespaces for its own purposes. To avoid any conflict with these namespaces, _devenv-4-iom_ will not allow you to use an `ID` that starts with: _default_, _docker_ or _kube_. Hence, the orphaned _Kubernetes_ namespace will never start with any of these three phrases. -The following box shows how to list all existing namespaces. According to the naming rules of namespaces created by _devenv-4-iom_, only two entries in the list of results are of interest: _customerprojectiom400_ and _oldprojectiom3000_. If you know the `ID`s of your currently existing configurations, you can find out the name of the orphaned namespace. In our example, _oldprojectiom3000_ is the one we have searched for. +The following box shows how to list all existing namespaces. According to the naming rules of namespaces created by _devenv-4-iom_, only two entries in the list of results are of interest: _customerprojectiom410_ and _oldprojectiom3000_. If you know the `ID`s of your currently existing configurations, you can find out the name of the orphaned namespace. In our example, _oldprojectiom3000_ is the one we have searched for. # list all existing Kubernetes namespaces kubectl get namespace --context="docker-desktop" NAME STATUS AGE - customerprojectiom400 Active 40m + customerprojectiom410 Active 40m default Active 28d docker Active 28d kube-node-lease Active 28d @@ -241,7 +241,7 @@ Hence, if the orphaned _Kubernetes_ namespaces is _oldprojectiom3000_, the accor # list all existing Docker volumes docker volume ls -q 008e5dc60890b954a68de526da1ba73113143b8dcb9edbf382db585cb7cf2736 - customerprojectiom400-pgdata + customerprojectiom410-pgdata oldprojectiom3000-pgdata # delete orphaned Docker volume @@ -263,11 +263,11 @@ Hence, if the orphaned _Kubernetes_ namespaces is _oldprojectiom3000_, the accor When trying a `docker login` from a Linux-like terminal on Windows such as _Git bash_ or _Docker quickstart terminal_, you will get the following error. - docker login docker.intershop.de + docker login docker.tools.intershop.com > Error: Cannot perform an interactive login from a non TTY device # The trick here is to use: - winpty docker login docker.intershop.de + winpty docker login docker.tools.intershop.com --- [< Log Messages](05_log_messages.md) | [^ Index](../README.md) diff --git a/devenv-4-iom/templates/config.properties.template b/devenv-4-iom/templates/config.properties.template index 46a3c12..6cdb15c 100644 --- a/devenv-4-iom/templates/config.properties.template +++ b/devenv-4-iom/templates/config.properties.template @@ -56,22 +56,22 @@ MAILHOG_IMAGE=${MAILHOG_IMAGE} # iom dbaccount image (name:tag) # examples: -# local image: iom-dbaccount:1.3.0.0 -# release from ISH Docker registry: docker.intershop.de/intershophub/iom-dbaccount:1.3.0.0 +# local image: iom-dbaccount:1.5.0 +# release from ISH Docker registry: docker.tools.intershop.com/iom/intershophub/iom-dbaccount:1.5.0 IOM_DBACCOUNT_IMAGE=${IOM_DBACCOUNT_IMAGE} # iom config image (name:tag) # examples: # local image: iom-config:3.7.0.0 # locally built project image: prj-iom-config:3.7.0.0-1.2.0.0-SNAPSHOT -# IOM release from ISH registry: docker.intershop.de/intershophub/iom-config:3.7.0.0 +# IOM release from ISH registry: docker.tools.intershop.com/iom/intershophub/iom-config:3.7.0.0 IOM_CONFIG_IMAGE=${IOM_CONFIG_IMAGE} # iom app image (name:tag) # examples: # local image: iom-app:3.7.0.0 # locally built project image: prj-iom-app:3.7.0.0-1.2.0.0-SNAPSHOT -# IOM release from ISH registry: docker.intershop.de/intershophub/iom-app:3.7.0.0 +# IOM release from ISH registry: docker.tools.intershop.com/iom/intershophub/iom-app:3.7.0.0 IOM_APP_IMAGE=${IOM_APP_IMAGE} # iom image (name:tag) @@ -81,9 +81,9 @@ IOM_APP_IMAGE=${IOM_APP_IMAGE} # If IOM_IMAGE is set, the properties IOM_CONFIG_IMAGE and IOM_APP_IMAGE will # be ignored. # examples: -# local image: iom:4.0.0.0 -# locally built project image: prj-iom:4.0.0.0-1.2.0.0-SNAPSHOT -# IOM release from ISH registry: docker.intershop.de/intershophub/iom:4.0.0.0 +# local image: iom:4.1.0 +# locally built project image: prj-iom:1.2.0-SNAPSHOT +# IOM release from ISH registry: docker.tools.intershop.com/iom/intershophub/iom:4.1.0 IOM_IMAGE=${IOM_IMAGE} ################################################################################ @@ -254,6 +254,15 @@ CUSTOM_SQLCONF_DIR="${CUSTOM_SQLCONF_DIR}" # See: devenv-cli.sh apply json-config --help CUSTOM_JSONCONF_DIR="${CUSTOM_JSONCONF_DIR}" +################################################################################ +# Test related settings +################################################################################ + +# When starting the IOM application server and this property is set to true, +# a file testframework-config.user.yaml will be created in the directory holding +# the current devenv configuration. +CREATE_TEST_CONFIG="${CREATE_TEST_CONFIG}" + ################################################################################ # Access to developer VM ################################################################################ diff --git a/devenv-4-iom/templates/testframework-config.user.yaml.template b/devenv-4-iom/templates/testframework-config.user.yaml.template new file mode 100644 index 0000000..c7c8e2c --- /dev/null +++ b/devenv-4-iom/templates/testframework-config.user.yaml.template @@ -0,0 +1,16 @@ +testframework: + default-endpoint: + version: "V1" + endpoint: + host: "${HostIom}" + port: ${PORT_IOM_SERVICE} + protocol: "http" + database: + default: + version: "V1" + endpoint: + host: "${PgHostExtern}:${PgPortExtern}" + username: "${OMS_DB_USER}" + password: "${OMS_DB_PASS}" + parameters: + dbName: "${OMS_DB_NAME}" diff --git a/devenv.project.properties b/devenv.project.properties index a29e4ab..55e5081 100644 --- a/devenv.project.properties +++ b/devenv.project.properties @@ -53,7 +53,7 @@ MAILHOG_IMAGE=mailhog/mailhog # examples: # local image: iom-dbaccount:1.3.0.0 # release from ISH Docker registry: docker.intershop.de/intershophub/iom-dbaccount:1.3.0.0 -IOM_DBACCOUNT_IMAGE=docker-internal.rnd.intershop.de/intershophub/iom-dbaccount:1.5.0 +IOM_DBACCOUNT_IMAGE=docker.tools.intershop.com/iom/intershophub/iom-dbaccount:1.5.0 # iom config image (name:tag) # examples: @@ -79,7 +79,7 @@ IOM_APP_IMAGE= # local image: iom:4.1.2 # locally built project image: prj-iom:4.1.2-1.2.0.0-SNAPSHOT # IOM release from ISH registry: docker.intershop.de/intershophub/iom:4.1.2 -IOM_IMAGE=docker.io/library/iom-blueprint-project-iom:1.2.0 +IOM_IMAGE=docker.io/library/iom-blueprint-project-iom:1.3.0-SNAPSHOT ################################################################################ # Database Configuration diff --git a/pom.xml b/pom.xml index ff5fb12..f083835 100644 --- a/pom.xml +++ b/pom.xml @@ -6,15 +6,15 @@ com.intershop.oms.blueprint iom-blueprint-project - 1.2.0 + 1.3.0-SNAPSHOT war IOM iom-blueprint-project APPLICATION IOM iom-blueprint-project APPLICATION UTF-8 - 4.1.2 - docker-internal.rnd.intershop.de/intershophub/ + 4.1.3 + docker.tools.intershop.com/iom/intershophub/ iom-blueprint-project ${project.version}${image.version.suffix} diff --git a/setenv.sh b/setenv.sh index 5ed8748..50648a4 100644 --- a/setenv.sh +++ b/setenv.sh @@ -2,4 +2,5 @@ kubectl config use-context docker-desktop mkdir -p devenv-share export PATH="$(pwd)/devenv-4-iom/bin:$PATH" +eval "$(devenv-cli.sh get bash-completion)" diff --git a/src/main/java/com/intershop/oms/blueprint/BlueprintConstants.java b/src/main/java/com/intershop/oms/blueprint/BlueprintConstants.java index d4619f4..a60de52 100644 --- a/src/main/java/com/intershop/oms/blueprint/BlueprintConstants.java +++ b/src/main/java/com/intershop/oms/blueprint/BlueprintConstants.java @@ -2,6 +2,20 @@ public interface BlueprintConstants { - static final String DISPATCH_PROPERTY_GROUP_DISPATCH = "dispatch"; - static final String DISPATCH_PROPERTY_KEY_CREATE_INVOICE = "createInvoice"; + // to be used to check for properties + // objects + static final String PROPERTY_ORDER = "order"; + static final String PROPERTY_RESPONSE = "response"; + static final String PROPERTY_DISPATCH = "dispatch"; + static final String PROPERTY_RMA = "rma"; + static final String PROPERTY_RETURN = "return"; + + // keys + static final String PROPERTY_CREATE_INVOICE = "createInvoice"; + static final String PROPERTY_EMAIL = "email"; + static final String PROPERTY_EXPORT = "export"; + + // values + static final String PROPERTY_VALUE_FALSE = "false"; + static final String PROPERTY_VALUE_TRUE = "true"; } diff --git a/src/main/java/com/intershop/oms/blueprint/email/SendEmailDecisionBean.java b/src/main/java/com/intershop/oms/blueprint/email/SendEmailDecisionBean.java new file mode 100644 index 0000000..ae32053 --- /dev/null +++ b/src/main/java/com/intershop/oms/blueprint/email/SendEmailDecisionBean.java @@ -0,0 +1,206 @@ +package com.intershop.oms.blueprint.email; + +import java.util.EnumSet; +import java.util.List; + +import javax.ejb.EJB; +import javax.ejb.Stateless; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.intershop.oms.blueprint.BlueprintConstants; + +import bakery.logic.service.util.AbstractExecutionDecider; +import bakery.logic.service.util.OrderHelper; +import bakery.persistence.dataobject.common.PropertyOwner; +import bakery.persistence.dataobject.configuration.common.InvoicingTypeDefDO; +import bakery.persistence.dataobject.configuration.connections.TransmissionTypeDefDO; +import bakery.persistence.dataobject.configuration.mail.MailEventRegistryEntryDO; +import bakery.persistence.dataobject.configuration.states.InvoicingTransmissionStatesDefDO; +import bakery.persistence.dataobject.invoicing.InvoicingDO; +import bakery.persistence.dataobject.invoicing.InvoicingTransmissionDO; +import bakery.persistence.dataobject.order.DispatchDO; +import bakery.persistence.dataobject.order.OrderDO; +import bakery.persistence.dataobject.order.ReturnDO; +import bakery.persistence.dataobject.rma.ReturnAnnouncementDO; + +/** + * Checks if an email should be send to the customer. + * Fails/skips if custom level property is given as group|key|value = ...|email|fail or no receiver email is given. + */ +@Stateless +public class SendEmailDecisionBean extends AbstractExecutionDecider +{ + private static final Logger logger = LoggerFactory.getLogger(SendEmailDecisionBean.class); + + @EJB(lookup = OrderHelper.LOGIC_ORDERHELPERBEAN) + private OrderHelper orderHelperLogicService; + + @Override + public boolean isExecutionRequired(OrderDO orderDO, MailEventRegistryEntryDO eventRegistry) + { + // has email and not contains the custom property + return hasEmailAddress(orderDO) && (!hasCustomProperty(orderDO, BlueprintConstants.PROPERTY_ORDER, + BlueprintConstants.PROPERTY_EMAIL, BlueprintConstants.PROPERTY_VALUE_FALSE)); + } + + @Override + public boolean isExecutionRequired(DispatchDO dispatchDO, MailEventRegistryEntryDO eventRegistry) + { + // has email and not contains the custom property + return hasEmailAddress(dispatchDO.getOrderDO()) && (!hasCustomProperty(dispatchDO, + BlueprintConstants.PROPERTY_DISPATCH, BlueprintConstants.PROPERTY_EMAIL, + BlueprintConstants.PROPERTY_VALUE_FALSE)); + } + + @Override + public boolean isExecutionRequired(ReturnAnnouncementDO returnAnnouncementDO, + MailEventRegistryEntryDO eventRegistry) + { + // has email and not contains the custom property + return hasEmailAddress(returnAnnouncementDO.getOrder()) && (!hasCustomProperty(returnAnnouncementDO, + BlueprintConstants.PROPERTY_RMA, BlueprintConstants.PROPERTY_EMAIL, + BlueprintConstants.PROPERTY_VALUE_FALSE)); + } + + @Override + public boolean isExecutionRequired(ReturnDO returnDO, MailEventRegistryEntryDO eventRegistry) + { + // has email and not contains the custom property + return hasEmailAddress(returnDO.getOrderDO()) && (!hasCustomProperty(returnDO, + BlueprintConstants.PROPERTY_RETURN, BlueprintConstants.PROPERTY_EMAIL, + BlueprintConstants.PROPERTY_VALUE_FALSE)); + } + + @Override + public boolean isExecutionRequired(InvoicingDO invoicingDO, MailEventRegistryEntryDO eventRegistry) + { + // has email ? + if (StringUtils.isEmpty(invoicingDO.getEmailAddress())) + { + logger.debug("For customer number '{}' with invoice number '{}' no email address exists. Couldn't send email.", + invoicingDO.getShopCustomerNo(), invoicingDO.getInvoiceNo()); + return false; + } + + // consider type of invoice vs. credit note + InvoicingTypeDefDO invoicingTypeDefDO = invoicingDO.getInvoicingTypeDefDO(); + EnumSet transmissionTypes = null; + + switch (invoicingTypeDefDO) + { + case INVOICE: + transmissionTypes = EnumSet.of(TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_INVOICE, + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_DISPATCH_INVOICE); + break; + case CREDITNOTE: + // the "manual" credit note is not a return mail + if(invoicingDO.getReferenceId() != null) + { + transmissionTypes = EnumSet.of(TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_CREDITNOTE); + } + else + { + transmissionTypes = EnumSet.of( + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_CREDITNOTE, + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_RETURN_CREDITNOTE, + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_RETURN_CAN_CREDITNOTE, + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_RETURN_DEF_CREDITNOTE, + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_RETURN_INV_CREDITNOTE, + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_RETURN_RCL010_CREDITNOTE, + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_RETURN_RCL020_CREDITNOTE, + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_RETURN_RCL021_CREDITNOTE, + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_RETURN_RCL045_CREDITNOTE, + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_RETURN_RCL980_CREDITNOTE, + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_RETURN_RCL_CREDITNOTE, + TransmissionTypeDefDO.SEND_CUSTOMER_MAIL_RETURN_RET_CREDITNOTE); + } + break; + default: + logger.error("Invoicing type " + invoicingTypeDefDO.name() + " is not implemented yet."); + } + + // transmission type is configured ? + if (!transmissionTypes.contains(eventRegistry.getTransmissionTypeDefDO())) + { + logger.debug("Transmission type '{}' is not configured for emails. Couldn't send email.", + eventRegistry.getTransmissionTypeDefDO()); + return false; + } + + return true; + } + + @Override + public boolean isExecutionRequired(InvoicingTransmissionDO invoicingTransmissionDO, MailEventRegistryEntryDO eventRegistry) + { + // has email ? + if (!this.hasEmailAddress(invoicingTransmissionDO.getInvoicingDO().getOrderList())) + { + return false; + } + + /** + * only execute if 1) type CREATE_DOCUMENT 2) and in status TRANSMISSIONED 3) and hosted invoiceDO should be executed + */ + return ((invoicingTransmissionDO.getTransmissionTypeDefDO() == TransmissionTypeDefDO.CREATE_DOCUMENT) + && (invoicingTransmissionDO.getState() == InvoicingTransmissionStatesDefDO.STATE_TRANSMISSIONED) + && (this.isExecutionRequired(invoicingTransmissionDO.getInvoicingDO(), eventRegistry))); + } + + /** + * Whether the object contains the given custom properties or not. + * @param owner + * @param group + * @param key + * @param value + * @return + */ + private boolean hasCustomProperty(PropertyOwner owner, String group, String key, String value) + { + String currentValue = owner.getPropertyValue(group, key); + return ( (currentValue != null) && currentValue.equals(value) ); + } + + /** + * Whether the customer has an email address or not. + * + * @param orderDO the order to check + * @return + */ + private boolean hasEmailAddress(OrderDO orderDO) + { + String receiverEmailAddress = orderHelperLogicService.getReceiverEmailAddress4OrderOrCustomer(orderDO); + + if (!StringUtils.isEmpty(receiverEmailAddress)) + { + return true; + } + + logger.debug("For customer number '{}' with order number '{}' no email address exists. Couldn't send email.", + orderDO.getShopCustomerNo(), orderDO.getId()); + + return false; + } + + /** + * Whether the customer has an email address or not. + * + * @param orderDOs, a list of orders + * @return + */ + private boolean hasEmailAddress(List orderDOs) + { + for (OrderDO orderDO : orderDOs) + { + if (hasEmailAddress(orderDO)) + { + return true; + } + } + return false; + } + +} \ No newline at end of file diff --git a/src/main/java/com/intershop/oms/blueprint/invoicing/InvoicingDecisionBean.java b/src/main/java/com/intershop/oms/blueprint/invoicing/InvoicingDecisionBean.java index ea487a3..ad19c7d 100644 --- a/src/main/java/com/intershop/oms/blueprint/invoicing/InvoicingDecisionBean.java +++ b/src/main/java/com/intershop/oms/blueprint/invoicing/InvoicingDecisionBean.java @@ -10,7 +10,6 @@ import com.intershop.oms.blueprint.BlueprintConstants; import bakery.logic.service.util.AbstractExecutionDecider; -import bakery.logic.service.util.ExecutionDecider; import bakery.persistence.dataobject.configuration.common.InvoicingTypeDefDO; import bakery.persistence.dataobject.configuration.common.ReturnTypeDefDO; import bakery.persistence.dataobject.configuration.invoicing.InvoicingEventRegistryEntryDO; @@ -20,7 +19,6 @@ @Stateless @TransactionAttribute(TransactionAttributeType.REQUIRED) public class InvoicingDecisionBean extends AbstractExecutionDecider - implements ExecutionDecider { public static final List RETURN_TYPES_WITH_INVOICE = Arrays.asList(ReturnTypeDefDO.RET, ReturnTypeDefDO.INV, ReturnTypeDefDO.DEF); @@ -36,8 +34,8 @@ public boolean isExecutionRequired(DispatchDO dispatchDO, } // check for special dispatch property - String createInvoiceProperty = dispatchDO.getPropertyValue(BlueprintConstants.DISPATCH_PROPERTY_GROUP_DISPATCH, - BlueprintConstants.DISPATCH_PROPERTY_KEY_CREATE_INVOICE); + String createInvoiceProperty = dispatchDO.getPropertyValue(BlueprintConstants.PROPERTY_DISPATCH, + BlueprintConstants.PROPERTY_CREATE_INVOICE); if (Boolean.FALSE.toString().equals(createInvoiceProperty)) { return false; diff --git a/src/main/java/com/intershop/oms/blueprint/transmitter/OrderTransmissionDecisionBean.java b/src/main/java/com/intershop/oms/blueprint/transmitter/OrderTransmissionDecisionBean.java deleted file mode 100644 index 70cf8e2..0000000 --- a/src/main/java/com/intershop/oms/blueprint/transmitter/OrderTransmissionDecisionBean.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.intershop.oms.blueprint.transmitter; - -import javax.ejb.Stateless; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import bakery.logic.service.util.AbstractExecutionDecider; -import bakery.logic.service.util.ExecutionDecider; -import bakery.persistence.dataobject.configuration.connections.CommunicationPartnerDO; -import bakery.persistence.dataobject.order.OrderDO; -import bakery.util.exception.TechnicalException; - -/** - * Order should not be exported if custom order level property is given as group|key|value = order|export|false - */ -@Stateless -public class OrderTransmissionDecisionBean extends AbstractExecutionDecider implements ExecutionDecider -{ - - private static final String GROUP = "order"; - private static final String KEY = "export"; - private static final String VALUE = "false"; - - private Logger log = LoggerFactory.getLogger(OrderTransmissionDecisionBean.class); - - @Override - public boolean isExecutionRequired(OrderDO orderDO, CommunicationPartnerDO communicationPartner) - { - if (null == orderDO) - { - throw new TechnicalException(OrderDO.class, "OrderDO is null"); - } - - String value = orderDO.getPropertyValue(GROUP, KEY); - if ((value != null) && value.equals(VALUE)) - { - log.debug("Skipping order export, because custom order property group|key|value = " + String.format("%s|%s|%s", GROUP, KEY, VALUE) + " found."); - return false; - } - - return true; - - } - -} diff --git a/src/main/java/com/intershop/oms/blueprint/transmitter/CustomOrderMessageTransmitterBean.java b/src/main/java/com/intershop/oms/blueprint/transmitter/ShopMessageTransmitterBean.java similarity index 50% rename from src/main/java/com/intershop/oms/blueprint/transmitter/CustomOrderMessageTransmitterBean.java rename to src/main/java/com/intershop/oms/blueprint/transmitter/ShopMessageTransmitterBean.java index d3a0729..6a5d283 100644 --- a/src/main/java/com/intershop/oms/blueprint/transmitter/CustomOrderMessageTransmitterBean.java +++ b/src/main/java/com/intershop/oms/blueprint/transmitter/ShopMessageTransmitterBean.java @@ -7,30 +7,37 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.theberlinbakery.types.v1_2.StoreOrder; +import com.theberlinbakery.types.v2_0.ReturnAnnouncementExport; import bakery.logic.communication.mapper.out.OrderMapperOut; +import bakery.logic.communication.mapper.out.ReturnAnnouncementMapperOut; import bakery.logic.service.transmission.MessageTransmitter; import bakery.logic.service.transmission.TransmissionWrapper; import bakery.logic.service.transmission.TransmissionWrapperFactory; import bakery.persistence.dataobject.order.AbstractTransmission; import bakery.persistence.dataobject.order.OrderTransmissionDO; +import bakery.persistence.dataobject.rma.ReturnAnnouncementTransmissionDO; import bakery.util.DeploymentConfig; import bakery.util.exception.TechnicalException; import bakery.util.exception.ValidationException; /** - * Exports an order to a 3rd party system by HTTP API call. + * Exports a shop message (order, rma) to a 3rd party system by REST API call. */ @Stateless -public class CustomOrderMessageTransmitterBean implements MessageTransmitter +public class ShopMessageTransmitterBean implements MessageTransmitter { - private static final Logger log = LoggerFactory.getLogger(CustomOrderMessageTransmitterBean.class); + private static final Logger log = LoggerFactory.getLogger(ShopMessageTransmitterBean.class); + //@EJB(lookup=OrderMapperOut.LOGIC_ORDERMAPPEROUT) @EJB(lookup = "java:global/bakery.base-app-" + DeploymentConfig.APP_VERSION + "/bakery.logic-core-" + DeploymentConfig.APP_VERSION + "/OrderMapperOutBean_v1_1!bakery.logic.communication.mapper.out.OrderMapperOut") private OrderMapperOut orderMapperOut; + @EJB(lookup=ReturnAnnouncementMapperOut.JNDI_NAME_V2_0) + private ReturnAnnouncementMapperOut returnAnnouncementMapperOut; + @EJB(lookup = TransmissionWrapperFactory.LOGIC_TRANSMISSIONFACTORYBEAN) private TransmissionWrapperFactory transmissionWrapperFactory; @@ -45,27 +52,39 @@ public AbstractTransmission transmit(AbstractTransmission abstractTransmission) throw new IllegalArgumentException("Transmission object is null."); } + // order transmission if (abstractTransmission instanceof OrderTransmissionDO) { OrderTransmissionDO orderTransmissionDO = (OrderTransmissionDO)abstractTransmission; - return this.transmitOrder(orderTransmissionDO); + return transmitOrder(orderTransmissionDO); + } + + // rma transmission + if (abstractTransmission instanceof ReturnAnnouncementTransmissionDO) + { + ReturnAnnouncementTransmissionDO returnAnnouncementTransmissionDO = (ReturnAnnouncementTransmissionDO)abstractTransmission; + + return transmitReturnAnnouncement(returnAnnouncementTransmissionDO); } return abstractTransmission; } - private OrderTransmissionDO transmitOrder(OrderTransmissionDO orderTransmissionDO) + private OrderTransmissionDO transmitOrder(OrderTransmissionDO transmissionDO) { StoreOrder storeOrder; - Long orderId = orderTransmissionDO.getOrderDO().getId(); + Long orderId = transmissionDO.getOrderDO().getId(); log.debug("Started transmitting order " + orderId); - TransmissionWrapper transmissionWrapper = transmissionWrapperFactory.getTransmissionWrapper(orderTransmissionDO); + /** + * Map to API-object. + */ + TransmissionWrapper transmissionWrapper = transmissionWrapperFactory.getTransmissionWrapper(transmissionDO); try { - storeOrder = (StoreOrder)orderMapperOut.mapOrder(orderTransmissionDO, transmissionWrapper); + storeOrder = (StoreOrder)orderMapperOut.mapOrder(transmissionDO, transmissionWrapper); } catch(ValidationException e) { @@ -74,16 +93,42 @@ private OrderTransmissionDO transmitOrder(OrderTransmissionDO orderTransmissionD } /** - * If required storeOrder can be extended storeOrder-object using the related orderTransmissionDO.getOrder() + * If desired, add more data to storeOrder */ /** - * Make 3rd party API call using storeOrder-object. + * Make 3rd party API call using storeOrder */ log.debug("Finished transmitting order " + orderId); - return orderTransmissionDO; + return transmissionDO; + } + + private ReturnAnnouncementTransmissionDO transmitReturnAnnouncement(ReturnAnnouncementTransmissionDO transmissionDO) + { + ReturnAnnouncementExport returnAnnouncementExport; + + Long orderId = transmissionDO.getOrderDO().getId(); + Long returnAnnouncementId = transmissionDO.getReturnAnnouncementDO().getId(); + log.debug("Started transmitting return annoucement " + returnAnnouncementId + " for order " + orderId); + + /** + * Map to API-object. + */ + returnAnnouncementExport = (ReturnAnnouncementExport)returnAnnouncementMapperOut.mapReturnAnnouncement(transmissionDO); + + /** + * If desired, add more data to returnAnnouncementExport + */ + + /** + * Make 3rd party API call using returnAnnouncementExport + */ + + log.debug("Finished transmitting return annoucement " + returnAnnouncementId + " for order " + orderId); + + return transmissionDO; } @Override diff --git a/src/main/java/com/intershop/oms/blueprint/transmitter/ShopTransmissionDecisionBean.java b/src/main/java/com/intershop/oms/blueprint/transmitter/ShopTransmissionDecisionBean.java new file mode 100644 index 0000000..f0ffc99 --- /dev/null +++ b/src/main/java/com/intershop/oms/blueprint/transmitter/ShopTransmissionDecisionBean.java @@ -0,0 +1,89 @@ +package com.intershop.oms.blueprint.transmitter; + +import javax.ejb.Stateless; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.intershop.oms.blueprint.BlueprintConstants; + +import bakery.logic.service.util.AbstractExecutionDecider; +import bakery.persistence.dataobject.configuration.connections.CommunicationPartnerDO; +import bakery.persistence.dataobject.configuration.states.ReturnAnnouncementStatesDefDO; +import bakery.persistence.dataobject.order.OrderDO; +import bakery.persistence.dataobject.rma.ReturnAnnouncementDO; +import bakery.util.exception.TechnicalException; + +/** + * Transmission of a shop-related message should be executed or not. + */ +@Stateless +public class ShopTransmissionDecisionBean extends AbstractExecutionDecider +{ + + private Logger log = LoggerFactory.getLogger(ShopTransmissionDecisionBean.class); + + /** + * Order should not be exported if custom order level property is given as group|key|value = order|export|false. + */ + @Override + public boolean isExecutionRequired(OrderDO orderDO, CommunicationPartnerDO communicationPartner) + { + if (null == orderDO) + { + throw new TechnicalException(OrderDO.class, "OrderDO is null"); + } + + String value = orderDO.getPropertyValue(BlueprintConstants.PROPERTY_ORDER, BlueprintConstants.PROPERTY_EXPORT); + if ((value != null) && value.equals(BlueprintConstants.PROPERTY_VALUE_FALSE)) + { + log.debug("Skipping order export, because custom order property group|key|value = " + + String.format("%s|%s|%s", BlueprintConstants.PROPERTY_ORDER, + BlueprintConstants.PROPERTY_EXPORT, BlueprintConstants.PROPERTY_VALUE_FALSE) + + " found."); + return false; + } + + return true; + } + + /** + * RMA request/ ReturnAnnouncementDO should not be exported if: + * - approval rejected + * - OR custom return request property is given as group|key|value = ""|export|false. + */ + @Override + public boolean isExecutionRequired(ReturnAnnouncementDO returnAnnouncementDO, CommunicationPartnerDO communicationPartner) + { + if (null == returnAnnouncementDO) + { + throw new TechnicalException(ReturnAnnouncementDO.class, "ReturnAnnouncementDO is null"); + } + + // true if the return announcement is/was in status ACCEPTED + boolean accepted = returnAnnouncementDO.getReturnAnnouncementStateHistoryList() != null + ? returnAnnouncementDO.getReturnAnnouncementStateHistoryList().stream().anyMatch( + rma -> rma.getTargetState() == ReturnAnnouncementStatesDefDO.STATE_ACCEPTED) + : false; + + if(!accepted) + { + return false; + } + + // check custom properties + String value = returnAnnouncementDO.getPropertyValue("", BlueprintConstants.PROPERTY_EXPORT); + if ((value != null) && value.equals(BlueprintConstants.PROPERTY_VALUE_FALSE)) + { + log.debug( + "Skipping order export, because custom order property group|key|value = " + + String.format("%s|%s|%s", "", + BlueprintConstants.PROPERTY_EXPORT, BlueprintConstants.PROPERTY_VALUE_FALSE) + + " found."); + return false; + } + + return true; + } + +} diff --git a/src/main/java/com/intershop/oms/blueprint/transmitter/SupplierMessageTransmitterBean.java b/src/main/java/com/intershop/oms/blueprint/transmitter/SupplierMessageTransmitterBean.java index e5a0ded..c8f1998 100644 --- a/src/main/java/com/intershop/oms/blueprint/transmitter/SupplierMessageTransmitterBean.java +++ b/src/main/java/com/intershop/oms/blueprint/transmitter/SupplierMessageTransmitterBean.java @@ -26,12 +26,11 @@ import bakery.util.exception.ValidationException; /** - * Exports a supplier message (response, dispatch, return) to a 3rd party system by HTTP API call. + * Exports a supplier message (response, dispatch, return) to a 3rd party system by API call. */ @Stateless public class SupplierMessageTransmitterBean implements MessageTransmitter { - private static final Logger log = LoggerFactory.getLogger(SupplierMessageTransmitterBean.class); @EJB(lookup = "java:global/bakery.base-app-" + DeploymentConfig.APP_VERSION + "/bakery.logic-core-" @@ -39,7 +38,7 @@ public class SupplierMessageTransmitterBean implements MessageTransmitter + "/ResponseMapperOutBean!bakery.logic.communication.mapper.out.ResponseMapperOut") private ResponseMapperOut responseMapperOut; - @EJB(lookup = DispatchMapperOut.LOGIC_DSIPATCHMAPPEROUT) // there's an API-typo + @EJB(lookup = DispatchMapperOut.LOGIC_DISPATCHMAPPEROUT) private DispatchMapperOut dispatchMapperOut; @EJB(lookup = "java:global/bakery.base-app-" + DeploymentConfig.APP_VERSION + "/bakery.logic-core-" @@ -85,11 +84,6 @@ public AbstractTransmission transmit(AbstractTransmission abstractTransmission) return abstractTransmission; } - /** - * Make API-call to submit the data. - * @param responseTransmissionDO - * @return - */ private ResponseTransmissionDO transmitResponse(ResponseTransmissionDO responseTransmissionDO) { StoreResponse storeResponse; @@ -125,11 +119,6 @@ private ResponseTransmissionDO transmitResponse(ResponseTransmissionDO responseT return responseTransmissionDO; } - /** - * Make API-call to submit the data. - * @param dispatchTransmissionDO - * @return - */ private DispatchTransmissionDO transmitDispatch(DispatchTransmissionDO dispatchTransmissionDO) { StoreDispatch storeDispatch; @@ -165,11 +154,6 @@ private DispatchTransmissionDO transmitDispatch(DispatchTransmissionDO dispatchT return dispatchTransmissionDO; } - /** - * Make API-call to submit the data. - * @param returnTransmissionDO - * @return - */ private ReturnTransmissionDO transmitReturn(ReturnTransmissionDO returnTransmissionDO) { StoreReturn storeReturn; diff --git a/src/main/java/com/intershop/oms/blueprint/transmitter/SupplierTransmissionDecisionBean.java b/src/main/java/com/intershop/oms/blueprint/transmitter/SupplierTransmissionDecisionBean.java index 8b5e972..d434a9b 100644 --- a/src/main/java/com/intershop/oms/blueprint/transmitter/SupplierTransmissionDecisionBean.java +++ b/src/main/java/com/intershop/oms/blueprint/transmitter/SupplierTransmissionDecisionBean.java @@ -6,7 +6,6 @@ import org.slf4j.LoggerFactory; import bakery.logic.service.util.AbstractExecutionDecider; -import bakery.logic.service.util.ExecutionDecider; import bakery.persistence.dataobject.configuration.connections.CommunicationPartnerDO; import bakery.persistence.dataobject.order.DispatchDO; import bakery.persistence.dataobject.order.ResponseDO; @@ -17,9 +16,8 @@ * Message (response, dispatch, return) should not be exported if custom root level property is given as group|key|value = |export|false */ @Stateless -public class SupplierTransmissionDecisionBean extends AbstractExecutionDecider implements ExecutionDecider -{ - +public class SupplierTransmissionDecisionBean extends AbstractExecutionDecider +{ private static final String GROUP_RES = "response"; private static final String GROUP_DIS = "dispatch"; private static final String GROUP_RET = "return"; @@ -44,8 +42,7 @@ public boolean isExecutionRequired(ResponseDO responseDO, CommunicationPartnerDO return false; } - return true; - + return true; } @Override @@ -65,7 +62,6 @@ public boolean isExecutionRequired(DispatchDO dispatchDO, CommunicationPartnerDO } return true; - } @Override @@ -85,7 +81,6 @@ public boolean isExecutionRequired(ReturnDO returnDO, CommunicationPartnerDO com } return true; - } } diff --git a/src/main/java/com/intershop/oms/enums/expand/ExpandedDecisionBeanDefDO.java b/src/main/java/com/intershop/oms/enums/expand/ExpandedDecisionBeanDefDO.java index a2b88b2..ccafb81 100644 --- a/src/main/java/com/intershop/oms/enums/expand/ExpandedDecisionBeanDefDO.java +++ b/src/main/java/com/intershop/oms/enums/expand/ExpandedDecisionBeanDefDO.java @@ -21,6 +21,7 @@ public enum ExpandedDecisionBeanDefDO implements EnumInterface // general 1xxxx GENERAL_DECISION_BEAN(Integer.valueOf(-10000), "java:global/iom-blueprint-project/TBD"), + INVOICING_DECISION_BEAN(Integer.valueOf(10001), "java:global/iom-blueprint-project/InvoicingDecisionBean"), // order approval 2xxxx @@ -31,8 +32,11 @@ public enum ExpandedDecisionBeanDefDO implements EnumInterface RMA_DECISION_BEAN(Integer.valueOf(-30000), "java:global/iom-blueprint-project/TBD"), // export|transmissions 4xxxx - ORDER_TRANSMISSION_DECISION_BEAN(Integer.valueOf(40000), "java:global/iom-blueprint-project/OrderTransmissionDecisionBean"), - SUPPLIER_TRANSMISSION_DECISION_BEAN(Integer.valueOf(41000), "java:global/iom-blueprint-project/SupplierTransmissionDecisionBean") + SHOP_TRANSMISSION_DECISION_BEAN(Integer.valueOf(40000), "java:global/iom-blueprint-project/ShopTransmissionDecisionBean"), + SUPPLIER_TRANSMISSION_DECISION_BEAN(Integer.valueOf(41000), "java:global/iom-blueprint-project/SupplierTransmissionDecisionBean"), + + // emails 5xxxx + SEND_EMAIL_DECISION_BEAN(Integer.valueOf(50000), "java:global/iom-blueprint-project/SendEmailDecisionBean") ; private Integer id; diff --git a/src/main/java/com/intershop/oms/enums/expand/ExpandedExecutionBeanDefDO.java b/src/main/java/com/intershop/oms/enums/expand/ExpandedExecutionBeanDefDO.java index 9f36aaa..bca2fc4 100644 --- a/src/main/java/com/intershop/oms/enums/expand/ExpandedExecutionBeanDefDO.java +++ b/src/main/java/com/intershop/oms/enums/expand/ExpandedExecutionBeanDefDO.java @@ -24,7 +24,7 @@ public enum ExpandedExecutionBeanDefDO implements ExecutionBeanDefDOEnumInterfac * The name must be unique across both classes. * Values with negative id are meant as syntax example and are ignored (won't get persisted within the database). */ - CUSTOM_ORDER_MESSAGE_TRANSMITTER(Integer.valueOf(10000), "java:global/iom-blueprint-project/CustomOrderMessageTransmitterBean!bakery.logic.service.transmission.MessageTransmitter", null), + SHOP_MESSAGE_TRANSMITTER(Integer.valueOf(10000), "java:global/iom-blueprint-project/ShopMessageTransmitterBean!bakery.logic.service.transmission.MessageTransmitter", null), SUPPLIER_MESSAGE_TRANSMITTER(Integer.valueOf(20000), "java:global/iom-blueprint-project/SupplierMessageTransmitterBean!bakery.logic.service.transmission.MessageTransmitter", null) ; diff --git a/src/main/java/com/intershop/oms/enums/expand/ExpandedExecutionBeanKeyDefDO.java b/src/main/java/com/intershop/oms/enums/expand/ExpandedExecutionBeanKeyDefDO.java index d08ddb1..4dafd36 100644 --- a/src/main/java/com/intershop/oms/enums/expand/ExpandedExecutionBeanKeyDefDO.java +++ b/src/main/java/com/intershop/oms/enums/expand/ExpandedExecutionBeanKeyDefDO.java @@ -19,8 +19,9 @@ public enum ExpandedExecutionBeanKeyDefDO implements ExecutionBeanKeyDefDOEnumIn * Values with negative id are meant as syntax example and are ignored (won't get persisted within the database). */ - CUSTOM_WISH(-1, ExpandedExecutionBeanDefDO.CUSTOM_ORDER_MESSAGE_TRANSMITTER.getId(), "customWish", ParameterTypeDefDO.UNSPECIFIED, false, null ); + // CUSTOM_WISH(-1, ExpandedExecutionBeanDefDO.CUSTOM_ORDER_MESSAGE_TRANSMITTER.getId(), "customWish", ParameterTypeDefDO.UNSPECIFIED, false, null ); // EXAMPLE_SHOPCUSTOMERMAILSENDERBEAN_SHOP_EMAIL_ADDRESS( 10001, ExpandedExecutionBeanDefDO.CUSTOM_ORDER_MESSAGE_TRANSMITTER.getId(), "shopEmailAddress", ParameterTypeDefDO.EMAIL, ExecutionBeanKeyDefDO.Flag.OPTIONAL, null); + ; private Integer id; private Integer executionBeanDefRef; diff --git a/src/sql-config/config/base/002_Shop.sql b/src/sql-config/config/base/002_Shop.sql index 0de99fa..3462107 100644 --- a/src/sql-config/config/base/002_Shop.sql +++ b/src/sql-config/config/base/002_Shop.sql @@ -33,7 +33,7 @@ PERFORM create_or_update_shop( -- "amountDaysForPaymentReminderMailOfPrepaidOrders", "amountDaysForAutoCancellationOfPrepaidOrders", "isReservationWithDOSE" NULL, NULL, TRUE, -- "shopRMANumberSequenceName", "shopRMANumberSequenceFormatString" - NULL, NULL + 'rma_number_sequence_generator', 'rma-number-{0}' -- will produce number like 'rma-number-10000' ); -- inTRONICS b2b Shop @@ -59,7 +59,7 @@ PERFORM create_or_update_shop( -- "amountDaysForPaymentReminderMailOfPrepaidOrders", "amountDaysForAutoCancellationOfPrepaidOrders", "isReservationWithDOSE" NULL, NULL, TRUE, -- "shopRMANumberSequenceName", "shopRMANumberSequenceFormatString" - NULL, NULL + 'rma_number_sequence_generator', 'rma-number-{0}' -- will produce number like 'rma-number-10000' ); END; diff --git a/src/sql-config/config/base/009_Returns.sql b/src/sql-config/config/base/009_Returns.sql index 94563b0..286f119 100644 --- a/src/sql-config/config/base/009_Returns.sql +++ b/src/sql-config/config/base/009_Returns.sql @@ -14,13 +14,16 @@ shop2supplier2reducereasonref bigint; BEGIN --- Shop Return Types + +-- Shop return types FOREACH shopref in array shops_all LOOP + -- RETURN IF NOT EXISTS (SELECT NULL FROM "Shop2ReturnTypeDefDO" WHERE "shopRef" = shopref AND "returnTypeDefRef" = 4) THEN INSERT INTO "Shop2ReturnTypeDefDO" SELECT nextval('"Shop2ReturnTypeDefDO_id_seq"'), 4, 'RET', shopref; END IF; + -- DEFECT IF NOT EXISTS (SELECT NULL FROM "Shop2ReturnTypeDefDO" WHERE "shopRef" = shopref AND "returnTypeDefRef" = 5) THEN INSERT INTO "Shop2ReturnTypeDefDO" @@ -29,21 +32,28 @@ FOREACH shopref in array shops_all LOOP END LOOP; --- Shop Return Reasons + +-- Shop return reasons FOREACH shopref IN ARRAY shops_all LOOP INSERT INTO "Shop2ReturnReasonDefDO" (id, "returnReasonDefRef", "shopReturnReasonName", "shopRef") + SELECT nextval('"Shop2ReturnReasonDefDO_id_seq"'), 301, 'RET020', shopref UNION ALL + SELECT nextval('"Shop2ReturnReasonDefDO_id_seq"'), 313, 'RET045', shopref UNION ALL SELECT nextval('"Shop2ReturnReasonDefDO_id_seq"'), 304, 'RET050', shopref UNION ALL SELECT nextval('"Shop2ReturnReasonDefDO_id_seq"'), 305, 'RET060', shopref UNION ALL SELECT nextval('"Shop2ReturnReasonDefDO_id_seq"'), 308, 'RET090', shopref UNION ALL - SELECT nextval('"Shop2ReturnReasonDefDO_id_seq"'), 313, 'RET045', shopref UNION ALL - SELECT nextval('"Shop2ReturnReasonDefDO_id_seq"'), 323, 'RET190', shopref --UNION ALL + SELECT nextval('"Shop2ReturnReasonDefDO_id_seq"'), 323, 'RET190', shopref UNION ALL + SELECT nextval('"Shop2ReturnReasonDefDO_id_seq"'), 312, 'RET990', shopref + + /* in preparation */ --SELECT nextval('"Shop2ReturnReasonDefDO_id_seq"'), 1, 'CAN010', shopref UNION ALL --SELECT nextval('"Shop2ReturnReasonDefDO_id_seq"'), 114, 'RCL045', shopref - ON CONFLICT ("returnReasonDefRef", "shopRef") DO UPDATE SET "shopReturnReasonName" = EXCLUDED."shopReturnReasonName"; + ON CONFLICT ("returnReasonDefRef", "shopRef") DO UPDATE SET "shopReturnReasonName" = EXCLUDED."shopReturnReasonName" + ; + /* in preparation */ -- approval reason mapping Shop2ReturnReason2ApprovalStateCodeReasonDefDO /* INSERT INTO "Shop2ReturnReason2ApprovalStateCodeReasonDefDO"(id, "approvalStateCodeReasonDefRef", "shop2ReturnReasonDefRef") @@ -54,24 +64,38 @@ LOOP END LOOP; --- Supplier Return Types + +-- Supplier return types FOREACH supplierref IN ARRAY suppliers_all LOOP INSERT INTO "Supplier2ReturnTypeDefDO"(id, "returnTypeDefRef", "supplierReturnTypeName", "supplierRef", "rmaNo", preselected) + SELECT nextval('"Supplier2ReturnTypeDefDO_id_seq"'), 1, 'CAN', supplierref, '', false UNION ALL SELECT nextval('"Supplier2ReturnTypeDefDO_id_seq"'), 2, 'RCL', supplierref, '', false UNION ALL SELECT nextval('"Supplier2ReturnTypeDefDO_id_seq"'), 3, 'INV', supplierref, '', false UNION ALL - SELECT nextval('"Supplier2ReturnTypeDefDO_id_seq"'), 4, 'RET', supplierref, '', true UNION ALL + SELECT nextval('"Supplier2ReturnTypeDefDO_id_seq"'), 4, 'RET', supplierref, '', true UNION ALL SELECT nextval('"Supplier2ReturnTypeDefDO_id_seq"'), 5, 'DEF', supplierref, '', false ON CONFLICT DO NOTHING ; + END LOOP; --- Supplier Return Reasons + +-- Supplier return reasons FOREACH supplierref IN ARRAY suppliers_all LOOP INSERT INTO "Supplier2ReturnReasonDefDO" (id, "returnReasonDefRef", "supplierReturnReasonName", "supplierRef", "preselected") + + SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 301, 'RET020', supplierref, false UNION ALL + SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 313, 'RET045', supplierref, false UNION ALL + SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 304, 'RET050', supplierref, false UNION ALL + SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 305, 'RET060', supplierref, false UNION ALL + SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 308, 'RET090', supplierref, false UNION ALL + SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 323, 'RET190', supplierref, false UNION ALL + SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 312, 'RET990', supplierref, false + + /* in preparation */ --SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 1, 'CAN010', supplierref, false UNION ALL --SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 2, 'CAN020', supplierref, false UNION ALL --SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 12, 'CAN990', supplierref, false UNION ALL @@ -82,19 +106,12 @@ LOOP --SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 109, 'RCL990', supplierref, false UNION ALL --SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 204, 'INV990', supplierref, false UNION ALL - - SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 301, 'RET020', supplierref, false UNION ALL - SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 304, 'RET050', supplierref, false UNION ALL - SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 305, 'RET060', supplierref, false UNION ALL - SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 308, 'RET090', supplierref, false UNION ALL - SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 312, 'RET990', supplierref, false UNION ALL - SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 313, 'RET045', supplierref, false UNION ALL - SELECT nextval('"Supplier2ReturnReasonDefDO_id_seq"'), 323, 'RET190', supplierref, false ; END LOOP; --- Supplier Return Addresses (based on entries in Shop2SupplierDO and Supplier2ReturnTypeDefDO) + +-- Supplier return addresses (based on entries in Shop2SupplierDO and Supplier2ReturnTypeDefDO) DELETE FROM oms."SupplierReturnAddressDO"; FOREACH shopref IN ARRAY shops_all @@ -110,7 +127,7 @@ LOOP INSERT INTO "SupplierReturnAddressDO"( "id", "addressLine1", "addressLine2", "addressLine3", "addressLine4", "addressLine5", "supplier2ReturnTypeDefRef", "shop2SupplierRef") - SELECT nextval('"SupplierReturnAddressDO_id_seq"'), 'inTRONICS Warehouse c/o Intershop Communications, Inc.' , '25 Lusk Street, Suite 210', 'San Francisco, CA 94107, United States', 'Tel.: +1 415 844-1500', 'Fax: +1 415 844-3800', + SELECT nextval('"SupplierReturnAddressDO_id_seq"'), 'inTRONICS Return Center c/o Intershop Communications, Inc.' , '25 Lusk Street', 'San Francisco, CA 94107, United States', 'Phone.: +1 123 456-0000', 'Fax: +1 123 456-0099', (select id from "Supplier2ReturnTypeDefDO" where "supplierRef" = supplierref and "supplierReturnTypeName" = reason_name), (select id from "Shop2SupplierDO" where "supplierRef" = supplierref and "shopRef" = shopref) from RES ON CONFLICT DO NOTHING @@ -120,7 +137,8 @@ LOOP END LOOP; --- Return Reductions + +-- Return reductions -- lazy upsert - delete everything DELETE FROM "ReductionValueDO"; @@ -130,7 +148,7 @@ FOREACH shopref IN ARRAY shops_all LOOP FOREACH supplierref IN ARRAY suppliers_all || supplier_int LOOP - -- make sure we only iterate over existing Shop2SupplierDOs + -- iterate existing Shop2SupplierDOs shop2supplierref = (SELECT id FROM oms."Shop2SupplierDO" WHERE "shopRef" = shopref and "supplierRef" = supplierref); CONTINUE WHEN shop2supplierref IS NULL; @@ -149,6 +167,27 @@ LOOP END LOOP; + +-- to generate RMA numbers +CREATE SEQUENCE IF NOT EXISTS "rma_number_sequence_generator" + INCREMENT 1 + START 10000 + CYCLE -- allows the sequence to wrap around when the maxvalue or minvalue has been reached by an ascending or descending sequence respectively +; + + + +-- Enable the creation of return-related documents + +-- return slip +perform admin.add_document_transformer_config(1, 2, 7, shopRef, 2, true); /* p_documentformatdefref, p_documentmapperdefref, p_documenttypedefref, p_shopref, p_transformerframeworkdefref, p_save */ + +-- return label and documentMapperDefRef=1 +-- requires BarCodeGenDO +perform admin.add_document_transformer_config(1, 1, 1, shopRef, 2, true); /* p_documentformatdefref, p_documentmapperdefref, p_documenttypedefref, p_shopref, p_transformerframeworkdefref, p_save */ + + + END; -- RESUME velocity parser ]]# diff --git a/src/sql-config/config/base/014_eMails.sql b/src/sql-config/config/base/014_eMails.sql index 5eeb420..5e2d63e 100644 --- a/src/sql-config/config/base/014_eMails.sql +++ b/src/sql-config/config/base/014_eMails.sql @@ -119,7 +119,8 @@ LOOP -- Mail Event Registry Configuration /* mailEventDefRef = 1 (MailEventDefDO.SEND_SHOP_CUSTOMER_MAIL_PC) - decisionBeanDefRef = 50 (ExpandedDecisionBeanDefDO.SEND_EMAIL_DECIDER_BEAN) -> SendEmailDeciderBean.java + (core) decisionBeanDefRef = 50 (DecisionBeanDefDO.SEND_EMAIL_DECIDER_BEAN) -> SendEmailDeciderBean.java + (custom) decisionBeanDefRef = 50000 (ExpandedDecisionBeanDefDO.SEND_EMAIL_DECISION_BEAN) -> SendEmailDecisionBean.java transmissionTypeDefRef = transmissionType_id (see TransmissionTypeDefDO) */ INSERT INTO "MailEventRegistryEntryDO"( @@ -129,7 +130,7 @@ LOOP SELECT nextval('"MailEventRegistryEntryDO_id_seq"'), 0, now(), now(), true, eventRegistryEntry_id, - 1, 50, transmissionType_id -- "mailEventDefRef", "decisionBeanDefRef", "transmissionTypeDefRef" + 1, db_send_email, transmissionType_id -- "mailEventDefRef", "decisionBeanDefRef", "transmissionTypeDefRef" WHERE NOT EXISTS ( SELECT * FROM "MailEventRegistryEntryDO" diff --git a/src/sql-config/config/base/015_Documents.sql b/src/sql-config/config/base/015_Documents.sql index 525c5a8..996b06b 100644 --- a/src/sql-config/config/base/015_Documents.sql +++ b/src/sql-config/config/base/015_Documents.sql @@ -15,14 +15,7 @@ FOREACH shopref IN ARRAY shops_all LOOP -- delivery note - perform admin.add_document_transformer_config(1, 2, 6, shopRef, 2, true); - - -- return slip - perform admin.add_document_transformer_config(1, 2, 7, shopRef, 2, true); - - -- returnLabel and documentMapperDefRef=1 - -- requires BarCodeGenDO - perform admin.add_document_transformer_config(1, 1, 1, shopRef, 2, true); + perform admin.add_document_transformer_config(1, 2, 6, shopRef, 2, true); /* p_documentformatdefref, p_documentmapperdefref, p_documenttypedefref, p_shopref, p_transformerframeworkdefref, p_save */ END LOOP; diff --git a/src/sql-config/config/base/020_Communication.sql b/src/sql-config/config/base/020_Communication.sql index 93db235..4a06ae0 100644 --- a/src/sql-config/config/base/020_Communication.sql +++ b/src/sql-config/config/base/020_Communication.sql @@ -2,6 +2,8 @@ SET client_min_messages=error; #parse("src/sql-config/config/vars.vm") -- import global variables $vars_shop_supplier +$vars_execution_beans +$vars_decision_beans -- PAUSE velocity parser #[[ @@ -12,22 +14,40 @@ supplierId int8; supplierIds int8[]; senderId int8; receiverId int8; -order_transmitter varchar = 'customOrderMessageTransmitter'; -order_decisionBean varchar = 'orderTransmissionDecisionBean'; -supplier_transmitter varchar = 'supplierMessageTransmitter'; + +-- keys +k_shop_transmitter_order varchar = 'shopMessageTransmitterOrder'; +k_shop_transmitter_rma varchar = 'shopMessageTransmitterRMA'; supplier_transmitter_key_res varchar = 'supplierMessageTransmitterRes'; supplier_transmitter_key_dis varchar = 'supplierMessageTransmitterDis'; supplier_transmitter_key_ret varchar = 'supplierMessageTransmitterRet'; -supplier_decisionBean varchar = 'supplierTransmissionDecisionBean'; communicationId int8; + +-- ids (instead of subselects) +id_docformat_xml int8 = 2; -- see oms."DocumentFormatDefDO" +id_commversion_1 int8 = 1; -- see oms."CommunicationVersionDefDO" +id_transform_push int8 = 10; -- see oms."TransmissionFormDefDO" +id_transtype_sendorder int8 = 10; -- see oms."TransmissionTypeDefDO" +id_transtype_sendresponse int8 = 40; -- see oms."TransmissionTypeDefDO" +id_transtype_senddispatch int8 = 80; -- see oms."TransmissionTypeDefDO" +id_transtype_sendrma int8 = 64; -- see oms."TransmissionTypeDefDO" +id_transtype_sendreturn int8 = 60; -- see oms."TransmissionTypeDefDO" + -- end variables block with BEGIN + + + /* + SHOP MESSAGES + */ + -- ORDER EXPORT/TRANSMISSION - -- REGISTER customOrderMessageTransmitter + -- REGISTER shopMessageTransmitter + INSERT INTO oms."CommunicationDO" ( - id, + id, active, "activeOMT", key, @@ -37,19 +57,19 @@ BEGIN "communicationVersionDefRef", "transmissionFormDefRef" ) - SELECT + SELECT nextval('"CommunicationDO_id_seq"'), true, null, - order_transmitter, - (SELECT id FROM oms."DocumentFormatDefDO" WHERE name = 'XML'), - (SELECT id FROM oms."ExecutionBeanDefDO" WHERE description = order_transmitter), - (SELECT id FROM oms."TransmissionTypeDefDO" WHERE name = 'sendAnnounceOrder'), - (SELECT id FROM oms."CommunicationVersionDefDO" WHERE "incomingURLParameter" = 'v1.0'), - (SELECT id FROM oms."TransmissionFormDefDO" WHERE name = 'PUSH') - WHERE NOT EXISTS (SELECT * FROM oms."CommunicationDO" where key = order_transmitter); + k_shop_transmitter_order, + id_docformat_xml, + eb_shop_transmitter, + id_transtype_sendorder, + id_commversion_1, + id_transform_push + WHERE NOT EXISTS (SELECT * FROM oms."CommunicationDO" WHERE key = k_shop_transmitter_order AND "transmissionTypeDefRef" = id_transtype_sendorder); - communicationId := (SELECT id FROM oms."CommunicationDO" WHERE key = order_transmitter); + communicationId := (SELECT id FROM oms."CommunicationDO" WHERE key = k_shop_transmitter_order AND "transmissionTypeDefRef" = id_transtype_sendorder); -- CONFIGURE partners FOREACH shopId IN ARRAY shops_all LOOP @@ -82,11 +102,11 @@ BEGIN ) SELECT nextval('"CommunicationPartnerDO_id_seq"'), - (SELECT id FROM oms."DecisionBeanDefDO" WHERE description = order_decisionBean), -- skip export ? + db_shop_transmission, -- skip export ? false, communicationId, - senderId, -- a shop - receiverId, -- a supplier + senderId, -- a shop + receiverId, -- a supplier 5, '2m', false; @@ -99,11 +119,82 @@ BEGIN + -- RETURN ANNOUNCEMENT EXPORT/TRANSMISSION + -- REGISTER shopMessageTransmitter + INSERT INTO oms."CommunicationDO" + ( + id, + active, + "activeOMT", + key, + "documentFormatDefRef", + "executionBeanDefRef", + "transmissionTypeDefRef", + "communicationVersionDefRef", + "transmissionFormDefRef" + ) + SELECT + nextval('"CommunicationDO_id_seq"'), + true, + null, + k_shop_transmitter_rma, + id_docformat_xml, + eb_shop_transmitter, + id_transtype_sendrma, + id_commversion_1, + id_transform_push + WHERE NOT EXISTS (SELECT * FROM oms."CommunicationDO" where key = k_shop_transmitter_rma AND "transmissionTypeDefRef" = id_transtype_sendrma); + + communicationId := (SELECT id FROM oms."CommunicationDO" WHERE key = k_shop_transmitter_rma AND "transmissionTypeDefRef" = id_transtype_sendrma); + + -- CONFIGURE partners + FOREACH shopId IN ARRAY shops_all LOOP + + senderId := (SELECT id FROM oms."PartnerReferrerDO" WHERE "shopRef" = shopId); + IF NOT EXISTS (SELECT * FROM "CommunicationPartnerDO" + WHERE "sendingPartnerReferrerRef" = senderId + AND "receivingPartnerReferrerRef" = NULL -- NULL, because no supplier is assigned to be checked + AND "communicationRef" = communicationId) + THEN + + INSERT INTO oms."CommunicationPartnerDO" + ( + id, + "decisionBeanDefRef", + "splitTransmission", + "communicationRef", + "sendingPartnerReferrerRef", + "receivingPartnerReferrerRef", + "maxNoOfRetries", + "retryDelay", + "splitTransmissionPerSupplier" + ) + SELECT + nextval('"CommunicationPartnerDO_id_seq"'), + db_shop_transmission, -- skip export ? + false, + communicationId, + senderId, -- a shop + NULL, -- NULL, because no supplier is assigned to be checked + 5, + '2m', + false; + + END IF; + + END LOOP; + + + + /* + SUPPLIER MESSAGES + */ + -- RESPONSE EXPORT/TRANSMISSION -- REGISTER supplierMessageTransmitter for responses INSERT INTO oms."CommunicationDO" ( - id, + id, active, "activeOMT", key, @@ -113,17 +204,17 @@ BEGIN "communicationVersionDefRef", "transmissionFormDefRef" ) - SELECT + SELECT nextval('"CommunicationDO_id_seq"'), true, null, supplier_transmitter_key_res, - (SELECT id FROM oms."DocumentFormatDefDO" WHERE name = 'XML'), - (SELECT id FROM oms."ExecutionBeanDefDO" WHERE description = supplier_transmitter), - (SELECT id FROM oms."TransmissionTypeDefDO" WHERE name = 'sendResponse'), - (SELECT id FROM oms."CommunicationVersionDefDO" WHERE "incomingURLParameter" = 'v1.0'), - (SELECT id FROM oms."TransmissionFormDefDO" WHERE name = 'PUSH') - WHERE NOT EXISTS (SELECT * FROM oms."CommunicationDO" WHERE key = supplier_transmitter_key_res); + id_docformat_xml, + eb_supplier_transmitter, + id_transtype_sendresponse, + id_commversion_1, + id_transform_push + WHERE NOT EXISTS (SELECT * FROM oms."CommunicationDO" WHERE key = supplier_transmitter_key_res); communicationId := (SELECT id FROM oms."CommunicationDO" WHERE key = supplier_transmitter_key_res); @@ -139,8 +230,7 @@ BEGIN senderId := (SELECT id FROM oms."PartnerReferrerDO" WHERE "supplierRef" = supplierId); IF NOT EXISTS (SELECT * FROM "CommunicationPartnerDO" - WHERE "sendingPartnerReferrerRef" = senderId - --AND "receivingPartnerReferrerRef" = receiverId + WHERE "sendingPartnerReferrerRef" = senderId AND "communicationRef" = communicationId) THEN @@ -158,10 +248,10 @@ BEGIN ) SELECT nextval('"CommunicationPartnerDO_id_seq"'), - (SELECT id FROM oms."DecisionBeanDefDO" WHERE description = supplier_decisionBean), -- skip export ? + db_supplier_transmission, -- skip export ? false, communicationId, - senderId, -- a supplier + senderId, -- a supplier null, 5, '2m', @@ -179,7 +269,7 @@ BEGIN -- REGISTER supplierMessageTransmitter for dispatches INSERT INTO oms."CommunicationDO" ( - id, + id, active, "activeOMT", key, @@ -189,17 +279,17 @@ BEGIN "communicationVersionDefRef", "transmissionFormDefRef" ) - SELECT + SELECT nextval('"CommunicationDO_id_seq"'), true, null, supplier_transmitter_key_dis, - (SELECT id FROM oms."DocumentFormatDefDO" WHERE name = 'XML'), - (SELECT id FROM oms."ExecutionBeanDefDO" WHERE description = supplier_transmitter), - (SELECT id FROM oms."TransmissionTypeDefDO" WHERE name = 'sendDispatch'), - (SELECT id FROM oms."CommunicationVersionDefDO" WHERE "incomingURLParameter" = 'v1.0'), - (SELECT id FROM oms."TransmissionFormDefDO" WHERE name = 'PUSH') - WHERE NOT EXISTS (SELECT * FROM oms."CommunicationDO" WHERE key = supplier_transmitter_key_dis); + id_docformat_xml, + eb_supplier_transmitter, + id_transtype_senddispatch, + id_commversion_1, + id_transform_push + WHERE NOT EXISTS (SELECT * FROM oms."CommunicationDO" WHERE key = supplier_transmitter_key_dis); communicationId := (SELECT id FROM oms."CommunicationDO" WHERE key = supplier_transmitter_key_dis); @@ -215,8 +305,7 @@ BEGIN senderId := (SELECT id FROM oms."PartnerReferrerDO" WHERE "supplierRef" = supplierId); IF NOT EXISTS (SELECT * FROM "CommunicationPartnerDO" - WHERE "sendingPartnerReferrerRef" = senderId - --AND "receivingPartnerReferrerRef" = receiverId + WHERE "sendingPartnerReferrerRef" = senderId AND "communicationRef" = communicationId) THEN @@ -232,12 +321,12 @@ BEGIN "retryDelay", "splitTransmissionPerSupplier" ) - SELECT + SELECT nextval('"CommunicationPartnerDO_id_seq"'), - (SELECT id FROM oms."DecisionBeanDefDO" WHERE description = supplier_decisionBean), -- skip export ? + db_supplier_transmission, -- skip export ? false, communicationId, - senderId, -- a supplier + senderId, -- a supplier null, 5, '2m', @@ -255,7 +344,7 @@ BEGIN -- REGISTER supplierMessageTransmitter for returns INSERT INTO oms."CommunicationDO" ( - id, + id, active, "activeOMT", key, @@ -265,17 +354,17 @@ BEGIN "communicationVersionDefRef", "transmissionFormDefRef" ) - SELECT + SELECT nextval('"CommunicationDO_id_seq"'), true, null, supplier_transmitter_key_ret, - (SELECT id FROM oms."DocumentFormatDefDO" WHERE name = 'XML'), - (SELECT id FROM oms."ExecutionBeanDefDO" WHERE description = supplier_transmitter), - (SELECT id FROM oms."TransmissionTypeDefDO" WHERE name = 'sendReturn'), - (SELECT id FROM oms."CommunicationVersionDefDO" WHERE "incomingURLParameter" = 'v1.0'), - (SELECT id FROM oms."TransmissionFormDefDO" WHERE name = 'PUSH') - WHERE NOT EXISTS (SELECT * FROM oms."CommunicationDO" WHERE key = supplier_transmitter_key_ret); + id_docformat_xml, + eb_supplier_transmitter, + id_transtype_sendreturn, + id_commversion_1, + id_transform_push + WHERE NOT EXISTS (SELECT * FROM oms."CommunicationDO" WHERE key = supplier_transmitter_key_ret); communicationId := (SELECT id FROM oms."CommunicationDO" WHERE key = supplier_transmitter_key_ret); @@ -290,8 +379,7 @@ BEGIN senderId := (SELECT id FROM oms."PartnerReferrerDO" WHERE "supplierRef" = supplierId); IF NOT EXISTS (SELECT * FROM "CommunicationPartnerDO" - WHERE "sendingPartnerReferrerRef" = senderId - --AND "receivingPartnerReferrerRef" = receiverId + WHERE "sendingPartnerReferrerRef" = senderId AND "communicationRef" = communicationId) THEN @@ -309,10 +397,10 @@ BEGIN ) SELECT nextval('"CommunicationPartnerDO_id_seq"'), - (SELECT id FROM oms."DecisionBeanDefDO" WHERE description = supplier_decisionBean), -- skip export ? + db_supplier_transmission, -- skip export ? false, communicationId, - senderId, -- a supplier + senderId, -- a supplier null, 5, '2m', diff --git a/src/sql-config/config/base/090_UsersRolesRights.sql b/src/sql-config/config/base/090_UsersRolesRights.sql index 14d6ea9..039e7dc 100644 --- a/src/sql-config/config/base/090_UsersRolesRights.sql +++ b/src/sql-config/config/base/090_UsersRolesRights.sql @@ -26,8 +26,7 @@ shop_service_rights int8[] = ARRAY[1,2,67,123,124,125,126,131,137,139,140,141,14 --technical supplier APIs supplier_service_user_name text = 'webservice_supplier'; --if you change the name, change cryptedPassword too supplier_service_role_name text = 'supplier_services'; - --returns, ATP, Dispatches Create_receipt_message -supplier_service_rights int8[] = ARRAY[131,139,140,141,142, 123, 10,11, 13]; +supplier_service_rights int8[] = ARRAY[7,10,11,13,123,131,139,140,141,142]; --technical supplier API @@ -238,6 +237,16 @@ BEGIN FROM "RoleDO" WHERE "name" IN( user_admin_role_name) ON CONFLICT ("organizationRef", "roleRef", "userRef") DO NOTHING; + -- Ensure that the role FullPlatformAdmin present in the initial database has all existing rights + -- NOT RECOMMENED FOR PRODUCTIVE SYSTEMS + + WITH ADMINROLE as (select id from "RoleDO" WHERE name='FullPlatformAdmin') + INSERT INTO "Role2RightDO" ("rightDefRef", "roleRef") + SELECT r.id, adminRole.id + FROM "RightDefDO" r JOIN ADMINROLE ON true + EXCEPT -- already in + SELECT "rightDefRef", "roleRef" FROM "Role2RightDO" + WHERE "roleRef" = (select id from ADMINROLE); END; diff --git a/src/sql-config/config/vars.vm b/src/sql-config/config/vars.vm index 50c2b80..682652c 100644 --- a/src/sql-config/config/vars.vm +++ b/src/sql-config/config/vars.vm @@ -54,19 +54,20 @@ av_erp_endpoint varchar = ''erpEndpointUrl''; av_erp_username varchar = ''erpUsername''; av_erp_password varchar = ''erpPassword''; - - ') #set($vars_execution_beans = ' -eb_erp int = 1000; - +eb_shop_transmitter int = 10000; +eb_supplier_transmitter int = 20000; ') #set($vars_decision_beans = ' -- decision beans db_mail int = 1000; db_invoicing int = 10001; +db_shop_transmission int = 40000; +db_supplier_transmission int = 41000; +db_send_email int = 50000; ') #set($vars_payment_methods = ' diff --git a/src/sql-config/dbmigrate/001_ExpandedEnumerations.sql b/src/sql-config/dbmigrate/001_ExpandedEnumerations.sql index 3fc1e17..700c024 100644 --- a/src/sql-config/dbmigrate/001_ExpandedEnumerations.sql +++ b/src/sql-config/dbmigrate/001_ExpandedEnumerations.sql @@ -13,15 +13,16 @@ BEGIN (10001, 'invoicingDecisionBean'), (20000, 'codPaymentDecisionBean'), (20001, 'maxOrderValueDecisionBean'), - (40000, 'orderTransmissionDecisionBean'), - (41000, 'supplierTransmissionDecisionBean') + (40000, 'shopTransmissionDecisionBean'), + (41000, 'supplierTransmissionDecisionBean'), + (50000, 'sendEmailDecisionBean') ON CONFLICT (id) DO NOTHING; --EXECUTION BEANS INSERT INTO oms."ExecutionBeanDefDO"(id, "decisionBeanDefRef", description) values - (10000, null, 'customOrderMessageTransmitter'), + (10000, null, 'shopMessageTransmitter'), (20000, null, 'supplierMessageTransmitter') ON CONFLICT (id) DO NOTHING; diff --git a/testframework-config.user.yaml b/testframework-config.user.yaml deleted file mode 100644 index e2a87d0..0000000 --- a/testframework-config.user.yaml +++ /dev/null @@ -1,18 +0,0 @@ -testframework: - default-endpoint: - version: "V1" - username: "admin" - password: "!InterShop00!" - endpoint: - host: "localhost" - port: 8130 - protocol: "http" - database: - default: - version: "V1" - endpoint: - host: "localhost:5482" - username: "oms_user" - password: "oms_pw" - parameters: - dbName: "oms_db" \ No newline at end of file diff --git a/testframework-config.yaml b/testframework-config.yaml index 26f1e40..d5442d2 100644 --- a/testframework-config.yaml +++ b/testframework-config.yaml @@ -1,7 +1,10 @@ testframework: + default-endpoint: + username: "admin" + password: "!InterShop00!" order-service: default: version: "V2_2" supplier-service: default: - version: "V2_11" \ No newline at end of file + version: "V2_11"