commit cecef19c4a26f699c7b149a14a896aeb6d827578 Author: jkhong Date: Thu Aug 24 16:34:53 2023 +0900 first diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2a3040 --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..e76d1f3 --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..2cc7d4a Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..642d572 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/lib/apptemplate-log4j2.jar b/lib/apptemplate-log4j2.jar new file mode 100644 index 0000000..3568301 Binary files /dev/null and b/lib/apptemplate-log4j2.jar differ diff --git a/lib/apptemplate-log4j2/apptemplate-log4j2/9.0.007/apptemplate-log4j2.jar b/lib/apptemplate-log4j2/apptemplate-log4j2/9.0.007/apptemplate-log4j2.jar new file mode 100644 index 0000000..3568301 Binary files /dev/null and b/lib/apptemplate-log4j2/apptemplate-log4j2/9.0.007/apptemplate-log4j2.jar differ diff --git a/lib/apptemplate.jar b/lib/apptemplate.jar new file mode 100644 index 0000000..9891bfb Binary files /dev/null and b/lib/apptemplate.jar differ diff --git a/lib/apptemplate/apptemplate/9.0.007/apptemplate.jar b/lib/apptemplate/apptemplate/9.0.007/apptemplate.jar new file mode 100644 index 0000000..9891bfb Binary files /dev/null and b/lib/apptemplate/apptemplate/9.0.007/apptemplate.jar differ diff --git a/lib/clusterprotocolappblock.jar b/lib/clusterprotocolappblock.jar new file mode 100644 index 0000000..157e85d Binary files /dev/null and b/lib/clusterprotocolappblock.jar differ diff --git a/lib/clusterprotocolappblock/clusterprotocolappblock/9.0.007/clusterprotocolappblock.jar b/lib/clusterprotocolappblock/clusterprotocolappblock/9.0.007/clusterprotocolappblock.jar new file mode 100644 index 0000000..157e85d Binary files /dev/null and b/lib/clusterprotocolappblock/clusterprotocolappblock/9.0.007/clusterprotocolappblock.jar differ diff --git a/lib/comappblock.jar b/lib/comappblock.jar new file mode 100644 index 0000000..5e880fb Binary files /dev/null and b/lib/comappblock.jar differ diff --git a/lib/comappblock/comappblock/9.0.007/comappblock.jar b/lib/comappblock/comappblock/9.0.007/comappblock.jar new file mode 100644 index 0000000..5e880fb Binary files /dev/null and b/lib/comappblock/comappblock/9.0.007/comappblock.jar differ diff --git a/lib/commons.jar b/lib/commons.jar new file mode 100644 index 0000000..fda126f Binary files /dev/null and b/lib/commons.jar differ diff --git a/lib/commons/commons/9.0.007/commons.jar b/lib/commons/commons/9.0.007/commons.jar new file mode 100644 index 0000000..fda126f Binary files /dev/null and b/lib/commons/commons/9.0.007/commons.jar differ diff --git a/lib/commonsappblock.jar b/lib/commonsappblock.jar new file mode 100644 index 0000000..2a26345 Binary files /dev/null and b/lib/commonsappblock.jar differ diff --git a/lib/commonsappblock/commonsappblock/9.0.007/commonsappblock.jar b/lib/commonsappblock/commonsappblock/9.0.007/commonsappblock.jar new file mode 100644 index 0000000..2a26345 Binary files /dev/null and b/lib/commonsappblock/commonsappblock/9.0.007/commonsappblock.jar differ diff --git a/lib/configurationprotocol.jar b/lib/configurationprotocol.jar new file mode 100644 index 0000000..36f03e6 Binary files /dev/null and b/lib/configurationprotocol.jar differ diff --git a/lib/configurationprotocol/configurationprotocol/9.0.007/configurationprotocol.jar b/lib/configurationprotocol/configurationprotocol/9.0.007/configurationprotocol.jar new file mode 100644 index 0000000..36f03e6 Binary files /dev/null and b/lib/configurationprotocol/configurationprotocol/9.0.007/configurationprotocol.jar differ diff --git a/lib/connection.jar b/lib/connection.jar new file mode 100644 index 0000000..b18b725 Binary files /dev/null and b/lib/connection.jar differ diff --git a/lib/connection/connection/9.0.007/connection.jar b/lib/connection/connection/9.0.007/connection.jar new file mode 100644 index 0000000..b18b725 Binary files /dev/null and b/lib/connection/connection/9.0.007/connection.jar differ diff --git a/lib/contactsprotocol.jar b/lib/contactsprotocol.jar new file mode 100644 index 0000000..234c02b Binary files /dev/null and b/lib/contactsprotocol.jar differ diff --git a/lib/contactsprotocol/contactsprotocol/9.0.007/contactsprotocol.jar b/lib/contactsprotocol/contactsprotocol/9.0.007/contactsprotocol.jar new file mode 100644 index 0000000..234c02b Binary files /dev/null and b/lib/contactsprotocol/contactsprotocol/9.0.007/contactsprotocol.jar differ diff --git a/lib/jackson2-module.jar b/lib/jackson2-module.jar new file mode 100644 index 0000000..d9acf1d Binary files /dev/null and b/lib/jackson2-module.jar differ diff --git a/lib/jackson2-module/jackson2-module/9.0.007/jackson2-module.jar b/lib/jackson2-module/jackson2-module/9.0.007/jackson2-module.jar new file mode 100644 index 0000000..d9acf1d Binary files /dev/null and b/lib/jackson2-module/jackson2-module/9.0.007/jackson2-module.jar differ diff --git a/lib/kvlistbinding.jar b/lib/kvlistbinding.jar new file mode 100644 index 0000000..c5e851c Binary files /dev/null and b/lib/kvlistbinding.jar differ diff --git a/lib/kvlistbinding/kvlistbinding/9.0.007/kvlistbinding.jar b/lib/kvlistbinding/kvlistbinding/9.0.007/kvlistbinding.jar new file mode 100644 index 0000000..c5e851c Binary files /dev/null and b/lib/kvlistbinding/kvlistbinding/9.0.007/kvlistbinding.jar differ diff --git a/lib/kvlists.jar b/lib/kvlists.jar new file mode 100644 index 0000000..afc6841 Binary files /dev/null and b/lib/kvlists.jar differ diff --git a/lib/kvlists/kvlists/9.0.007/kvlists.jar b/lib/kvlists/kvlists/9.0.007/kvlists.jar new file mode 100644 index 0000000..afc6841 Binary files /dev/null and b/lib/kvlists/kvlists/9.0.007/kvlists.jar differ diff --git a/lib/logging.jar b/lib/logging.jar new file mode 100644 index 0000000..b2598c8 Binary files /dev/null and b/lib/logging.jar differ diff --git a/lib/logging/logging/9.0.007/logging.jar b/lib/logging/logging/9.0.007/logging.jar new file mode 100644 index 0000000..b2598c8 Binary files /dev/null and b/lib/logging/logging/9.0.007/logging.jar differ diff --git a/lib/managementprotocol.jar b/lib/managementprotocol.jar new file mode 100644 index 0000000..1e53618 Binary files /dev/null and b/lib/managementprotocol.jar differ diff --git a/lib/managementprotocol/managementprotocol/9.0.007/managementprotocol.jar b/lib/managementprotocol/managementprotocol/9.0.007/managementprotocol.jar new file mode 100644 index 0000000..1e53618 Binary files /dev/null and b/lib/managementprotocol/managementprotocol/9.0.007/managementprotocol.jar differ diff --git a/lib/messagebrokerappblock.jar b/lib/messagebrokerappblock.jar new file mode 100644 index 0000000..b7fa2fb Binary files /dev/null and b/lib/messagebrokerappblock.jar differ diff --git a/lib/messagebrokerappblock/messagebrokerappblock/9.0.007/messagebrokerappblock.jar b/lib/messagebrokerappblock/messagebrokerappblock/9.0.007/messagebrokerappblock.jar new file mode 100644 index 0000000..b7fa2fb Binary files /dev/null and b/lib/messagebrokerappblock/messagebrokerappblock/9.0.007/messagebrokerappblock.jar differ diff --git a/lib/netty-all-4.1.51.Final.jar b/lib/netty-all-4.1.51.Final.jar new file mode 100644 index 0000000..e9b056a Binary files /dev/null and b/lib/netty-all-4.1.51.Final.jar differ diff --git a/lib/netty-all-4.1.51.Final/netty-all-4.1.51.Final/4.1.51.Final/netty-all-4.1.51.Final.jar b/lib/netty-all-4.1.51.Final/netty-all-4.1.51.Final/4.1.51.Final/netty-all-4.1.51.Final.jar new file mode 100644 index 0000000..e9b056a Binary files /dev/null and b/lib/netty-all-4.1.51.Final/netty-all-4.1.51.Final/4.1.51.Final/netty-all-4.1.51.Final.jar differ diff --git a/lib/openmediaprotocol.jar b/lib/openmediaprotocol.jar new file mode 100644 index 0000000..85305c5 Binary files /dev/null and b/lib/openmediaprotocol.jar differ diff --git a/lib/openmediaprotocol/openmediaprotocol/9.0.007/openmediaprotocol.jar b/lib/openmediaprotocol/openmediaprotocol/9.0.007/openmediaprotocol.jar new file mode 100644 index 0000000..85305c5 Binary files /dev/null and b/lib/openmediaprotocol/openmediaprotocol/9.0.007/openmediaprotocol.jar differ diff --git a/lib/outboundprotocol.jar b/lib/outboundprotocol.jar new file mode 100644 index 0000000..853f635 Binary files /dev/null and b/lib/outboundprotocol.jar differ diff --git a/lib/outboundprotocol/outboundprotocol/9.0.007/outboundprotocol.jar b/lib/outboundprotocol/outboundprotocol/9.0.007/outboundprotocol.jar new file mode 100644 index 0000000..853f635 Binary files /dev/null and b/lib/outboundprotocol/outboundprotocol/9.0.007/outboundprotocol.jar differ diff --git a/lib/protocol.jar b/lib/protocol.jar new file mode 100644 index 0000000..9c1b5c2 Binary files /dev/null and b/lib/protocol.jar differ diff --git a/lib/protocol/protocol/9.0.007/protocol.jar b/lib/protocol/protocol/9.0.007/protocol.jar new file mode 100644 index 0000000..9c1b5c2 Binary files /dev/null and b/lib/protocol/protocol/9.0.007/protocol.jar differ diff --git a/lib/protocolmanagerappblock.jar b/lib/protocolmanagerappblock.jar new file mode 100644 index 0000000..a344ef3 Binary files /dev/null and b/lib/protocolmanagerappblock.jar differ diff --git a/lib/protocolmanagerappblock/protocolmanagerappblock/9.0.007/protocolmanagerappblock.jar b/lib/protocolmanagerappblock/protocolmanagerappblock/9.0.007/protocolmanagerappblock.jar new file mode 100644 index 0000000..a344ef3 Binary files /dev/null and b/lib/protocolmanagerappblock/protocolmanagerappblock/9.0.007/protocolmanagerappblock.jar differ diff --git a/lib/reportingprotocol.jar b/lib/reportingprotocol.jar new file mode 100644 index 0000000..17d2bf9 Binary files /dev/null and b/lib/reportingprotocol.jar differ diff --git a/lib/reportingprotocol/reportingprotocol/9.0.007/reportingprotocol.jar b/lib/reportingprotocol/reportingprotocol/9.0.007/reportingprotocol.jar new file mode 100644 index 0000000..17d2bf9 Binary files /dev/null and b/lib/reportingprotocol/reportingprotocol/9.0.007/reportingprotocol.jar differ diff --git a/lib/routingprotocol.jar b/lib/routingprotocol.jar new file mode 100644 index 0000000..51d32b9 Binary files /dev/null and b/lib/routingprotocol.jar differ diff --git a/lib/routingprotocol/routingprotocol/9.0.007/routingprotocol.jar b/lib/routingprotocol/routingprotocol/9.0.007/routingprotocol.jar new file mode 100644 index 0000000..51d32b9 Binary files /dev/null and b/lib/routingprotocol/routingprotocol/9.0.007/routingprotocol.jar differ diff --git a/lib/system.jar b/lib/system.jar new file mode 100644 index 0000000..bef9296 Binary files /dev/null and b/lib/system.jar differ diff --git a/lib/system/system/9.0.007/system.jar b/lib/system/system/9.0.007/system.jar new file mode 100644 index 0000000..bef9296 Binary files /dev/null and b/lib/system/system/9.0.007/system.jar differ diff --git a/lib/voiceprotocol.jar b/lib/voiceprotocol.jar new file mode 100644 index 0000000..5c730b5 Binary files /dev/null and b/lib/voiceprotocol.jar differ diff --git a/lib/voiceprotocol/voiceprotocol/9.0.007/voiceprotocol.jar b/lib/voiceprotocol/voiceprotocol/9.0.007/voiceprotocol.jar new file mode 100644 index 0000000..5c730b5 Binary files /dev/null and b/lib/voiceprotocol/voiceprotocol/9.0.007/voiceprotocol.jar differ diff --git a/lib/warmstandbyappblock.jar b/lib/warmstandbyappblock.jar new file mode 100644 index 0000000..6d59caf Binary files /dev/null and b/lib/warmstandbyappblock.jar differ diff --git a/lib/warmstandbyappblock/warmstandbyappblock/9.0.007/warmstandbyappblock.jar b/lib/warmstandbyappblock/warmstandbyappblock/9.0.007/warmstandbyappblock.jar new file mode 100644 index 0000000..6d59caf Binary files /dev/null and b/lib/warmstandbyappblock/warmstandbyappblock/9.0.007/warmstandbyappblock.jar differ diff --git a/lib/webmediaprotocol.jar b/lib/webmediaprotocol.jar new file mode 100644 index 0000000..5d0b1cf Binary files /dev/null and b/lib/webmediaprotocol.jar differ diff --git a/lib/webmediaprotocol/webmediaprotocol/9.0.007/webmediaprotocol.jar b/lib/webmediaprotocol/webmediaprotocol/9.0.007/webmediaprotocol.jar new file mode 100644 index 0000000..5d0b1cf Binary files /dev/null and b/lib/webmediaprotocol/webmediaprotocol/9.0.007/webmediaprotocol.jar differ diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..a16b543 --- /dev/null +++ b/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b04b400 --- /dev/null +++ b/pom.xml @@ -0,0 +1,259 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.5.1 + + + kr.co.i4way + Gen_Web_API + 0.0.1-SNAPSHOT + Gen_Web_API + Genesys Web Application + + + 1.8 + 3.1.1 + + + + + + org.springframework.boot + spring-boot-starter-web + + + + com.oracle.database.jdbc + ojdbc8 + runtime + + + mysql + mysql-connector-java + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + + + commons-codec + commons-codec + 1.11 + + + + org.json + json + 20180813 + + + + + net.minidev + json-smart + 2.3 + + + + + apptemplate + apptemplate + 9.0.007 + system + ${basedir}/lib/apptemplate.jar + + + apptemplate-log4j2 + apptemplate-log4j2 + 9.0.007 + system + ${basedir}/lib/apptemplate-log4j2.jar + + + clusterprotocolappblock + clusterprotocolappblock + 9.0.007 + system + ${basedir}/lib/clusterprotocolappblock.jar + + + comappblock + comappblock + 9.0.007 + system + ${basedir}/lib/comappblock.jar + + + commons + commons + 9.0.007 + system + ${basedir}/lib/commons.jar + + + commonsappblock + commonsappblock + 9.0.007 + system + ${basedir}/lib/commonsappblock.jar + + + configurationprotocol + configurationprotocol + 9.0.007 + system + ${basedir}/lib/configurationprotocol.jar + + + connection + connection + 9.0.007 + system + ${basedir}/lib/connection.jar + + + contactsprotocol + contactsprotocol + 9.0.007 + system + ${basedir}/lib/contactsprotocol.jar + + + jackson2-module + jackson2-module + 9.0.007 + system + ${basedir}/lib/jackson2-module.jar + + + kvlistbinding + kvlistbinding + 9.0.007 + system + ${basedir}/lib/kvlistbinding.jar + + + kvlists + kvlists + 9.0.007 + system + ${basedir}/lib/kvlists.jar + + + logging + logging + 9.0.007 + system + ${basedir}/lib/logging.jar + + + managementprotocol + managementprotocol + 9.0.007 + system + ${basedir}/lib/managementprotocol.jar + + + messagebrokerappblock + messagebrokerappblock + 9.0.007 + system + ${basedir}/lib/messagebrokerappblock.jar + + + netty-all-4.1.51.Final + netty-all-4.1.51.Final + 4.1.51.Final + system + ${basedir}/lib/netty-all-4.1.51.Final.jar + + + openmediaprotocol + openmediaprotocol + 9.0.007 + system + ${basedir}/lib/openmediaprotocol.jar + + + outboundprotocol + outboundprotocol + 9.0.007 + system + ${basedir}/lib/outboundprotocol.jar + + + protocol + protocol + 9.0.007 + system + ${basedir}/lib/protocol.jar + + + protocolmanagerappblock + protocolmanagerappblock + 9.0.007 + system + ${basedir}/lib/protocolmanagerappblock.jar + + + reportingprotocol + reportingprotocol + 9.0.007 + system + ${basedir}/lib/reportingprotocol.jar + + + routingprotocol + routingprotocol + 9.0.007 + system + ${basedir}/lib/routingprotocol.jar + + + system + system + 9.0.007 + system + ${basedir}/lib/system.jar + + + voiceprotocol + voiceprotocol + 9.0.007 + system + ${basedir}/lib/voiceprotocol.jar + + + warmstandbyappblock + warmstandbyappblock + 9.0.007 + system + ${basedir}/lib/warmstandbyappblock.jar + + + webmediaprotocol + webmediaprotocol + 9.0.007 + system + ${basedir}/lib/webmediaprotocol.jar + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/src/main/java/kr/co/i4way/I4way_Service.java b/src/main/java/kr/co/i4way/I4way_Service.java new file mode 100644 index 0000000..0e70e61 --- /dev/null +++ b/src/main/java/kr/co/i4way/I4way_Service.java @@ -0,0 +1,40 @@ +/* +package kr.co.i4way; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +//외장Tomcat 사용시 +@SpringBootApplication +//@EnableScheduling +public class I4way_Service extends SpringBootServletInitializer{ + + public static void main(String[] args) { + SpringApplication.run(I4way_Service.class, args); + } + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { + return builder.sources(I4way_Service.class); + } +} +*/ + +/* 내장Tomcat 사용시*/ +package kr.co.i4way; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication +//@EnableScheduling +public class I4way_Service { + + public static void main(String[] args) { + SpringApplication.run(I4way_Service.class, args); + } + +} diff --git a/src/main/java/kr/co/i4way/common/CommandMap.java b/src/main/java/kr/co/i4way/common/CommandMap.java new file mode 100644 index 0000000..c17a5c3 --- /dev/null +++ b/src/main/java/kr/co/i4way/common/CommandMap.java @@ -0,0 +1,54 @@ +package kr.co.i4way.common; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +public class CommandMap { + Map map = new HashMap(); + + public Object get(String key){ + return map.get(key); + } + + public void put(String key, Object value){ + map.put(key, value); + } + + public Object remove(String key){ + return map.remove(key); + } + + public boolean containsKey(String key){ + return map.containsKey(key); + } + + public boolean containsValue(Object value){ + return map.containsValue(value); + } + + public void clear(){ + map.clear(); + } + + public Set> entrySet(){ + return map.entrySet(); + } + + public Set keySet(){ + return map.keySet(); + } + + public boolean isEmpty(){ + return map.isEmpty(); + } + + public void putAll(Map m){ + map.putAll(m); + } + + public Map getMap(){ + return map; + } +} \ No newline at end of file diff --git a/src/main/java/kr/co/i4way/common/util/CipherAES.java b/src/main/java/kr/co/i4way/common/util/CipherAES.java new file mode 100644 index 0000000..6b73f00 --- /dev/null +++ b/src/main/java/kr/co/i4way/common/util/CipherAES.java @@ -0,0 +1,74 @@ +package kr.co.i4way.common.util; + +import java.lang.reflect.Field; +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import org.apache.commons.codec.binary.Base64; + +public class CipherAES { + static String AES_CBC_PKCS5Padding = "AES/CBC/PKCS5Padding"; + + static String MONITOR_KEY_VALUE = "BLUEQsiteUSE#MNS"; + static String MONITOR_IV_VALUE = "SmartLOGIN201407"; + + private static String getKeyIvValue(String staticValue) throws Exception { + Class cipherAes = CipherAES.class; + Field cipherAesFields[] = cipherAes.getDeclaredFields(); + + String keyIvValue = ""; + for (int i = 0; i < cipherAesFields.length; i++) { + if (staticValue.equals(cipherAesFields[i].getName())) { + keyIvValue = (String) cipherAesFields[i].get(cipherAes); + + break; + } + } + return keyIvValue; + } + +// Key 생성 + public static SecretKey generateKey(String keyValue) throws Exception { + return new SecretKeySpec(keyValue.getBytes("UTF-8"), "AES"); + } + +// 복호화(String Decode) + public static String decrypt(String keyScn, String param) throws Exception { + System.out.println("keyScn==>"+keyScn); + System.out.println("param==>"+param); + return decrypt(AES_CBC_PKCS5Padding, param, getKeyIvValue(keyScn + "_KEY_VALUE"), + getKeyIvValue(keyScn + "_IV_VALUE"), "string"); + } + +// 복호화 + public static String decrypt(String transType, String srcData, String keyValue, String ivValue, String encodeType) + throws Exception { + String result = ""; + byte[] decData = null; + + try { + SecretKey key = generateKey(keyValue); + + Cipher cipher = Cipher.getInstance(transType); + + if (transType.equals(AES_CBC_PKCS5Padding)) { + if (null != ivValue && ivValue.length() > 0) { + cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(ivValue.getBytes())); + } else { + cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(new byte[16])); + } + } else { + cipher.init(Cipher.DECRYPT_MODE, key); + } + + decData = cipher.doFinal(Base64.decodeBase64(srcData)); + + result = new String(decData); + } catch (Exception e) { + result = ""; + } + + return result; + } +} diff --git a/src/main/java/kr/co/i4way/common/util/JsonUtil.java b/src/main/java/kr/co/i4way/common/util/JsonUtil.java new file mode 100644 index 0000000..1c39336 --- /dev/null +++ b/src/main/java/kr/co/i4way/common/util/JsonUtil.java @@ -0,0 +1,117 @@ +package kr.co.i4way.common.util; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import net.minidev.json.JSONArray; +import net.minidev.json.JSONObject; + +/** + * 일반문자열 유틸. + * + * @author someone + * @version 1.0.0 + */ +public class JsonUtil { + + /** + * Map을 json으로 변환한다. + * + * @param map Map. + * @return JSONObject. + */ + public static JSONObject getJsonStringFromMap( Map map ) + { + JSONObject jsonObject = new JSONObject(); + for( Map.Entry entry : map.entrySet() ) { + String key = entry.getKey(); + Object value = entry.getValue(); + jsonObject.put(key, value); + } + + return jsonObject; + } + + /** + * List을 jsonArray로 변환한다. + * + * @param list List>. + * @return JSONArray. + */ + public static JSONArray getJsonArrayFromList( List> list ) + { + JSONArray jsonArray = new JSONArray(); + for( Map map : list ) { + jsonArray.add( getJsonStringFromMap( map ) ); + } + + return jsonArray; + } + + /** + * List을 jsonString으로 변환한다. + * + * @param list List>. + * @return String. + */ + public static String getJsonStringFromList( List> list ) + { + JSONArray jsonArray = getJsonArrayFromList( list ); + return jsonArray.toJSONString(); + } + + /** + * JsonObject를 Map으로 변환한다. + * + * @param jsonObj JSONObject. + * @return Map. + */ + @SuppressWarnings("unchecked") + public static Map getMapFromJsonObject( JSONObject jsonObj ) + { + Map map = null; + + try { + + map = new ObjectMapper().readValue(jsonObj.toJSONString(), Map.class) ; + + } catch (JsonParseException e) { + e.printStackTrace(); + } catch (JsonMappingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + return map; + } + + /** + * JsonArray를 List>으로 변환한다. + * + * @param jsonArray JSONArray. + * @return List>. + */ + public static List> getListMapFromJsonArray( JSONArray jsonArray ) + { + List> list = new ArrayList>(); + + if( jsonArray != null ) + { + int jsonSize = jsonArray.size(); + for( int i = 0; i < jsonSize; i++ ) + { + Map map = JsonUtil.getMapFromJsonObject( ( JSONObject ) jsonArray.get(i) ); + list.add( map ); + } + } + + return list; + } +} + diff --git a/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigAgentGroup.java b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigAgentGroup.java new file mode 100644 index 0000000..fdac088 --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigAgentGroup.java @@ -0,0 +1,532 @@ +package kr.co.i4way.genesys.cfgserver; + +import java.util.Collection; +import java.util.HashSet; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.genesyslab.platform.applicationblocks.com.ConfigException; +import com.genesyslab.platform.applicationblocks.com.IConfService; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.objects.CfgTreatment; +import com.genesyslab.platform.applicationblocks.com.queries.CfgAgentGroupQuery; +import com.genesyslab.platform.commons.collections.KeyValueCollection; + +public class ConfigAgentGroup { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + ConfigPerson ps = null; + + public ConfigAgentGroup(){ + } + + /** + * AgentGroup을 조회한다. + * @param service + * @param tenant_dbid + * @param group_name + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgAgentGroup getAgentGroupInfo( + final IConfService service, + int tenant_dbid, + String group_name + ) { + CfgAgentGroup agentgroup = null; + try { + CfgAgentGroupQuery agentgroupquery = new CfgAgentGroupQuery(); + agentgroupquery.setTenantDbid(tenant_dbid); + agentgroupquery.setName(group_name); + agentgroup = service.retrieveObject(CfgAgentGroup.class, agentgroupquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return agentgroup; + } + + /** + * AgentGroup을 조회한다. + * @param service + * @param tenant_dbid + * @param group_dbid + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgAgentGroup getAgentGroupInfo( + final IConfService service, + int tenant_dbid, + int group_dbid + ) { + CfgAgentGroup agentgroup = null; + try { + CfgAgentGroupQuery agentgroupquery = new CfgAgentGroupQuery(); + agentgroupquery.setTenantDbid(tenant_dbid); + agentgroupquery.setDbid(group_dbid); + agentgroup = service.retrieveObject(CfgAgentGroup.class, agentgroupquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + + return agentgroup; + } + + /** + * AgentGroup을 조회한다. + * @param iTenantDBID + * @param service + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public Collection getAgentGroupInfo( + final IConfService service, + int tenant_dbid + ) { + Collection agentgroups = null; + try { + CfgAgentGroupQuery agentgroupquery = new CfgAgentGroupQuery(); + agentgroupquery.setTenantDbid(tenant_dbid); + agentgroups = service.retrieveMultipleObjects(CfgAgentGroup.class, + agentgroupquery); + + } catch (ConfigException e) { + logger.error("ConfigException", e); + }catch (InterruptedException e) { + logger.error("InterruptedException", e); + } + return agentgroups; + } + + /** + * AgentGroup에 Assign 조회한다. + * @param service + * @param tenant_dbid + * @param person_dbid + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public Collection getAssignAgentGroup( + final IConfService service, + int tenant_dbid, + int person_dbid + ) { + Collection agentgroups = null; + try { + CfgAgentGroupQuery agentgroupquery = new CfgAgentGroupQuery(); + agentgroupquery.setTenantDbid(tenant_dbid); + agentgroupquery.setPersonDbid(person_dbid); + + agentgroups = service.retrieveMultipleObjects(CfgAgentGroup.class, + agentgroupquery); + + } catch (ConfigException e) { + logger.error("ConfigException", e); + }catch (InterruptedException e) { + logger.error("InterruptedException", e); + } + return agentgroups; + } + + /** + * AgentGroup을 생성한다. + * @param service + * @param tenant_dbid + * @param group_name + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgAgentGroup createAgentGroup( + final IConfService service, + int tenant_dbid, + String group_name) { + CfgGroup group = new CfgGroup(service, null); + CfgAgentGroup cfggroup = null; + KeyValueCollection kvc = new KeyValueCollection(); + + try { + group.setTenantDBID(tenant_dbid); + group.setName(group_name); + kvc.addString("app", "true"); + group.getUserProperties().addList("app", kvc); + //group.setUserProperties(kvc); + + cfggroup = new CfgAgentGroup(service); + cfggroup.setGroupInfo(group); + + //cfggroup.getGroupInfo().setUserProperties(kvc); + //KeyValuePair kv = new KeyValuePair("app", "true"); + //cfggroup.setProperty("app", "true"); + + cfggroup.save(); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return cfggroup; + } + + /** + * AgentGroup을 수정한다 + * @param service + * @param tenant_dbid + * @param group_dbid + * @param group_name + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgAgentGroup modifyAgentGroup( + final IConfService service, + int tenant_dbid, + int group_dbid, + String group_name) { + // Read configuration objects: + CfgAgentGroup agentgroup = null; + try { + CfgAgentGroupQuery agentgroupquery = new CfgAgentGroupQuery(); + agentgroupquery.setTenantDbid(tenant_dbid); + agentgroupquery.setDbid(group_dbid); + agentgroup = service.retrieveObject(CfgAgentGroup.class,agentgroupquery); + + if(agentgroup != null){ + agentgroup.getGroupInfo().setName(group_name); + agentgroup.save(); + } + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + + return agentgroup; + } + + + /** + * AgentGroup을 삭제한다. + * @param service + * @param tenant_dbid + * @param group_dbid + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public Boolean deleteAgentGroup( + final IConfService service, + int tenant_dbid, + int group_dbid) { + Boolean rtnval = false; + + try { + CfgAgentGroupQuery agentgroupquery = new CfgAgentGroupQuery(); + agentgroupquery.setTenantDbid(tenant_dbid); + agentgroupquery.setDbid(group_dbid); + CfgAgentGroup agentgroup = service.retrieveObject(CfgAgentGroup.class,agentgroupquery); + + if(agentgroup != null){ + agentgroup.delete(); + rtnval = true; + } + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnval; + } + + /** + * AgentGroup에 상담사를 Assign한다. + * @param service + * @param tenant_dbid + * @param group_name + * @param employee_ids + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgAgentGroup assignPersonToAgentGroup( + final IConfService service, + int tenant_dbid, + String group_name, + String employee_ids + ) { + CfgAgentGroup agentgroup = null; + Collection rtn_persons = null; + CfgPerson rtn_person = null; + try{ + CfgAgentGroupQuery agentgroupquery = new CfgAgentGroupQuery(); + agentgroupquery.setTenantDbid(tenant_dbid); + agentgroupquery.setName(group_name); + agentgroup = service.retrieveObject(CfgAgentGroup.class, agentgroupquery); + String[] emps = employee_ids.split(","); + if(emps != null && emps.length > 0) { + ps = new ConfigPerson(); + + if(agentgroup != null){ + if(agentgroup.getAgentDBIDs() != null){ + for(int i=0; i(); + + for(int i=0; i rtn_persons = null; + CfgAgentGroup agentgroup = null; + try{ + CfgAgentGroupQuery agentgroupquery = new CfgAgentGroupQuery(); + agentgroupquery.setTenantDbid(tenant_dbid); + agentgroupquery.setDbid(group_dbid); + agentgroup = service.retrieveObject(CfgAgentGroup.class, agentgroupquery); + + if(agentgroup != null){ + if(agentgroup.getAgentDBIDs() != null){ + logger.info("null아님"); + agentgroup.getAgentDBIDs().add(person_dbid); + }else{ + logger.info("null임"); + rtn_persons = ps.getPersonInfo(service, tenant_dbid, person_dbid); + agentgroup.setAgents(rtn_persons); + } + agentgroup.save(); + } + }catch(ConfigException ex){ + logger.error("ConfigException", ex); + } + return agentgroup; + } + + /** + * AgentGroup에 Assign된 상담사를 삭제한다. + * @param service + * @param tenant_dbid + * @param group_dbid + * @param person_dbid + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgAgentGroup removePersonFromAgentGroup( + final IConfService service, + int tenant_dbid, + String group_name, + String employee_ids + ){ + + Boolean rtnval = false; + CfgPerson person = null; + CfgAgentGroup agentgroup = null; + try{ + CfgAgentGroupQuery agentgroupquery = new CfgAgentGroupQuery(); + agentgroupquery.setTenantDbid(tenant_dbid); + agentgroupquery.setName(group_name); + agentgroup = service.retrieveObject(CfgAgentGroup.class, agentgroupquery); + String[] emps = employee_ids.split(","); + if(agentgroup != null){ + ps = new ConfigPerson(); + for(int i=0; i rtnpersons = new HashSet(); + s_agentgroup.setAgents(rtnpersons); + s_agentgroup.save(); + } + } + } + } + }catch(ConfigException ex){ + logger.error("ConfigException", ex); + } + return t_agentgroup; + } + + /** + * Source AgentGroup에 속한 Person을 Target AgentGroup으로 이동한다. + * @param service + * @param tenant_dbid + * @param source_group_name + * @param target_group_name + * @param employee_ids + * @param delete_yn + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgAgentGroup movePerson2( + final IConfService service, + int tenant_dbid, + String source_group_name, + String target_group_name, + String employee_ids, + String delete_yn + ){ + + Boolean rtnval = false; + CfgAgentGroup s_agentgroup = null; + CfgAgentGroup t_agentgroup = null; + Collection rtn_persons = null; + try{ + CfgAgentGroupQuery agentgroupquery = new CfgAgentGroupQuery(); + agentgroupquery.setTenantDbid(tenant_dbid); + agentgroupquery.setName(source_group_name); + s_agentgroup = service.retrieveObject(CfgAgentGroup.class, agentgroupquery); + agentgroupquery.setName(target_group_name); + t_agentgroup = service.retrieveObject(CfgAgentGroup.class, agentgroupquery); + String[] emps = employee_ids.split(","); + if(s_agentgroup != null) { + if(s_agentgroup.getAgentDBIDs() != null) { + if(t_agentgroup != null) { + + + if(emps != null && emps.length > 0) { + if(t_agentgroup.getAgentDBIDs() != null) { //Person이 있을때 (있는거에 add) + for(CfgPerson person : s_agentgroup.getAgents()) { + for(int i=0; i(); + for(CfgPerson person : s_agentgroup.getAgents()) { + for(int i=0; i delpersons = s_agentgroup.getAgents(); + if(delpersons != null) { + if(rtn_persons != null) { + for(CfgPerson ps : rtn_persons) { + delpersons.remove(ps); + } + }else { + delpersons = new HashSet(); + } + }else { + delpersons = new HashSet(); + } + s_agentgroup.setAgents(delpersons); + s_agentgroup.save(); + } + } + } + } + }catch(ConfigException ex){ + logger.error("ConfigException", ex); + } + return t_agentgroup; + } +} diff --git a/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigAgentLogin.java b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigAgentLogin.java new file mode 100644 index 0000000..42937ed --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigAgentLogin.java @@ -0,0 +1,246 @@ +package kr.co.i4way.genesys.cfgserver; + +import java.util.Collection; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.genesyslab.platform.applicationblocks.com.ConfigException; +import com.genesyslab.platform.applicationblocks.com.IConfService; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLoginInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.queries.CfgAgentLoginQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgPersonQuery; +import com.genesyslab.platform.commons.collections.KeyValueCollection; +import com.genesyslab.platform.commons.collections.KeyValuePair; +import com.genesyslab.platform.configuration.protocol.types.CfgObjectState; + +public class ConfigAgentLogin { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + public ConfigAgentLogin() { + + } + + /** + * employee_id에 해당하는 Person에 Assign된 AgentLogin정보를 조회한다. + * @param service + * @param tenant_dbid + * @param employee_id + * @return + */ + public Collection getAgentLoginInfo(final IConfService service, int tenant_dbid, String employee_id){ + CfgPerson tmpCfgPerson = null; + Collection rtnAgentLoginInfo = null; + CfgPersonQuery personquery = new CfgPersonQuery(); + personquery.setTenantDbid(tenant_dbid); + personquery.setEmployeeId(employee_id); + try { + tmpCfgPerson = service.retrieveObject(CfgPerson.class, personquery); + + if(tmpCfgPerson != null) { + rtnAgentLoginInfo = tmpCfgPerson.getAgentInfo().getAgentLogins(); + } + }catch (ConfigException e) { + e.printStackTrace(); + } + + return rtnAgentLoginInfo; + } + + /** + * AgentLogin을 조회한다.(multi) + * @param service + * @param tenant_dbid + * @param switch_dbid + * @param assignable + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public Collection getAgentLogins( + final IConfService service, int tenant_dbid, int switch_dbid, String assignable) + throws ConfigException, InterruptedException { + // Read configuration objects: + CfgAgentLoginQuery agentloginquery = new CfgAgentLoginQuery(); + agentloginquery.setTenantDbid(tenant_dbid); + agentloginquery.setSwitchDbid(switch_dbid); + if(assignable.equals("yes")) { + agentloginquery.setNoPersonDbid(2); + } + + Collection agentlogin = null; + agentlogin = service.retrieveMultipleObjects(CfgAgentLogin.class, + agentloginquery); + return agentlogin; + } + + /** + * AgentLogin을 조회한다. + * @param service + * @param tenant_dbid + * @param switch_dbid + * @param login_code + * @return CfgAgentLogin + * @throws ConfigException + * @throws InterruptedException + */ + public CfgAgentLogin getAgentLogin( + final IConfService service, int tenant_dbid, int switch_dbid, String login_code + ) + throws ConfigException, InterruptedException { + // Read configuration objects: + CfgAgentLogin agentlogin = null; + CfgAgentLoginQuery agentloginquery = new CfgAgentLoginQuery(); + agentloginquery.setTenantDbid(tenant_dbid); + agentloginquery.setSwitchDbid(switch_dbid); + agentloginquery.setLoginCode(login_code); + + agentlogin = service.retrieveObject(CfgAgentLogin.class, agentloginquery); + return agentlogin; + } + + /** + * AgentLogin을 조회한다. + * @param service + * @param tenant_dbid + * @param switch_dbid + * @param agentLogin_dbid + * @return CfgAgentLogin + * @throws ConfigException + * @throws InterruptedException + */ + public CfgAgentLogin getAgentLogin( + final IConfService service, + int tenant_dbid, + int switch_dbid, + int agentLogin_dbid + ) + throws ConfigException, InterruptedException { + // Read configuration objects: + CfgAgentLogin agentlogin = null; + CfgAgentLoginQuery agentloginquery = new CfgAgentLoginQuery(); + agentloginquery.setTenantDbid(tenant_dbid); + agentloginquery.setSwitchDbid(switch_dbid); + agentloginquery.setDbid(agentLogin_dbid); + + agentlogin = service.retrieveObject(CfgAgentLogin.class, agentloginquery); + return agentlogin; + } + + /** + * AgentLogin의 Assign여부를 확인한다. + * @param loginDBID + * @param service + * @return true : Assign 가능, false : 이미 Assign중. + * @throws ConfigException + * @throws InterruptedException + */ + public boolean checkAssignYn(IConfService service, + int tenant_dbid, + int switch_dbid, + String login_code + ) + throws ConfigException, InterruptedException { + boolean rtnval = false; + + String warpuptm = ""; + + CfgAgentLoginQuery loginquery = new CfgAgentLoginQuery(); + loginquery.setTenantDbid(tenant_dbid); + loginquery.setSwitchDbid(switch_dbid); + loginquery.setLoginCode(login_code); + loginquery.setNoPersonDbid(2); + + CfgAgentLogin agentlogin = null; + agentlogin = service.retrieveObject(CfgAgentLogin.class,loginquery); + + if(agentlogin != null){ + KeyValueCollection appOptions = agentlogin.getUserProperties(); + + for(Object selectionObj : appOptions){ + KeyValuePair sectionKvp = (KeyValuePair) selectionObj; + + for (Object recordObj : sectionKvp.getTKVValue()) { + KeyValuePair recordKvp = (KeyValuePair) recordObj; + if(recordKvp.getStringKey().equals("wrap-up-time")){ + warpuptm = recordKvp.getStringValue(); + //logger.info("wrap-up-time=" + warpuptm); + } + } + } + if(warpuptm.equals("")){ + rtnval = true; + }else{ + rtnval = false; + } + } + return rtnval; + } + + /** + * AgentLogin을 생성한다. + * @param service + * @param tenant_dbid + * @param switch_dbid + * @param login_code + * @param switch_folder_dbid + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgAgentLogin createAgentLogin( + final IConfService service, + int tenant_dbid, + int switch_dbid, + String login_code + ) + throws ConfigException, InterruptedException { + // Read configuration objects: + CfgAgentLogin agentlogin = new CfgAgentLogin(service); + agentlogin.setTenantDBID(tenant_dbid); + agentlogin.setSwitchDBID(switch_dbid); + agentlogin.setLoginCode(login_code); + agentlogin.setSwitchSpecificType(1); + + agentlogin.save(); + + return agentlogin; + } + + /** + * AgentLogin을 삭제한다. + * @param service + * @param tenant_dbid + * @param switch_dbid + * @param login_code + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public boolean deleteAgentLogins( + final IConfService service, + int tenant_dbid, + int switch_dbid, + String login_code + ) + throws ConfigException, InterruptedException { + // Read configuration objects: + CfgAgentLogin agentlogin = null; + boolean rtnbool = false; + try{ + CfgAgentLoginQuery agentloginquery = new CfgAgentLoginQuery(); + agentloginquery.setTenantDbid(tenant_dbid); + agentloginquery.setSwitchDbid(switch_dbid); + agentloginquery.setLoginCode(login_code); + + agentlogin = service.retrieveObject(CfgAgentLogin.class,agentloginquery); + agentlogin.delete(); + rtnbool = true; + }catch(Exception e){ + rtnbool = false; + } + return rtnbool; + } + +} diff --git a/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigCallingList.java b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigCallingList.java new file mode 100644 index 0000000..d55f1d7 --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigCallingList.java @@ -0,0 +1,295 @@ +package kr.co.i4way.genesys.cfgserver; + +import java.util.Collection; +import java.util.HashSet; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.genesyslab.platform.applicationblocks.com.ConfigException; +import com.genesyslab.platform.applicationblocks.com.IConfService; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCallingList; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCallingListInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaignGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgFilter; +import com.genesyslab.platform.applicationblocks.com.objects.CfgGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.objects.CfgTableAccess; +import com.genesyslab.platform.applicationblocks.com.objects.CfgTreatment; +import com.genesyslab.platform.applicationblocks.com.queries.CfgAgentGroupQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgCallingListQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgCampaignGroupQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgTableAccessQuery; +import com.genesyslab.platform.commons.collections.KeyValueCollection; +import com.genesyslab.platform.configuration.protocol.types.CfgDialMode; +import com.genesyslab.platform.configuration.protocol.types.CfgFlag; +import com.genesyslab.platform.configuration.protocol.types.CfgObjectType; +import com.genesyslab.platform.configuration.protocol.types.CfgOperationMode; +import com.genesyslab.platform.configuration.protocol.types.CfgOptimizationMethod; + +public class ConfigCallingList { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + ConfigPerson ps = null; + + ConfigOB ob = null; + public ConfigCallingList(){ + } + + /** + * CallingList을 조회한다. + * @param service + * @param tenant_dbid + * @param callinglist_name + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgCallingList getCallingList( + final IConfService service, + int tenant_dbid, + String callinglist_name + ) { + CfgCallingList callinglist = null; + try { + CfgCallingListQuery callinglistquery = new CfgCallingListQuery(); + callinglistquery.setTenantDbid(tenant_dbid); + callinglistquery.setName(callinglist_name); + callinglist = service.retrieveObject(CfgCallingList.class, callinglistquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return callinglist; + } + + /** + * CallingList을 조회한다. + * @param service + * @param tenant_dbid + * @param callinglist_dbid + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgCallingList getCallingList( + final IConfService service, + int tenant_dbid, + int callinglist_dbid + ) { + CfgCallingList callinglist = null; + try { + CfgCallingListQuery callinglistquery = new CfgCallingListQuery(); + callinglistquery.setTenantDbid(tenant_dbid); + callinglistquery.setDbid(callinglist_dbid); + callinglist = service.retrieveObject(CfgCallingList.class, callinglistquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return callinglist; + } + + /** + * CallingList을 조회한다. + * @param iTenantDBID + * @param service + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public Collection getCallingList( + final IConfService service, + int tenant_dbid + ) { + Collection callinglist = null; + try { + CfgCallingListQuery callinglistquery = new CfgCallingListQuery(); + callinglistquery.setTenantDbid(tenant_dbid); + callinglist = service.retrieveMultipleObjects(CfgCallingList.class, callinglistquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + }catch (InterruptedException e) { + logger.error("InterruptedException", e); + } + return callinglist; + } + + /** + * CallingList을 삭제한다. + * @param service + * @param tenant_dbid + * @param calinglist_name + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public int deleteCallingList( + final IConfService service, + int tenant_dbid, + String calinglist_name + ) + throws ConfigException, InterruptedException { + // Read configuration objects: + int returnval = 0; + CfgCallingList callinglist = getCallingList(service, tenant_dbid, calinglist_name); + if(callinglist != null) { + callinglist.delete(); + returnval = 1; + } + + return returnval; + } + + + /** + * CallingList을 수정한다. + * @param service + * @param tenant_dbid + * @param calinglist_name + * @param table_name + * @param filter_name + * @param maximum + * @param treatment_names + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgCallingList modifyCallingList( + final IConfService service, + int tenant_dbid, + String calinglist_name, + String table_name, + String filter_name, + int maximum, + String treatment_names + ) + throws ConfigException, InterruptedException { + // Read configuration objects: + String[] arr_treatment = treatment_names.split(","); + Collection treatments = new HashSet(); + CfgCallingList callinglist = getCallingList(service, tenant_dbid, calinglist_name); + ob = new ConfigOB(); + CfgTreatment tmptreatment = null; + if(arr_treatment.length > 0) { + for(int i=0; i treatments = new HashSet(); + CfgCallingList callinglist = new CfgCallingList(service); + callinglist.setTenantDBID(tenant_dbid); + callinglist.setName(calinglist_name); + ob = new ConfigOB(); + CfgTreatment tmptreatment = null; + if(arr_treatment.length > 0) { + for(int i=0; i createCallingListInfo(final IConfService service, + int tenant_dbid, + CfgCallingList cl + ) { + Collection cmp = null; + CfgCallingListInfo newcli = null; + + try { + newcli = new CfgCallingListInfo(service, null); + cmp = new HashSet(); + newcli.setIsActive(CfgFlag.CFGTrue); + newcli.setShare(10); + newcli.setCallingList(cl); + cmp.add(newcli); + } catch (Exception e) { + logger.error("ConfigException", e); + } + return cmp; + } + + /** + * TableAccess을 조회한다. + * @param service + * @param tenant_dbid + * @param ta_name + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgTableAccess getTableAccess( + final IConfService service, + int tenant_dbid, + String ta_name + ) { + CfgTableAccess tableaccess = null; + try { + CfgTableAccessQuery taquery = new CfgTableAccessQuery(); + taquery.setTenantDbid(tenant_dbid); + taquery.setName(ta_name); + tableaccess = service.retrieveObject(CfgTableAccess.class, taquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return tableaccess; + } +} diff --git a/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigCampaign.java b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigCampaign.java new file mode 100644 index 0000000..a21c640 --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigCampaign.java @@ -0,0 +1,195 @@ +package kr.co.i4way.genesys.cfgserver; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.genesyslab.platform.applicationblocks.com.ConfigException; +import com.genesyslab.platform.applicationblocks.com.IConfService; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLoginInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCallingList; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCallingListInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaign; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaignGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaignGroupInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkill; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkillLevel; +import com.genesyslab.platform.applicationblocks.com.objects.CfgTreatment; +import com.genesyslab.platform.applicationblocks.com.queries.CfgCampaignQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgPersonQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgTreatmentQuery; +import com.genesyslab.platform.configuration.protocol.types.CfgFlag; +import com.genesyslab.platform.configuration.protocol.types.CfgObjectState; + +public class ConfigCampaign { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + private ConfigCampaignGroup configcampaigngroup = null; + public ConfigCampaign() { + + } + + public Collection getCampaignInfo(final IConfService service, int tenant_dbid) { + Collection rtnCampaign = null; + CfgCampaignQuery campaignquery = new CfgCampaignQuery(); + campaignquery.setTenantDbid(tenant_dbid); + try { + rtnCampaign = service.retrieveMultipleObjects(CfgCampaign.class, campaignquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } catch (InterruptedException e) { + logger.error("InterruptedException", e); + } + return rtnCampaign; + } + + public CfgCampaign getCampaignInfo(final IConfService service, int tenant_dbid, String campaign_name) { + CfgCampaign rtnCampaign = null; + CfgCampaignQuery campaignquery = new CfgCampaignQuery(); + campaignquery.setTenantDbid(tenant_dbid); + campaignquery.setName(campaign_name); + try { + rtnCampaign = service.retrieveObject(CfgCampaign.class, campaignquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnCampaign; + } + + public CfgCampaign getCampaignInfo(final IConfService service, int tenant_dbid, int campaign_dbid) { + CfgCampaign rtnCampaign = null; + CfgCampaignQuery campaignquery = new CfgCampaignQuery(); + campaignquery.setTenantDbid(tenant_dbid); + campaignquery.setDbid(campaign_dbid); + try { + rtnCampaign = service.retrieveObject(CfgCampaign.class, campaignquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnCampaign; + } + + /** + * Campaign을 생성한다. + * @param service + * @param campaign_name + * @param group_name + * @param callinglist_name + * @param vdn + * @return + */ + public CfgCampaign createCampaign( + final IConfService service, + int tenant_dbid, + String campaign_name, + Collection callinglist) { + CfgCampaign campaign = null; + Collection campaigngroups = null; + configcampaigngroup = new ConfigCampaignGroup(); + try{ + // Read configuration objects: + campaign = new CfgCampaign(service); + campaign.setTenantDBID(tenant_dbid); + campaign.setName(campaign_name); + campaign.setState(CfgObjectState.CFGEnabled); + campaign.setCallingLists(callinglist); + campaign.save(); + }catch (Exception e) { + e.printStackTrace(); + } + return campaign; + } + + /** + * campaign을 수정한다. + * @param service + * @param tenant_dbid + * @param campaign_dbid + * @param campaign_name + * @param callinglist + * @return + */ + public CfgCampaign modifyCampaign( + final IConfService service, + int tenant_dbid, + int campaign_dbid, + String campaign_name, + String campaign_state, + Collection callinglist){ + // Read configuration objects: + CfgCampaign campaign = null; + CfgCampaignQuery campaignquery = new CfgCampaignQuery(); + try { + campaignquery.setTenantDbid(tenant_dbid); + campaignquery.setDbid(campaign_dbid); + campaign = service.retrieveObject(CfgCampaign.class,campaignquery); + campaign.setCallingLists(callinglist); + campaign.setState(CfgObjectState.valueOf(campaign_state)); + campaign.save(); + }catch (ConfigException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return campaign; + } + + /** + * campaign을 삭제한다. + * @param service + * @param tenant_dbid + * @param campaign_dbid + * @return + */ + public boolean deleteCampaign( + final IConfService service, + int tenant_dbid, + int campaign_dbid){ + // Read configuration objects: + CfgCampaign campaign = null; + CfgCampaignQuery campaignquery = new CfgCampaignQuery(); + boolean rtnbool = false; + try { + campaignquery.setTenantDbid(tenant_dbid); + campaignquery.setDbid(campaign_dbid); + campaign = service.retrieveObject(CfgCampaign.class,campaignquery); + campaign.delete(); + rtnbool = true; + }catch (ConfigException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return rtnbool; + } + + public Collection getTreatments(final IConfService service, int tenant_dbid) { + Collection treatment = null; + CfgTreatmentQuery treatmentquery = new CfgTreatmentQuery(); + treatmentquery.setTenantDbid(tenant_dbid); + try { + treatment = service.retrieveMultipleObjects(CfgTreatment.class, treatmentquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } catch (InterruptedException e) { + logger.error("InterruptedException", e); + } + return treatment; + } + + public CfgTreatment getTreatment(final IConfService service, int tenant_dbid, String treatment_name) { + CfgTreatment treatment = null; + CfgTreatmentQuery treatmentquery = new CfgTreatmentQuery(); + treatmentquery.setTenantDbid(tenant_dbid); + treatmentquery.setName(treatment_name); + try { + treatment = service.retrieveObject(CfgTreatment.class, treatmentquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return treatment; + } +} diff --git a/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigCampaignGroup.java b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigCampaignGroup.java new file mode 100644 index 0000000..be1301b --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigCampaignGroup.java @@ -0,0 +1,260 @@ +package kr.co.i4way.genesys.cfgserver; + +import java.util.Collection; +import java.util.HashSet; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.genesyslab.platform.applicationblocks.com.ConfigException; +import com.genesyslab.platform.applicationblocks.com.ICfgQuery; +import com.genesyslab.platform.applicationblocks.com.IConfService; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaign; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaignGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaignGroupInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkillLevel; +import com.genesyslab.platform.applicationblocks.com.queries.CfgAgentGroupQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgCampaignGroupQuery; +import com.genesyslab.platform.commons.collections.KeyValueCollection; +import com.genesyslab.platform.configuration.protocol.types.CfgDialMode; +import com.genesyslab.platform.configuration.protocol.types.CfgObjectType; +import com.genesyslab.platform.configuration.protocol.types.CfgOperationMode; +import com.genesyslab.platform.configuration.protocol.types.CfgOptimizationMethod; + +public class ConfigCampaignGroup { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + ConfigPerson ps = null; + ConfigAgentGroup ag = null; + + public ConfigCampaignGroup(){ + } + + /** + * CampaignGroup을 조회한다. + * @param service + * @param tenant_dbid + * @param group_name + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgCampaignGroup getCampaignGroup( + final IConfService service, + int tenant_dbid, + String group_name + ) { + CfgCampaignGroup campaigngroup = null; + try { + CfgCampaignGroupQuery campaigngroupquery = new CfgCampaignGroupQuery(); + campaigngroupquery.setTenantDbid(tenant_dbid); + campaigngroupquery.setName(group_name); + campaigngroup = service.retrieveObject(CfgCampaignGroup.class, campaigngroupquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return campaigngroup; + } + + /** + * CampaignGroup을 조회한다. + * @param service + * @param tenant_dbid + * @param group_dbid + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgCampaignGroup getCampaignGroup( + final IConfService service, + int tenant_dbid, + int group_dbid + ) { + CfgCampaignGroup campaigngroup = null; + try { + CfgCampaignGroupQuery campaigngroupquery = new CfgCampaignGroupQuery(); + campaigngroupquery.setTenantDbid(tenant_dbid); + campaigngroupquery.setDbid(group_dbid); + campaigngroup = service.retrieveObject(CfgCampaignGroup.class, campaigngroupquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return campaigngroup; + } + + /** + * CampaignGroup을 조회한다. + * @param iTenantDBID + * @param service + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public Collection getCampaignGroup( + final IConfService service, + int tenant_dbid + ) { + Collection campaigngroup = null; + try { + CfgCampaignGroupQuery campaigngroupquery = new CfgCampaignGroupQuery(); + campaigngroupquery.setTenantDbid(tenant_dbid); + campaigngroup = service.retrieveMultipleObjects(CfgCampaignGroup.class, + campaigngroupquery); + + } catch (ConfigException e) { + logger.error("ConfigException", e); + }catch (InterruptedException e) { + logger.error("InterruptedException", e); + } + return campaigngroup; + } + +// /** +// * CampaignGroup을 조회한다. +// * @param service +// * @param tenant_dbid +// * @param group_name +// * @return +// * @throws ConfigException +// * @throws InterruptedException +// */ +// public Collection getCampaignGroupInfo( +// final IConfService service, +// int tenant_dbid, +// String group_name +// ) { +// Collection campaigngroup = null; +// try { +// CfgCampaignGroupInfo bbb = null; +// CfgCampaignGroup aa = null; +// aa. +//// CfgCamp +//// +//// CfgCampaignGroupQuery campaigngroupquery = new CfgCampaignGroupQuery(); +//// campaigngroupquery.setTenantDbid(tenant_dbid); +//// campaigngroupquery.setName(group_name); +// campaigngroup = service.retrieveMultipleObjects(CfgCampaignGroupInfo.class); +// } catch (ConfigException e) { +// logger.error("ConfigException", e); +// }catch (InterruptedException e) { +// logger.error("InterruptedException", e); +// } +// return campaigngroup; +// } + + + + /** + * 캠페인 그룹을 생성한다. + * @param service + * @param tenant_dbid + * @param group_name + * @param campaign_name + * @param obj_type(CFGAgentGroup, CFGPlaceGroup) + * @param dialmode(CFGDMPower, CFGDMPredict, CFGDMPreview, CFGDMProgress) + * @param opmode(CFGOMMaxOperationMode, CFGOMNoOperationMode, CFGOMSchedule) + * @param optmode(CFGOMBusyFactor, CFGOMDistributionTime, CFGOMMaximumGain, CFGOMMaxOptimizationMethod, CFGOMNoOptimizationMethod, CFGOMOverdialRate, CFGOMWaitTime) + * @return + */ + public CfgCampaignGroup createCampaignGroup(final IConfService service, + int tenant_dbid, + String group_name, + String obj_type, + CfgCampaign cm, + String dialmode, + String opmode, + String optmode, + int ocs_dbid, + int min_rec_buff_size, + int rec_buff_size, + int num_channel, + int method_value + ) { + CfgCampaignGroup cmp = new CfgCampaignGroup(service); + ag = new ConfigAgentGroup(); + + try { + CfgAgentGroup agentgroup = ag.getAgentGroupInfo(service, tenant_dbid, group_name); + Collection server = new HashSet(); + if(agentgroup != null) { + cmp.setName(cm.getName() + "@" + group_name); + cmp.setCampaignDBID(cm.getDBID()); + cmp.setGroupDBID(agentgroup.getDBID()); + cmp.setGroupType(CfgObjectType.valueOf(obj_type)); + cmp.setDialMode(CfgDialMode.valueOf(dialmode)); + cmp.setOperationMode(CfgOperationMode.valueOf(opmode)); + cmp.setOptMethod(CfgOptimizationMethod.valueOf(optmode)); + server.add(ocs_dbid); + cmp.setServerDBIDs(server); + cmp.setMinRecBuffSize(min_rec_buff_size); + cmp.setOptRecBuffSize(rec_buff_size); + cmp.setNumOfChannels(num_channel); + cmp.setOptMethodValue(method_value); + cmp.save(); + }else { + logger.info("agentGroup is null"); + } + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return cmp; + } + + /** + * 캠페인 그룹을 수정한다. + * @param service + * @param tenant_dbid + * @param group_name + * @param campaign_name + * @param obj_type(CFGAgentGroup, CFGPlaceGroup) + * @param dialmode(CFGDMPower, CFGDMPredict, CFGDMPreview, CFGDMProgress) + * @param opmode(CFGOMMaxOperationMode, CFGOMNoOperationMode, CFGOMSchedule) + * @param optmode(CFGOMBusyFactor, CFGOMDistributionTime, CFGOMMaximumGain, CFGOMMaxOptimizationMethod, CFGOMNoOptimizationMethod, CFGOMOverdialRate, CFGOMWaitTime) + * @return + */ + public CfgCampaignGroup modifyCampaignGroup(final IConfService service, + int tenant_dbid, + CfgCampaignGroup campaigngroup, + String group_name, + String obj_type, + CfgCampaign cm, + String dialmode, + String opmode, + String optmode, + int ocs_dbid, + int min_rec_buff_size, + int rec_buff_size, + int num_channel, + int method_value + ) { + CfgAgentGroup agentgroup = null; + ag = new ConfigAgentGroup(); + + try { + agentgroup = ag.getAgentGroupInfo(service, tenant_dbid, group_name); + Collection server = new HashSet(); + if(agentgroup != null) { + campaigngroup.setName(cm.getName() + "@" + group_name); + campaigngroup.setGroupDBID(agentgroup.getDBID()); + campaigngroup.setGroupType(CfgObjectType.valueOf(obj_type)); + campaigngroup.setDialMode(CfgDialMode.valueOf(dialmode)); + campaigngroup.setOperationMode(CfgOperationMode.valueOf(opmode)); + campaigngroup.setOptMethod(CfgOptimizationMethod.valueOf(optmode)); + server.add(ocs_dbid); + campaigngroup.setServerDBIDs(server); + campaigngroup.setMinRecBuffSize(min_rec_buff_size); + campaigngroup.setOptRecBuffSize(rec_buff_size); + campaigngroup.setNumOfChannels(num_channel); + campaigngroup.setOptMethodValue(method_value); + campaigngroup.save(); + }else { + logger.info("agentGroup is null"); + } + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return campaigngroup; + } +} diff --git a/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigDn.java b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigDn.java new file mode 100644 index 0000000..38c8fea --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigDn.java @@ -0,0 +1,375 @@ +package kr.co.i4way.genesys.cfgserver; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.genesyslab.platform.applicationblocks.com.ConfigException; +import com.genesyslab.platform.applicationblocks.com.IConfService; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLoginInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCallingList; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCallingListInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaign; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaignGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaignGroupInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgDN; +import com.genesyslab.platform.applicationblocks.com.objects.CfgDNGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkill; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkillLevel; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSwitch; +import com.genesyslab.platform.applicationblocks.com.objects.CfgTransaction; +import com.genesyslab.platform.applicationblocks.com.queries.CfgAgentLoginQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgCampaignQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgDNGroupQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgDNQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgPersonQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgSwitchQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgTransactionQuery; +import com.genesyslab.platform.configuration.protocol.metadata.CfgTypeMask; +import com.genesyslab.platform.configuration.protocol.types.CfgDNGroupType; +import com.genesyslab.platform.configuration.protocol.types.CfgDNType; +import com.genesyslab.platform.configuration.protocol.types.CfgFlag; +import com.genesyslab.platform.configuration.protocol.types.CfgObjectState; +import com.genesyslab.platform.configuration.protocol.types.CfgRouteType; + +public class ConfigDn { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + public ConfigDn() { + + } + + /** + * CfgDN을 쿼리한다. + * @param service + * @param tenant_dbid + * @return + */ + public Collection getDn(final IConfService service, int tenant_dbid, int switch_dbid) { + Collection rtndn = null; + CfgDNQuery dnquery = new CfgDNQuery(); + dnquery.setTenantDbid(tenant_dbid); + try { + rtndn = service.retrieveMultipleObjects(CfgDN.class, dnquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } catch (InterruptedException e) { + logger.error("InterruptedException", e); + } + return rtndn; + } + + /** + * CfgSwitch을 쿼리한다. + * @param service + * @param tenant_dbid + * @param switch_name + * @return + */ + public CfgSwitch getSwitch(final IConfService service, int tenant_dbid, String switch_name) { + CfgSwitch rtnswitch = null; + CfgSwitchQuery switchquery = new CfgSwitchQuery(); + switchquery.setTenantDbid(tenant_dbid); + switchquery.setName(switch_name); + try { + rtnswitch = service.retrieveObject(CfgSwitch.class, switchquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnswitch; + } + + /** + * CfgDN을 쿼리한다. + * @param service + * @param tenant_dbid + * @param dn_name + * @return + */ + public CfgDN getDn(final IConfService service, int tenant_dbid, int switch_dbid, String dn_name) { + CfgDN rtndn = null; + CfgDNQuery dnquery = new CfgDNQuery(); + dnquery.setTenantDbid(tenant_dbid); + dnquery.setDnNumber(dn_name); + try { + rtndn = service.retrieveObject(CfgDN.class, dnquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtndn; + } + + /** + * CfgDN을 쿼리한다. + * @param service + * @param tenant_dbid + * @param dn_name + * @return + */ + public CfgTransaction gettr(final IConfService service, int tenant_dbid, int switch_dbid, String tr_name) { + CfgTransaction rtndn = null; + CfgTransactionQuery dnquery = new CfgTransactionQuery(); + dnquery.setTenantDbid(tenant_dbid); + dnquery.setName(tr_name); + try { + rtndn = service.retrieveObject(CfgTransaction.class, dnquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtndn; + } + + /** + * CfgDN을 쿼리한다. + * @param service + * @param tenant_dbid + * @param dn_dbid + * @return + */ + public CfgDN getDn(final IConfService service, int tenant_dbid, int switch_dbid, int dn_dbid) { + CfgDN rtndn = null; + CfgDNQuery dnquery = new CfgDNQuery(); + dnquery.setTenantDbid(tenant_dbid); + dnquery.setDbid(dn_dbid); + try { + rtndn = service.retrieveObject(CfgDN.class, dnquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtndn; + } + + /** + * DN을 생성한다. + * @param service + * @param tenant_dbid + * @param switch_dbid + * @param number + * @param dn_type + * @param route_type + * @param switch_spec_type + * @return + */ + public CfgDN createDN( + final IConfService service, + int tenant_dbid, + int switch_dbid, + String number, + String dn_type, + String route_type, + int switch_spec_type + ) { + // Read configuration objects: + CfgDN new_dn = new CfgDN(service); + try { + new_dn.setTenantDBID(tenant_dbid); + new_dn.setNumber(number); + new_dn.setSwitchDBID(switch_dbid); + new_dn.setState(CfgObjectState.CFGEnabled); + new_dn.setType(CfgDNType.valueOf(dn_type)); + new_dn.setRouteType(CfgRouteType.valueOf(route_type)); + new_dn.setSwitchSpecificType(switch_spec_type); + new_dn.save(); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + + return new_dn; + } + + /** + * AgentLogin을 삭제한다. + * @param service + * @param tenant_dbid + * @param switch_dbid + * @param login_code + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public boolean deleteDN( + final IConfService service, + int tenant_dbid, + int switch_dbid, + String dn_name + ) { + CfgDN rtndn = null; + boolean rtnval = false; + CfgDNQuery dnquery = new CfgDNQuery(); + dnquery.setTenantDbid(tenant_dbid); + dnquery.setSwitchDbid(switch_dbid); + dnquery.setDnNumber(dn_name); + try { + rtndn = service.retrieveObject(CfgDN.class, dnquery); + if(rtndn != null) { + rtndn.delete(); + rtnval = true; + } + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnval; + } + + + /** + * AgentLogin을 삭제한다. + * @param service + * @param tenant_dbid + * @param switch_dbid + * @param login_code + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public boolean deleteDN( + final IConfService service, + int tenant_dbid, + int switch_dbid, + String dn_name, + String dn_type + ) { + CfgDN rtndn = null; + boolean rtnval = false; + CfgDNQuery dnquery = new CfgDNQuery(); + dnquery.setTenantDbid(tenant_dbid); + dnquery.setDnNumber(dn_name); + dnquery.setDnType(CfgDNType.valueOf(dn_type)); + try { + rtndn = service.retrieveObject(CfgDN.class, dnquery); + if(rtndn != null) { + rtndn.delete(); + rtnval = false; + } + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnval; + } + + + + /** + * CfgDNGroup을 쿼리한다. + * @param service + * @param tenant_dbid + * @return + */ + public Collection getDnGroup(final IConfService service, int tenant_dbid) { + Collection rtndn = null; + CfgDNGroupQuery dnquery = new CfgDNGroupQuery(); + dnquery.setTenantDbid(tenant_dbid); + try { + rtndn = service.retrieveMultipleObjects(CfgDNGroup.class, dnquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } catch (InterruptedException e) { + logger.error("InterruptedException", e); + } + return rtndn; + } + + /** + * CfgDNGroup을 쿼리한다. + * @param service + * @param tenant_dbid + * @param gorup_name + * @return + */ + public CfgDNGroup getDnGroup(final IConfService service, int tenant_dbid, String gorup_name) { + CfgDNGroup rtndn = null; + CfgDNGroupQuery dnquery = new CfgDNGroupQuery(); + dnquery.setTenantDbid(tenant_dbid); + dnquery.setName(gorup_name); + try { + rtndn = service.retrieveObject(CfgDNGroup.class, dnquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtndn; + } + + /** + * CfgDNGroup을 쿼리한다. + * @param service + * @param tenant_dbid + * @param group_dbid + * @return + */ + public CfgDNGroup getDnGroup(final IConfService service, int tenant_dbid, int group_dbid) { + CfgDNGroup rtndn = null; + CfgDNGroupQuery dnquery = new CfgDNGroupQuery(); + dnquery.setTenantDbid(tenant_dbid); + dnquery.setDbid(group_dbid); + try { + rtndn = service.retrieveObject(CfgDNGroup.class, dnquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtndn; + } + + /** + * CfgDNGroup을 생성한다. + * @param service + * @param tenant_dbid + * @param gorup_name + * @param dngroup_type + * @return + */ + public CfgDNGroup createDNGroup( + final IConfService service, + int tenant_dbid, + String gorup_name, + String dngroup_type + ) { + // Read configuration objects: + CfgDNGroup new_group = new CfgDNGroup(service); + try { + CfgGroup groupinfo = new CfgGroup(service, null); + groupinfo.setName(gorup_name); + groupinfo.setTenantDBID(tenant_dbid); + new_group.setGroupInfo(groupinfo); + new_group.setType(CfgDNGroupType.valueOf(dngroup_type)); + new_group.save(); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return new_group; + } + + /** + * CfgDNGroup을 삭제한다. + * @param service + * @param tenant_dbid + * @param gorup_name + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public boolean deleteDNGroup( + final IConfService service, + int tenant_dbid, + String gorup_name + ) { + CfgDNGroup group = null; + boolean rtnval = false; + + try { + group = getDnGroup(service, tenant_dbid, gorup_name); + if(group != null) { + group.delete(); + rtnval = true; + } + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnval; + } +} diff --git a/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigFolder.java b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigFolder.java new file mode 100644 index 0000000..e9a795c --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigFolder.java @@ -0,0 +1,297 @@ +package kr.co.i4way.genesys.cfgserver; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.genesyslab.platform.applicationblocks.com.ConfigException; +import com.genesyslab.platform.applicationblocks.com.IConfService; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLoginInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCallingList; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCallingListInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaign; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaignGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaignGroupInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgDN; +import com.genesyslab.platform.applicationblocks.com.objects.CfgDNGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgFolder; +import com.genesyslab.platform.applicationblocks.com.objects.CfgGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkill; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkillLevel; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSwitch; +import com.genesyslab.platform.applicationblocks.com.objects.CfgTransaction; +import com.genesyslab.platform.applicationblocks.com.queries.CfgAgentLoginQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgCampaignQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgDNGroupQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgDNQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgFolderQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgPersonQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgSwitchQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgTransactionQuery; +import com.genesyslab.platform.configuration.protocol.metadata.CfgTypeMask; +import com.genesyslab.platform.configuration.protocol.types.CfgDNGroupType; +import com.genesyslab.platform.configuration.protocol.types.CfgDNType; +import com.genesyslab.platform.configuration.protocol.types.CfgFlag; +import com.genesyslab.platform.configuration.protocol.types.CfgObjectState; +import com.genesyslab.platform.configuration.protocol.types.CfgRouteType; + +public class ConfigFolder { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + public ConfigFolder() { + + } + + /** + * CfgFolder을 쿼리한다. + * @param service + * @param owner_type + * @param folder_dbid + * @return + */ + public CfgFolder getFolderInfo(final IConfService service, int owner_type, int folder_dbid) { + CfgFolder rtnfolder = null; + CfgFolderQuery folderquery = new CfgFolderQuery(); + folderquery.setOwnerType(owner_type); + folderquery.setDbid(folder_dbid); + try { + rtnfolder = service.retrieveObject(CfgFolder.class, folderquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnfolder; + } + + /** + * DN을 생성한다. + * @param service + * @param tenant_dbid + * @param switch_dbid + * @param number + * @param dn_type + * @param route_type + * @param switch_spec_type + * @return + */ + public CfgDN createDN( + final IConfService service, + int tenant_dbid, + int switch_dbid, + String number, + String dn_type, + String route_type, + int switch_spec_type + ) { + // Read configuration objects: + CfgDN new_dn = new CfgDN(service); + try { + new_dn.setTenantDBID(tenant_dbid); + new_dn.setNumber(number); + new_dn.setSwitchDBID(switch_dbid); + new_dn.setState(CfgObjectState.CFGEnabled); + new_dn.setType(CfgDNType.valueOf(dn_type)); + new_dn.setRouteType(CfgRouteType.valueOf(route_type)); + new_dn.setSwitchSpecificType(switch_spec_type); + new_dn.save(); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + + return new_dn; + } + + /** + * AgentLogin을 삭제한다. + * @param service + * @param tenant_dbid + * @param switch_dbid + * @param login_code + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public boolean deleteDN( + final IConfService service, + int tenant_dbid, + int switch_dbid, + String dn_name + ) { + CfgDN rtndn = null; + boolean rtnval = false; + CfgDNQuery dnquery = new CfgDNQuery(); + dnquery.setTenantDbid(tenant_dbid); + dnquery.setSwitchDbid(switch_dbid); + dnquery.setDnNumber(dn_name); + try { + rtndn = service.retrieveObject(CfgDN.class, dnquery); + if(rtndn != null) { + rtndn.delete(); + rtnval = true; + } + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnval; + } + + + /** + * AgentLogin을 삭제한다. + * @param service + * @param tenant_dbid + * @param switch_dbid + * @param login_code + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public boolean deleteDN( + final IConfService service, + int tenant_dbid, + int switch_dbid, + String dn_name, + String dn_type + ) { + CfgDN rtndn = null; + boolean rtnval = false; + CfgDNQuery dnquery = new CfgDNQuery(); + dnquery.setTenantDbid(tenant_dbid); + dnquery.setDnNumber(dn_name); + dnquery.setDnType(CfgDNType.valueOf(dn_type)); + try { + rtndn = service.retrieveObject(CfgDN.class, dnquery); + if(rtndn != null) { + rtndn.delete(); + rtnval = false; + } + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnval; + } + + + + /** + * CfgDNGroup을 쿼리한다. + * @param service + * @param tenant_dbid + * @return + */ + public Collection getDnGroup(final IConfService service, int tenant_dbid) { + Collection rtndn = null; + CfgDNGroupQuery dnquery = new CfgDNGroupQuery(); + dnquery.setTenantDbid(tenant_dbid); + try { + rtndn = service.retrieveMultipleObjects(CfgDNGroup.class, dnquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } catch (InterruptedException e) { + logger.error("InterruptedException", e); + } + return rtndn; + } + + /** + * CfgDNGroup을 쿼리한다. + * @param service + * @param tenant_dbid + * @param gorup_name + * @return + */ + public CfgDNGroup getDnGroup(final IConfService service, int tenant_dbid, String gorup_name) { + CfgDNGroup rtndn = null; + CfgDNGroupQuery dnquery = new CfgDNGroupQuery(); + dnquery.setTenantDbid(tenant_dbid); + dnquery.setName(gorup_name); + try { + rtndn = service.retrieveObject(CfgDNGroup.class, dnquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtndn; + } + + /** + * CfgDNGroup을 쿼리한다. + * @param service + * @param tenant_dbid + * @param group_dbid + * @return + */ + public CfgDNGroup getDnGroup(final IConfService service, int tenant_dbid, int group_dbid) { + CfgDNGroup rtndn = null; + CfgDNGroupQuery dnquery = new CfgDNGroupQuery(); + dnquery.setTenantDbid(tenant_dbid); + dnquery.setDbid(group_dbid); + try { + rtndn = service.retrieveObject(CfgDNGroup.class, dnquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtndn; + } + + /** + * CfgDNGroup을 생성한다. + * @param service + * @param tenant_dbid + * @param gorup_name + * @param dngroup_type + * @return + */ + public CfgDNGroup createDNGroup( + final IConfService service, + int tenant_dbid, + String gorup_name, + String dngroup_type + ) { + // Read configuration objects: + CfgDNGroup new_group = new CfgDNGroup(service); + try { + CfgGroup groupinfo = new CfgGroup(service, null); + groupinfo.setName(gorup_name); + groupinfo.setTenantDBID(tenant_dbid); + new_group.setGroupInfo(groupinfo); + new_group.setType(CfgDNGroupType.valueOf(dngroup_type)); + new_group.save(); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return new_group; + } + + /** + * CfgDNGroup을 삭제한다. + * @param service + * @param tenant_dbid + * @param gorup_name + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public boolean deleteDNGroup( + final IConfService service, + int tenant_dbid, + String gorup_name + ) { + CfgDNGroup group = null; + boolean rtnval = false; + + try { + group = getDnGroup(service, tenant_dbid, gorup_name); + if(group != null) { + group.delete(); + rtnval = true; + } + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnval; + } +} diff --git a/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigOB.java b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigOB.java new file mode 100644 index 0000000..7d7ed9d --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigOB.java @@ -0,0 +1,258 @@ +package kr.co.i4way.genesys.cfgserver; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.genesyslab.platform.applicationblocks.com.ConfigException; +import com.genesyslab.platform.applicationblocks.com.IConfService; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLoginInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCallingList; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCallingListInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaign; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaignGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaignGroupInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgDN; +import com.genesyslab.platform.applicationblocks.com.objects.CfgFilter; +import com.genesyslab.platform.applicationblocks.com.objects.CfgFormat; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkill; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkillLevel; +import com.genesyslab.platform.applicationblocks.com.objects.CfgTransaction; +import com.genesyslab.platform.applicationblocks.com.objects.CfgTreatment; +import com.genesyslab.platform.applicationblocks.com.queries.CfgAgentLoginQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgCampaignQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgDNQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgFilterQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgFormatQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgPersonQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgTransactionQuery; +import com.genesyslab.platform.applicationblocks.com.queries.CfgTreatmentQuery; +import com.genesyslab.platform.commons.collections.KeyValueCollection; +import com.genesyslab.platform.configuration.protocol.types.CfgDNType; +import com.genesyslab.platform.configuration.protocol.types.CfgFlag; +import com.genesyslab.platform.configuration.protocol.types.CfgObjectState; +import com.genesyslab.platform.configuration.protocol.types.CfgRouteType; + +public class ConfigOB { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + public ConfigOB() { + + } + + /** + * CfgFilter을 쿼리한다. + * @param service + * @param tenant_dbid + * @return + */ + public Collection getFilter(final IConfService service, int tenant_dbid) { + Collection rtnfilter = null; + CfgFilterQuery fquery = new CfgFilterQuery(); + fquery.setTenantDbid(tenant_dbid); + try { + rtnfilter = service.retrieveMultipleObjects(CfgFilter.class, fquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } catch (InterruptedException e) { + logger.error("InterruptedException", e); + } + return rtnfilter; + } + + /** + * CfgFilter을 쿼리한다. + * @param service + * @param tenant_dbid + * @param filter_name + * @return + */ + public CfgFilter getFilter(final IConfService service, int tenant_dbid, String filter_name) { + CfgFilter rtnfilter = null; + CfgFilterQuery fquery = new CfgFilterQuery(); + fquery.setTenantDbid(tenant_dbid); + fquery.setName(filter_name); + try { + rtnfilter = service.retrieveObject(CfgFilter.class, fquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnfilter; + } + + /** + * CfgFilter을 쿼리한다. + * @param service + * @param tenant_dbid + * @param filter_dbid + * @return + */ + public CfgFilter getFilter(final IConfService service, int tenant_dbid, int filter_dbid) { + CfgFilter rtnfilter = null; + CfgFilterQuery fquery = new CfgFilterQuery(); + fquery.setTenantDbid(tenant_dbid); + fquery.setDbid(filter_dbid); + try { + rtnfilter = service.retrieveObject(CfgFilter.class, fquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnfilter; + } + + /** + * CfgFormat을 쿼리한다. + * @param service + * @param tenant_dbid + * @param format_name + * @return + */ + public CfgFormat getFormat(final IConfService service, int tenant_dbid, String format_name) { + CfgFormat rtnformat = null; + CfgFormatQuery fquery = new CfgFormatQuery(); + fquery.setTenantDbid(tenant_dbid); + fquery.setName(format_name); + try { + rtnformat = service.retrieveObject(CfgFormat.class, fquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnformat; + } + + /** + * CfgTreatment을 쿼리한다. + * @param service + * @param tenant_dbid + * @param treatment_name + * @return + */ + public CfgTreatment getTreatment(final IConfService service, int tenant_dbid, String treatment_name) { + CfgTreatment rtnTreatment = null; + CfgTreatmentQuery tquery = new CfgTreatmentQuery(); + tquery.setTenantDbid(tenant_dbid); + tquery.setName(treatment_name); + try { + rtnTreatment = service.retrieveObject(CfgTreatment.class, tquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnTreatment; + } + + /** + * CfgFilter을 생성한다. + * @param service + * @param tenant_dbid + * @param filter_name + * @param format_name + * @param criteria + * @param orderby + * @return + */ + public CfgFilter createFilter( + final IConfService service, + int tenant_dbid, + String filter_name, + String format_name, + String criteria, + String orderby + ) { + // Read configuration objects: + CfgFilter new_filter = new CfgFilter(service); + CfgFormat format = null; + try { + new_filter.setTenantDBID(tenant_dbid); + new_filter.setName(filter_name); + + KeyValueCollection mainSection = new KeyValueCollection(); + KeyValueCollection defaultSection = new KeyValueCollection(); + if (criteria != null) + defaultSection.addString("criteria", criteria); + if (orderby != null) + defaultSection.addString("order_by", orderby); + + mainSection.addObject("default", defaultSection); + new_filter.setUserProperties(mainSection); + format = getFormat(service, tenant_dbid, format_name); + new_filter.setFormat(format); + new_filter.save(); + } catch (ConfigException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return new_filter; + } + + /** + * CfgFilter을 수정한다. + * @param service + * @param tenant_dbid + * @param filter_name + * @param format_name + * @param criteria + * @param orderby + * @return + */ + public CfgFilter modifyFilter( + final IConfService service, + int tenant_dbid, + String filter_name, + String criteria, + String orderby + ) { + // Read configuration objects: + CfgFilter filter = getFilter(service, tenant_dbid, filter_name); + try { + KeyValueCollection mainSection = new KeyValueCollection(); + KeyValueCollection defaultSection = new KeyValueCollection(); + if (criteria != null) + defaultSection.addString("criteria", criteria); + if (orderby != null) + defaultSection.addString("order_by", orderby); + + mainSection.addObject("default", defaultSection); + filter.setUserProperties(mainSection); + filter.save(); + } catch (ConfigException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return filter; + } + + /** + * CfgFilter을 삭제한다. + * @param service + * @param tenant_dbid + * @param filter_name + * @return + */ + public int deleteFilter( + final IConfService service, + int tenant_dbid, + String filter_name + ) { + int returnval = 0; + CfgFilter filter = getFilter(service, tenant_dbid, filter_name); + try { + if(filter != null) { + filter.delete(); + returnval = 1; + } + } catch (ConfigException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return returnval; + } + + +} diff --git a/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigPerson.java b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigPerson.java new file mode 100644 index 0000000..9f6f2af --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/cfgserver/ConfigPerson.java @@ -0,0 +1,474 @@ +package kr.co.i4way.genesys.cfgserver; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.genesyslab.platform.applicationblocks.com.ConfigException; +import com.genesyslab.platform.applicationblocks.com.IConfService; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLoginInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkill; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkillLevel; +import com.genesyslab.platform.applicationblocks.com.queries.CfgPersonQuery; +import com.genesyslab.platform.configuration.protocol.types.CfgFlag; +import com.genesyslab.platform.configuration.protocol.types.CfgObjectState; + +public class ConfigPerson { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + public ConfigPerson() { + + } + + public CfgPerson getPersonInfo(final IConfService service, int tenant_dbid, String qyery_type, String query_string) { + CfgPerson rtnCfgPerson = null; + CfgPersonQuery personquery = new CfgPersonQuery(); + personquery.setTenantDbid(tenant_dbid); + if(qyery_type.equals("usr")) { + personquery.setUserName(query_string); + }else if(qyery_type.equals("emp")) { + personquery.setEmployeeId(query_string); + } + try { + rtnCfgPerson = service.retrieveObject(CfgPerson.class, personquery); + } catch (ConfigException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return rtnCfgPerson; + } + + public CfgPerson getPersonInfo_single(final IConfService service, int tenant_dbid, int person_dbid) { + CfgPerson rtnCfgPerson = null; + CfgPersonQuery personquery = new CfgPersonQuery(); + personquery.setTenantDbid(tenant_dbid); + personquery.setDbid(person_dbid); + try { + rtnCfgPerson = service.retrieveObject(CfgPerson.class, personquery); + } catch (ConfigException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return rtnCfgPerson; + } + + public Collection getPersonInfo(final IConfService service, int tenant_dbid, int person_dbid) { + Collection rtnpersons = null; + CfgPersonQuery personquery = new CfgPersonQuery(); + personquery.setTenantDbid(tenant_dbid); + personquery.setDbid(person_dbid); + try { + rtnpersons = service.retrieveMultipleObjects(CfgPerson.class, personquery); + } catch (ConfigException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return rtnpersons; + } + + public Collection getPersonInfo(final IConfService service, int tenant_dbid) { + Collection rtnpersons = null; + CfgPersonQuery personquery = new CfgPersonQuery(); + personquery.setIsAgent(2); + personquery.setTenantDbid(tenant_dbid); + try { + rtnpersons = service.retrieveMultipleObjects(CfgPerson.class, personquery); + } catch (ConfigException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return rtnpersons; + } + + public Collection getPersonInfo(final IConfService service, int tenant_dbid, int skill_dbid, int skill_level) { + Collection rtnpersons = new HashSet(); + Collection tmppersons = null; + CfgPersonQuery personquery = new CfgPersonQuery(); + personquery.setIsAgent(2); + personquery.setTenantDbid(tenant_dbid); + personquery.setSkillDbid(skill_dbid); + try { + tmppersons = service.retrieveMultipleObjects(CfgPerson.class, personquery); + for (CfgPerson person : tmppersons){ + Collection skill_levels = person.getAgentInfo().getSkillLevels(); + boolean chklevel = false; + for (CfgSkillLevel skilllevel : skill_levels){ + if(skilllevel.getLevel() == skill_level) { + chklevel = true; + } + } + if(chklevel) { + rtnpersons.add(person); + } + } + } catch (ConfigException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return rtnpersons; + } + + /** + * Person을 생성한다. + * @param service + * @param tenant_dbid + * @param first_name + * @param last_name + * @param employee_id + * @param user_name + * @param folder_dbid + * @return + */ + public CfgPerson createPerson( + final IConfService service, + int tenant_dbid, + int switch_dbid, + String first_name, + String last_name, + String employee_id, + String user_name, + int folder_dbid) { + CfgPerson person = null; + try{ + // Read configuration objects: + person = new CfgPerson(service); + person.setTenantDBID(tenant_dbid); + person.setFirstName(first_name); + person.setLastName(last_name); + person.setEmployeeID(employee_id); + person.setUserName(user_name); + person.setIsAgent(CfgFlag.CFGTrue); + if(folder_dbid != 0) { + person.setFolderId(folder_dbid); + } + + person.save(); + + if(person != null) { + if(setAgentLoginToPerson(service, person, tenant_dbid, switch_dbid, employee_id)) { + person = getPersonInfo(service, tenant_dbid, "emp", employee_id); + } + } + }catch (ConfigException e) { + e.printStackTrace(); + } + return person; + } + + /** + * Person을 수정한다. + * @param service + * @param person + * @param first_name + * @param last_name + * @param employee_id + * @param user_name + * @return + */ + public CfgPerson modifyPerson( + final IConfService service, + CfgPerson person, + String first_name, + String last_name, + String employee_id, + String user_name){ + // Read configuration objects: + try { + person.setFirstName(first_name); + person.setLastName(last_name); + person.setUserName(user_name); + + person.save(); + }catch (ConfigException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return person; + } + + /** + * Person을 삭제한다. + * @param service + * @param tenant_dbid + * @param person_dbid + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public boolean deletePerson( + final IConfService service, + int tenant_dbid, + int person_dbid + ) + throws ConfigException, InterruptedException { + // Read configuration objects: + CfgPerson person = null; + boolean rtnbool = false; + try{ + CfgPersonQuery personquery = new CfgPersonQuery(); + personquery.setTenantDbid(tenant_dbid); + personquery.setDbid(person_dbid); + + person = service.retrieveObject(CfgPerson.class,personquery); + person.delete(); + rtnbool = true; + }catch(Exception e){ + rtnbool = false; + } + return rtnbool; + } + + /** + * Person을 삭제한다. + * @param service + * @param person + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public boolean deletePerson( + final IConfService service, + CfgPerson person + ) + throws ConfigException, InterruptedException { + boolean rtnbool = false; + try{ + person.delete(); + rtnbool = true; + }catch(Exception e){ + rtnbool = false; + } + return rtnbool; + } + + /** + * Person의 상태를 변경한다. + * @param service + * @param person 상태 변경할 Person 객체 + * @param flag (true = Enabled, false = Disabled) + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public CfgPerson setPersonState( + final IConfService service, + CfgPerson person, + boolean flag + ) + throws ConfigException, InterruptedException { + // Read configuration objects: + if(flag){ + person.setState(CfgObjectState.CFGEnabled); + }else{ + person.setState(CfgObjectState.CFGDisabled); + } + person.save(); + return person; + } + + /** + * Person에 AgentLogin을 Assign한다. + * @param service + * @param person + * @param tenant_dbid + * @param switch_dbid + * @param employee_id + * @return + */ + public boolean setAgentLoginToPerson( + final IConfService service, + CfgPerson person, + int tenant_dbid, + int switch_dbid, + String employee_id) { + ConfigAgentLogin configagentlogin = new ConfigAgentLogin(); + boolean assignyn = false; + boolean rtnResult = false; + + try { + CfgAgentLogin agentlogin = configagentlogin.getAgentLogin(service, tenant_dbid, switch_dbid, employee_id); + + if(agentlogin == null) { + agentlogin = configagentlogin.createAgentLogin(service, tenant_dbid, switch_dbid, employee_id); + assignyn = true; + }else { + assignyn = configagentlogin.checkAssignYn(service, tenant_dbid, switch_dbid, employee_id); + } + System.out.println(assignyn); + + //AgentLoginId가 Assign된 상태가 아니면(assignyn true이면 Assign가능) + if(assignyn) { + CfgAgentLoginInfo logininfo = new CfgAgentLoginInfo(service, null); + logininfo.setAgentLoginDBID(agentlogin.getDBID()); + logininfo.setAgentLogin(agentlogin); + logininfo.setWrapupTime(0); + person.getAgentInfo().getAgentLogins().add(logininfo); + person.save(); + rtnResult = true; + } + }catch (ConfigException e) { + rtnResult = false; + e.printStackTrace(); + }catch ( InterruptedException e) { + rtnResult = false; + e.printStackTrace(); + } + return rtnResult; + } + + /** + * Person에 Assign된 AgentLoginID를 삭제한다. + * @param service + * @param person + * @param tenant_dbid + * @param switch_dbid + * @param employee_id + * @return + */ + public boolean removeAgentLoginToPerson( + final IConfService service, + CfgPerson person, + int tenant_dbid, + int switch_dbid, + String employee_id) { + boolean deleteYn = false; + + try { + Collection agentlogininfo = person.getAgentInfo().getAgentLogins(); //기존 AgentLogin정보 + Collection newinfoAgentLoginInfos = new HashSet(); //새로운 AgentLogin정보 + + Iterator iter = agentlogininfo.iterator(); + while (iter.hasNext()) { + CfgAgentLoginInfo cfgagentlogininfo = iter.next(); + if(!cfgagentlogininfo.getAgentLogin().getLoginCode().equals(employee_id)) { + newinfoAgentLoginInfos.add(cfgagentlogininfo); + } + } + + person.getAgentInfo().getAgentLogins().clear(); + person.getAgentInfo().setAgentLogins(newinfoAgentLoginInfos); + person.save(); + deleteYn = true; + }catch (ConfigException e) { + deleteYn = false; + e.printStackTrace(); + } + return deleteYn; + } + + /** + * Person에Skill를 Assign한다. + * @param service + * @param personobj + * @param skill_dbids + * @param skill_levels + * @return + * @throws ConfigException + * @throws InterruptedException + */ + public boolean setSkillsToPerson( + final IConfService service, + CfgPerson personobj, + String[] skill_dbids, + String[] skill_levels) + throws ConfigException, InterruptedException { + boolean rtnbool = false; + try{ + Collection skill = new HashSet(); + if(skill_dbids != null && skill_levels != null) { + for(int i=0; i cfgSkillLevel = null; + Collection tmpSkillLevel = new HashSet(); + cfgSkillLevel = person.getAgentInfo().getSkillLevels(); + tmpSkillLevel.addAll(cfgSkillLevel); + if(cfgSkillLevel.size() > 0){ + for(CfgSkillLevel lvl : cfgSkillLevel){ + for(int i=0; i getPlace(final IConfService service, int tenant_dbid) { + Collection rtnplace = null; + CfgPlaceQuery placequery = new CfgPlaceQuery(); + placequery.setTenantDbid(tenant_dbid); + try { + rtnplace = service.retrieveMultipleObjects(CfgPlace.class, placequery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } catch (InterruptedException e) { + logger.error("InterruptedException", e); + } + return rtnplace; + } + + /** + * CfgPlace을 쿼리한다. + * @param service + * @param tenant_dbid + * @param place_name + * @return + */ + public CfgPlace getPlace(final IConfService service, int tenant_dbid, String place_name) { + CfgPlace rtnplace = null; + CfgPlaceQuery placequery = new CfgPlaceQuery(); + placequery.setTenantDbid(tenant_dbid); + placequery.setName(place_name); + try { + rtnplace = service.retrieveObject(CfgPlace.class, placequery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnplace; + } + + /** + * CfgPlace을 쿼리한다. + * @param service + * @param tenant_dbid + * @param place_dbid + * @return + */ + public CfgPlace getPlace(final IConfService service, int tenant_dbid, int place_dbid) { + CfgPlace rtnplace = null; + CfgPlaceQuery placequery = new CfgPlaceQuery(); + placequery.setTenantDbid(tenant_dbid); + placequery.setDbid(place_dbid); + try { + rtnplace = service.retrieveObject(CfgPlace.class, placequery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnplace; + } + + /** + * CfgPlace을 생성한다. + * @param service + * @param tenant_dbid + * @param switch_dbid + * @param place_name + * @param dn + * @return + */ + public CfgPlace createPlace( + final IConfService service, + int tenant_dbid, + int switch_dbid, + String place_name, + String[] dn + ) { + CfgPlace new_place = new CfgPlace(service); + configdn = new ConfigDn(); + CfgDN tmpdn = null; + Collection dns = new HashSet(); + try { + new_place.setTenantDBID(tenant_dbid); + new_place.setName(place_name); + if(dn.length > 0) { + for(int i=0; i dns = new HashSet(); + try { + place = getPlace(service, tenant_dbid, old_place_name); + if(place != null) { + place.setName(new_place_name); + if(dn.length > 0) { + for(int i=0; i getPlaceGroup(final IConfService service, int tenant_dbid) { + Collection rtnplacegroup = null; + CfgPlaceGroupQuery placequery = new CfgPlaceGroupQuery(); + placequery.setTenantDbid(tenant_dbid); + try { + rtnplacegroup = service.retrieveMultipleObjects(CfgPlaceGroup.class, placequery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } catch (InterruptedException e) { + logger.error("InterruptedException", e); + } + return rtnplacegroup; + } + + /** + * CfgPlaceGroup을 쿼리한다. + * @param service + * @param tenant_dbid + * @param place_name + * @return + */ + public CfgPlaceGroup getPlaceGroup(final IConfService service, int tenant_dbid, String group_name) { + CfgPlaceGroup rtnplacegroup = null; + CfgPlaceGroupQuery groupquery = new CfgPlaceGroupQuery(); + groupquery.setTenantDbid(tenant_dbid); + groupquery.setName(group_name); + try { + rtnplacegroup = service.retrieveObject(CfgPlaceGroup.class, groupquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnplacegroup; + } + + /** + * CfgPlace을 쿼리한다. + * @param service + * @param tenant_dbid + * @param place_dbid + * @return + */ + public CfgPlaceGroup getPlaceGroup(final IConfService service, int tenant_dbid, int place_dbid) { + CfgPlaceGroup rtnplacegroup = null; + CfgPlaceGroupQuery groupquery = new CfgPlaceGroupQuery(); + groupquery.setTenantDbid(tenant_dbid); + groupquery.setDbid(place_dbid); + try { + rtnplacegroup = service.retrieveObject(CfgPlaceGroup.class, groupquery); + } catch (ConfigException e) { + logger.error("ConfigException", e); + } + return rtnplacegroup; + } + + + +} diff --git a/src/main/java/kr/co/i4way/genesys/cfgserver/ManageUserProperties.java b/src/main/java/kr/co/i4way/genesys/cfgserver/ManageUserProperties.java new file mode 100644 index 0000000..d59cc6d --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/cfgserver/ManageUserProperties.java @@ -0,0 +1,454 @@ +package kr.co.i4way.genesys.cfgserver; + +import java.util.Collection; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.genesyslab.platform.applicationblocks.com.CfgObject; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgCampaign; +import com.genesyslab.platform.applicationblocks.com.objects.CfgDN; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkillLevel; +import com.genesyslab.platform.applicationblocks.com.objects.CfgTransaction; +import com.genesyslab.platform.commons.collections.KeyValueCollection; +import com.genesyslab.platform.commons.collections.KeyValuePair; +import com.genesyslab.platform.configuration.protocol.types.CfgFlag; + +import net.minidev.json.JSONArray; +import net.minidev.json.JSONObject; + +public class ManageUserProperties { + + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + public ManageUserProperties() { + + } + + public JSONObject getUserProperties(CfgTransaction obj) { + KeyValueCollection kv = null; + JSONObject jsonObj = new JSONObject(); + JSONObject jsonObj2 = new JSONObject(); + JSONObject rtnObj = new JSONObject(); + String opt_name = null; + kv = obj.getUserProperties(); + + if(kv != null) { + for(Object selObj : kv) { + opt_name = ""; + KeyValuePair sectionKvp = (KeyValuePair) selObj; + opt_name = sectionKvp.getStringKey(); + jsonObj = new JSONObject(); + for (Object recordObj : sectionKvp.getTKVValue()) { + KeyValuePair recordKvp = (KeyValuePair) recordObj; + jsonObj.put(recordKvp.getStringKey(), recordKvp.getStringValue()); + } + jsonObj2.put(opt_name, jsonObj); + } + rtnObj.put("Sections", jsonObj2); + + } + //System.out.println(rtnObj.toJSONString()); + return rtnObj; + } + + public CfgAgentGroup setUserProperties(CfgAgentGroup obj, String sec_name, String[] k, String[] v) { + KeyValueCollection obj_kv = null; + KeyValueCollection insert_kv = null; + String opt_name = null; + boolean update_flag = false; + KeyValuePair sectionKvp = null; + KeyValuePair tmpkvp = null; + + try { + obj_kv = obj.getGroupInfo().getUserProperties(); + + if(obj_kv != null && obj_kv.length() > 0) { + for(Object selObj : obj_kv) { + opt_name = ""; + sectionKvp = (KeyValuePair) selObj; + opt_name = sectionKvp.getStringKey(); + if(sec_name.equals(opt_name)) { + logger.info("update mode"); + update_flag = true; + break; + }else { + logger.info("insert mode1"); + } + } + if(!update_flag) { + insert_kv = new KeyValueCollection(); + for(int i=0; i 0) { + for(Object selObj : obj_kv) { + opt_name = ""; + sectionKvp = (KeyValuePair) selObj; + opt_name = sectionKvp.getStringKey(); + KeyValueCollection tmp_kv = sectionKvp.getTKVValue(); + if(sec_name.equals(opt_name)) { + if(k != null && k.length > 0) { + if(sectionKvp != null) { + if(sec_name.equals(opt_name)) { + insert_kv = new KeyValueCollection(); + for(int i=0; ik.length; i++) { +// insert_kv.addString(k[i], v[i]); +// } +// tmpkvp = new KeyValuePair(sec_name, insert_kv); +// obj_kv.addPair(tmpkvp); +// obj.setUserProperties(obj_kv); +// obj.save(); +// } +// } +// +// } +// }catch(Exception e) { +// +// } +// return obj; +// } + +// public JSONObject getUserProperties(CfgObject obj) { +// KeyValueCollection kv = null; +// JSONObject jsonObj = new JSONObject(); +// JSONObject jsonObj2 = new JSONObject(); +// JSONObject rtnObj = new JSONObject(); +// String opt_name = null; +// if (obj instanceof CfgPerson) { +// CfgPerson cast_obj = (CfgPerson) obj; +// kv = cast_obj.getUserProperties(); +// }else if (obj instanceof CfgAgentGroup) { +// CfgAgentGroup cast_obj = (CfgAgentGroup) obj; +// kv = cast_obj.getGroupInfo().getUserProperties(); +// }else if (obj instanceof CfgAgentLogin) { +// CfgAgentLogin cast_obj = (CfgAgentLogin) obj; +// kv = cast_obj.getUserProperties(); +// }else if (obj instanceof CfgCampaign) { +// CfgCampaign cast_obj = (CfgCampaign) obj; +// kv = cast_obj.getUserProperties(); +// }else if (obj instanceof CfgDN) { +// CfgDN cast_obj = (CfgDN) obj; +// kv = cast_obj.getUserProperties(); +// }else if (obj instanceof CfgTransaction) { +// CfgTransaction cast_obj = (CfgTransaction) obj; +// kv = cast_obj.getUserProperties(); +// } +// if(kv != null) { +// for(Object selObj : kv) { +// opt_name = ""; +// KeyValuePair sectionKvp = (KeyValuePair) selObj; +// opt_name = sectionKvp.getStringKey(); +// jsonObj = new JSONObject(); +// for (Object recordObj : sectionKvp.getTKVValue()) { +// KeyValuePair recordKvp = (KeyValuePair) recordObj; +// jsonObj.put(recordKvp.getStringKey(), recordKvp.getStringValue()); +// } +// jsonObj2.put(opt_name, jsonObj); +// } +// rtnObj.put("Sections", jsonObj2); +// +// } +// //System.out.println(rtnObj.toJSONString()); +// return rtnObj; +// } + + private void createProperties() { + + } + + private void modifyProperties() { + + } + +// public KeyValueCollection setUserProperties(CfgObject obj, String section_name, String k, String v) { +// KeyValueCollection kv = null; +// KeyValueCollection tmpkv1 = new KeyValueCollection(); +// KeyValueCollection tmpkv2 = new KeyValueCollection(); +// KeyValueCollection tmpkv3 = new KeyValueCollection(); +// +// boolean tmpFlag = false; +// String opt_name = null; +// +// try { +// if (obj instanceof CfgPerson) { +// CfgPerson cast_obj = (CfgPerson) obj; +// kv = cast_obj.getUserProperties(); +// }else if (obj instanceof CfgAgentGroup) { +// CfgAgentGroup cast_obj = (CfgAgentGroup) obj; +// kv = cast_obj.getGroupInfo().getUserProperties(); +// }else if (obj instanceof CfgAgentLogin) { +// CfgAgentLogin cast_obj = (CfgAgentLogin) obj; +// kv = cast_obj.getUserProperties(); +// }else if (obj instanceof CfgCampaign) { +// CfgCampaign cast_obj = (CfgCampaign) obj; +// kv = cast_obj.getUserProperties(); +// }else if (obj instanceof CfgDN) { +// CfgDN cast_obj = (CfgDN) obj; +// kv = cast_obj.getUserProperties(); +// }else if (obj instanceof CfgTransaction) { +// CfgTransaction cast_obj = (CfgTransaction) obj; +// kv = cast_obj.getUserProperties(); +// } +// +// if(kv != null) { +// for(Object selObj : kv) { +// KeyValuePair sectionKvp = (KeyValuePair) selObj; +// opt_name = sectionKvp.getStringKey(); +// if(opt_name.equals(section_name)) { +// logger.info("modify mode"); +// }else { +// logger.info("create mode"); +// } +// } +// +// +// +// tmpkv1 = new KeyValueCollection(); +// } +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +//// if(kv != null) { +//// tmpkv1 = new KeyValueCollection(); +//// for(Object selObj : kv) { +//// opt_name = ""; +//// KeyValuePair sectionKvp = (KeyValuePair) selObj; +//// opt_name = sectionKvp.getStringKey(); +//// +//// if(opt_name.equals(section_name)) { //기존에 있던 옵션명이면 +//// tmpkv2 = sectionKvp.getTKVValue(); +//// for(Object kvp : tmpkv2) { +//// KeyValuePair section2Kvp = (KeyValuePair) kvp; +//// if(section2Kvp.getStringKey().equals(k)) { +//// tmpFlag = true; +//// } +//// } +//// if(tmpFlag) { +//// tmpkv2.remove(k); +//// tmpkv2.addString(k, v); +//// sectionKvp.getTKVValue().remove(key); +//// +//// } +//// +//// +////// KeyValueCollection aa = new KeyValueCollection(); +////// KeyValuePair tmpKeyValuePair = new KeyValuePair(k, v); +////// aa.add(tmpKeyValuePair); +////// sectionKvp.setTKVValue(aa); +////// kv.addPair(sectionKvp); +//// }else { //새로만들어야할 옵션명이면 +//// tmpkv = new KeyValueCollection(); +//// tmpkv.addString(k, v); +//// kv.addList(section_name, tmpkv); +//// } +//// } +//// } +// }catch(Exception ex) { +// logger.error("Exception", ex); +// } +// //System.out.println(rtnObj.toJSONString()); +// return kv; +// } + + private KeyValueCollection getKv(CfgObject obj) { + KeyValueCollection rtnkv = null; + if (obj instanceof CfgPerson) { + CfgPerson cast_obj = (CfgPerson) obj; + rtnkv = cast_obj.getUserProperties(); + }else if (obj instanceof CfgAgentGroup) { + CfgAgentGroup cast_obj = (CfgAgentGroup) obj; + rtnkv = cast_obj.getGroupInfo().getUserProperties(); + }else if (obj instanceof CfgAgentLogin) { + CfgAgentLogin cast_obj = (CfgAgentLogin) obj; + rtnkv = cast_obj.getUserProperties(); + }else if (obj instanceof CfgCampaign) { + CfgCampaign cast_obj = (CfgCampaign) obj; + rtnkv = cast_obj.getUserProperties(); + }else if (obj instanceof CfgDN) { + CfgDN cast_obj = (CfgDN) obj; + rtnkv = cast_obj.getUserProperties(); + }else if (obj instanceof CfgTransaction) { + CfgTransaction cast_obj = (CfgTransaction) obj; + rtnkv = cast_obj.getUserProperties(); + } + return rtnkv; + } + +} diff --git a/src/main/java/kr/co/i4way/genesys/cfgserver/initConfigService.java b/src/main/java/kr/co/i4way/genesys/cfgserver/initConfigService.java new file mode 100644 index 0000000..0a6e655 --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/cfgserver/initConfigService.java @@ -0,0 +1,185 @@ +package kr.co.i4way.genesys.cfgserver; + +import java.util.EventObject; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import com.genesyslab.platform.applicationblocks.com.ConfServiceFactory; +import com.genesyslab.platform.applicationblocks.com.ConfigException; +import com.genesyslab.platform.applicationblocks.com.IConfService; +import com.genesyslab.platform.commons.connection.Connection; +import com.genesyslab.platform.commons.connection.configuration.PropertyConfiguration; +import com.genesyslab.platform.commons.protocol.ChannelClosedEvent; +import com.genesyslab.platform.commons.protocol.ChannelErrorEvent; +import com.genesyslab.platform.commons.protocol.ChannelListener; +import com.genesyslab.platform.commons.protocol.ChannelState; +import com.genesyslab.platform.commons.protocol.Endpoint; +import com.genesyslab.platform.commons.protocol.ProtocolException; +import com.genesyslab.platform.configuration.protocol.ConfServerProtocol; +import com.genesyslab.platform.configuration.protocol.types.CfgAppType; + +import kr.co.i4way.genesys.model.GenesysInfoVo; + +public class initConfigService { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + + @Autowired + private GenesysInfoVo genesysinfovo; + public IConfService service; + + private static initConfigService m_initConfigServiceInstance = null; + + public initConfigService() { + } + + public static initConfigService getInstance() { + if (m_initConfigServiceInstance == null) + m_initConfigServiceInstance = new initConfigService(); + return m_initConfigServiceInstance; + } + + public ChannelState openConfigService(GenesysInfoVo vo) throws ConfigException, InterruptedException { + genesysinfovo = vo; + + if(checkConfService() == ChannelState.Opened) { + return ChannelState.Opened; + } + + PropertyConfiguration config = new PropertyConfiguration(); + config.setUseAddp(true); + config.setAddpClientTimeout(5); + config.setAddpServerTimeout(5); + config.setOption(Connection.STR_ATTR_ENCODING_NAME_KEY, genesysinfovo.getCfg_charset()); + + Endpoint cfgServerEndpoint = new Endpoint(genesysinfovo.getCfg_endpoint_p(), genesysinfovo.getCfg_ip_p(), + genesysinfovo.getCfg_port_p(), config); + + ConfServerProtocol protocol = new ConfServerProtocol(cfgServerEndpoint); + protocol.addChannelListener(new ChannelListener() { + @Override + public void onChannelClosed(ChannelClosedEvent arg0) { + protocolClosed(arg0); + // TODO Auto-generated method stub + } + @Override + public void onChannelError(ChannelErrorEvent arg0) { + protocolError(arg0); + // TODO Auto-generated method stub + } + @Override + public void onChannelOpened(EventObject arg0) { + protocolOpend(arg0); + // TODO Auto-generated method stub + } + }); + + protocol.setClientName(genesysinfovo.getCfg_client_name()); + protocol.setClientApplicationType(CfgAppType.CFGSCE.ordinal()); + protocol.setUserName(genesysinfovo.getCfg_id()); + protocol.setUserPassword(genesysinfovo.getCfg_passwd()); + + service = ConfServiceFactory.createConfService(protocol); + try { + logger.info("Primary서버로 접속시도 : IP=" + genesysinfovo.getCfg_ip_p() + ", Port=" + genesysinfovo.getCfg_port_p()); + protocol.open(); + logger.info(service.getProtocol().getEndpoint().getConfiguration().toString()); + + Integer cfgServerEncoding = protocol.getServerContext().getServerEncoding(); + if (cfgServerEncoding != null && cfgServerEncoding.intValue() == 1) { + logger.info("Charset을 UTF-8로 변경"); + protocol.close(); + config.setStringsEncoding("UTF-8"); + protocol.setEndpoint(new Endpoint(genesysinfovo.getCfg_endpoint_p(), genesysinfovo.getCfg_ip_p(), + genesysinfovo.getCfg_port_p(), config)); + protocol.open(); + } else { + logger.info("Charset 변경안함"); + } + } catch (ProtocolException e) { + logger.error("ProtocolException", e); + logger.info("Backup서버로 접속시도 : IP=" + genesysinfovo.getCfg_ip_b() + ", Port=" + genesysinfovo.getCfg_port_b()); + protocol.setEndpoint(new Endpoint(genesysinfovo.getCfg_endpoint_b(), genesysinfovo.getCfg_ip_b(), + genesysinfovo.getCfg_port_b(), config)); + try { + protocol.open(); + logger.info(service.getProtocol().getEndpoint().getConfiguration().toString()); + + Integer cfgServerEncoding = protocol.getServerContext().getServerEncoding(); + if (cfgServerEncoding != null && cfgServerEncoding.intValue() == 1) { + logger.info("Charset을 UTF-8로 변경"); + protocol.close(); + config.setStringsEncoding("UTF-8"); + protocol.setEndpoint(new Endpoint(genesysinfovo.getCfg_endpoint_b(), genesysinfovo.getCfg_ip_b(), + genesysinfovo.getCfg_port_b(), config)); + protocol.open(); + } else { + logger.info("Charset 변경안함"); + } + } catch (ProtocolException | IllegalStateException e1) { + logger.error("ProtocolException | IllegalStateException", e1); + } + } + return service.getProtocol().getState(); + } + + private void protocolClosed(ChannelClosedEvent args) { + logger.info("protocol Closed"); + } + private void protocolError(ChannelErrorEvent args) { + logger.info("protocol Error"); + } + private void protocolOpend(EventObject args) { + logger.info("protocol Opend"); + } + + public void closeConfigService() throws ProtocolException, IllegalStateException, InterruptedException { + try { + if (service.getProtocol().getState() != ChannelState.Closed) { + service.getProtocol().close(); + + } + ConfServiceFactory.releaseConfService(service); + service = null; + }catch(Exception ex) { + logger.error("Exception", ex); + } + } + + public String checkAndConnectConfigService() { + String rtnStr = "null"; + try { + if(service != null) { + if (service.getProtocol().getState() != ChannelState.Closed) { + closeConfigService(); + rtnStr = "close"; + } + } + } catch (ProtocolException | IllegalStateException | InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + rtnStr = "error_close"; + } + try { + if(genesysinfovo != null) { + openConfigService(genesysinfovo); + rtnStr = "open"; + } + } catch (ConfigException | InterruptedException e) { + logger.error("ConfigException | InterruptedException", e); + rtnStr = "error_open"; + } + return rtnStr; + } + + public ChannelState checkConfService() { + ChannelState rtnState = ChannelState.Closed; + if(service == null) { + rtnState = ChannelState.Closed; + }else { + rtnState = service.getProtocol().getState(); + } + return rtnState; + } +} diff --git a/src/main/java/kr/co/i4way/genesys/controller/AgentLoginController.java b/src/main/java/kr/co/i4way/genesys/controller/AgentLoginController.java new file mode 100644 index 0000000..822fb39 --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/controller/AgentLoginController.java @@ -0,0 +1,322 @@ +package kr.co.i4way.genesys.controller; + +import java.util.Collection; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLoginInfo; +import com.genesyslab.platform.commons.collections.KeyValueCollection; +import com.genesyslab.platform.commons.collections.KeyValuePair; +import com.genesyslab.platform.commons.protocol.ChannelState; + +import kr.co.i4way.genesys.cfgserver.ConfigAgentLogin; +import kr.co.i4way.genesys.cfgserver.initConfigService; +import kr.co.i4way.genesys.model.GenesysInfoVo; +import net.minidev.json.JSONArray; +import net.minidev.json.JSONObject; + +/** + * AgentLogin용 Controller + * @author jkhong + * + */ +@Controller +@CrossOrigin(origins = "*") +public class AgentLoginController { + @Autowired + private GenesysInfoVo genesysinfovo; + initConfigService initconfigservice = initConfigService.getInstance(); + ConfigAgentLogin cfgagentlogin = null; + + /** + * CfgPerson에 Assign되어있는 AgentLogin정보를 조회한다. + * @param request + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/agentLogin/getPersonAgentLoginInfo") + public JSONObject getPersonAgentLoginInfo(HttpServletRequest request) throws Exception{ + Collection agentlogininfo = null; + JSONObject rtnobj = new JSONObject(); + //Map map = new HashMap<>(); + + try { + String employee_id = request.getParameter("employee_id") != null ? request.getParameter("employee_id") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgagentlogin = new ConfigAgentLogin(); + agentlogininfo = cfgagentlogin.getAgentLoginInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), employee_id); + rtnobj = convertAgentLoginInfos_jsonObj(agentlogininfo); + //map = JsonUtil.getMapFromJsonObject(rtnobj); + } + rtnobj.put("command", "getPersonAgentLoginInfo"); + rtnobj.put("employee_id", employee_id); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + /** + * 전체CfgAgentLogin 정보를 조회한다. + * @param request("assignable") : Assign여부 yes : assign된 Object + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/agentLogin/getAgentLogins") + public JSONObject getAgentLogins(HttpServletRequest request) throws Exception{ + Collection agentlogininfo = null; + JSONObject rtnobj = new JSONObject(); + //Map map = new HashMap<>(); + + try { + String Assignable = request.getParameter("assignable") != null ? request.getParameter("assignable") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgagentlogin = new ConfigAgentLogin(); + agentlogininfo = cfgagentlogin.getAgentLogins(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid(), Assignable); + rtnobj = convertAgentLogins_jsonObj(agentlogininfo); + //map = JsonUtil.getMapFromJsonObject(rtnobj); + } + rtnobj.put("command", "getAgentLogins"); + rtnobj.put("assignable", Assignable); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + /** + * CfgAgentLogin 정보를 조회한다. + * @param request("qry_type") : 쿼리타입 loginCode : loginCode로 쿼리, dbid : dbid로 쿼리 + * @param request("qry_str") : Assign여부 yes : assign된 Object + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/agentLogin/getAgentLogin") + public JSONObject getAgentLogin(HttpServletRequest request) throws Exception{ + CfgAgentLogin agentlogininfo = null; + JSONObject rtnobj = new JSONObject(); + //Map map = new HashMap<>(); + + try { + String qry_type = request.getParameter("qry_type") != null ? request.getParameter("qry_type") : ""; + String qry_str = request.getParameter("qry_str") != null ? request.getParameter("qry_str") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgagentlogin = new ConfigAgentLogin(); + if(qry_type.equals("loginCode")) { + agentlogininfo = cfgagentlogin.getAgentLogin(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid(), qry_str); + }else if(qry_type.equals("dbid")) { + agentlogininfo = cfgagentlogin.getAgentLogin(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid(), Integer.parseInt(qry_str)); + } + rtnobj = convertAgentLogins_jsonObj(agentlogininfo); + rtnobj.put("command", "getAgentLogin"); + rtnobj.put("qry_type", qry_type); + rtnobj.put("qry_str", qry_str); + } + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @ResponseBody + @RequestMapping("/agentLogin/checkAgentLogin") + public JSONObject checkAgentLogin(HttpServletRequest request) throws Exception{ + CfgAgentLogin agentlogininfo = null; + JSONObject tmpobj = new JSONObject(); + JSONObject rtnobj = new JSONObject(); + //Map map = new HashMap<>(); + String warpuptm = ""; + + try { + String login_code = request.getParameter("login_code") != null ? request.getParameter("login_code") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgagentlogin = new ConfigAgentLogin(); + agentlogininfo = cfgagentlogin.getAgentLogin(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid(), login_code); + rtnobj.put("command", "checkAgentLogin"); + if(agentlogininfo != null){ + KeyValueCollection appOptions = agentlogininfo.getUserProperties(); + + for(Object selectionObj : appOptions){ + KeyValuePair sectionKvp = (KeyValuePair) selectionObj; + + for (Object recordObj : sectionKvp.getTKVValue()) { + KeyValuePair recordKvp = (KeyValuePair) recordObj; + if(recordKvp.getStringKey().equals("wrap-up-time")){ + warpuptm = recordKvp.getStringValue(); + } + } + } + if(warpuptm.equals("")){ + rtnobj.put("result", false); + }else{ + rtnobj.put("result", true); + } + rtnobj.put("loginCode", agentlogininfo.getLoginCode()); + }else { + rtnobj.put("result", false); + rtnobj.put("loginCode", null); + } + + } + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @ResponseBody + @RequestMapping("/agentLogin/createAgentLogin") + public JSONObject createAgentLogin(HttpServletRequest request) throws Exception{ + CfgAgentLogin agentlogininfo = null; + JSONObject rtnobj = new JSONObject(); + + try { + String login_code = request.getParameter("login_code") != null ? request.getParameter("login_code") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgagentlogin = new ConfigAgentLogin(); + agentlogininfo = cfgagentlogin.createAgentLogin(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid(), login_code); + rtnobj = convertAgentLogins_jsonObj(agentlogininfo); + } + rtnobj.put("command", "checkAgentLogin"); + rtnobj.put("login_code", login_code); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @ResponseBody + @RequestMapping("/agentLogin/deleteAgentLogin") + public JSONObject deleteAgentLogin(HttpServletRequest request) throws Exception{ + JSONObject rtnobj = new JSONObject(); + boolean result = false; + try { + String login_code = request.getParameter("login_code") != null ? request.getParameter("login_code") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgagentlogin = new ConfigAgentLogin(); + result = cfgagentlogin.deleteAgentLogins(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid(), login_code); + rtnobj.put("result", result); + rtnobj.put("loginCode", login_code); + rtnobj.put("command", "deleteAgentLogin"); + } + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + private JSONObject convertAgentLogins_jsonObj(Collection agentlogins) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + String warpuptm = ""; + + if(agentlogins != null) { + for (CfgAgentLogin agentlogin : agentlogins) { + warpuptm = ""; + jsonObj = new JSONObject(); + jsonObj.put("dbid", agentlogin.getDBID()); + jsonObj.put("loginCode", agentlogin.getLoginCode()); + if(agentlogin != null){ + KeyValueCollection appOptions = agentlogin.getUserProperties(); + + for(Object selectionObj : appOptions){ + KeyValuePair sectionKvp = (KeyValuePair) selectionObj; + + for (Object recordObj : sectionKvp.getTKVValue()) { + KeyValuePair recordKvp = (KeyValuePair) recordObj; + if(recordKvp.getStringKey().equals("wrap-up-time")){ + warpuptm = recordKvp.getStringValue(); + } + } + } + } + + if(warpuptm.equals("")){ + jsonObj.put("isAssign", false); + }else{ + jsonObj.put("isAssign", true); + } + jsonArray.add(jsonObj); + } + finalJsonObj.put("agentLogins", jsonArray); + }else { + finalJsonObj.put("agentLogins", null); + } + return finalJsonObj; + } + + private JSONObject convertAgentLogins_jsonObj(CfgAgentLogin agentlogin) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + String warpuptm = ""; + + if(agentlogin != null) { + jsonObj = new JSONObject(); + jsonObj.put("dbid", agentlogin.getDBID()); + jsonObj.put("loginCode", agentlogin.getLoginCode()); + if(agentlogin != null){ + KeyValueCollection appOptions = agentlogin.getUserProperties(); + + for(Object selectionObj : appOptions){ + KeyValuePair sectionKvp = (KeyValuePair) selectionObj; + + for (Object recordObj : sectionKvp.getTKVValue()) { + KeyValuePair recordKvp = (KeyValuePair) recordObj; + if(recordKvp.getStringKey().equals("wrap-up-time")){ + warpuptm = recordKvp.getStringValue(); + } + } + } + } + + if(warpuptm.equals("")){ + jsonObj.put("isAssign", false); + }else{ + jsonObj.put("isAssign", true); + } + jsonArray.add(jsonObj); + finalJsonObj.put("agentLogins", jsonArray); + }else { + finalJsonObj.put("agentLogins", null); + } + return finalJsonObj; + } + + private JSONObject convertAgentLoginInfos_jsonObj(Collection agentlogininfos) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + + if(agentlogininfos != null) { + for (CfgAgentLoginInfo agentlogininfo : agentlogininfos) { + jsonObj = new JSONObject(); + jsonObj.put("dbid", agentlogininfo.getAgentLogin().getDBID()); + jsonObj.put("loginCode", agentlogininfo.getAgentLogin().getLoginCode()); + jsonArray.add(jsonObj); + } + finalJsonObj.put("agentLogins", jsonArray); + }else { + finalJsonObj.put("agentLogins", null); + } + return finalJsonObj; + } + +} diff --git a/src/main/java/kr/co/i4way/genesys/controller/DnController.java b/src/main/java/kr/co/i4way/genesys/controller/DnController.java new file mode 100644 index 0000000..2fb88f0 --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/controller/DnController.java @@ -0,0 +1,357 @@ +package kr.co.i4way.genesys.controller; + +import java.util.Collection; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLoginInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgDN; +import com.genesyslab.platform.applicationblocks.com.objects.CfgDNGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgDNInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.commons.collections.KeyValueCollection; +import com.genesyslab.platform.commons.collections.KeyValuePair; +import com.genesyslab.platform.commons.protocol.ChannelState; +import com.genesyslab.platform.configuration.protocol.types.CfgFlag; + +import kr.co.i4way.genesys.cfgserver.ConfigAgentLogin; +import kr.co.i4way.genesys.cfgserver.ConfigDn; +import kr.co.i4way.genesys.cfgserver.initConfigService; +import kr.co.i4way.genesys.model.GenesysInfoVo; +import net.minidev.json.JSONArray; +import net.minidev.json.JSONObject; + +/** + * Dn용 Controller + * @author jkhong + * + */ +@Controller +@CrossOrigin(origins = "*") +public class DnController { + @Autowired + private GenesysInfoVo genesysinfovo; + initConfigService initconfigservice = initConfigService.getInstance(); + ConfigDn cfgdn = null; + + /** + * CfgDN정보를 조회한다. + * @param request + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/dn/getDnsInfo") + public JSONObject getDnsInfo(HttpServletRequest request) throws Exception{ + Collection dninfo = null; + JSONObject rtnobj = new JSONObject(); + + try { + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgdn = new ConfigDn(); + dninfo = cfgdn.getDn(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid()); + rtnobj = convertDns_jsonObj(dninfo); + } + rtnobj.put("command", "getDnsInfo"); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + /** + * CfgDN정보를 조회한다. + * @param request + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/dn/getDnInfo") + public JSONObject getDnInfo(HttpServletRequest request) throws Exception{ + CfgDN dninfo = null; + JSONObject rtnobj = new JSONObject(); + + try { + String dn_number = request.getParameter("dn_number") != null ? request.getParameter("dn_number") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgdn = new ConfigDn(); + dninfo = cfgdn.getDn(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid(), dn_number); + rtnobj = convertDns_jsonObj(dninfo); + } + rtnobj.put("command", "getDnInfo"); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @ResponseBody + @RequestMapping("/dn/createDn") + public JSONObject createDn(HttpServletRequest request) throws Exception{ + CfgDN dn = null; + JSONObject rtnobj = new JSONObject(); + + try { + String dn_number = request.getParameter("dn_number") != null ? request.getParameter("dn_number") : ""; + String dn_type = request.getParameter("dn_type") != null ? request.getParameter("dn_type") : ""; + String route_type = request.getParameter("route_type") != null ? request.getParameter("route_type") : ""; + int switch_spec_type = request.getParameter("switch_spec_type") != null ? Integer.parseInt(request.getParameter("switch_spec_type")) : 0; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgdn = new ConfigDn(); + dn = cfgdn.createDN(initconfigservice.service + , genesysinfovo.getCfg_tenant_dbid() + , genesysinfovo.getCfg_switch_dbid() + , dn_number + , dn_type + , route_type + , switch_spec_type); + rtnobj = convertDns_jsonObj(dn); + } + rtnobj.put("command", "createDn"); + rtnobj.put("dn_number", dn_number); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @ResponseBody + @RequestMapping("/dn/deleteDn") + public JSONObject deleteDn(HttpServletRequest request) throws Exception{ + boolean rtnval = false; + JSONObject rtnobj = new JSONObject(); + + try { + String dn_number = request.getParameter("dn_number") != null ? request.getParameter("dn_number") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgdn = new ConfigDn(); + rtnval = cfgdn.deleteDN(initconfigservice.service + , genesysinfovo.getCfg_tenant_dbid() + , genesysinfovo.getCfg_switch_dbid() + , dn_number); + } + rtnobj.put("command", "deleteDn"); + rtnobj.put("result", rtnval); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + + /** + * CfgDnGroup정보를 조회한다. + * @param request + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/dn/getDnGroupsInfo") + public JSONObject getDnGroupsInfo(HttpServletRequest request) throws Exception{ + Collection dngroupinfo = null; + JSONObject rtnobj = new JSONObject(); + + try { + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgdn = new ConfigDn(); + dngroupinfo = cfgdn.getDnGroup(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid()); + rtnobj = convertDnGroup_jsonObj(dngroupinfo); + } + rtnobj.put("command", "getDnGroupsInfo"); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + /** + * CfgDnGroup정보를 조회한다. + * @param request + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/dn/getDnGroupInfo") + public JSONObject getDnGroupInfo(HttpServletRequest request) throws Exception{ + CfgDNGroup dninfo = null; + JSONObject rtnobj = new JSONObject(); + + try { + String group_name = request.getParameter("group_name") != null ? request.getParameter("group_name") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgdn = new ConfigDn(); + dninfo = cfgdn.getDnGroup(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), group_name); + rtnobj = convertDnGroup_jsonObj(dninfo); + } + rtnobj.put("command", "getDnGroupInfo"); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @ResponseBody + @RequestMapping("/dn/createDnGroup") + public JSONObject createDnGroup(HttpServletRequest request) throws Exception{ + CfgDNGroup dngroup = null; + JSONObject rtnobj = new JSONObject(); + + try { + String group_name = request.getParameter("group_name") != null ? request.getParameter("group_name") : ""; + String group_type = request.getParameter("group_type") != null ? request.getParameter("group_type") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgdn = new ConfigDn(); + dngroup = cfgdn.createDNGroup(initconfigservice.service + , genesysinfovo.getCfg_tenant_dbid() + , group_name + , group_type); + rtnobj = convertDnGroup_jsonObj(dngroup); + } + rtnobj.put("command", "createDnGroup"); + rtnobj.put("group_name", group_name); + rtnobj.put("group_type", group_type); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @ResponseBody + @RequestMapping("/dn/deleteDnGroup") + public JSONObject deleteDnGroup(HttpServletRequest request) throws Exception{ + boolean rtnval = false; + JSONObject rtnobj = new JSONObject(); + + try { + String group_name = request.getParameter("group_name") != null ? request.getParameter("group_name") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgdn = new ConfigDn(); + rtnval = cfgdn.deleteDNGroup(initconfigservice.service + , genesysinfovo.getCfg_tenant_dbid() + , group_name); + } + rtnobj.put("command", "deleteDnGroup"); + rtnobj.put("result", rtnval); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + + + + private JSONObject convertDns_jsonObj(Collection dns) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + String warpuptm = ""; + + if(dns != null) { + for (CfgDN dn : dns) { + warpuptm = ""; + jsonObj = new JSONObject(); + jsonObj.put("dbid", dn.getDBID()); + jsonObj.put("number", dn.getNumber()); + jsonObj.put("switch_dbid", dn.getSwitchDBID()); + jsonObj.put("tenant_dbid", dn.getTenantDBID()); + jsonObj.put("object_type", dn.getType().toString()); + jsonArray.add(jsonObj); + } + finalJsonObj.put("Dns", jsonArray); + }else { + finalJsonObj.put("Dns", null); + } + return finalJsonObj; + } + + private JSONObject convertDns_jsonObj(CfgDN dn) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + + if(dn != null) { + finalJsonObj.put("dbid", dn.getDBID()); + finalJsonObj.put("number", dn.getNumber()); + finalJsonObj.put("switch_dbid", dn.getSwitchDBID()); + finalJsonObj.put("tenant_dbid", dn.getTenantDBID()); + finalJsonObj.put("object_type", dn.getType().toString()); + } + return finalJsonObj; + } + + private JSONObject convertDnGroup_jsonObj(Collection dngroups) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + Collection dns; + String warpuptm = ""; + + if(dngroups != null) { + for (CfgDNGroup dngroup : dngroups) { + warpuptm = ""; + jsonObj = new JSONObject(); + jsonObj.put("dbid", dngroup.getDBID()); + jsonObj.put("name", dngroup.getGroupInfo().getName()); + jsonObj.put("object_type", dngroup.getType().toString()); + dns = dngroup.getDNs(); + if(dns != null) { + jsonObj.put("dns", getCfgDnInfoCollectionInfo(dns)); + } + jsonArray.add(jsonObj); + } + finalJsonObj.put("Groups", jsonArray); + }else { + finalJsonObj.put("Groups", null); + } + return finalJsonObj; + } + + private JSONArray getCfgDnInfoCollectionInfo(Collection coll) { + JSONArray rtnArray = new JSONArray(); + JSONObject jsonObj; + for (CfgDNInfo dninfo : coll) { + jsonObj = new JSONObject(); + jsonObj.put("dbid", dninfo.getDNDBID()); + jsonObj.put("number", dninfo.getDN().getNumber()); + jsonObj.put("switch_dbid", dninfo.getDN().getSwitchDBID()); + jsonObj.put("tenant_dbid", dninfo.getDN().getTenantDBID()); + jsonObj.put("object_type", dninfo.getDN().getType().toString()); + rtnArray.add(jsonObj); + } + return rtnArray; + } + + private JSONObject convertDnGroup_jsonObj(CfgDNGroup dngroup) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + Collection dns; + + if(dngroup != null) { + finalJsonObj.put("dbid", dngroup.getDBID()); + finalJsonObj.put("name", dngroup.getGroupInfo().getName()); + finalJsonObj.put("object_type", dngroup.getType().toString()); + dns = dngroup.getDNs(); + if(dns != null) { + finalJsonObj.put("dns", getCfgDnInfoCollectionInfo(dns)); + } + } + return finalJsonObj; + } +} diff --git a/src/main/java/kr/co/i4way/genesys/controller/GroupController.java b/src/main/java/kr/co/i4way/genesys/controller/GroupController.java new file mode 100644 index 0000000..72f5790 --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/controller/GroupController.java @@ -0,0 +1,333 @@ +package kr.co.i4way.genesys.controller; + +import java.io.StringWriter; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.json.XML; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; +import org.w3c.dom.Node; + +import com.genesyslab.platform.applicationblocks.com.CfgObject; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLoginInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkillLevel; +import com.genesyslab.platform.commons.collections.KeyValueCollection; +import com.genesyslab.platform.commons.collections.KeyValuePair; +import com.genesyslab.platform.commons.protocol.ChannelState; +import com.genesyslab.platform.configuration.protocol.types.CfgFlag; + +import kr.co.i4way.common.util.JsonUtil; +import kr.co.i4way.genesys.cfgserver.ConfigAgentGroup; +import kr.co.i4way.genesys.cfgserver.ConfigAgentLogin; +import kr.co.i4way.genesys.cfgserver.ConfigPerson; +import kr.co.i4way.genesys.cfgserver.initConfigService; +import kr.co.i4way.genesys.model.GenesysInfoVo; +import net.minidev.json.JSONArray; +import net.minidev.json.JSONObject; + +@RestController +@CrossOrigin(origins = "*") +public class GroupController { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + @Autowired + private GenesysInfoVo genesysinfovo; + initConfigService initconfigservice = initConfigService.getInstance(); + ConfigAgentGroup cfg = new ConfigAgentGroup(); + ConfigPerson ps = new ConfigPerson(); + + @RequestMapping("/group/getAgentGroupInfo") + public JSONObject getAgentGroupInfo(HttpServletRequest request) throws Exception{ + CfgAgentGroup agentgroup = null; + JSONObject rtnobj = new JSONObject(); + Map map = new HashMap<>(); + String rtnStr = ""; + + try { + //DBID로 조회 + //int group_dbid = request.getParameter("group_dbid") != null ? Integer.parseInt(request.getParameter("group_dbid")) : 0; + //그룹명으로 조회 + String group_name = request.getParameter("group_name") != null ? request.getParameter("group_name") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfg = new ConfigAgentGroup(); + //agentgroup = cfg.getAgentGroupInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), group_dbid); + agentgroup = cfg.getAgentGroupInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), group_name); + rtnobj = convertGroupInfo_jsonObj(agentgroup); + } + rtnobj.put("command", "getAgentGroupInfo"); + }catch(Exception e) { + logger.error("Exception", e); + }finally { + } + return rtnobj; + } + + @RequestMapping("/group/getAllAgentGroupInfo") + public JSONObject getAgentGroupInfoAll(HttpServletRequest request) throws Exception{ + Collection agentgroups = null; + JSONObject rtnobj = new JSONObject(); + Map map = new HashMap<>(); + String rtnStr = ""; + + try { + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfg = new ConfigAgentGroup(); + agentgroups = cfg.getAgentGroupInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid()); + rtnobj = convertGroupInfo_jsonObj(agentgroups); + } + rtnobj.put("command", "getAgentGroupInfoAll"); + }catch(Exception e) { + logger.error("Exception", e); + }finally { + } + return rtnobj; + } + + @RequestMapping("/group/getAssignGroupInfo") + public JSONObject getAssignGroupInfo(HttpServletRequest request) throws Exception{ + Collection agentgroups = null; + CfgPerson person = null; + JSONObject rtnobj = new JSONObject(); + Map map = new HashMap<>(); + String rtnStr = ""; + + try { + String employee_id = request.getParameter("employee_id") != null ? request.getParameter("employee_id") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + ps = new ConfigPerson(); + person = ps.getPersonInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), "emp", employee_id); + + cfg = new ConfigAgentGroup(); + agentgroups = cfg.getAssignAgentGroup(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), person.getDBID()); + + rtnobj = convertGroupInfo_jsonObj(agentgroups); + } + rtnobj.put("command", "getAssignGroupInfo"); + }catch(Exception e) { + logger.error("Exception", e); + }finally { + } + return rtnobj; + } + + @RequestMapping("/group/createAgentGroup") + public JSONObject createAgentGroup(HttpServletRequest request) throws Exception{ + JSONObject rtnobj = new JSONObject(); + CfgAgentGroup agentgroup = null; + + try { + String group_name = request.getParameter("group_name") != null ? request.getParameter("group_name") : ""; + cfg = new ConfigAgentGroup(); + + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + agentgroup = cfg.getAgentGroupInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), group_name); + + if(agentgroup == null) { + logger.info("Create Person~"); + agentgroup = cfg.createAgentGroup(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), group_name); + rtnobj = convertGroupInfo_jsonObj(agentgroup); + } + } + rtnobj.put("command", "createAgentGroup"); + }catch(Exception e) { + logger.error("Exception", e); + } + return rtnobj; + } + + @RequestMapping("/group/modifyAgentGroup") + public JSONObject modifyAgentGroup(HttpServletRequest request) throws Exception{ + CfgAgentGroup agentgroup = null; + JSONObject rtnobj = new JSONObject(); + try { + String before_group_name = request.getParameter("before_group_name") != null ? request.getParameter("before_group_name") : ""; + String after_group_name = request.getParameter("after_group_name") != null ? request.getParameter("after_group_name") : ""; + cfg = new ConfigAgentGroup(); + + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + agentgroup = cfg.getAgentGroupInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), before_group_name); + + if(agentgroup != null) { //수정모드 + agentgroup = cfg.modifyAgentGroup(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), agentgroup.getDBID(), after_group_name); + logger.info("Modify AgentGroup~"); + } + rtnobj = convertGroupInfo_jsonObj(agentgroup); + } + rtnobj.put("command", "modifyAgentGroup"); + }catch(Exception e) { + logger.error("Exception", e); + } + return rtnobj; + } + + @RequestMapping("/group/deleteAgentGroup") + public JSONObject deleteAgentGroup(HttpServletRequest request) throws Exception{ + JSONObject rtnobj = new JSONObject(); + boolean del_agentgroup_result = false; + CfgAgentGroup agentgroup = null; + + try { + String group_name = request.getParameter("group_name") != null ? request.getParameter("group_name") : ""; + cfg = new ConfigAgentGroup(); + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + agentgroup = cfg.getAgentGroupInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), group_name); + + if(agentgroup != null) { //삭제모드 + del_agentgroup_result = cfg.deleteAgentGroup(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), agentgroup.getDBID()); + logger.info("delete AgentGroup~"); + } + } + rtnobj.put("command", "deleteAgentGroup"); + rtnobj.put("result_delete_agentgroup", del_agentgroup_result); + }catch(Exception e) { + e.printStackTrace(); + } + return rtnobj; + } + + @RequestMapping("/group/assignPersonToAgentGroup") + public JSONObject assignPersonToAgentGroup(HttpServletRequest request) throws Exception{ + JSONObject rtnobj = new JSONObject(); + boolean del_agentgroup_result = false; + CfgAgentGroup agentgroup = null; + + try { + String group_name = request.getParameter("group_name") != null ? request.getParameter("group_name") : ""; + String employee_ids = request.getParameter("employee_ids") != null ? request.getParameter("employee_ids") : ""; + cfg = new ConfigAgentGroup(); + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + agentgroup = cfg.assignPersonToAgentGroup(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), group_name, employee_ids); + rtnobj = convertGroupInfo_jsonObj(agentgroup); + } + rtnobj.put("command", "assignPersonToAgentGroup"); + }catch(Exception e) { + e.printStackTrace(); + } + return rtnobj; + } + + @RequestMapping("/group/removePersonFromAgentGroup") + public JSONObject removePersonFromAgentGroup(HttpServletRequest request) throws Exception{ + JSONObject rtnobj = new JSONObject(); + boolean del_agentgroup_result = false; + CfgAgentGroup agentgroup = null; + + try { + String group_name = request.getParameter("group_name") != null ? request.getParameter("group_name") : ""; + String employee_ids = request.getParameter("employee_ids") != null ? request.getParameter("employee_ids") : ""; + cfg = new ConfigAgentGroup(); + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + agentgroup = cfg.removePersonFromAgentGroup(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), group_name, employee_ids); + rtnobj = convertGroupInfo_jsonObj(agentgroup); + } + rtnobj.put("command", "removePersonFromAgentGroup"); + }catch(Exception e) { + e.printStackTrace(); + } + return rtnobj; + } + + @RequestMapping("/group/movePersonFromAgentGroup") + public JSONObject movePersonFromAgentGroup(HttpServletRequest request) throws Exception{ + JSONObject rtnobj = new JSONObject(); + boolean del_agentgroup_result = false; + CfgAgentGroup agentgroup = null; + + try { + String src_group_name = request.getParameter("src_group_name") != null ? request.getParameter("src_group_name") : ""; + String tgt_group_name = request.getParameter("tgt_group_name") != null ? request.getParameter("tgt_group_name") : ""; + String employee_id = request.getParameter("employee_id") != null ? request.getParameter("employee_id") : ""; + String delete_yn = request.getParameter("delete_yn") != null ? request.getParameter("delete_yn") : ""; + cfg = new ConfigAgentGroup(); + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + agentgroup = cfg.movePerson2(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), src_group_name, tgt_group_name, employee_id, delete_yn); + rtnobj = convertGroupInfo_jsonObj(agentgroup); + } + rtnobj.put("command", "movePersonFromAgentGroup"); + }catch(Exception e) { + e.printStackTrace(); + } + return rtnobj; + } + + private JSONObject convertGroupInfo_jsonObj(CfgAgentGroup group) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + + if(group != null) { + Collection persons = group.getAgents(); + if(persons != null) { + finalJsonObj.put("agents", getCfgPersonCollectionInfo(persons)); + } + + finalJsonObj.put("dbid", group.getDBID()); + finalJsonObj.put("name", group.getGroupInfo().getName()); + finalJsonObj.put("folderDbid", group.getFolderId()); + } + return finalJsonObj; + } + + private JSONObject convertGroupInfo_jsonObj(Collection groups) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + Collection persons; + String warpuptm = ""; + + if(groups != null) { + for (CfgAgentGroup agentgroup : groups) { + warpuptm = ""; + persons = null; + jsonObj = new JSONObject(); + jsonObj.put("dbid", agentgroup.getDBID()); + jsonObj.put("name", agentgroup.getGroupInfo().getName()); + jsonObj.put("folderDbid", agentgroup.getFolderId()); + persons = agentgroup.getAgents(); + if(persons != null) { + jsonObj.put("agents", getCfgPersonCollectionInfo(persons)); + } + jsonArray.add(jsonObj); + } + finalJsonObj.put("agentGroups", jsonArray); + }else { + finalJsonObj.put("agentGroups", null); + } + return finalJsonObj; + } + + private JSONArray getCfgPersonCollectionInfo(Collection coll) { + JSONArray rtnArray = new JSONArray(); + JSONObject jsonObj; + for (CfgPerson person : coll) { + jsonObj = new JSONObject(); + jsonObj.put("dbid", person.getDBID()); + jsonObj.put("firstName", person.getFirstName()); + jsonObj.put("lastName", person.getLastName()); + jsonObj.put("userName", person.getUserName()); + jsonObj.put("employeeId", person.getEmployeeID()); + jsonObj.put("isAgent", person.getIsAgent().ordinal()); + jsonObj.put("state", person.getState().ordinal()); + rtnArray.add(jsonObj); + } + return rtnArray; + } +} diff --git a/src/main/java/kr/co/i4way/genesys/controller/OutboundController.java b/src/main/java/kr/co/i4way/genesys/controller/OutboundController.java new file mode 100644 index 0000000..97f5af3 --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/controller/OutboundController.java @@ -0,0 +1,204 @@ +package kr.co.i4way.genesys.controller; + +import java.util.Collection; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import kr.co.i4way.genesys.model.GenesysInfoVo; +import kr.co.i4way.genesys.ocserver.OutboundModule; +import net.minidev.json.JSONArray; +import net.minidev.json.JSONObject; + +/** + * Place용 Controller + * @author jkhong + * + */ +@Controller +@CrossOrigin(origins = "*") +public class OutboundController { + @Autowired + private GenesysInfoVo genesysinfovo; + private OutboundModule om = null; + + /** + * Campaign을 로드한다. + * @param request + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/outbound/loadCampaign") + public JSONObject loadCampaign(HttpServletRequest request) throws Exception{ + JSONObject rtnobj = new JSONObject(); + String rtnval = ""; + try { + int campaign_dbid = request.getParameter("campaign_dbid") != null ? Integer.parseInt(request.getParameter("campaign_dbid")) : 0; + int group_dbid = request.getParameter("group_dbid") != null ? Integer.parseInt(request.getParameter("group_dbid")) : 0; + rtnobj.put("campaign_dbid", campaign_dbid); + rtnobj.put("group_dbid", group_dbid); + rtnobj.put("command", "loadCampaign"); + + om = new OutboundModule(); + om.setOcServerInfo(genesysinfovo.getOc_ip_p() , genesysinfovo.getOc_port_p(), genesysinfovo.getOc_charset()); + if(om.connectOcServer()) { + rtnval = om.loadCampaign(campaign_dbid, group_dbid); + rtnobj.put("result", rtnval); + } + }catch(Exception e) { + }finally { + if(om.disConnectOcServer()) { + om = null; + } + } + return rtnobj; + } + + /** + * Campaign을 언로드한다. + * @param request + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/outbound/unloadCampaign") + public JSONObject unloadCampaign(HttpServletRequest request) throws Exception{ + JSONObject rtnobj = new JSONObject(); + String rtnval = ""; + try { + int campaign_dbid = request.getParameter("campaign_dbid") != null ? Integer.parseInt(request.getParameter("campaign_dbid")) : 0; + int group_dbid = request.getParameter("group_dbid") != null ? Integer.parseInt(request.getParameter("group_dbid")) : 0; + rtnobj.put("campaign_dbid", campaign_dbid); + rtnobj.put("group_dbid", group_dbid); + rtnobj.put("command", "unloadCampaign"); + + om = new OutboundModule(); + om.setOcServerInfo(genesysinfovo.getOc_ip_p() , genesysinfovo.getOc_port_p(), genesysinfovo.getOc_charset()); + if(om.connectOcServer()) { + rtnval = om.unloadCampaign(campaign_dbid, group_dbid); + rtnobj.put("result", rtnval); + } + }catch(Exception e) { + }finally { + if(om.disConnectOcServer()) { + om = null; + } + } + return rtnobj; + } + + /** + * 다이얼링을 시작한다. + * @param request + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/outbound/startDial") + public JSONObject startDial(HttpServletRequest request) throws Exception{ + JSONObject rtnobj = new JSONObject(); + String rtnval = ""; + try { + int campaign_dbid = request.getParameter("campaign_dbid") != null ? Integer.parseInt(request.getParameter("campaign_dbid")) : 0; + int group_dbid = request.getParameter("group_dbid") != null ? Integer.parseInt(request.getParameter("group_dbid")) : 0; + String dial_mode = request.getParameter("dial_mode") != null ? request.getParameter("dial_mode") : ""; + String opti_method = request.getParameter("opti_method") != null ? request.getParameter("opti_method") : ""; + int opti_goal = request.getParameter("opti_goal") != null ? Integer.parseInt(request.getParameter("opti_goal")) : 0; + rtnobj.put("campaign_dbid", campaign_dbid); + rtnobj.put("group_dbid", group_dbid); + + rtnobj.put("dialingMode", dial_mode); + rtnobj.put("optimizeMethod", opti_method); + rtnobj.put("optimizeGoal", opti_goal); + + rtnobj.put("command", "startDial"); + + om = new OutboundModule(); + om.setOcServerInfo(genesysinfovo.getOc_ip_p() , genesysinfovo.getOc_port_p(), genesysinfovo.getOc_charset()); + if(om.connectOcServer()) { + rtnval = om.startDialing(campaign_dbid, group_dbid, dial_mode, opti_method, opti_goal); + rtnobj.put("result", rtnval); + } + }catch(Exception e) { + }finally { + if(om.disConnectOcServer()) { + om = null; + } + } + return rtnobj; + } + + /** + * 다이얼링을 정지한다. + * @param request + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/outbound/stopDial") + public JSONObject stopDial(HttpServletRequest request) throws Exception{ + JSONObject rtnobj = new JSONObject(); + String rtnval = ""; + try { + int campaign_dbid = request.getParameter("campaign_dbid") != null ? Integer.parseInt(request.getParameter("campaign_dbid")) : 0; + int group_dbid = request.getParameter("group_dbid") != null ? Integer.parseInt(request.getParameter("group_dbid")) : 0; + rtnobj.put("campaign_dbid", campaign_dbid); + rtnobj.put("group_dbid", group_dbid); + rtnobj.put("command", "stopDial"); + + om = new OutboundModule(); + om.setOcServerInfo(genesysinfovo.getOc_ip_p() , genesysinfovo.getOc_port_p(), genesysinfovo.getOc_charset()); + if(om.connectOcServer()) { + rtnval = om.stopDialing(campaign_dbid, group_dbid); + rtnobj.put("result", rtnval); + } + }catch(Exception e) { + }finally { + if(om.disConnectOcServer()) { + om = null; + } + } + return rtnobj; + } + + /** + * Campaign 상태를 체크한다. + * @param request + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/outbound/checkCampaignStatus") + public JSONObject checkCampaignStatus(HttpServletRequest request) throws Exception{ + JSONObject rtnobj = new JSONObject(); + String rtnval = ""; + try { + int campaign_dbid = request.getParameter("campaign_dbid") != null ? Integer.parseInt(request.getParameter("campaign_dbid")) : 0; + int group_dbid = request.getParameter("group_dbid") != null ? Integer.parseInt(request.getParameter("group_dbid")) : 0; + rtnobj.put("campaign_dbid", campaign_dbid); + rtnobj.put("group_dbid", group_dbid); + rtnobj.put("command", "checkCampaignStatus"); + + om = new OutboundModule(); + om.setOcServerInfo(genesysinfovo.getOc_ip_p() , genesysinfovo.getOc_port_p(), genesysinfovo.getOc_charset()); + if(om.connectOcServer()) { + rtnval = om.getCampaignStat(campaign_dbid, group_dbid); + rtnobj.put("result", rtnval); + } + }catch(Exception e) { + }finally { + if(om.disConnectOcServer()) { + om = null; + } + } + return rtnobj; + } + + +} diff --git a/src/main/java/kr/co/i4way/genesys/controller/PersonController.java b/src/main/java/kr/co/i4way/genesys/controller/PersonController.java new file mode 100644 index 0000000..2c574f0 --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/controller/PersonController.java @@ -0,0 +1,640 @@ +package kr.co.i4way.genesys.controller; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLoginInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgFolder; +import com.genesyslab.platform.applicationblocks.com.objects.CfgObjectID; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.objects.CfgSkillLevel; +import com.genesyslab.platform.commons.collections.KeyValueCollection; +import com.genesyslab.platform.commons.collections.KeyValuePair; +import com.genesyslab.platform.commons.protocol.ChannelState; +import com.genesyslab.platform.configuration.protocol.types.CfgFlag; + +import kr.co.i4way.genesys.cfgserver.ConfigAgentLogin; +import kr.co.i4way.genesys.cfgserver.ConfigFolder; +import kr.co.i4way.genesys.cfgserver.ConfigPerson; +import kr.co.i4way.genesys.cfgserver.initConfigService; +import kr.co.i4way.genesys.model.GenesysInfoVo; +import kr.co.i4way.genesys.model.QueryVo; +import net.minidev.json.JSONArray; +import net.minidev.json.JSONObject; + +@RestController +@CrossOrigin(origins = "*") +public class PersonController { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + @Autowired + private GenesysInfoVo genesysinfovo; + initConfigService initconfigservice = initConfigService.getInstance(); + ConfigPerson cfgperson = null; + ConfigFolder cfgfolder = null; + ConfigAgentLogin cfgagentlogin = null; + + @PostMapping("/person/getPersonInfo") + public JSONObject getPersonInfo(@RequestBody QueryVo vo) throws Exception { + CfgPerson person = null; + JSONObject rtnobj = new JSONObject(); + Map map = new HashMap<>(); + String rtnStr = ""; + + try { + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgperson = new ConfigPerson(); + person = cfgperson.getPersonInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), + vo.getQry_type(), vo.getQry_str()); + rtnobj = convertPersonInfo_jsonObj(person); + // logger.info(map.toString()); + } + rtnobj.put("command", "getPersonInfo"); + } catch (Exception e) { + logger.error("Exception", e); + } finally { + } + return rtnobj; + } + + private JSONObject getPersonInfo(int dbid) throws Exception { + CfgPerson person = null; + JSONObject rtnobj = new JSONObject(); + + try { + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgperson = new ConfigPerson(); + person = cfgperson.getPersonInfo_single(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), + dbid); + rtnobj = convertPersonInfo_jsonObj(person); + // logger.info(map.toString()); + } + rtnobj.put("command", "getPersonInfo"); + } catch (Exception e) { + logger.error("Exception", e); + } finally { + } + return rtnobj; + } + + private JSONObject getFolderInfo(int owner_type, int dbid) throws Exception { + CfgFolder folder = null; + JSONObject rtnobj = new JSONObject(); + + try { + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgfolder = new ConfigFolder(); + folder = cfgfolder.getFolderInfo(initconfigservice.service, owner_type, dbid); + rtnobj = convertFolderInfo_jsonObj(folder); + // logger.info(map.toString()); + } + rtnobj.put("command", "getFolderInfo"); + } catch (Exception e) { + logger.error("Exception", e); + } finally { + + } + return rtnobj; + } + + /* + * private CfgFolder getFolderInfo(int owner_type, int dbid) throws Exception { + * CfgFolder folder = null; + * + * try { if (initconfigservice.openConfigService(genesysinfovo) == + * ChannelState.Opened) { cfgfolder = new ConfigFolder(); folder = + * cfgfolder.getFolderInfo(initconfigservice.service, owner_type, dbid); } } + * catch (Exception e) { logger.error("Exception", e); } finally { } return + * folder; } + */ + @RequestMapping("/person/getAllPersonInfo") + public JSONObject getAllPersonInfo() throws Exception { + CfgPerson person = null; + JSONObject rtnobj = new JSONObject(); + Map map = new HashMap<>(); + String rtnStr = ""; + + try { + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgperson = new ConfigPerson(); + Collection persons = cfgperson.getPersonInfo(initconfigservice.service, + genesysinfovo.getCfg_tenant_dbid()); + rtnobj = convertPersonInfo_jsonObj(persons); + + // map = JsonUtil.getMapFromJsonObject(rtnobj); + // logger.info(map.toString()); + } + rtnobj.put("command", "getAllPersonInfo"); + } catch (Exception e) { + logger.error("Exception", e); + } finally { + } + return rtnobj; + } + + @RequestMapping("/person/getFolderInfo") + public JSONObject getFolderInfo(@RequestBody QueryVo vo) throws Exception { + CfgFolder folder = null; + JSONObject rtnobj = new JSONObject(); + Map map = new HashMap<>(); + String rtnStr = ""; + + try { + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgfolder = new ConfigFolder(); + folder = cfgfolder.getFolderInfo(initconfigservice.service, vo.getFolder_type(), vo.getFolder_dbid()); + rtnobj = convertFolderInfo_jsonObj(folder); + + // map = JsonUtil.getMapFromJsonObject(rtnobj); + // logger.info(map.toString()); + } + rtnobj.put("command", "getAllPersonInfo"); + } catch (Exception e) { + logger.error("Exception", e); + } finally { + } + return rtnobj; + } + + @RequestMapping("/person/checkPerson") + public JSONObject checkPerson(HttpServletRequest request) throws Exception { + CfgPerson person = null; + JSONObject tmpobj = new JSONObject(); + JSONObject rtnobj = new JSONObject(); + Map map = new HashMap<>(); + String rtnStr = ""; + + try { + String qry_type = request.getParameter("qry_type") != null ? request.getParameter("qry_type") : ""; + String qry_str = request.getParameter("qry_str") != null ? request.getParameter("qry_str") : ""; + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgperson = new ConfigPerson(); + person = cfgperson.getPersonInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), + qry_type, qry_str); + if (person == null) { + rtnobj.put("result", false); + } else { + rtnobj.put("result", true); + } + } + rtnobj.put("qry_type", qry_type); + rtnobj.put("qry_str", qry_str); + rtnobj.put("command", "checkPerson"); + } catch (Exception e) { + } finally { + // initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @RequestMapping("/person/createPerson") + public JSONObject createPerson(HttpServletRequest request) throws Exception { + CfgAgentLogin agentlogininfo = null; + JSONObject rtnobj = new JSONObject(); + CfgPerson person = null; + + try { + String employee_id = request.getParameter("employee_id") != null ? request.getParameter("employee_id") : ""; + String user_name = request.getParameter("user_name") != null ? request.getParameter("user_name") : ""; + String first_name = request.getParameter("first_name") != null ? request.getParameter("first_name") : ""; + String last_name = request.getParameter("last_name") != null ? request.getParameter("last_name") : ""; + String folder_dbid = request.getParameter("folder_dbid") != null ? request.getParameter("folder_dbid") + : "0"; + cfgperson = new ConfigPerson(); + + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + person = cfgperson.getPersonInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), "emp", + employee_id); + + if (person != null) { // 수정모드 + person = cfgperson.modifyPerson(initconfigservice.service, person, first_name, last_name, + employee_id, user_name); + logger.info("Modify Person~"); + } else { + logger.info("Create Person~"); + person = cfgperson.createPerson(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), + genesysinfovo.getCfg_switch_dbid(), first_name, last_name, employee_id, user_name, + Integer.parseInt(folder_dbid)); + } + rtnobj = convertPersonInfo_jsonObj(person); + } + rtnobj.put("command", "createPerson"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + // initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @RequestMapping("/person/modifyPerson") + public JSONObject modifyPerson(HttpServletRequest request) throws Exception { + CfgAgentLogin agentlogininfo = null; + JSONObject rtnobj = new JSONObject(); + CfgPerson person = null; + + try { + String employee_id = request.getParameter("employee_id") != null ? request.getParameter("employee_id") : ""; + String user_name = request.getParameter("user_name") != null ? request.getParameter("user_name") : ""; + String first_name = request.getParameter("first_name") != null ? request.getParameter("first_name") : ""; + String last_name = request.getParameter("last_name") != null ? request.getParameter("last_name") : ""; + cfgperson = new ConfigPerson(); + + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + person = cfgperson.getPersonInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), "emp", + employee_id); + + if (person != null) { // 수정모드 + person = cfgperson.modifyPerson(initconfigservice.service, person, first_name, last_name, + employee_id, user_name); + logger.info("Modify Person~"); + } + rtnobj = convertPersonInfo_jsonObj(person); + } + rtnobj.put("command", "modifyPerson"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + // initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @RequestMapping("/person/deletePerson") + public JSONObject deletePerson(HttpServletRequest request) throws Exception { + JSONObject rtnobj = new JSONObject(); + boolean del_login_result = false; + boolean del_person_result = false; + CfgPerson person = null; + + try { + String employee_id = request.getParameter("employee_id") != null ? request.getParameter("employee_id") : ""; + cfgperson = new ConfigPerson(); + cfgagentlogin = new ConfigAgentLogin(); + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + person = cfgperson.getPersonInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), "emp", + employee_id); + + if (person != null) { // 삭제 + if (person.getAgentInfo().getAgentLogins() != null) { + Collection aglo = person.getAgentInfo().getAgentLogins(); + for (CfgAgentLoginInfo al : aglo) { + cfgagentlogin.deleteAgentLogins(initconfigservice.service, + genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid(), + al.getAgentLogin().getLoginCode()); + } + } + logger.info("Delete Person~"); + del_person_result = cfgperson.deletePerson(initconfigservice.service, person); + } + } + rtnobj.put("command", "deletePerson"); + rtnobj.put("result_delete_agentLogin", del_login_result); + rtnobj.put("result_delete_person", del_login_result); + rtnobj.put("employee_id", employee_id); + } catch (Exception e) { + e.printStackTrace(); + } finally { + // initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @RequestMapping("/person/setPersonState") + public JSONObject setPersonState(HttpServletRequest request) throws Exception { + JSONObject rtnobj = new JSONObject(); + CfgPerson person = null; + + try { + String employee_id = request.getParameter("employee_id") != null ? request.getParameter("employee_id") : ""; + String state = request.getParameter("state") != null ? request.getParameter("state") : ""; + cfgperson = new ConfigPerson(); + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + person = cfgperson.getPersonInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), "emp", + employee_id); + + if (person != null) { // 삭제 + logger.info("set Person State~"); + if (state.equals("true")) { + person = cfgperson.setPersonState(initconfigservice.service, person, true); + } else if (state.equals("false")) { + person = cfgperson.setPersonState(initconfigservice.service, person, false); + } else { + } + } + } + rtnobj.put("command", "setPersonState"); + rtnobj.put("state", person.getState().name()); + rtnobj.put("employee_id", person.getEmployeeID()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + // initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @RequestMapping("/person/setAgentloginToPerson") + public JSONObject setAgentloginToPerson(HttpServletRequest request) throws Exception { + JSONObject rtnobj = new JSONObject(); + CfgPerson person = null; + boolean assign_result = false; + try { + String employee_id = request.getParameter("employee_id") != null ? request.getParameter("employee_id") : ""; + String agent_login_id = request.getParameter("agent_login_id") != null + ? request.getParameter("agent_login_id") + : ""; + cfgperson = new ConfigPerson(); + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + person = cfgperson.getPersonInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), "emp", + employee_id); + + if (person != null) { // person이 널이 아니면 + logger.info("set Agent Login To Person~"); + if (cfgperson.setAgentLoginToPerson(initconfigservice.service, person, + genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid(), agent_login_id)) { + assign_result = true; + } + } + } + rtnobj.put("command", "setAgentloginToPerson"); + rtnobj.put("result", assign_result); + rtnobj.put("agent_login_id", agent_login_id); + rtnobj.put("employee_id", person.getEmployeeID()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + // initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @RequestMapping("/person/removeAgentloginToPerson") + public JSONObject removeAgentloginToPerson(HttpServletRequest request) throws Exception { + JSONObject rtnobj = new JSONObject(); + CfgPerson person = null; + boolean remove_result = false; + + try { + String employee_id = request.getParameter("employee_id") != null ? request.getParameter("employee_id") : ""; + String agent_login_id = request.getParameter("agent_login_id") != null + ? request.getParameter("agent_login_id") + : ""; + cfgperson = new ConfigPerson(); + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + person = cfgperson.getPersonInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), "emp", + employee_id); + + if (person != null) { // person이 널이 아니면 + logger.info("remove Agent Login To Person~"); + if (cfgperson.removeAgentLoginToPerson(initconfigservice.service, person, + genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid(), agent_login_id)) { + remove_result = true; + } + } + } + rtnobj.put("command", "removeAgentloginToPerson"); + rtnobj.put("result", remove_result); + rtnobj.put("employee_id", person.getEmployeeID()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + // initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @RequestMapping("/person/setSkillsToPerson") + public JSONObject setSkillToPerson(HttpServletRequest request) throws Exception { + JSONObject rtnobj = new JSONObject(); + CfgPerson person = null; + boolean assign_result = false; + try { + String employee_id = request.getParameter("employee_id") != null ? request.getParameter("employee_id") : ""; + String skill_dbids = request.getParameter("skill_dbids") != null ? request.getParameter("skill_dbids") : ""; + String skill_levels = request.getParameter("skill_levels") != null ? request.getParameter("skill_levels") + : ""; + String[] skillArry = skill_dbids.split(","); + String[] levelArry = skill_levels.split(","); + cfgperson = new ConfigPerson(); + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + person = cfgperson.getPersonInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), "emp", + employee_id); + + if (person != null) { // person이 널이 아니면 + logger.info("set Skill To Person~"); + if (cfgperson.setSkillsToPerson(initconfigservice.service, person, skillArry, levelArry)) { + assign_result = true; + } + } + } + rtnobj.put("command", "setSkillsToPerson"); + rtnobj.put("resault", assign_result); + rtnobj.put("skill_dbids", skill_dbids); + rtnobj.put("skill_levels", skill_levels); + rtnobj.put("employee_id", person.getEmployeeID()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + // initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @RequestMapping("/person/removeSkillsToPerson") + public JSONObject removeSkillsToPerson(HttpServletRequest request) throws Exception { + JSONObject rtnobj = new JSONObject(); + CfgPerson person = null; + boolean remove_result = false; + + try { + String employee_id = request.getParameter("employee_id") != null ? request.getParameter("employee_id") : ""; + String skill_dbids = request.getParameter("skill_dbids") != null ? request.getParameter("skill_dbids") : ""; + String skill_levels = request.getParameter("skill_levels") != null ? request.getParameter("skill_levels") + : ""; + String[] skillArry = skill_dbids.split(","); + String[] levelArry = skill_levels.split(","); + cfgperson = new ConfigPerson(); + if (initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + person = cfgperson.getPersonInfo(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), "emp", + employee_id); + + if (person != null) { // person이 널이 아니면 + logger.info("set Skill To Person~"); + if (cfgperson.removeSkillsToPerson(initconfigservice.service, person, skillArry, levelArry)) { + remove_result = true; + } + } + } + rtnobj.put("command", "removeSkillsToPerson"); + rtnobj.put("resault", remove_result); + rtnobj.put("skill_dbids", skill_dbids); + rtnobj.put("skill_levels", skill_levels); + rtnobj.put("employee_id", person.getEmployeeID()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + // initconfigservice.closeConfigService(); + } + return rtnobj; + } + + private JSONObject convertPersonInfo_jsonObj(CfgPerson person) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + + if (person != null) { + if (person.getIsAgent() == CfgFlag.CFGTrue) { + finalJsonObj.put("skills", getCfgSkillLevelCollectionInfo(person.getAgentInfo().getSkillLevels())); + finalJsonObj.put("agentLogins", getCfgAgentInfoCollectionInfo(person.getAgentInfo().getAgentLogins())); + } + + finalJsonObj.put("dbid", person.getDBID()); + finalJsonObj.put("firstName", person.getFirstName()); + finalJsonObj.put("lastName", person.getLastName()); + finalJsonObj.put("userName", person.getUserName()); + finalJsonObj.put("employeeId", person.getEmployeeID()); + finalJsonObj.put("isAgent", person.getIsAgent().ordinal()); + finalJsonObj.put("state", person.getState().ordinal()); + finalJsonObj.put("annex", getAnnexInfo(person.getUserProperties())); + finalJsonObj.put("obj", "CfgPerson"); + } + return finalJsonObj; + } + + private JSONObject convertPersonInfo_jsonObj(Collection persons) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + + if (persons != null) { + for (CfgPerson person : persons) { + jsonObj = new JSONObject(); + if (person.getIsAgent() == CfgFlag.CFGTrue) { + jsonObj.put("skills", getCfgSkillLevelCollectionInfo(person.getAgentInfo().getSkillLevels())); + jsonObj.put("agentLogins", getCfgAgentInfoCollectionInfo(person.getAgentInfo().getAgentLogins())); + } + jsonObj.put("dbid", person.getDBID()); + jsonObj.put("firstName", person.getFirstName()); + jsonObj.put("lastName", person.getLastName()); + jsonObj.put("userName", person.getUserName()); + jsonObj.put("employeeId", person.getEmployeeID()); + jsonObj.put("isAgent", person.getIsAgent().ordinal()); + jsonObj.put("state", person.getState().ordinal()); + jsonObj.put("annex", getAnnexInfo(person.getUserProperties())); + jsonObj.put("obj", "CfgPerson"); + jsonArray.add(jsonObj); + } + finalJsonObj.put("persons", jsonArray); + } + return finalJsonObj; + } + + private JSONObject getAnnexInfo(KeyValueCollection kv) { + JSONObject jsonObj = new JSONObject(); + JSONObject jsonObj2 = new JSONObject(); + KeyValuePair tmppair; + + for (Object selectionObj : kv) { + jsonObj = new JSONObject(); + KeyValuePair sectionKvp = (KeyValuePair) selectionObj; + + for (Object recordObj : sectionKvp.getTKVValue()) { + tmppair = (KeyValuePair) recordObj; + jsonObj.put(tmppair.getStringKey(), tmppair.getStringValue()); + } + jsonObj2.put(sectionKvp.getStringKey(), jsonObj); + } + return jsonObj2; + } + + private JSONArray getCfgAgentInfoCollectionInfo(Collection coll) { + JSONArray rtnArray = new JSONArray(); + JSONObject jsonObj; + for (CfgAgentLoginInfo cfgagentinfo : coll) { + jsonObj = new JSONObject(); + jsonObj.put("dbid", cfgagentinfo.getAgentLoginDBID()); + jsonObj.put("loginCode", cfgagentinfo.getAgentLogin().getLoginCode()); + jsonObj.put("warpupTime", cfgagentinfo.getWrapupTime()); + jsonObj.put("obj", "CfgAgentLoginInfo"); + rtnArray.add(jsonObj); + } + return rtnArray; + } + + private JSONArray getCfgSkillLevelCollectionInfo(Collection coll) { + JSONArray rtnArray = new JSONArray(); + JSONObject jsonObj; + for (CfgSkillLevel cfgskilllevel : coll) { + jsonObj = new JSONObject(); + jsonObj.put("dbid", cfgskilllevel.getSkillDBID()); + jsonObj.put("skillName", cfgskilllevel.getSkill().getName()); + jsonObj.put("level", cfgskilllevel.getLevel()); + jsonObj.put("obj", "CfgSkillLevel"); + rtnArray.add(jsonObj); + } + return rtnArray; + } + + private JSONArray getCfgObjectIDCollectionInfo(Collection coll) { + JSONArray rtnArray = new JSONArray(); + JSONObject jsonObj; + CfgFolder folder = null; + try { + for (CfgObjectID cfgobjectid : coll) { + jsonObj = new JSONObject(); + if (cfgobjectid.getType().name().equals("CFGPerson")) { + jsonObj = getPersonInfo(cfgobjectid.getDBID()); + } else if (cfgobjectid.getType().name().equals("CFGFolder")) { + // folder = getFolderInfo(cfgobjectid.getType().ordinal(), + // cfgobjectid.getDBID()); + // jsonObj = new JSONObject(); + // jsonObj.put("dbid", cfgobjectid.getDBID()); + // jsonObj.put("type", cfgobjectid.getType().ordinal()); + // jsonObj.put("typeName", cfgobjectid.getType().name()); + // jsonObj.put("name", folder.getName()); + jsonObj = getFolderInfo(cfgobjectid.getType().ordinal(), cfgobjectid.getDBID()); + jsonObj.put("obj", "CfgFolder"); + } + rtnArray.add(jsonObj); + } + } catch (Exception ex) { + } + return rtnArray; + } + + private JSONObject convertFolderInfo_jsonObj(CfgFolder folder) { + JSONObject finalJsonObj = new JSONObject(); + + if (folder != null) { + + finalJsonObj.put("dbid", folder.getDBID()); + finalJsonObj.put("name", folder.getName()); + finalJsonObj.put("objectType", folder.getObjectType().ordinal()); + finalJsonObj.put("folderId", folder.getFolderId()); + finalJsonObj.put("objectDbid", folder.getObjectDbid()); + finalJsonObj.put("objectIds", getCfgObjectIDCollectionInfo(folder.getObjectIDs())); + finalJsonObj.put("ownerDbid", folder.getOwnerID().getDBID()); + finalJsonObj.put("ownerType", folder.getOwnerID().getType().ordinal()); + finalJsonObj.put("type", folder.getType().ordinal()); + finalJsonObj.put("state", folder.getState().ordinal()); + finalJsonObj.put("annex", getAnnexInfo(folder.getUserProperties())); + finalJsonObj.put("obj", "CfgFolder"); + + } + return finalJsonObj; + } +} diff --git a/src/main/java/kr/co/i4way/genesys/controller/PlaceController.java b/src/main/java/kr/co/i4way/genesys/controller/PlaceController.java new file mode 100644 index 0000000..9abd5b2 --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/controller/PlaceController.java @@ -0,0 +1,338 @@ +package kr.co.i4way.genesys.controller; + +import java.util.Collection; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLogin; +import com.genesyslab.platform.applicationblocks.com.objects.CfgAgentLoginInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgDN; +import com.genesyslab.platform.applicationblocks.com.objects.CfgDNGroup; +import com.genesyslab.platform.applicationblocks.com.objects.CfgDNInfo; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPerson; +import com.genesyslab.platform.applicationblocks.com.objects.CfgPlace; +import com.genesyslab.platform.commons.collections.KeyValueCollection; +import com.genesyslab.platform.commons.collections.KeyValuePair; +import com.genesyslab.platform.commons.protocol.ChannelState; +import com.genesyslab.platform.configuration.protocol.types.CfgFlag; + +import kr.co.i4way.genesys.cfgserver.ConfigAgentLogin; +import kr.co.i4way.genesys.cfgserver.ConfigDn; +import kr.co.i4way.genesys.cfgserver.ConfigPlace; +import kr.co.i4way.genesys.cfgserver.initConfigService; +import kr.co.i4way.genesys.model.GenesysInfoVo; +import net.minidev.json.JSONArray; +import net.minidev.json.JSONObject; + +/** + * Place용 Controller + * @author jkhong + * + */ +@Controller +@CrossOrigin(origins = "*") +public class PlaceController { + @Autowired + private GenesysInfoVo genesysinfovo; + initConfigService initconfigservice = initConfigService.getInstance(); + ConfigPlace cfgplace = null; + + /** + * CfgPlace정보를 조회한다. + * @param request + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/place/getPlacesInfo") + public JSONObject getPlacesInfo(HttpServletRequest request) throws Exception{ + Collection placeinfo = null; + JSONObject rtnobj = new JSONObject(); + + try { + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgplace = new ConfigPlace(); + placeinfo = cfgplace.getPlace(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid()); + rtnobj = convertPlace_jsonObj(placeinfo); + } + rtnobj.put("command", "getDnsInfo"); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + /** + * CfgPlace정보를 조회한다. + * @param request + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/place/getPlaceInfo") + public JSONObject getDnInfo(HttpServletRequest request) throws Exception{ + CfgPlace placeinfo = null; + JSONObject rtnobj = new JSONObject(); + + try { + String place_name = request.getParameter("place_name") != null ? request.getParameter("place_name") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + cfgplace = new ConfigPlace(); + placeinfo = cfgplace.getPlace(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), place_name); + rtnobj = convertPlace_jsonObj(placeinfo); + } + rtnobj.put("command", "getDnInfo"); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @ResponseBody + @RequestMapping("/place/createPlace") + public JSONObject createPlace(HttpServletRequest request) throws Exception{ + CfgPlace placeinfo = null; + JSONObject rtnobj = new JSONObject(); + + try { + String place_name = request.getParameter("place_name") != null ? request.getParameter("place_name") : ""; + String dn = request.getParameter("dn") != null ? request.getParameter("dn") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + String[] dns = dn.split(","); + cfgplace = new ConfigPlace(); + placeinfo = cfgplace.createPlace(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid(), place_name, dns); + rtnobj = convertPlace_jsonObj(placeinfo); + } + rtnobj.put("command", "createPlace"); + rtnobj.put("place_name", place_name); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + + @ResponseBody + @RequestMapping("/place/modifyPlace") + public JSONObject modifyPlace(HttpServletRequest request) throws Exception{ + CfgPlace placeinfo = null; + JSONObject rtnobj = new JSONObject(); + + try { + String old_place_name = request.getParameter("old_place_name") != null ? request.getParameter("old_place_name") : ""; + String new_place_name = request.getParameter("new_place_name") != null ? request.getParameter("new_place_name") : ""; + String dn = request.getParameter("dn") != null ? request.getParameter("dn") : ""; + if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { + String[] dns = dn.split(","); + cfgplace = new ConfigPlace(); + placeinfo = cfgplace.modifyPlace(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), genesysinfovo.getCfg_switch_dbid(), old_place_name, new_place_name, dns); + rtnobj = convertPlace_jsonObj(placeinfo); + } + rtnobj.put("command", "modifyPlace"); + rtnobj.put("old_place_name", old_place_name); + rtnobj.put("new_place_name", new_place_name); + }catch(Exception e) { + }finally { + //initconfigservice.closeConfigService(); + } + return rtnobj; + } + +// @ResponseBody +// @RequestMapping("/dn/deleteDn") +// public JSONObject deleteDn(HttpServletRequest request) throws Exception{ +// boolean rtnval = false; +// JSONObject rtnobj = new JSONObject(); +// +// try { +// String dn_number = request.getParameter("dn_number") != null ? request.getParameter("dn_number") : ""; +// if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { +// cfgdn = new ConfigDn(); +// rtnval = cfgdn.deleteDN(initconfigservice.service +// , genesysinfovo.getCfg_tenant_dbid() +// , genesysinfovo.getCfg_switch_dbid() +// , dn_number); +// } +// rtnobj.put("command", "deleteDn"); +// rtnobj.put("result", rtnval); +// }catch(Exception e) { +// }finally { +// //initconfigservice.closeConfigService(); +// } +// return rtnobj; +// } +// +// +// /** +// * CfgDnGroup정보를 조회한다. +// * @param request +// * @return +// * @throws Exception +// */ +// @ResponseBody +// @RequestMapping("/dn/getDnGroupsInfo") +// public JSONObject getDnGroupsInfo(HttpServletRequest request) throws Exception{ +// Collection dngroupinfo = null; +// JSONObject rtnobj = new JSONObject(); +// +// try { +// if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { +// cfgdn = new ConfigDn(); +// dngroupinfo = cfgdn.getDnGroup(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid()); +// rtnobj = convertDnGroup_jsonObj(dngroupinfo); +// } +// rtnobj.put("command", "getDnGroupsInfo"); +// }catch(Exception e) { +// }finally { +// //initconfigservice.closeConfigService(); +// } +// return rtnobj; +// } +// +// /** +// * CfgDnGroup정보를 조회한다. +// * @param request +// * @return +// * @throws Exception +// */ +// @ResponseBody +// @RequestMapping("/dn/getDnGroupInfo") +// public JSONObject getDnGroupInfo(HttpServletRequest request) throws Exception{ +// CfgDNGroup dninfo = null; +// JSONObject rtnobj = new JSONObject(); +// +// try { +// String group_name = request.getParameter("group_name") != null ? request.getParameter("group_name") : ""; +// if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { +// cfgdn = new ConfigDn(); +// dninfo = cfgdn.getDnGroup(initconfigservice.service, genesysinfovo.getCfg_tenant_dbid(), group_name); +// rtnobj = convertDnGroup_jsonObj(dninfo); +// } +// rtnobj.put("command", "getDnGroupInfo"); +// }catch(Exception e) { +// }finally { +// //initconfigservice.closeConfigService(); +// } +// return rtnobj; +// } +// +// @ResponseBody +// @RequestMapping("/dn/createDnGroup") +// public JSONObject createDnGroup(HttpServletRequest request) throws Exception{ +// CfgDNGroup dngroup = null; +// JSONObject rtnobj = new JSONObject(); +// +// try { +// String group_name = request.getParameter("group_name") != null ? request.getParameter("group_name") : ""; +// String group_type = request.getParameter("group_type") != null ? request.getParameter("group_type") : ""; +// if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { +// cfgdn = new ConfigDn(); +// dngroup = cfgdn.createDNGroup(initconfigservice.service +// , genesysinfovo.getCfg_tenant_dbid() +// , group_name +// , group_type); +// rtnobj = convertDnGroup_jsonObj(dngroup); +// } +// rtnobj.put("command", "createDnGroup"); +// rtnobj.put("group_name", group_name); +// rtnobj.put("group_type", group_type); +// }catch(Exception e) { +// }finally { +// //initconfigservice.closeConfigService(); +// } +// return rtnobj; +// } +// +// @ResponseBody +// @RequestMapping("/dn/deleteDnGroup") +// public JSONObject deleteDnGroup(HttpServletRequest request) throws Exception{ +// boolean rtnval = false; +// JSONObject rtnobj = new JSONObject(); +// +// try { +// String group_name = request.getParameter("group_name") != null ? request.getParameter("group_name") : ""; +// if(initconfigservice.openConfigService(genesysinfovo) == ChannelState.Opened) { +// cfgdn = new ConfigDn(); +// rtnval = cfgdn.deleteDNGroup(initconfigservice.service +// , genesysinfovo.getCfg_tenant_dbid() +// , group_name); +// } +// rtnobj.put("command", "deleteDnGroup"); +// rtnobj.put("result", rtnval); +// }catch(Exception e) { +// }finally { +// //initconfigservice.closeConfigService(); +// } +// return rtnobj; +// } + + + + + private JSONObject convertPlace_jsonObj(Collection places) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + Collection dns; + String warpuptm = ""; + + if(places != null) { + for (CfgPlace place : places) { + warpuptm = ""; + jsonObj = new JSONObject(); + jsonObj.put("dbid", place.getDBID()); + jsonObj.put("name", place.getName()); + dns = place.getDNs(); + if(dns != null) { + jsonObj.put("dns", getCfgDnInfoCollectionInfo(dns)); + } + jsonArray.add(jsonObj); + } + finalJsonObj.put("Places", jsonArray); + }else { + finalJsonObj.put("Places", null); + } + return finalJsonObj; + } + + private JSONObject convertPlace_jsonObj(CfgPlace place) { + JSONObject jsonObj = new JSONObject(); + JSONArray jsonArray = new JSONArray(); + JSONObject finalJsonObj = new JSONObject(); + Collection dns; + + if(place != null) { + finalJsonObj.put("dbid", place.getDBID()); + finalJsonObj.put("name", place.getName()); + dns = place.getDNs(); + if(dns != null) { + finalJsonObj.put("dns", getCfgDnInfoCollectionInfo(dns)); + } + } + return finalJsonObj; + } + + private JSONArray getCfgDnInfoCollectionInfo(Collection coll) { + JSONArray rtnArray = new JSONArray(); + JSONObject jsonObj; + for (CfgDN dn : coll) { + jsonObj = new JSONObject(); + jsonObj.put("dbid", dn.getDBID()); + jsonObj.put("number", dn.getNumber()); + jsonObj.put("switch_dbid", dn.getSwitchDBID()); + jsonObj.put("tenant_dbid", dn.getTenantDBID()); + jsonObj.put("object_type", dn.getType().toString()); + rtnArray.add(jsonObj); + } + return rtnArray; + } + +} diff --git a/src/main/java/kr/co/i4way/genesys/controller/ServiceController.java b/src/main/java/kr/co/i4way/genesys/controller/ServiceController.java new file mode 100644 index 0000000..a1b494a --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/controller/ServiceController.java @@ -0,0 +1,27 @@ +package kr.co.i4way.genesys.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.genesyslab.platform.commons.protocol.ChannelState; +import kr.co.i4way.genesys.cfgserver.initConfigService; + +@Controller +@CrossOrigin(origins = "*") +public class ServiceController { + initConfigService initconfigservice = initConfigService.getInstance(); + + @ResponseBody + @RequestMapping("/service/resetService") + public String resetService() throws Exception{ + return initconfigservice.checkAndConnectConfigService(); + } + + @ResponseBody + @RequestMapping("/service/checkService") + public String checkService() throws Exception{ + return initconfigservice.checkConfService().name(); + } +} diff --git a/src/main/java/kr/co/i4way/genesys/model/GenesysInfoVo.java b/src/main/java/kr/co/i4way/genesys/model/GenesysInfoVo.java new file mode 100644 index 0000000..8b14a0c --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/model/GenesysInfoVo.java @@ -0,0 +1,156 @@ +package kr.co.i4way.genesys.model; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConfigurationProperties(prefix = "genesysinfo") +public class GenesysInfoVo { + + private String cfg_ip_p; + private String cfg_ip_b; + private int cfg_port_p; + private int cfg_port_b; + private String cfg_endpoint_p; + private String cfg_endpoint_b; + private String cfg_client_name; + private int cfg_tenant_dbid; + private int cfg_switch_dbid; + private String cfg_id; + private String cfg_passwd; + private String cfg_charset; + + String oc_ip_p; + int oc_port_p; + String oc_id; + String oc_passwd; + String oc_client_id; + String oc_client_passwd; + String oc_charset; + + + public String getOc_ip_p() { + return oc_ip_p; + } + public void setOc_ip_p(String oc_ip_p) { + this.oc_ip_p = oc_ip_p; + } + public int getOc_port_p() { + return oc_port_p; + } + public void setOc_port_p(int oc_port_p) { + this.oc_port_p = oc_port_p; + } + public String getOc_id() { + return oc_id; + } + public void setOc_id(String oc_id) { + this.oc_id = oc_id; + } + public String getOc_passwd() { + return oc_passwd; + } + public void setOc_passwd(String oc_passwd) { + this.oc_passwd = oc_passwd; + } + public String getOc_client_id() { + return oc_client_id; + } + public void setOc_client_id(String oc_client_id) { + this.oc_client_id = oc_client_id; + } + public String getOc_client_passwd() { + return oc_client_passwd; + } + public void setOc_client_passwd(String oc_client_passwd) { + this.oc_client_passwd = oc_client_passwd; + } + public String getOc_charset() { + return oc_charset; + } + public void setOc_charset(String oc_charset) { + this.oc_charset = oc_charset; + } + + public String getCfg_ip_p() { + return cfg_ip_p; + } + public void setCfg_ip_p(String cfg_ip_p) { + this.cfg_ip_p = cfg_ip_p; + } + public String getCfg_ip_b() { + return cfg_ip_b; + } + public void setCfg_ip_b(String cfg_ip_b) { + this.cfg_ip_b = cfg_ip_b; + } + public int getCfg_port_p() { + return cfg_port_p; + } + public void setCfg_port_p(int cfg_port_p) { + this.cfg_port_p = cfg_port_p; + } + public int getCfg_port_b() { + return cfg_port_b; + } + public void setCfg_port_b(int cfg_port_b) { + this.cfg_port_b = cfg_port_b; + } + public String getCfg_endpoint_p() { + return cfg_endpoint_p; + } + public void setCfg_endpoint_p(String cfg_endpoint_p) { + this.cfg_endpoint_p = cfg_endpoint_p; + } + public String getCfg_endpoint_b() { + return cfg_endpoint_b; + } + public void setCfg_endpoint_b(String cfg_endpoint_b) { + this.cfg_endpoint_b = cfg_endpoint_b; + } + public String getCfg_client_name() { + return cfg_client_name; + } + public void setCfg_client_name(String cfg_client_name) { + this.cfg_client_name = cfg_client_name; + } + public String getCfg_id() { + return cfg_id; + } + public void setCfg_id(String cfg_id) { + this.cfg_id = cfg_id; + } + public String getCfg_passwd() { + return cfg_passwd; + } + public void setCfg_passwd(String cfg_passwd) { + this.cfg_passwd = cfg_passwd; + } + public String getCfg_charset() { + return cfg_charset; + } + public void setCfg_charset(String cfg_charset) { + this.cfg_charset = cfg_charset; + } + public int getCfg_tenant_dbid() { + return cfg_tenant_dbid; + } + public void setCfg_tenant_dbid(int cfg_tenant_dbid) { + this.cfg_tenant_dbid = cfg_tenant_dbid; + } + public int getCfg_switch_dbid() { + return cfg_switch_dbid; + } + public void setCfg_switch_dbid(int cfg_switch_dbid) { + this.cfg_switch_dbid = cfg_switch_dbid; + } + @Override + public String toString() { + return "GenesysInfoVo [cfg_ip_p=" + cfg_ip_p + ", cfg_ip_b=" + cfg_ip_b + ", cfg_port_p=" + cfg_port_p + + ", cfg_port_b=" + cfg_port_b + ", cfg_endpoint_p=" + cfg_endpoint_p + ", cfg_endpoint_b=" + + cfg_endpoint_b + ", cfg_client_name=" + cfg_client_name + ", cfg_tenant_dbid=" + cfg_tenant_dbid + + ", cfg_switch_dbid=" + cfg_switch_dbid + ", cfg_id=" + cfg_id + ", cfg_passwd=" + cfg_passwd + + ", cfg_charset=" + cfg_charset + "]"; + } + +} \ No newline at end of file diff --git a/src/main/java/kr/co/i4way/genesys/model/QueryVo.java b/src/main/java/kr/co/i4way/genesys/model/QueryVo.java new file mode 100644 index 0000000..9f6dda4 --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/model/QueryVo.java @@ -0,0 +1,36 @@ +package kr.co.i4way.genesys.model; + +public class QueryVo { + String qry_type; + String qry_str; + int folder_type; + int folder_dbid; + + + + public int getFolder_type() { + return folder_type; + } + public void setFolder_type(int folder_type) { + this.folder_type = folder_type; + } + public int getFolder_dbid() { + return folder_dbid; + } + public void setFolder_dbid(int folder_dbid) { + this.folder_dbid = folder_dbid; + } + public String getQry_type() { + return qry_type; + } + public void setQry_type(String qry_type) { + this.qry_type = qry_type; + } + public String getQry_str() { + return qry_str; + } + public void setQry_str(String qry_str) { + this.qry_str = qry_str; + } + +} diff --git a/src/main/java/kr/co/i4way/genesys/ocserver/CampaignCtrl.java b/src/main/java/kr/co/i4way/genesys/ocserver/CampaignCtrl.java new file mode 100644 index 0000000..29883ce --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/ocserver/CampaignCtrl.java @@ -0,0 +1,463 @@ +package kr.co.i4way.genesys.ocserver; + +import java.net.URI; +import java.net.URISyntaxException; + +import com.genesyslab.platform.commons.protocol.ChannelState; +import com.genesyslab.platform.commons.protocol.Endpoint; +import com.genesyslab.platform.commons.protocol.Message; +import com.genesyslab.platform.commons.protocol.ProtocolException; +import com.genesyslab.platform.commons.protocol.RegistrationException; +import com.genesyslab.platform.outbound.protocol.OutboundServerProtocol; +import com.genesyslab.platform.outbound.protocol.outboundserver.DialMode; +import com.genesyslab.platform.outbound.protocol.outboundserver.OptimizationMethod; +import com.genesyslab.platform.outbound.protocol.outboundserver.events.EventCampaignLoaded; +import com.genesyslab.platform.outbound.protocol.outboundserver.events.EventCampaignStatus; +import com.genesyslab.platform.outbound.protocol.outboundserver.events.EventCampaignUnloaded; +import com.genesyslab.platform.outbound.protocol.outboundserver.events.EventDialingStarted; +import com.genesyslab.platform.outbound.protocol.outboundserver.events.EventDialingStopped; +import com.genesyslab.platform.outbound.protocol.outboundserver.requests.RequestForceUnloadCampaign; +import com.genesyslab.platform.outbound.protocol.outboundserver.requests.RequestGetCampaignStatus; +import com.genesyslab.platform.outbound.protocol.outboundserver.requests.RequestLoadCampaign; +import com.genesyslab.platform.outbound.protocol.outboundserver.requests.RequestStartDialing; +import com.genesyslab.platform.outbound.protocol.outboundserver.requests.RequestStopDialing; +import com.genesyslab.platform.outbound.protocol.outboundserver.requests.RequestUnloadCampaign; + +public class CampaignCtrl { + + URI outboundServerUri; + public OutboundServerProtocol outboundServerProtocol; + + String ocServerUri = null; + String clientName = null; + String clientPw = null; + String appName = null; + String appPw = null; + + + public void initalize(String svrUri, String app_nm, String appPw, String cl_nm, String cl_pw){ + ocServerUri = svrUri; + clientName = cl_nm; + clientPw = cl_pw; + appName = app_nm; + appPw = appPw; + + + } + + public void openProtocol(){ + try { + outboundServerUri = new URI(ocServerUri); + } catch (URISyntaxException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + outboundServerProtocol = + new OutboundServerProtocol( + new Endpoint( + outboundServerUri)); + + outboundServerProtocol.setClientName(clientName); + outboundServerProtocol.setClientPassword(clientPw); + outboundServerProtocol.setUserName(appName); + outboundServerProtocol.setUserPassword(appPw); + + try { + outboundServerProtocol.open(); + } catch (RegistrationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ProtocolException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalStateException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void closeProtocol(){ + if(outboundServerProtocol.getState() == ChannelState.Opened){ + try { + outboundServerProtocol.close(); + } catch (ProtocolException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalStateException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public String getCampaignStat(int campaignDBID, int agentGroupDBID) + { + String rtnval = ""; + if(outboundServerProtocol.getState() == ChannelState.Opened){ + RequestGetCampaignStatus req = + RequestGetCampaignStatus.create(); + req.setCampaignId(campaignDBID); + req.setGroupId(agentGroupDBID); + + Message msg = null; + try { + msg = outboundServerProtocol.request(req); + if ( msg != null && msg.messageId() == EventCampaignLoaded.ID ) + { + EventCampaignLoaded evt = (EventCampaignLoaded)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventDialingStarted.ID ) + { + EventDialingStarted evt = (EventDialingStarted)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventDialingStopped.ID ) + { + EventDialingStopped evt = (EventDialingStopped)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventCampaignUnloaded.ID ) + { + EventCampaignUnloaded evt = (EventCampaignUnloaded)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventCampaignStatus.ID ) + { + EventCampaignStatus evt = (EventCampaignStatus)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else + { + rtnval = "Error_4"; + } + } catch (ProtocolException e) { + rtnval = "Error_1"; + } catch (IllegalStateException e) { + rtnval = "Error_2"; + } + } + else + { + rtnval = "Error_3"; + } + return rtnval; + } + + public String LoadCampaign(int campaignDBID, int agentGroupDBID) + { + String rtnval = ""; + if(outboundServerProtocol.getState() == ChannelState.Opened){ + RequestLoadCampaign req = + RequestLoadCampaign.create(); + req.setCampaignId(campaignDBID); + req.setGroupId(agentGroupDBID); + + Message msg = null; + try { + msg = outboundServerProtocol.request( req ); + if ( msg != null && msg.messageId() == EventCampaignLoaded.ID ) + { + EventCampaignLoaded evt = (EventCampaignLoaded)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventDialingStarted.ID ) + { + EventDialingStarted evt = (EventDialingStarted)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventDialingStopped.ID ) + { + EventDialingStopped evt = (EventDialingStopped)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventCampaignUnloaded.ID ) + { + EventCampaignUnloaded evt = (EventCampaignUnloaded)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventCampaignStatus.ID ) + { + EventCampaignStatus evt = (EventCampaignStatus)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else + { + rtnval = "Error_4"; + } + } catch (ProtocolException e) { + rtnval = "Error_1"; + } catch (IllegalStateException e) { + rtnval = "Error_2"; + } + } + else + { + rtnval = "Error_3"; + } + return rtnval; + } + + public String UnloadCampaign(int campaignDBID, int agentGroupDBID) + { + String rtnval = ""; + if(outboundServerProtocol.getState() == ChannelState.Opened){ + RequestUnloadCampaign req = + RequestUnloadCampaign.create(); + req.setCampaignId(campaignDBID); + req.setGroupId(agentGroupDBID); + + Message msg = null; + try { + msg = outboundServerProtocol.request( req ); + if ( msg != null && msg.messageId() == EventCampaignLoaded.ID ) + { + EventCampaignLoaded evt = (EventCampaignLoaded)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventDialingStarted.ID ) + { + EventDialingStarted evt = (EventDialingStarted)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventDialingStopped.ID ) + { + EventDialingStopped evt = (EventDialingStopped)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventCampaignUnloaded.ID ) + { + EventCampaignUnloaded evt = (EventCampaignUnloaded)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventCampaignStatus.ID ) + { + EventCampaignStatus evt = (EventCampaignStatus)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else + { + rtnval = "Error_4"; + } + } catch (ProtocolException e) { + rtnval = "Error_1"; + } catch (IllegalStateException e) { + rtnval = "Error_2"; + } + } + else + { + rtnval = "Error_3"; + } + return rtnval; + } + + + public String ForceUnloadCampaign(int campaignDBID, int agentGroupDBID) + { + String rtnval = ""; + if(outboundServerProtocol.getState() == ChannelState.Opened){ + RequestForceUnloadCampaign req = + RequestForceUnloadCampaign.create(); + req.setCampaignId(campaignDBID); + req.setGroupId(agentGroupDBID); + + Message msg = null; + try { + msg = outboundServerProtocol.request( req ); + if ( msg != null && msg.messageId() == EventCampaignLoaded.ID ) + { + EventCampaignLoaded evt = (EventCampaignLoaded)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventDialingStarted.ID ) + { + EventDialingStarted evt = (EventDialingStarted)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventDialingStopped.ID ) + { + EventDialingStopped evt = (EventDialingStopped)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventCampaignUnloaded.ID ) + { + EventCampaignUnloaded evt = (EventCampaignUnloaded)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventCampaignStatus.ID ) + { + EventCampaignStatus evt = (EventCampaignStatus)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else + { + rtnval = "Error_4"; + } + } catch (ProtocolException e) { + rtnval = "Error_1"; + } catch (IllegalStateException e) { + rtnval = "Error_2"; + } + + + } + else + { + rtnval = "Error_3"; + } + return rtnval; + } + + private OptimizationMethod GetOptimizationMethod( String strOptimizationMethod ) + { + if(strOptimizationMethod.equals("BusyFactor")){ + return OptimizationMethod.BusyFactor; + }else if(strOptimizationMethod.equals("OverdialRate")){ + return OptimizationMethod.OverdialRate; + }else if(strOptimizationMethod.equals("WaitTime")){ + return OptimizationMethod.WaitTime; + }else{ + return OptimizationMethod.NoOptimizationMethod; + } + } + + private DialMode GetDialingMode( String strDialMode ) + { + if(strDialMode.equals("Predict")){ + return DialMode.Predict; + }else if(strDialMode.equals("PredictAndSeize")){ + return DialMode.PredictAndSeize; + }else if(strDialMode.equals("Preview")){ + return DialMode.Preview; + }else if(strDialMode.equals("Progress")){ + return DialMode.Progress; + }else if(strDialMode.equals("ProgressAndSeize")){ + return DialMode.ProgressAndSeize; + }else{ + return DialMode.NoDialMode; + } + } + + public String StartDialing(int campaignDBID, int agentGroupDBID, String dialingMode, String optimizeMethod, int optimizeGoal ) + { + String rtnval = ""; + if(outboundServerProtocol.getState() == ChannelState.Opened){ + RequestStartDialing req = + RequestStartDialing.create(); + req.setCampaignId(campaignDBID); + req.setGroupId(agentGroupDBID); + req.setDialMode(GetDialingMode(dialingMode)); + req.setOptimizeBy(GetOptimizationMethod(optimizeMethod)); + req.setOptimizeGoal(optimizeGoal); + + Message msg = null; + try { + msg = outboundServerProtocol.request( req ); + if ( msg != null && msg.messageId() == EventCampaignLoaded.ID ) + { + EventCampaignLoaded evt = (EventCampaignLoaded)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventDialingStarted.ID ) + { + EventDialingStarted evt = (EventDialingStarted)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventDialingStopped.ID ) + { + EventDialingStopped evt = (EventDialingStopped)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventCampaignUnloaded.ID ) + { + EventCampaignUnloaded evt = (EventCampaignUnloaded)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventCampaignStatus.ID ) + { + EventCampaignStatus evt = (EventCampaignStatus)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else + { + System.out.println(msg.messageId()); + rtnval = "Error_4"; + } + } catch (ProtocolException e) { + rtnval = "Error_1"; + } catch (IllegalStateException e) { + rtnval = "Error_2"; + } + } + else + { + rtnval = "Error_3"; + } + return rtnval; + } + + public String StopDialing(int campaignDBID, int agentGroupDBID) + { + String rtnval = ""; + if(outboundServerProtocol.getState() == ChannelState.Opened){ + RequestStopDialing req = + RequestStopDialing.create(); + + req.setCampaignId(campaignDBID); + req.setGroupId(agentGroupDBID); + + Message msg = null; + try { + msg = outboundServerProtocol.request( req ); + if ( msg != null && msg.messageId() == EventCampaignLoaded.ID ) + { + EventCampaignLoaded evt = (EventCampaignLoaded)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventDialingStarted.ID ) + { + EventDialingStarted evt = (EventDialingStarted)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventDialingStopped.ID ) + { + EventDialingStopped evt = (EventDialingStopped)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventCampaignUnloaded.ID ) + { + EventCampaignUnloaded evt = (EventCampaignUnloaded)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else if ( msg != null && msg.messageId() == EventCampaignStatus.ID ) + { + EventCampaignStatus evt = (EventCampaignStatus)msg; + rtnval = evt.getGroupCampaignStatus().toString(); + } + else + { + rtnval = "Error_4"; + } + } catch (ProtocolException e) { + rtnval = "Error_1"; + } catch (IllegalStateException e) { + rtnval = "Error_2"; + } + } + else + { + rtnval = "Error_3"; + } + return rtnval; + } + + +} diff --git a/src/main/java/kr/co/i4way/genesys/ocserver/OutboundModule.java b/src/main/java/kr/co/i4way/genesys/ocserver/OutboundModule.java new file mode 100644 index 0000000..821c21c --- /dev/null +++ b/src/main/java/kr/co/i4way/genesys/ocserver/OutboundModule.java @@ -0,0 +1,229 @@ +package kr.co.i4way.genesys.ocserver; + +import java.util.Collection; + +import com.genesyslab.platform.applicationblocks.com.ConfigException; +import com.genesyslab.platform.commons.protocol.ChannelState; +import com.genesyslab.platform.commons.protocol.ProtocolException; + +import kr.co.i4way.genesys.ocserver.CampaignCtrl; + +public class OutboundModule { + + CampaignCtrl cc = null; + String ocSvrIp = ""; + int ocSvrPort = 0; + String ocSvrId = ""; + String ocSvrPasswd = ""; + String ocClientName = ""; + String ocClientPasswd = ""; + String charSet = ""; + + /** + * 아웃바운드서버 접속정보를 세팅한다. + * @param String svrIp CTI서버 IP + * @param int svrPort CTI서비스 Port + * @param String charset 케릭터셋 + */ + public void setOcServerInfo(String svrIp, int svrPort, String charset){ + ocSvrIp = svrIp; + ocSvrPort = svrPort; + ocSvrId = "ocserver"; + ocSvrPasswd = null; + ocClientName = "default"; + ocClientPasswd = ""; + String mOCServerURI = "tcp://"+svrIp+":" + svrPort; + cc = new CampaignCtrl(); + cc.initalize(mOCServerURI, ocSvrId, ocSvrPasswd, ocClientName, ocClientPasswd); + } + + /** + * OutboundContact 서버에 접속한다. + * @return boolean + */ + public boolean connectOcServer(){ + boolean rtnval = false; + try { + if(cc != null){ + cc.openProtocol(); + if(cc.outboundServerProtocol != null) { + cc.outboundServerProtocol.getState().toString(); + System.out.println("OcServer service Is Opend"); + }else { + System.out.println("OcServer service Is null"); + } + rtnval = true; + }else{ + System.out.println("cc is null"); + } + } catch(Exception ex){ + ex.printStackTrace(); + rtnval = false; + } + return rtnval; + } + + /** + * OutboundContact 서버와 접속을 해제한다. + * @return boolean + */ + public boolean disConnectOcServer(){ + boolean rtnval = false; + try { + if(cc != null){ + if(cc.outboundServerProtocol.getState() == ChannelState.Opened){ + cc.closeProtocol(); + System.out.println("OcServer service Is Closed"); + rtnval = true; + }else{ + System.out.println("OcServer service Already Close"); + } + }else{ + System.out.println("cc is null"); + } + } catch(Exception ex){ + ex.printStackTrace(); + rtnval = false; + } + return rtnval; + } + + /** + * 캠페인 상태를 확인한다 + * @return boolean + */ + public String getCampaignStat(int campaignDBID, int agentGroupDBID){ + String rtnval = ""; + try { + if(cc != null){ + if(cc.outboundServerProtocol.getState() == ChannelState.Opened){ + rtnval = cc.getCampaignStat(campaignDBID, agentGroupDBID); + }else{ + System.out.println("OcServer service is Not Opend"); + } + }else{ + System.out.println("cc is null"); + } + } catch(Exception ex){ + ex.printStackTrace(); + rtnval = ""; + } + return rtnval; + } + + /** + * 캠페인을 로드한다 + * @return String + */ + public String loadCampaign(int campaignDBID, int agentGroupDBID){ + String rtnval = ""; + try { + if(cc != null){ + if(cc.outboundServerProtocol.getState() == ChannelState.Opened){ + rtnval = cc.LoadCampaign(campaignDBID, agentGroupDBID); + }else{ + System.out.println("OcServer service is Not Opend"); + } + }else{ + System.out.println("cc is null"); + } + } catch(Exception ex){ + ex.printStackTrace(); + rtnval = ""; + } + return rtnval; + } + + /** + * 캠페인을 언로드한다 + * @return String + */ + public String unloadCampaign(int campaignDBID, int agentGroupDBID){ + String rtnval = ""; + try { + if(cc != null){ + if(cc.outboundServerProtocol.getState() == ChannelState.Opened){ + rtnval = cc.UnloadCampaign(campaignDBID, agentGroupDBID); + }else{ + System.out.println("OcServer service is Not Opend"); + } + }else{ + System.out.println("cc is null"); + } + } catch(Exception ex){ + ex.printStackTrace(); + rtnval = ""; + } + return rtnval; + } + + /** + * 캠페인을 강제 언로드한다 + * @return String + */ + public String forceUnloadCampaign(int campaignDBID, int agentGroupDBID){ + String rtnval = ""; + try { + if(cc != null){ + if(cc.outboundServerProtocol.getState() == ChannelState.Opened){ + rtnval = cc.ForceUnloadCampaign(campaignDBID, agentGroupDBID); + }else{ + System.out.println("OcServer service is Not Opend"); + } + }else{ + System.out.println("cc is null"); + } + } catch(Exception ex){ + ex.printStackTrace(); + rtnval = ""; + } + return rtnval; + } + + /** + * 다이얼링을 시작한다 + * @return String + */ + public String startDialing(int campaignDBID, int agentGroupDBID, String dialingMode, String optimizeMethod, int optimizeGoal){ + String rtnval = ""; + try { + if(cc != null){ + if(cc.outboundServerProtocol.getState() == ChannelState.Opened){ + rtnval = cc.StartDialing(campaignDBID, agentGroupDBID, dialingMode, optimizeMethod, optimizeGoal); + }else{ + System.out.println("OcServer service is Not Opend"); + } + }else{ + System.out.println("cc is null"); + } + } catch(Exception ex){ + ex.printStackTrace(); + rtnval = ""; + } + return rtnval; + } + + + /** + * 다이얼링을 정지한다 + * @return String + */ + public String stopDialing(int campaignDBID, int agentGroupDBID){ + String rtnval = ""; + try { + if(cc != null){ + if(cc.outboundServerProtocol.getState() == ChannelState.Opened){ + rtnval = cc.StopDialing(campaignDBID, agentGroupDBID); + }else{ + System.out.println("OcServer service is Not Opend"); + } + }else{ + System.out.println("cc is null"); + } + } catch(Exception ex){ + ex.printStackTrace(); + rtnval = ""; + } + return rtnval; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..376ffba --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,20 @@ +#Genesys Server Info +genesysinfo.cfg_ip_p=172.168.30.2 +genesysinfo.cfg_ip_b=172.168.30.2 +genesysinfo.cfg_port_p=2020 +genesysinfo.cfg_port_b=2020 +genesysinfo.cfg_endpoint_p=Cfg_EP_P +genesysinfo.cfg_endpoint_b=Cfg_EP_B +genesysinfo.cfg_client_name=default +genesysinfo.cfg_tenant_dbid=101 +genesysinfo.cfg_switch_dbid=101 +genesysinfo.cfg_id=default +genesysinfo.cfg_passwd=password +genesysinfo.cfg_charset=MS949 +genesysinfo.oc_ip_p=172.168.30.2 +genesysinfo.oc_port_p=7004 +genesysinfo.oc_id=default +genesysinfo.oc_passwd=pwssword +genesysinfo.oc_client_id= +genesysinfo.oc_client_passwd= +genesysinfo.oc_charset=MS949 \ No newline at end of file diff --git a/src/main/resources/mappers/MainMapper.xml b/src/main/resources/mappers/MainMapper.xml new file mode 100644 index 0000000..21c06f4 --- /dev/null +++ b/src/main/resources/mappers/MainMapper.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/src/test/java/kr/co/i4way/web/GenWebApiApplicationTests.java b/src/test/java/kr/co/i4way/web/GenWebApiApplicationTests.java new file mode 100644 index 0000000..6b9191a --- /dev/null +++ b/src/test/java/kr/co/i4way/web/GenWebApiApplicationTests.java @@ -0,0 +1,13 @@ +package kr.co.i4way.web; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class GenWebApiApplicationTests { + + @Test + void contextLoads() { + } + +}