Joshua Chung 6 years ago
commit
e81e4cd9ec
32 changed files with 1505 additions and 0 deletions
  1. 25
    0
      .gitignore
  2. BIN
      .mvn/wrapper/maven-wrapper.jar
  3. 1
    0
      .mvn/wrapper/maven-wrapper.properties
  4. 0
    0
      README.md
  5. 225
    0
      mvnw
  6. 143
    0
      mvnw.cmd
  7. 114
    0
      pom.xml
  8. 11
    0
      src/main/java/com/proximity/demo/DemoApplication.java
  9. 100
    0
      src/main/java/com/proximity/demo/eventbriteApi/Categories/Category.java
  10. 25
    0
      src/main/java/com/proximity/demo/eventbriteApi/Categories/CategoryController.java
  11. 10
    0
      src/main/java/com/proximity/demo/eventbriteApi/Categories/CategoryRepository.java
  12. 31
    0
      src/main/java/com/proximity/demo/eventbriteApi/Categories/CategoryService.java
  13. 21
    0
      src/main/java/com/proximity/demo/eventbriteApi/Categories/CategoryWrapper.java
  14. 187
    0
      src/main/java/com/proximity/demo/eventbriteApi/Events/Event.java
  15. 27
    0
      src/main/java/com/proximity/demo/eventbriteApi/Events/EventController.java
  16. 13
    0
      src/main/java/com/proximity/demo/eventbriteApi/Events/EventRepository.java
  17. 38
    0
      src/main/java/com/proximity/demo/eventbriteApi/Events/EventService.java
  18. 19
    0
      src/main/java/com/proximity/demo/eventbriteApi/Events/EventWrapper.java
  19. 110
    0
      src/main/java/com/proximity/demo/eventbriteApi/Subcategories/Subcategory.java
  20. 25
    0
      src/main/java/com/proximity/demo/eventbriteApi/Subcategories/SubcategoryController.java
  21. 11
    0
      src/main/java/com/proximity/demo/eventbriteApi/Subcategories/SubcategoryRepository.java
  22. 37
    0
      src/main/java/com/proximity/demo/eventbriteApi/Subcategories/SubcategoryService.java
  23. 17
    0
      src/main/java/com/proximity/demo/eventbriteApi/Subcategories/SubcategoryWrapper.java
  24. 156
    0
      src/main/java/com/proximity/demo/eventbriteApi/Venues/Venue.java
  25. 25
    0
      src/main/java/com/proximity/demo/eventbriteApi/Venues/VenueController.java
  26. 13
    0
      src/main/java/com/proximity/demo/eventbriteApi/Venues/VenueRepository.java
  27. 49
    0
      src/main/java/com/proximity/demo/eventbriteApi/Venues/VenueService.java
  28. 16
    0
      src/main/java/com/proximity/demo/eventbriteApi/Venues/VenueWrapper.java
  29. 5
    0
      src/main/resources/application.properties
  30. 16
    0
      src/test/java/com/proximity/demo/DemoApplicationTests.java
  31. 19
    0
      src/test/java/com/proximity/demo/eventbriteApi/Events/eventServiceTest.java
  32. 16
    0
      src/test/java/com/proximity/demo/eventbriteApi/Subcategories/SubcategoryServiceTest.java

+ 25
- 0
.gitignore View File

@@ -0,0 +1,25 @@
1
+/target/
2
+!.mvn/wrapper/maven-wrapper.jar
3
+
4
+### STS ###
5
+.apt_generated
6
+.classpath
7
+.factorypath
8
+.project
9
+.settings
10
+.springBeans
11
+.sts4-cache
12
+
13
+### IntelliJ IDEA ###
14
+.idea
15
+*.iws
16
+*.iml
17
+*.ipr
18
+
19
+### NetBeans ###
20
+/nbproject/private/
21
+/build/
22
+/nbbuild/
23
+/dist/
24
+/nbdist/
25
+/.nb-gradle/

BIN
.mvn/wrapper/maven-wrapper.jar View File


+ 1
- 0
.mvn/wrapper/maven-wrapper.properties View File

@@ -0,0 +1 @@
1
+distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip

+ 0
- 0
README.md View File


+ 225
- 0
mvnw View File

@@ -0,0 +1,225 @@
1
+#!/bin/sh
2
+# ----------------------------------------------------------------------------
3
+# Licensed to the Apache Software Foundation (ASF) under one
4
+# or more contributor license agreements.  See the NOTICE file
5
+# distributed with this work for additional information
6
+# regarding copyright ownership.  The ASF licenses this file
7
+# to you under the Apache License, Version 2.0 (the
8
+# "License"); you may not use this file except in compliance
9
+# with the License.  You may obtain a copy of the License at
10
+#
11
+#    http://www.apache.org/licenses/LICENSE-2.0
12
+#
13
+# Unless required by applicable law or agreed to in writing,
14
+# software distributed under the License is distributed on an
15
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+# KIND, either express or implied.  See the License for the
17
+# specific language governing permissions and limitations
18
+# under the License.
19
+# ----------------------------------------------------------------------------
20
+
21
+# ----------------------------------------------------------------------------
22
+# Maven2 Start Up Batch script
23
+#
24
+# Required ENV vars:
25
+# ------------------
26
+#   JAVA_HOME - location of a JDK home dir
27
+#
28
+# Optional ENV vars
29
+# -----------------
30
+#   M2_HOME - location of maven2's installed home dir
31
+#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
32
+#     e.g. to debug Maven itself, use
33
+#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34
+#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35
+# ----------------------------------------------------------------------------
36
+
37
+if [ -z "$MAVEN_SKIP_RC" ] ; then
38
+
39
+  if [ -f /etc/mavenrc ] ; then
40
+    . /etc/mavenrc
41
+  fi
42
+
43
+  if [ -f "$HOME/.mavenrc" ] ; then
44
+    . "$HOME/.mavenrc"
45
+  fi
46
+
47
+fi
48
+
49
+# OS specific support.  $var _must_ be set to either true or false.
50
+cygwin=false;
51
+darwin=false;
52
+mingw=false
53
+case "`uname`" in
54
+  CYGWIN*) cygwin=true ;;
55
+  MINGW*) mingw=true;;
56
+  Darwin*) darwin=true
57
+    # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58
+    # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59
+    if [ -z "$JAVA_HOME" ]; then
60
+      if [ -x "/usr/libexec/java_home" ]; then
61
+        export JAVA_HOME="`/usr/libexec/java_home`"
62
+      else
63
+        export JAVA_HOME="/Library/Java/Home"
64
+      fi
65
+    fi
66
+    ;;
67
+esac
68
+
69
+if [ -z "$JAVA_HOME" ] ; then
70
+  if [ -r /etc/gentoo-release ] ; then
71
+    JAVA_HOME=`java-config --jre-home`
72
+  fi
73
+fi
74
+
75
+if [ -z "$M2_HOME" ] ; then
76
+  ## resolve links - $0 may be a link to maven's home
77
+  PRG="$0"
78
+
79
+  # need this for relative symlinks
80
+  while [ -h "$PRG" ] ; do
81
+    ls=`ls -ld "$PRG"`
82
+    link=`expr "$ls" : '.*-> \(.*\)$'`
83
+    if expr "$link" : '/.*' > /dev/null; then
84
+      PRG="$link"
85
+    else
86
+      PRG="`dirname "$PRG"`/$link"
87
+    fi
88
+  done
89
+
90
+  saveddir=`pwd`
91
+
92
+  M2_HOME=`dirname "$PRG"`/..
93
+
94
+  # make it fully qualified
95
+  M2_HOME=`cd "$M2_HOME" && pwd`
96
+
97
+  cd "$saveddir"
98
+  # echo Using m2 at $M2_HOME
99
+fi
100
+
101
+# For Cygwin, ensure paths are in UNIX format before anything is touched
102
+if $cygwin ; then
103
+  [ -n "$M2_HOME" ] &&
104
+    M2_HOME=`cygpath --unix "$M2_HOME"`
105
+  [ -n "$JAVA_HOME" ] &&
106
+    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107
+  [ -n "$CLASSPATH" ] &&
108
+    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109
+fi
110
+
111
+# For Migwn, ensure paths are in UNIX format before anything is touched
112
+if $mingw ; then
113
+  [ -n "$M2_HOME" ] &&
114
+    M2_HOME="`(cd "$M2_HOME"; pwd)`"
115
+  [ -n "$JAVA_HOME" ] &&
116
+    JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117
+  # TODO classpath?
118
+fi
119
+
120
+if [ -z "$JAVA_HOME" ]; then
121
+  javaExecutable="`which javac`"
122
+  if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
123
+    # readlink(1) is not available as standard on Solaris 10.
124
+    readLink=`which readlink`
125
+    if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
126
+      if $darwin ; then
127
+        javaHome="`dirname \"$javaExecutable\"`"
128
+        javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
129
+      else
130
+        javaExecutable="`readlink -f \"$javaExecutable\"`"
131
+      fi
132
+      javaHome="`dirname \"$javaExecutable\"`"
133
+      javaHome=`expr "$javaHome" : '\(.*\)/bin'`
134
+      JAVA_HOME="$javaHome"
135
+      export JAVA_HOME
136
+    fi
137
+  fi
138
+fi
139
+
140
+if [ -z "$JAVACMD" ] ; then
141
+  if [ -n "$JAVA_HOME"  ] ; then
142
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
143
+      # IBM's JDK on AIX uses strange locations for the executables
144
+      JAVACMD="$JAVA_HOME/jre/sh/java"
145
+    else
146
+      JAVACMD="$JAVA_HOME/bin/java"
147
+    fi
148
+  else
149
+    JAVACMD="`which java`"
150
+  fi
151
+fi
152
+
153
+if [ ! -x "$JAVACMD" ] ; then
154
+  echo "Error: JAVA_HOME is not defined correctly." >&2
155
+  echo "  We cannot execute $JAVACMD" >&2
156
+  exit 1
157
+fi
158
+
159
+if [ -z "$JAVA_HOME" ] ; then
160
+  echo "Warning: JAVA_HOME environment variable is not set."
161
+fi
162
+
163
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164
+
165
+# traverses directory structure from process work directory to filesystem root
166
+# first directory with .mvn subdirectory is considered project base directory
167
+find_maven_basedir() {
168
+
169
+  if [ -z "$1" ]
170
+  then
171
+    echo "Path not specified to find_maven_basedir"
172
+    return 1
173
+  fi
174
+
175
+  basedir="$1"
176
+  wdir="$1"
177
+  while [ "$wdir" != '/' ] ; do
178
+    if [ -d "$wdir"/.mvn ] ; then
179
+      basedir=$wdir
180
+      break
181
+    fi
182
+    # workaround for JBEAP-8937 (on Solaris 10/Sparc)
183
+    if [ -d "${wdir}" ]; then
184
+      wdir=`cd "$wdir/.."; pwd`
185
+    fi
186
+    # end of workaround
187
+  done
188
+  echo "${basedir}"
189
+}
190
+
191
+# concatenates all lines of a file
192
+concat_lines() {
193
+  if [ -f "$1" ]; then
194
+    echo "$(tr -s '\n' ' ' < "$1")"
195
+  fi
196
+}
197
+
198
+BASE_DIR=`find_maven_basedir "$(pwd)"`
199
+if [ -z "$BASE_DIR" ]; then
200
+  exit 1;
201
+fi
202
+
203
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204
+echo $MAVEN_PROJECTBASEDIR
205
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
206
+
207
+# For Cygwin, switch paths to Windows format before running java
208
+if $cygwin; then
209
+  [ -n "$M2_HOME" ] &&
210
+    M2_HOME=`cygpath --path --windows "$M2_HOME"`
211
+  [ -n "$JAVA_HOME" ] &&
212
+    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
213
+  [ -n "$CLASSPATH" ] &&
214
+    CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
215
+  [ -n "$MAVEN_PROJECTBASEDIR" ] &&
216
+    MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
217
+fi
218
+
219
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
220
+
221
+exec "$JAVACMD" \
222
+  $MAVEN_OPTS \
223
+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
224
+  "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
225
+  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

+ 143
- 0
mvnw.cmd View File

@@ -0,0 +1,143 @@
1
+@REM ----------------------------------------------------------------------------
2
+@REM Licensed to the Apache Software Foundation (ASF) under one
3
+@REM or more contributor license agreements.  See the NOTICE file
4
+@REM distributed with this work for additional information
5
+@REM regarding copyright ownership.  The ASF licenses this file
6
+@REM to you under the Apache License, Version 2.0 (the
7
+@REM "License"); you may not use this file except in compliance
8
+@REM with the License.  You may obtain a copy of the License at
9
+@REM
10
+@REM    http://www.apache.org/licenses/LICENSE-2.0
11
+@REM
12
+@REM Unless required by applicable law or agreed to in writing,
13
+@REM software distributed under the License is distributed on an
14
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+@REM KIND, either express or implied.  See the License for the
16
+@REM specific language governing permissions and limitations
17
+@REM under the License.
18
+@REM ----------------------------------------------------------------------------
19
+
20
+@REM ----------------------------------------------------------------------------
21
+@REM Maven2 Start Up Batch script
22
+@REM
23
+@REM Required ENV vars:
24
+@REM JAVA_HOME - location of a JDK home dir
25
+@REM
26
+@REM Optional ENV vars
27
+@REM M2_HOME - location of maven2's installed home dir
28
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31
+@REM     e.g. to debug Maven itself, use
32
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34
+@REM ----------------------------------------------------------------------------
35
+
36
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37
+@echo off
38
+@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39
+@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
40
+
41
+@REM set %HOME% to equivalent of $HOME
42
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43
+
44
+@REM Execute a user defined script before this one
45
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
47
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49
+:skipRcPre
50
+
51
+@setlocal
52
+
53
+set ERROR_CODE=0
54
+
55
+@REM To isolate internal variables from possible post scripts, we use another setlocal
56
+@setlocal
57
+
58
+@REM ==== START VALIDATION ====
59
+if not "%JAVA_HOME%" == "" goto OkJHome
60
+
61
+echo.
62
+echo Error: JAVA_HOME not found in your environment. >&2
63
+echo Please set the JAVA_HOME variable in your environment to match the >&2
64
+echo location of your Java installation. >&2
65
+echo.
66
+goto error
67
+
68
+:OkJHome
69
+if exist "%JAVA_HOME%\bin\java.exe" goto init
70
+
71
+echo.
72
+echo Error: JAVA_HOME is set to an invalid directory. >&2
73
+echo JAVA_HOME = "%JAVA_HOME%" >&2
74
+echo Please set the JAVA_HOME variable in your environment to match the >&2
75
+echo location of your Java installation. >&2
76
+echo.
77
+goto error
78
+
79
+@REM ==== END VALIDATION ====
80
+
81
+:init
82
+
83
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84
+@REM Fallback to current working directory if not found.
85
+
86
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88
+
89
+set EXEC_DIR=%CD%
90
+set WDIR=%EXEC_DIR%
91
+:findBaseDir
92
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
93
+cd ..
94
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
95
+set WDIR=%CD%
96
+goto findBaseDir
97
+
98
+:baseDirFound
99
+set MAVEN_PROJECTBASEDIR=%WDIR%
100
+cd "%EXEC_DIR%"
101
+goto endDetectBaseDir
102
+
103
+:baseDirNotFound
104
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105
+cd "%EXEC_DIR%"
106
+
107
+:endDetectBaseDir
108
+
109
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110
+
111
+@setlocal EnableExtensions EnableDelayedExpansion
112
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114
+
115
+:endReadAdditionalConfig
116
+
117
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118
+
119
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121
+
122
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123
+if ERRORLEVEL 1 goto error
124
+goto end
125
+
126
+:error
127
+set ERROR_CODE=1
128
+
129
+:end
130
+@endlocal & set ERROR_CODE=%ERROR_CODE%
131
+
132
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
134
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136
+:skipRcPost
137
+
138
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
140
+
141
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142
+
143
+exit /B %ERROR_CODE%

+ 114
- 0
pom.xml View File

@@ -0,0 +1,114 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+    <modelVersion>4.0.0</modelVersion>
5
+
6
+    <groupId>com.proximity</groupId>
7
+    <artifactId>demo</artifactId>
8
+    <version>0.0.1-SNAPSHOT</version>
9
+    <packaging>jar</packaging>
10
+
11
+    <eventName>demo</eventName>
12
+    <eventDescription>Demo project for Spring Boot</eventDescription>
13
+
14
+    <parent>
15
+        <groupId>org.springframework.boot</groupId>
16
+        <artifactId>spring-boot-starter-parent</artifactId>
17
+        <version>2.0.3.RELEASE</version>
18
+        <relativePath/> <!-- lookup parent from repository -->
19
+    </parent>
20
+
21
+    <properties>
22
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24
+        <java.version>1.8</java.version>
25
+    </properties>
26
+
27
+    <dependencies>
28
+        <dependency>
29
+            <groupId>org.springframework.boot</groupId>
30
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
31
+        </dependency>
32
+        <dependency>
33
+            <groupId>org.springframework.boot</groupId>
34
+            <artifactId>spring-boot-starter-actuator</artifactId>
35
+        </dependency>
36
+        <dependency>
37
+            <groupId>org.springframework.boot</groupId>
38
+            <artifactId>spring-boot-starter-data-rest</artifactId>
39
+        </dependency>
40
+        <!--<dependency>-->
41
+            <!--<groupId>org.springframework.boot</groupId>-->
42
+            <!--<artifactId>spring-boot-starter-security</artifactId>-->
43
+        <!--</dependency>-->
44
+        <dependency>
45
+            <groupId>org.springframework.boot</groupId>
46
+            <artifactId>spring-boot-starter-web</artifactId>
47
+        </dependency>
48
+        <dependency>
49
+            <groupId>org.springframework.boot</groupId>
50
+            <artifactId>spring-boot-starter-web-services</artifactId>
51
+        </dependency>
52
+        <dependency>
53
+            <groupId>org.springframework.boot</groupId>
54
+            <artifactId>spring-boot-starter-websocket</artifactId>
55
+        </dependency>
56
+        <dependency>
57
+            <groupId>com.ticketmaster.api</groupId>
58
+            <artifactId>discovery-java</artifactId>
59
+            <version>0.1.8</version>
60
+        </dependency>
61
+        <dependency>
62
+            <groupId>com.ticketmaster.api</groupId>
63
+            <artifactId>discovery-model-java</artifactId>
64
+            <version>0.1.8</version>
65
+        </dependency>
66
+        <dependency>
67
+            <groupId>org.springframework.boot</groupId>
68
+            <artifactId>spring-boot-devtools</artifactId>
69
+            <scope>runtime</scope>
70
+        </dependency>
71
+        <dependency>
72
+            <groupId>mysql</groupId>
73
+            <artifactId>mysql-connector-java</artifactId>
74
+            <scope>runtime</scope>
75
+        </dependency>
76
+        <dependency>
77
+            <groupId>org.projectlombok</groupId>
78
+            <artifactId>lombok</artifactId>
79
+            <optional>true</optional>
80
+        </dependency>
81
+        <dependency>
82
+            <groupId>org.springframework.boot</groupId>
83
+            <artifactId>spring-boot-starter-test</artifactId>
84
+            <scope>test</scope>
85
+        </dependency>
86
+        <dependency>
87
+            <groupId>org.springframework.security</groupId>
88
+            <artifactId>spring-security-test</artifactId>
89
+            <scope>test</scope>
90
+        </dependency>
91
+        <dependency>
92
+            <groupId>com.fasterxml.jackson.core</groupId>
93
+            <artifactId>jackson-databind</artifactId>
94
+        </dependency>
95
+        <!-- https://mvnrepository.com/artifact/org.json/json -->
96
+        <dependency>
97
+            <groupId>org.json</groupId>
98
+            <artifactId>json</artifactId>
99
+            <version>20180130</version>
100
+        </dependency>
101
+
102
+    </dependencies>
103
+
104
+    <build>
105
+        <plugins>
106
+            <plugin>
107
+                <groupId>org.springframework.boot</groupId>
108
+                <artifactId>spring-boot-maven-plugin</artifactId>
109
+            </plugin>
110
+        </plugins>
111
+    </build>
112
+
113
+
114
+</project>

+ 11
- 0
src/main/java/com/proximity/demo/DemoApplication.java View File

@@ -0,0 +1,11 @@
1
+package com.proximity.demo;
2
+
3
+import com.proximity.demo.eventbriteApi.Events.EventService;
4
+import org.springframework.boot.SpringApplication;
5
+import org.springframework.boot.autoconfigure.SpringBootApplication;
6
+
7
+@SpringBootApplication
8
+public class DemoApplication {
9
+
10
+    public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); }
11
+}

+ 100
- 0
src/main/java/com/proximity/demo/eventbriteApi/Categories/Category.java View File

@@ -0,0 +1,100 @@
1
+package com.proximity.demo.eventbriteApi.Categories;
2
+
3
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4
+import com.proximity.demo.eventbriteApi.Events.Event;
5
+import com.proximity.demo.eventbriteApi.Subcategories.Subcategory;
6
+
7
+import javax.persistence.*;
8
+import java.util.HashSet;
9
+import java.util.Set;
10
+
11
+@Entity
12
+@JsonIgnoreProperties(ignoreUnknown = true)
13
+@Table(name="CATEGORY")
14
+public class Category {
15
+
16
+    @Id
17
+    @GeneratedValue(strategy = GenerationType.AUTO)
18
+    private int categoryid;
19
+
20
+    @Column(unique = true)
21
+    private int id;
22
+    private String name;
23
+    private String short_name;
24
+
25
+    public Category() { }
26
+
27
+    @ManyToMany(mappedBy = "category", fetch = FetchType.EAGER)
28
+    private Set<Event> events = new HashSet<>();
29
+
30
+    @OneToMany(mappedBy = "subToCategory", fetch = FetchType.EAGER)
31
+    private Set<Subcategory> subcategories = new HashSet<>();
32
+
33
+    public Category(int id, String name, String short_name, Set<Event> events, Set<Subcategory> subcategories) {
34
+        this.id = id;
35
+        this.name = name;
36
+        this.short_name = short_name;
37
+        this.events = events;
38
+        this.subcategories = subcategories;
39
+    }
40
+
41
+    public int getCategoryid() {
42
+        return categoryid;
43
+    }
44
+
45
+    public void setCategoryid(int categoryid) {
46
+        this.categoryid = categoryid;
47
+    }
48
+
49
+    public int getId() {
50
+        return id;
51
+    }
52
+
53
+    public void setId(int id) {
54
+        this.id = id;
55
+    }
56
+
57
+    public String getName() {
58
+        return name;
59
+    }
60
+
61
+    public void setName(String name) {
62
+        this.name = name;
63
+    }
64
+
65
+    public String getShort_name() {
66
+        return short_name;
67
+    }
68
+
69
+    public void setShort_name(String short_name) {
70
+        this.short_name = short_name;
71
+    }
72
+
73
+    public Set<Event> getEvents() {
74
+        return events;
75
+    }
76
+
77
+    public void setEvents(Set<Event> events) {
78
+        this.events = events;
79
+    }
80
+
81
+    public Set<Subcategory> getSubcategories() {
82
+        return subcategories;
83
+    }
84
+
85
+    public void setSubcategories(Set<Subcategory> subcategories) {
86
+        this.subcategories = subcategories;
87
+    }
88
+
89
+    @Override
90
+    public String toString() {
91
+        return "Category{" +
92
+                "categoryid=" + categoryid +
93
+                ", id=" + id +
94
+                ", name='" + name + '\'' +
95
+                ", short_name='" + short_name + '\'' +
96
+                ", events=" + events +
97
+                ", subcategories=" + subcategories +
98
+                '}';
99
+    }
100
+}

+ 25
- 0
src/main/java/com/proximity/demo/eventbriteApi/Categories/CategoryController.java View File

@@ -0,0 +1,25 @@
1
+package com.proximity.demo.eventbriteApi.Categories;
2
+
3
+import org.springframework.beans.factory.annotation.Autowired;
4
+import org.springframework.web.bind.annotation.CrossOrigin;
5
+import org.springframework.web.bind.annotation.GetMapping;
6
+import org.springframework.web.bind.annotation.RestController;
7
+
8
+import java.util.List;
9
+
10
+@RestController
11
+@CrossOrigin
12
+public class CategoryController {
13
+
14
+    @Autowired
15
+    private CategoryService categoryService;
16
+
17
+    @Autowired
18
+    private  CategoryRepository categoryRepository;
19
+
20
+    @GetMapping("/categories")
21
+    public List<Category> getAll() {
22
+        categoryService.getCategories();
23
+        return categoryRepository.findAll();
24
+    }
25
+}

+ 10
- 0
src/main/java/com/proximity/demo/eventbriteApi/Categories/CategoryRepository.java View File

@@ -0,0 +1,10 @@
1
+package com.proximity.demo.eventbriteApi.Categories;
2
+
3
+import com.proximity.demo.eventbriteApi.Subcategories.Subcategory;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.stereotype.Repository;
6
+
7
+@Repository
8
+public interface CategoryRepository extends JpaRepository<Category, Long> {
9
+
10
+}

+ 31
- 0
src/main/java/com/proximity/demo/eventbriteApi/Categories/CategoryService.java View File

@@ -0,0 +1,31 @@
1
+package com.proximity.demo.eventbriteApi.Categories;
2
+
3
+import org.springframework.beans.factory.annotation.Autowired;
4
+import org.springframework.boot.web.client.RestTemplateBuilder;
5
+import org.springframework.stereotype.Service;
6
+import org.springframework.web.client.RestTemplate;
7
+
8
+@Service
9
+public class CategoryService {
10
+
11
+    private static final String token = "SMEZ5DGCKW5IDHS7HXNI";
12
+    private final RestTemplate restTemplate;
13
+    private CategoryRepository categoryRepository;
14
+
15
+    @Autowired
16
+    public CategoryService(RestTemplateBuilder restTemplateBuilder, CategoryRepository categoryRepository) {
17
+        this.restTemplate = restTemplateBuilder.build();
18
+        this.categoryRepository = categoryRepository;
19
+    }
20
+
21
+    public Category getCategories() {
22
+        String url = "http://www.eventbriteapi.com/v3/categories?"
23
+                + "token=" + token;
24
+        CategoryWrapper wrapper = restTemplate.getForObject(url, CategoryWrapper.class);
25
+        categoryRepository.saveAll(wrapper.getCategories());
26
+        return null;
27
+    }
28
+
29
+    private Category save(Category category) { return this.categoryRepository.save(category); }
30
+
31
+}

+ 21
- 0
src/main/java/com/proximity/demo/eventbriteApi/Categories/CategoryWrapper.java View File

@@ -0,0 +1,21 @@
1
+package com.proximity.demo.eventbriteApi.Categories;
2
+
3
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4
+
5
+import java.util.List;
6
+
7
+@JsonIgnoreProperties(ignoreUnknown = true)
8
+public class CategoryWrapper {
9
+
10
+    public CategoryWrapper() { }
11
+
12
+    private List<Category> categories;
13
+
14
+    public List<Category> getCategories() {
15
+        return categories;
16
+    }
17
+
18
+    public void setCategories(List<Category> categories) {
19
+        this.categories = categories;
20
+    }
21
+}

+ 187
- 0
src/main/java/com/proximity/demo/eventbriteApi/Events/Event.java View File

@@ -0,0 +1,187 @@
1
+package com.proximity.demo.eventbriteApi.Events;
2
+
3
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4
+import com.fasterxml.jackson.annotation.JsonProperty;
5
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
6
+import com.proximity.demo.eventbriteApi.Categories.Category;
7
+import com.proximity.demo.eventbriteApi.Subcategories.Subcategory;
8
+import com.proximity.demo.eventbriteApi.Venues.Venue;
9
+
10
+import javax.persistence.*;
11
+import java.time.LocalDateTime;
12
+import java.util.Date;
13
+import java.util.HashSet;
14
+import java.util.Map;
15
+import java.util.Set;
16
+
17
+@Entity
18
+@JsonIgnoreProperties(ignoreUnknown = true)
19
+@Table(name="EVENT")
20
+public class Event {
21
+
22
+    @Id
23
+    @GeneratedValue(strategy = GenerationType.AUTO)
24
+    private long eventId;
25
+
26
+    private long id;
27
+    @Column(unique = true)
28
+    private String eventName;
29
+    @Column(length = 10000)
30
+    private String eventDescription;
31
+    private long category_id;
32
+    private long subcategory_id;
33
+    private long venue_id;
34
+    private LocalDateTime startDate;
35
+    private LocalDateTime endDate;
36
+    private String status;
37
+    private Date created;
38
+    private String resource_url;
39
+    private String logo;
40
+
41
+    public Event() { }
42
+
43
+    public Event(String eventName, String eventDescription, long category_id, long subcategory_id, long venue_id,
44
+                 LocalDateTime startDate, LocalDateTime endDate, String status, Date created, String resource_url,
45
+                 String logo, Set<Venue> venue) {
46
+        this.eventName = eventName;
47
+        this.eventDescription = eventDescription;
48
+        this.category_id = category_id;
49
+        this.subcategory_id = subcategory_id;
50
+        this.venue_id = venue_id;
51
+        this.startDate = startDate;
52
+        this.endDate = endDate;
53
+        this.status = status;
54
+        this.created = created;
55
+        this.resource_url = resource_url;
56
+        this.logo = logo;
57
+        this.venue = venue;
58
+    }
59
+
60
+    @JsonProperty("name")
61
+    private void unpackName(Map<String, Object> name) {
62
+        this.eventName = (String) name.get("text");
63
+    }
64
+
65
+    @JsonProperty("description")
66
+    private void unpackDescription(Map<String, Object> description) {
67
+        this.eventDescription = (String) description.get("text");
68
+    }
69
+
70
+    @JsonProperty("start")
71
+    private void unpackStart(Map<String, Object> start) {
72
+        this.startDate = LocalDateTime.parse((String) start.get("local"));
73
+    }
74
+
75
+    @JsonProperty("end")
76
+    private void unpackEnd(Map<String, Object> end) {
77
+        this.endDate =  LocalDateTime.parse((String) end.get("local"));
78
+    }
79
+
80
+    @JsonProperty("logo")
81
+    private void unpackLogo(Map<String, Object> logo) {
82
+        this.logo = (String) logo.get("url");
83
+    }
84
+
85
+    @ManyToMany(fetch = FetchType.EAGER)
86
+    @JoinTable(name="event_venue",
87
+            joinColumns=@JoinColumn(name="event_id"),
88
+            inverseJoinColumns=@JoinColumn(name="venue_id"))
89
+    private Set<Venue> venue = new HashSet<>();
90
+
91
+    @ManyToMany(fetch = FetchType.EAGER)
92
+    @JoinTable(name="event_category",
93
+    joinColumns = @JoinColumn(name="category_id"),
94
+    inverseJoinColumns=@JoinColumn(name="event_id"))
95
+    private Set<Category> category = new HashSet<>();
96
+
97
+    @ManyToMany(fetch = FetchType.EAGER)
98
+    @JoinTable(name="Event_subcategory",
99
+    joinColumns = @JoinColumn(name="subcategory_id"),
100
+    inverseJoinColumns = @JoinColumn(name="event_id"))
101
+    private Set<Subcategory> subcategory = new HashSet<>();
102
+
103
+
104
+    public long getId() { return id; }
105
+
106
+    public void setId(long id) { this.id = id; }
107
+
108
+    public String getEventName() { return eventName; }
109
+
110
+    public void setEventName(String eventName) { this.eventName = eventName; }
111
+
112
+    public String getEventDescription() { return eventDescription; }
113
+
114
+    public void setEventDescription(String eventDescription) { this.eventDescription = eventDescription; }
115
+
116
+    public long getCategory_id() { return category_id; }
117
+
118
+    public void setCategory_id(long category_id) { this.category_id = category_id; }
119
+
120
+    public long getSubcategory_id() { return subcategory_id; }
121
+
122
+    public void setSubcategory_id(long subcategory_id) { this.subcategory_id = subcategory_id; }
123
+
124
+    public long getVenue_id() { return venue_id; }
125
+
126
+    public void setVenue_id(long venue_id) { this.venue_id = venue_id; }
127
+
128
+    public LocalDateTime getStartDate() { return startDate; }
129
+
130
+    public void setStartDate(LocalDateTime startDate) { this.startDate = startDate; }
131
+
132
+    public LocalDateTime getEndDate() { return endDate; }
133
+
134
+    public void setEndDate(LocalDateTime endDate) { this.endDate = endDate; }
135
+
136
+    public String getStatus() { return status; }
137
+
138
+    public void setStatus(String status) { this.status = status; }
139
+
140
+    public Date getCreated() { return created; }
141
+
142
+    public void setCreated(Date created) { this.created = created; }
143
+
144
+    public String getResource_url() { return resource_url; }
145
+
146
+    public void setResource_url(String resource_url) { this.resource_url = resource_url; }
147
+
148
+    public String getLogo() { return logo; }
149
+
150
+    public void setLogo(String logo) { this.logo = logo; }
151
+
152
+    public Set<Venue> getVenue() { return venue; }
153
+
154
+    public void setVenue(Set<Venue> venue) { this.venue = venue; }
155
+
156
+    public Set<Category> getCategory() { return category; }
157
+
158
+    public void setCategory(Set<Category> category) { this.category = category; }
159
+
160
+    @Override
161
+    public String toString() {
162
+        return "Event{" +
163
+                "id=" + id +
164
+                ", eventName='" + eventName + '\'' +
165
+                ", eventDescription='" + eventDescription + '\'' +
166
+                ", category_id=" + category_id +
167
+                ", subcategory_id=" + subcategory_id +
168
+                ", venue_id=" + venue_id +
169
+                ", startDate=" + startDate +
170
+                ", endDate=" + endDate +
171
+                ", status='" + status + '\'' +
172
+                ", created=" + created +
173
+                ", resource_url='" + resource_url + '\'' +
174
+                ", logo='" + logo + '\'' +
175
+                ", venue=" + venue +
176
+                '}';
177
+    }
178
+
179
+    public Set<Subcategory> getSubcategory() {
180
+        return subcategory;
181
+    }
182
+
183
+
184
+    public void setSubcategory(Set<Subcategory> subcategory) {
185
+        this.subcategory = subcategory;
186
+    }
187
+}

+ 27
- 0
src/main/java/com/proximity/demo/eventbriteApi/Events/EventController.java View File

@@ -0,0 +1,27 @@
1
+package com.proximity.demo.eventbriteApi.Events;
2
+
3
+
4
+import com.proximity.demo.eventbriteApi.Venues.VenueService;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.web.bind.annotation.CrossOrigin;
7
+import org.springframework.web.bind.annotation.GetMapping;
8
+import org.springframework.web.bind.annotation.RestController;
9
+
10
+import java.util.List;
11
+
12
+@RestController
13
+@CrossOrigin
14
+public class EventController {
15
+
16
+    @Autowired
17
+    private EventService eventService;
18
+
19
+    @Autowired
20
+    private EventRepository repository;
21
+
22
+    @GetMapping("/events")
23
+    public List<Event> getAll(){
24
+        eventService.getEventsInPhilly();
25
+        return repository.findAll();
26
+    }
27
+}

+ 13
- 0
src/main/java/com/proximity/demo/eventbriteApi/Events/EventRepository.java View File

@@ -0,0 +1,13 @@
1
+package com.proximity.demo.eventbriteApi.Events;
2
+
3
+import com.proximity.demo.eventbriteApi.Venues.Venue;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.stereotype.Repository;
6
+
7
+@Repository
8
+public interface EventRepository extends JpaRepository<Event, Long> {
9
+
10
+    Event findByVenue(Venue venue);
11
+
12
+    Event findByEventName(String name);
13
+}

+ 38
- 0
src/main/java/com/proximity/demo/eventbriteApi/Events/EventService.java View File

@@ -0,0 +1,38 @@
1
+package com.proximity.demo.eventbriteApi.Events;
2
+
3
+import org.springframework.beans.factory.annotation.Autowired;
4
+import org.springframework.boot.web.client.RestTemplateBuilder;
5
+import org.springframework.core.ParameterizedTypeReference;
6
+import org.springframework.http.HttpMethod;
7
+import org.springframework.http.ResponseEntity;
8
+import org.springframework.stereotype.Service;
9
+import org.springframework.web.client.RestTemplate;
10
+
11
+
12
+@Service
13
+public class EventService{
14
+
15
+    private static final String token = "SMEZ5DGCKW5IDHS7HXNI";
16
+    private final RestTemplate restTemplate;
17
+    private Event Event = new Event();
18
+    private EventRepository eventRepository;
19
+
20
+    @Autowired
21
+    public EventService(RestTemplateBuilder restTemplateBuilder, EventRepository eventRepository) {
22
+        this.restTemplate = restTemplateBuilder.build();
23
+        this.eventRepository = eventRepository;
24
+    }
25
+
26
+    public Event getEventsInPhilly() {
27
+        String url = "https://www.eventbriteapi.com/v3/events/search/?"
28
+                + "token=" + token
29
+                + "&location.address=philadelphia";
30
+        EventWrapper wrapper = restTemplate.getForObject(url, EventWrapper.class);
31
+        eventRepository.saveAll(wrapper.getEvents());
32
+        return null;
33
+    }
34
+
35
+    public Event save(Event Event) { return this.eventRepository.save(Event); }
36
+
37
+    public Event find(String name) { return this.eventRepository.findByEventName(Event.getEventName()); }
38
+}

+ 19
- 0
src/main/java/com/proximity/demo/eventbriteApi/Events/EventWrapper.java View File

@@ -0,0 +1,19 @@
1
+package com.proximity.demo.eventbriteApi.Events;
2
+
3
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4
+import com.fasterxml.jackson.annotation.JsonProperty;
5
+
6
+import java.util.List;
7
+
8
+
9
+@JsonIgnoreProperties(ignoreUnknown = true)
10
+public class EventWrapper {
11
+
12
+    public EventWrapper() { }
13
+
14
+    private List<Event> events;
15
+
16
+    public List<Event> getEvents() { return events; }
17
+
18
+    public void setEvents(List<Event> events) { this.events = events; }
19
+}

+ 110
- 0
src/main/java/com/proximity/demo/eventbriteApi/Subcategories/Subcategory.java View File

@@ -0,0 +1,110 @@
1
+package com.proximity.demo.eventbriteApi.Subcategories;
2
+
3
+import com.fasterxml.jackson.annotation.JsonIgnore;
4
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5
+import com.fasterxml.jackson.annotation.JsonProperty;
6
+import com.proximity.demo.eventbriteApi.Categories.Category;
7
+import com.proximity.demo.eventbriteApi.Events.Event;
8
+
9
+import javax.persistence.*;
10
+import java.util.HashSet;
11
+import java.util.Map;
12
+import java.util.Set;
13
+
14
+@Entity
15
+@JsonIgnoreProperties(ignoreUnknown = true)
16
+@Table(name="SUBCATEGORY")
17
+public class Subcategory {
18
+
19
+    @Id
20
+    @GeneratedValue(strategy = GenerationType.AUTO)
21
+    private int subcategoryid;
22
+
23
+    @Column(unique = true)
24
+    private int id;
25
+    private String name;
26
+    private int parent_id;
27
+
28
+    public Subcategory() {}
29
+
30
+    public Subcategory(int id, String name, int parent_id, Category subToCategory, Set<Event> event) {
31
+        this.id = id;
32
+        this.name = name;
33
+        this.parent_id = parent_id;
34
+        this.subToCategory = subToCategory;
35
+        this.event = event;
36
+    }
37
+
38
+    @JsonProperty("parent_category")
39
+    private void unpackParentCategory(Map<String, Object> parent_category) {
40
+        this.parent_id = Integer.valueOf((String)parent_category.get("id"));
41
+    }
42
+
43
+    @ManyToOne(fetch = FetchType.EAGER)
44
+    @JoinColumn(name = "category_id")
45
+    @JsonIgnore
46
+    private Category subToCategory;
47
+
48
+    @ManyToMany(mappedBy = "subcategory")
49
+    private Set<Event> event = new HashSet<>();
50
+
51
+    public int getSubcategoryid() {
52
+        return subcategoryid;
53
+    }
54
+
55
+    public void setSubcategoryid(int subcategoryid) {
56
+        this.subcategoryid = subcategoryid;
57
+    }
58
+
59
+    public int getId() {
60
+        return id;
61
+    }
62
+
63
+    public void setId(int id) {
64
+        this.id = id;
65
+    }
66
+
67
+    public String getName() {
68
+        return name;
69
+    }
70
+
71
+    public void setName(String name) {
72
+        this.name = name;
73
+    }
74
+
75
+    public int getParent_id() {
76
+        return parent_id;
77
+    }
78
+
79
+    public void setParent_id(int parent_id) {
80
+        this.parent_id = parent_id;
81
+    }
82
+
83
+    public Category getSubToCategory() {
84
+        return subToCategory;
85
+    }
86
+
87
+    public void setSubToCategory(Category subToCategory) {
88
+        this.subToCategory = subToCategory;
89
+    }
90
+
91
+    public Set<Event> getEvent() {
92
+        return event;
93
+    }
94
+
95
+    public void setEvent(Set<Event> event) {
96
+        this.event = event;
97
+    }
98
+
99
+    @Override
100
+    public String toString() {
101
+        return "Subcategory{" +
102
+                "subcategoryid=" + subcategoryid +
103
+                ", id=" + id +
104
+                ", name='" + name + '\'' +
105
+                ", parent_id=" + parent_id +
106
+                ", subToCategory=" + subToCategory +
107
+                ", event=" + event +
108
+                '}';
109
+    }
110
+}

+ 25
- 0
src/main/java/com/proximity/demo/eventbriteApi/Subcategories/SubcategoryController.java View File

@@ -0,0 +1,25 @@
1
+package com.proximity.demo.eventbriteApi.Subcategories;
2
+
3
+import org.springframework.beans.factory.annotation.Autowired;
4
+import org.springframework.web.bind.annotation.CrossOrigin;
5
+import org.springframework.web.bind.annotation.GetMapping;
6
+import org.springframework.web.bind.annotation.RestController;
7
+
8
+import java.util.List;
9
+
10
+@RestController
11
+@CrossOrigin
12
+public class SubcategoryController {
13
+
14
+    @Autowired
15
+    private SubcategoryService subcategoryService;
16
+
17
+    @Autowired
18
+    private SubcategoryRepository subcategoryRepository;
19
+
20
+    @GetMapping("/subcategories")
21
+    public List<Subcategory> getAll() {
22
+        subcategoryService.getSubcategories();
23
+        return subcategoryRepository.findAll();
24
+    }
25
+}

+ 11
- 0
src/main/java/com/proximity/demo/eventbriteApi/Subcategories/SubcategoryRepository.java View File

@@ -0,0 +1,11 @@
1
+package com.proximity.demo.eventbriteApi.Subcategories;
2
+
3
+import com.proximity.demo.eventbriteApi.Events.Event;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.stereotype.Repository;
6
+
7
+@Repository
8
+public interface SubcategoryRepository extends JpaRepository<Subcategory, Long> {
9
+
10
+    Subcategory findSubcategoryByEvent(Event event);
11
+}

+ 37
- 0
src/main/java/com/proximity/demo/eventbriteApi/Subcategories/SubcategoryService.java View File

@@ -0,0 +1,37 @@
1
+package com.proximity.demo.eventbriteApi.Subcategories;
2
+
3
+import com.proximity.demo.eventbriteApi.Events.Event;
4
+import com.proximity.demo.eventbriteApi.Events.EventRepository;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.boot.web.client.RestTemplateBuilder;
7
+import org.springframework.stereotype.Service;
8
+import org.springframework.web.client.RestTemplate;
9
+
10
+import java.util.List;
11
+
12
+@Service
13
+public class SubcategoryService {
14
+
15
+    private static final String token = "SMEZ5DGCKW5IDHS7HXNI";
16
+    private final RestTemplate restTemplate;
17
+    private EventRepository eventRepository;
18
+    private SubcategoryRepository subcategoryRepository;
19
+
20
+    @Autowired
21
+    public SubcategoryService(RestTemplateBuilder restTemplateBuilder, EventRepository eventRepository,
22
+                              SubcategoryRepository subcategoryRepository) {
23
+        this.restTemplate = restTemplateBuilder.build();
24
+        this.eventRepository = eventRepository;
25
+        this.subcategoryRepository = subcategoryRepository;
26
+    }
27
+
28
+    public Subcategory getSubcategories() {
29
+        String url = "http://www.eventbriteapi.com/v3/subcategories?"
30
+                + "token=" + token;
31
+        SubcategoryWrapper wrapper = restTemplate.getForObject(url, SubcategoryWrapper.class);
32
+        subcategoryRepository.saveAll(wrapper.getSubcategories());
33
+        return null;
34
+    }
35
+
36
+    private Subcategory save(Subcategory subcategory) { return this.subcategoryRepository.save(subcategory); }
37
+}

+ 17
- 0
src/main/java/com/proximity/demo/eventbriteApi/Subcategories/SubcategoryWrapper.java View File

@@ -0,0 +1,17 @@
1
+package com.proximity.demo.eventbriteApi.Subcategories;
2
+
3
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4
+
5
+import java.util.List;
6
+
7
+@JsonIgnoreProperties(ignoreUnknown = true)
8
+public class SubcategoryWrapper {
9
+
10
+    public SubcategoryWrapper() { }
11
+
12
+    private List<Subcategory> subcategories;
13
+
14
+    public List<Subcategory> getSubcategories() { return subcategories; }
15
+
16
+    public void setSubcategories(List<Subcategory> subcategories) { this.subcategories = subcategories; }
17
+}

+ 156
- 0
src/main/java/com/proximity/demo/eventbriteApi/Venues/Venue.java View File

@@ -0,0 +1,156 @@
1
+package com.proximity.demo.eventbriteApi.Venues;
2
+
3
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4
+import com.fasterxml.jackson.annotation.JsonProperty;
5
+import com.proximity.demo.eventbriteApi.Events.Event;
6
+
7
+import javax.persistence.*;
8
+import java.io.Serializable;
9
+import java.util.HashSet;
10
+import java.util.Map;
11
+import java.util.Set;
12
+
13
+@Entity
14
+@JsonIgnoreProperties(ignoreUnknown = true)
15
+@Table(name="VENUE")
16
+public class Venue implements Serializable {
17
+
18
+    @Id
19
+    @GeneratedValue(strategy = GenerationType.AUTO)
20
+    private Long venueid;
21
+
22
+    @Column(unique = true)
23
+    private long id;
24
+    private String name;
25
+    private String address_1;
26
+    private String address_2;
27
+    private String city;
28
+    private String region;
29
+    private String postal_code;
30
+    private String country;
31
+    private String latitude;
32
+    private String longitude;
33
+    private String localized_multi_line_address_display;
34
+    private String resource_uri;
35
+    private int age_restriction;
36
+    private int capacity;
37
+
38
+    public Venue() { }
39
+
40
+    public Venue(String name, String address_1, String address_2, String city, String region,
41
+                 String postal_code, String country, String latitude, String longitude,
42
+                 String localized_multi_line_address_display, String resource_uri, int age_restriction,
43
+                 int capacity, Set<Event> event) {
44
+        this.name = name;
45
+        this.address_1 = address_1;
46
+        this.address_2 = address_2;
47
+        this.city = city;
48
+        this.region = region;
49
+        this.postal_code = postal_code;
50
+        this.country = country;
51
+        this.latitude = latitude;
52
+        this.longitude = longitude;
53
+        this.localized_multi_line_address_display = localized_multi_line_address_display;
54
+        this.resource_uri = resource_uri;
55
+        this.age_restriction = age_restriction;
56
+        this.capacity = capacity;
57
+        this.event = event;
58
+    }
59
+
60
+
61
+    @JsonProperty("address")
62
+    private void unpackAddress(Map<String, Object> address) {
63
+        this.address_1 = (String) address.get("address_1");
64
+        this.address_2 = (String) address.get("address_2");
65
+        this.city = (String) address.get("city");
66
+        this.region = (String) address.get("region");
67
+        this.postal_code = (String)address.get("postal_code");
68
+        this.country = (String) address.get("country");
69
+    }
70
+
71
+    @ManyToMany(mappedBy = "venue", fetch = FetchType.EAGER)
72
+    private Set<Event> event = new HashSet<>();
73
+
74
+    public Long getId() { return id; }
75
+
76
+    public void setId(Long id) { this.id = id; }
77
+
78
+    public String getName() { return name; }
79
+
80
+    public void setName(String name) { this.name = name; }
81
+
82
+    public String getAddress_1() { return address_1; }
83
+
84
+    public void setAddress_1(String address_1) { this.address_1 = address_1; }
85
+
86
+    public String getAddress_2() { return address_2; }
87
+
88
+    public void setAddress_2(String address_2) { this.address_2 = address_2; }
89
+
90
+    public String getCity() { return city; }
91
+
92
+    public void setCity(String city) { this.city = city; }
93
+
94
+    public String getRegion() { return region; }
95
+
96
+    public void setRegion(String region) { this.region = region; }
97
+
98
+    public String getPostal_code() { return postal_code; }
99
+
100
+    public void setPostal_code(String postal_code) { this.postal_code = postal_code; }
101
+
102
+    public String getCountry() { return country; }
103
+
104
+    public void setCountry(String country) { this.country = country; }
105
+
106
+    public String getLatitude() { return latitude; }
107
+
108
+    public void setLatitude(String latitude) { this.latitude = latitude; }
109
+
110
+    public String getLongitude() { return longitude; }
111
+
112
+    public void setLongitude(String longitude) { this.longitude = longitude; }
113
+
114
+    public String getLocalized_multi_line_address_display() { return localized_multi_line_address_display; }
115
+
116
+    public void setLocalized_multi_line_address_display(String localized_multi_line_address_display) {
117
+        this.localized_multi_line_address_display = localized_multi_line_address_display;
118
+    }
119
+
120
+    public String getResource_uri() { return resource_uri; }
121
+
122
+    public void setResource_uri(String resource_uri) { this.resource_uri = resource_uri; }
123
+
124
+    public int getAge_restriction() { return age_restriction; }
125
+
126
+    public void setAge_restriction(int age_restriction) { this.age_restriction = age_restriction; }
127
+
128
+    public int getCapacity() { return capacity; }
129
+
130
+    public void setCapacity(int capacity) { this.capacity = capacity; }
131
+
132
+    public Set<Event> getEvent() { return event; }
133
+
134
+    public void setEvent(Set<Event> event) { this.event = event; }
135
+
136
+    @Override
137
+    public String toString() {
138
+        return "Venue{" +
139
+                "id=" + id +
140
+                ", name='" + name + '\'' +
141
+                ", address_1='" + address_1 + '\'' +
142
+                ", address_2='" + address_2 + '\'' +
143
+                ", city='" + city + '\'' +
144
+                ", region='" + region + '\'' +
145
+                ", postal_code=" + postal_code +
146
+                ", country='" + country + '\'' +
147
+                ", latitude='" + latitude + '\'' +
148
+                ", longitude='" + longitude + '\'' +
149
+                ", localized_multi_line_address_display='" + localized_multi_line_address_display + '\'' +
150
+                ", resource_uri='" + resource_uri + '\'' +
151
+                ", age_restriction=" + age_restriction +
152
+                ", capacity=" + capacity +
153
+                ", event=" + event +
154
+                '}';
155
+    }
156
+}

+ 25
- 0
src/main/java/com/proximity/demo/eventbriteApi/Venues/VenueController.java View File

@@ -0,0 +1,25 @@
1
+package com.proximity.demo.eventbriteApi.Venues;
2
+
3
+import org.springframework.beans.factory.annotation.Autowired;
4
+import org.springframework.web.bind.annotation.CrossOrigin;
5
+import org.springframework.web.bind.annotation.GetMapping;
6
+import org.springframework.web.bind.annotation.RestController;
7
+
8
+import java.util.List;
9
+
10
+@RestController
11
+@CrossOrigin
12
+public class VenueController {
13
+
14
+    @Autowired
15
+    private VenueService venueService;
16
+
17
+    @Autowired
18
+    private VenueRepository venueRepository;
19
+
20
+    @GetMapping("/venues")
21
+    public List<Venue> getAll() {
22
+        venueService.getEventVenue();
23
+        return venueRepository.findAll();
24
+    }
25
+}

+ 13
- 0
src/main/java/com/proximity/demo/eventbriteApi/Venues/VenueRepository.java View File

@@ -0,0 +1,13 @@
1
+package com.proximity.demo.eventbriteApi.Venues;
2
+
3
+import com.proximity.demo.eventbriteApi.Events.Event;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.stereotype.Repository;
6
+
7
+@Repository
8
+public interface VenueRepository extends JpaRepository<Venue, Long> {
9
+
10
+    Venue findVenueByEvent(Event Event);
11
+
12
+    Venue findByName(String name);
13
+}

+ 49
- 0
src/main/java/com/proximity/demo/eventbriteApi/Venues/VenueService.java View File

@@ -0,0 +1,49 @@
1
+package com.proximity.demo.eventbriteApi.Venues;
2
+
3
+import com.proximity.demo.eventbriteApi.Events.Event;
4
+import com.proximity.demo.eventbriteApi.Events.EventRepository;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.boot.web.client.RestTemplateBuilder;
7
+import org.springframework.stereotype.Service;
8
+import org.springframework.web.client.RestTemplate;
9
+
10
+import java.util.ArrayList;
11
+import java.util.List;
12
+
13
+@Service
14
+public class VenueService {
15
+
16
+    private static final String token = "SMEZ5DGCKW5IDHS7HXNI";
17
+    private final RestTemplate restTemplate;
18
+    private Venue venue = new Venue();
19
+    private EventRepository eventRepository;
20
+    private VenueRepository venueRepository;
21
+
22
+    @Autowired
23
+    public VenueService(RestTemplateBuilder restTemplateBuilder, EventRepository eventRepository, VenueRepository venueRepository) {
24
+        this.restTemplate = restTemplateBuilder.build();
25
+        this.eventRepository = eventRepository;
26
+        this.venueRepository = venueRepository;
27
+    }
28
+
29
+    public Venue getEventVenue(){
30
+        List<Event> events = new ArrayList<>(eventRepository.findAll());
31
+        for(int i = 0; i < events.size() - 1; i++) {
32
+            Long venue_id = events.get(i).getVenue_id();
33
+
34
+            //check to see if the venue exist by the id, if it doesn't then save it
35
+
36
+            String url = "https://www.eventbriteapi.com/v3/venues/"
37
+                    + venue_id
38
+                    + "?token=" + token;
39
+            Venue venue = restTemplate.getForObject(url, Venue.class);
40
+
41
+            venueRepository.save(venue);
42
+        }
43
+        return null;
44
+    }
45
+
46
+    private Venue save(Venue venue) { return this.venueRepository.save(venue); }
47
+
48
+    public Venue find(String name) { return this.venueRepository.findByName(venue.getName()); }
49
+}

+ 16
- 0
src/main/java/com/proximity/demo/eventbriteApi/Venues/VenueWrapper.java View File

@@ -0,0 +1,16 @@
1
+package com.proximity.demo.eventbriteApi.Venues;
2
+
3
+import com.proximity.demo.eventbriteApi.Events.Event;
4
+
5
+import java.util.List;
6
+
7
+public class VenueWrapper {
8
+
9
+    public VenueWrapper() { }
10
+
11
+    private List<Venue> venues;
12
+
13
+    public List<Venue> getVenues() { return venues; }
14
+
15
+    public void setVenues(List<Venue> venues) { this.venues = venues; }
16
+}

+ 5
- 0
src/main/resources/application.properties View File

@@ -0,0 +1,5 @@
1
+spring.datasource.url= jdbc:mysql://localhost:3306/proximity?useSSL=False
2
+spring.datasource.username=jdot2791
3
+spring.datasource.password=molonlabe27
4
+spring.jpa.show-sql=true
5
+spring.jpa.hibernate.ddl-auto=update

+ 16
- 0
src/test/java/com/proximity/demo/DemoApplicationTests.java View File

@@ -0,0 +1,16 @@
1
+package com.proximity.demo;
2
+
3
+import org.junit.Test;
4
+import org.junit.runner.RunWith;
5
+import org.springframework.boot.test.context.SpringBootTest;
6
+import org.springframework.test.context.junit4.SpringRunner;
7
+
8
+@RunWith(SpringRunner.class)
9
+@SpringBootTest
10
+public class DemoApplicationTests {
11
+
12
+    @Test
13
+    public void contextLoads() {
14
+    }
15
+
16
+}

+ 19
- 0
src/test/java/com/proximity/demo/eventbriteApi/Events/eventServiceTest.java View File

@@ -0,0 +1,19 @@
1
+package com.proximity.demo.eventbriteApi.Events;
2
+
3
+import org.junit.Test;
4
+import org.springframework.beans.factory.annotation.Autowired;
5
+
6
+import static org.junit.Assert.*;
7
+
8
+public class eventServiceTest {
9
+
10
+    @Autowired
11
+    EventService eventService;
12
+
13
+    @Test
14
+    public void getEventsInPhilly() {
15
+        Event expected = eventService.save(new Event());
16
+        Event actual = eventService.save(eventService.getEventsInPhilly());
17
+        assertEquals(expected, actual);
18
+    }
19
+}

+ 16
- 0
src/test/java/com/proximity/demo/eventbriteApi/Subcategories/SubcategoryServiceTest.java View File

@@ -0,0 +1,16 @@
1
+package com.proximity.demo.eventbriteApi.Subcategories;
2
+
3
+import org.junit.Test;
4
+import org.springframework.beans.factory.annotation.Autowired;
5
+
6
+import static org.junit.Assert.*;
7
+
8
+public class SubcategoryServiceTest {
9
+    @Autowired
10
+    SubcategoryService ss;
11
+
12
+    @Test
13
+    public void getSubcategories() {
14
+        System.out.println(ss.getSubcategories());
15
+    }
16
+}