├── .gitignore
├── README.md
├── conference-demo
├── .gitignore
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── pluralsight
│ │ │ └── conferencedemo
│ │ │ ├── ConferenceDemoApplication.java
│ │ │ ├── controllers
│ │ │ ├── HomeController.java
│ │ │ ├── SessionsController.java
│ │ │ ├── SpeakersController.java
│ │ │ └── TicketPricesController.java
│ │ │ ├── models
│ │ │ ├── PricingCategory.java
│ │ │ ├── Session.java
│ │ │ ├── Speaker.java
│ │ │ ├── TicketPrice.java
│ │ │ └── TicketType.java
│ │ │ └── repositories
│ │ │ ├── PricingCategoryRepository.java
│ │ │ ├── SessionCustomJpaRepository.java
│ │ │ ├── SessionCustomJpaRepositoryImpl.java
│ │ │ ├── SessionJpaRepository.java
│ │ │ ├── SessionRepository.java
│ │ │ ├── SpeakerJpaRepository.java
│ │ │ ├── SpeakerRepository.java
│ │ │ ├── TicketPriceJpaRepository.java
│ │ │ ├── TicketPriceRepository.java
│ │ │ ├── TicketTypeJpaRepository.java
│ │ │ └── TicketTypeRepository.java
│ └── resources
│ │ └── application.properties
│ └── test
│ └── java
│ └── com
│ └── pluralsight
│ └── conferencedemo
│ ├── ConferenceDemoApplicationTests.java
│ └── models
│ ├── SessionTest.java
│ ├── SpeakerTest.java
│ ├── TicketPriceTest.java
│ └── TicketTypeTest.java
└── database
└── postgresql
├── README.md
├── create_tables.sql
└── insert_data.sql
/.gitignore:
--------------------------------------------------------------------------------
1 | conference-demo/.idea/
2 | conference-demo/target/
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ps-spring-data-rest
2 | repository and code resources for the Spring Data REST course
3 |
--------------------------------------------------------------------------------
/conference-demo/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/**
4 | !**/src/main/**
5 | !**/src/test/**
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 |
30 | ### VS Code ###
31 | .vscode/
32 |
--------------------------------------------------------------------------------
/conference-demo/mvnw:
--------------------------------------------------------------------------------
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 | # https://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 | # Maven 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 Mingw, 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 | fi
118 |
119 | if [ -z "$JAVA_HOME" ]; then
120 | javaExecutable="`which javac`"
121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
122 | # readlink(1) is not available as standard on Solaris 10.
123 | readLink=`which readlink`
124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
125 | if $darwin ; then
126 | javaHome="`dirname \"$javaExecutable\"`"
127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
128 | else
129 | javaExecutable="`readlink -f \"$javaExecutable\"`"
130 | fi
131 | javaHome="`dirname \"$javaExecutable\"`"
132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
133 | JAVA_HOME="$javaHome"
134 | export JAVA_HOME
135 | fi
136 | fi
137 | fi
138 |
139 | if [ -z "$JAVACMD" ] ; then
140 | if [ -n "$JAVA_HOME" ] ; then
141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
142 | # IBM's JDK on AIX uses strange locations for the executables
143 | JAVACMD="$JAVA_HOME/jre/sh/java"
144 | else
145 | JAVACMD="$JAVA_HOME/bin/java"
146 | fi
147 | else
148 | JAVACMD="`which java`"
149 | fi
150 | fi
151 |
152 | if [ ! -x "$JAVACMD" ] ; then
153 | echo "Error: JAVA_HOME is not defined correctly." >&2
154 | echo " We cannot execute $JAVACMD" >&2
155 | exit 1
156 | fi
157 |
158 | if [ -z "$JAVA_HOME" ] ; then
159 | echo "Warning: JAVA_HOME environment variable is not set."
160 | fi
161 |
162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
163 |
164 | # traverses directory structure from process work directory to filesystem root
165 | # first directory with .mvn subdirectory is considered project base directory
166 | find_maven_basedir() {
167 |
168 | if [ -z "$1" ]
169 | then
170 | echo "Path not specified to find_maven_basedir"
171 | return 1
172 | fi
173 |
174 | basedir="$1"
175 | wdir="$1"
176 | while [ "$wdir" != '/' ] ; do
177 | if [ -d "$wdir"/.mvn ] ; then
178 | basedir=$wdir
179 | break
180 | fi
181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
182 | if [ -d "${wdir}" ]; then
183 | wdir=`cd "$wdir/.."; pwd`
184 | fi
185 | # end of workaround
186 | done
187 | echo "${basedir}"
188 | }
189 |
190 | # concatenates all lines of a file
191 | concat_lines() {
192 | if [ -f "$1" ]; then
193 | echo "$(tr -s '\n' ' ' < "$1")"
194 | fi
195 | }
196 |
197 | BASE_DIR=`find_maven_basedir "$(pwd)"`
198 | if [ -z "$BASE_DIR" ]; then
199 | exit 1;
200 | fi
201 |
202 | ##########################################################################################
203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
204 | # This allows using the maven wrapper in projects that prohibit checking in binary data.
205 | ##########################################################################################
206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
207 | if [ "$MVNW_VERBOSE" = true ]; then
208 | echo "Found .mvn/wrapper/maven-wrapper.jar"
209 | fi
210 | else
211 | if [ "$MVNW_VERBOSE" = true ]; then
212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
213 | fi
214 | if [ -n "$MVNW_REPOURL" ]; then
215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
216 | else
217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
218 | fi
219 | while IFS="=" read key value; do
220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
221 | esac
222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
223 | if [ "$MVNW_VERBOSE" = true ]; then
224 | echo "Downloading from: $jarUrl"
225 | fi
226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
227 | if $cygwin; then
228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
229 | fi
230 |
231 | if command -v wget > /dev/null; then
232 | if [ "$MVNW_VERBOSE" = true ]; then
233 | echo "Found wget ... using wget"
234 | fi
235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
236 | wget "$jarUrl" -O "$wrapperJarPath"
237 | else
238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
239 | fi
240 | elif command -v curl > /dev/null; then
241 | if [ "$MVNW_VERBOSE" = true ]; then
242 | echo "Found curl ... using curl"
243 | fi
244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
245 | curl -o "$wrapperJarPath" "$jarUrl" -f
246 | else
247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
248 | fi
249 |
250 | else
251 | if [ "$MVNW_VERBOSE" = true ]; then
252 | echo "Falling back to using Java to download"
253 | fi
254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
255 | # For Cygwin, switch paths to Windows format before running javac
256 | if $cygwin; then
257 | javaClass=`cygpath --path --windows "$javaClass"`
258 | fi
259 | if [ -e "$javaClass" ]; then
260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
261 | if [ "$MVNW_VERBOSE" = true ]; then
262 | echo " - Compiling MavenWrapperDownloader.java ..."
263 | fi
264 | # Compiling the Java class
265 | ("$JAVA_HOME/bin/javac" "$javaClass")
266 | fi
267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
268 | # Running the downloader
269 | if [ "$MVNW_VERBOSE" = true ]; then
270 | echo " - Running MavenWrapperDownloader.java ..."
271 | fi
272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
273 | fi
274 | fi
275 | fi
276 | fi
277 | ##########################################################################################
278 | # End of extension
279 | ##########################################################################################
280 |
281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
282 | if [ "$MVNW_VERBOSE" = true ]; then
283 | echo $MAVEN_PROJECTBASEDIR
284 | fi
285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
286 |
287 | # For Cygwin, switch paths to Windows format before running java
288 | if $cygwin; then
289 | [ -n "$M2_HOME" ] &&
290 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
291 | [ -n "$JAVA_HOME" ] &&
292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
293 | [ -n "$CLASSPATH" ] &&
294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
295 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
297 | fi
298 |
299 | # Provide a "standardized" way to retrieve the CLI args that will
300 | # work with both Windows and non-Windows executions.
301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
302 | export MAVEN_CMD_LINE_ARGS
303 |
304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
305 |
306 | exec "$JAVACMD" \
307 | $MAVEN_OPTS \
308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
311 |
--------------------------------------------------------------------------------
/conference-demo/mvnw.cmd:
--------------------------------------------------------------------------------
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 https://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 Maven 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 keystroke 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 set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
124 |
125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
162 | if ERRORLEVEL 1 goto error
163 | goto end
164 |
165 | :error
166 | set ERROR_CODE=1
167 |
168 | :end
169 | @endlocal & set ERROR_CODE=%ERROR_CODE%
170 |
171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
175 | :skipRcPost
176 |
177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
179 |
180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
181 |
182 | exit /B %ERROR_CODE%
183 |
--------------------------------------------------------------------------------
/conference-demo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.3.4.RELEASE
9 |
10 |
11 | com.pluralsight
12 | conference-demo
13 | 0.0.1-SNAPSHOT
14 | conference-demo
15 | Demo project for Spring Boot
16 |
17 |
18 | 11
19 |
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-web
25 |
26 |
27 |
28 |
29 | org.postgresql
30 | postgresql
31 | runtime
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-data-jpa
37 |
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-starter-test
42 | test
43 |
44 |
45 | org.junit.vintage
46 | junit-vintage-engine
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | org.springframework.boot
56 | spring-boot-maven-plugin
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/ConferenceDemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class ConferenceDemoApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(ConferenceDemoApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/controllers/HomeController.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.controllers;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.web.bind.annotation.GetMapping;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | import java.util.HashMap;
9 | import java.util.Map;
10 |
11 | @RestController
12 | public class HomeController {
13 | @Value("${app.version}")
14 | private String appVersion;
15 |
16 |
17 | @GetMapping
18 | @RequestMapping("/")
19 | public Map getStatus() {
20 | Map map = new HashMap();
21 | map.put("app-version", appVersion);
22 | return map;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/controllers/SessionsController.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.controllers;
2 |
3 | import com.pluralsight.conferencedemo.models.Session;
4 | import com.pluralsight.conferencedemo.models.Speaker;
5 | import com.pluralsight.conferencedemo.repositories.SessionRepository;
6 | import org.springframework.beans.BeanUtils;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.web.bind.annotation.*;
9 |
10 | import javax.persistence.EntityManager;
11 | import javax.persistence.PersistenceContext;
12 | import java.util.List;
13 |
14 | @RestController
15 | @RequestMapping("/api/v1/sessions")
16 | public class SessionsController {
17 | @Autowired
18 | private SessionRepository repository;
19 |
20 | @GetMapping
21 | public List list(@RequestParam(required = false) String name) {
22 | if(name != null) {
23 | return repository.getSessionsThatHaveName(name);
24 | } else {
25 | return repository.list();
26 | }
27 | }
28 |
29 | @GetMapping
30 | @RequestMapping("{id}")
31 | public Session get(@PathVariable Long id) {
32 | return repository.find(id);
33 | }
34 |
35 | @PostMapping
36 | public Session create(@RequestBody final Session session){
37 | return repository.create(session);
38 | }
39 |
40 | @DeleteMapping
41 | public void delete(@PathVariable Long id) {
42 | repository.delete(id);
43 | }
44 |
45 | @PutMapping
46 | public Session update(@PathVariable Long id, @RequestBody Session session) {
47 | //because this is a PUT, we expect all attributes to be passed in. A PATCH would only need what has changed.
48 | //TODO: Add validation that all attributes are passed in, otherwise return a 400 bad payload
49 | Session existingSession = repository.find(id);
50 | BeanUtils.copyProperties(session, existingSession, "session_id");
51 | return repository.update(session);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/controllers/SpeakersController.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.controllers;
2 |
3 | import com.pluralsight.conferencedemo.models.Session;
4 | import com.pluralsight.conferencedemo.models.Speaker;
5 | import com.pluralsight.conferencedemo.repositories.SessionRepository;
6 | import com.pluralsight.conferencedemo.repositories.SpeakerRepository;
7 | import org.springframework.beans.BeanUtils;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.web.bind.annotation.*;
10 |
11 | import java.util.List;
12 |
13 | @RestController
14 | @RequestMapping("/api/v1/speakers")
15 | public class SpeakersController {
16 |
17 | @Autowired
18 | private SpeakerRepository repository;
19 |
20 | @GetMapping
21 | public List list() {
22 | return repository.list();
23 | }
24 |
25 | @GetMapping
26 | @RequestMapping("{id}")
27 | public Speaker get(@PathVariable Long id) {
28 | return repository.find(id);
29 | }
30 |
31 | @PostMapping
32 | public Speaker create(@RequestBody final Speaker speaker){
33 | return repository.create(speaker);
34 | }
35 |
36 | @DeleteMapping
37 | public void delete(@PathVariable Long id) {
38 | repository.delete(id);
39 | }
40 |
41 | @PutMapping
42 | public Speaker update(@PathVariable Long id, @RequestBody Speaker speaker) {
43 | //because this is a PUT, we expect all attributes to be passed in. A PATCH would only need what has changed.
44 | //TODO: Add validation that all attributes are passed in, otherwise return a 400 bad payload
45 | Speaker existingSpeaker = repository.find(id);
46 | BeanUtils.copyProperties(speaker, existingSpeaker, "session_id");
47 | return repository.update(speaker);
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/controllers/TicketPricesController.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.controllers;
2 |
3 | import com.pluralsight.conferencedemo.models.TicketPrice;
4 | import com.pluralsight.conferencedemo.repositories.TicketPriceRepository;
5 | import org.springframework.beans.BeanUtils;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.web.bind.annotation.*;
8 |
9 | import java.util.List;
10 |
11 | @RestController
12 | @RequestMapping("/api/v1/ticket_prices")
13 | public class TicketPricesController {
14 |
15 | @Autowired
16 | private TicketPriceRepository repository;
17 |
18 | @GetMapping
19 | public List list() {
20 | return repository.list();
21 | }
22 |
23 | @GetMapping
24 | @RequestMapping("{id}")
25 | public TicketPrice get(@PathVariable Long id) {
26 | return repository.find(id);
27 | }
28 |
29 | @PostMapping
30 | public TicketPrice create(@RequestBody final TicketPrice tp){
31 | return repository.create(tp);
32 | }
33 |
34 | @DeleteMapping
35 | public void delete(@PathVariable Long id) {
36 | repository.delete(id);
37 | }
38 |
39 | @PutMapping
40 | public TicketPrice update(@PathVariable Long id, @RequestBody TicketPrice tp) {
41 | //because this is a PUT, we expect all attributes to be passed in. A PATCH would only need what has changed.
42 | //TODO: Add validation that all attributes are passed in, otherwise return a 400 bad payload
43 | TicketPrice existingTp = repository.find(id);
44 | BeanUtils.copyProperties(tp, existingTp, "ticket_price_id");
45 | return repository.update(tp);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/models/PricingCategory.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.models;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnore;
4 |
5 | import javax.persistence.*;
6 | import java.util.Date;
7 | import java.util.List;
8 |
9 | @Entity
10 | @Table(name = "pricing_categories")
11 | public class PricingCategory {
12 | @Id
13 | @Column(name = "pricing_category_code")
14 | private String pricingCategoryCode;
15 |
16 | @Column(name = "pricing_category_name")
17 | private String pricingCategoryName;
18 |
19 | @Column(name = "pricing_start_date")
20 | private Date pricingStartDate;
21 |
22 | @Column(name = "pricing_end_date")
23 | private Date pricingEndDate;
24 |
25 | @OneToMany(mappedBy = "ticketType")
26 | @JsonIgnore
27 | private List ticketPrices;
28 |
29 | public PricingCategory() {
30 | }
31 |
32 | public String getPricingCategoryCode() {
33 | return pricingCategoryCode;
34 | }
35 |
36 | public void setPricingCategoryCode(String pricingCategoryCode) {
37 | this.pricingCategoryCode = pricingCategoryCode;
38 | }
39 |
40 | public String getPricingCategoryName() {
41 | return pricingCategoryName;
42 | }
43 |
44 | public void setPricingCategoryName(String pricingCategoryName) {
45 | this.pricingCategoryName = pricingCategoryName;
46 | }
47 |
48 | public Date getPricingStartDate() {
49 | return pricingStartDate;
50 | }
51 |
52 | public void setPricingStartDate(Date pricingStartDate) {
53 | this.pricingStartDate = pricingStartDate;
54 | }
55 |
56 | public Date getPricingEndDate() {
57 | return pricingEndDate;
58 | }
59 |
60 | public void setPricingEndDate(Date pricingEndDate) {
61 | this.pricingEndDate = pricingEndDate;
62 | }
63 |
64 | public List getTicketPrices() {
65 | return ticketPrices;
66 | }
67 |
68 | public void setTicketPrices(List ticketPrices) {
69 | this.ticketPrices = ticketPrices;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/models/Session.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.models;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import javax.persistence.*;
6 | import java.util.List;
7 |
8 | @Entity
9 | @Table(name = "sessions")
10 | @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
11 | public class Session {
12 | @Id
13 | @GeneratedValue(strategy = GenerationType.IDENTITY)
14 | @Column(name = "session_id")
15 | private Long sessionId;
16 |
17 | @Column(name = "session_name")
18 | private String sessionName;
19 |
20 | @Column(name = "session_description")
21 | private String sessionDescription;
22 |
23 | @Column(name = "session_length")
24 | private Integer sessionLength;
25 |
26 | @ManyToMany
27 | @JoinTable(
28 | name = "session_speakers",
29 | joinColumns = @JoinColumn(name = "session_id"),
30 | inverseJoinColumns = @JoinColumn(name = "speaker_id"))
31 | private List speakers;
32 |
33 | public Session() {
34 | }
35 |
36 | public List getSpeakers() {
37 | return speakers;
38 | }
39 |
40 | public void setSpeakers(List speakers) {
41 | this.speakers = speakers;
42 | }
43 |
44 | public Long getSessionId() {
45 | return sessionId;
46 | }
47 |
48 | public void setSessionId(Long sessionId) {
49 | this.sessionId = sessionId;
50 | }
51 |
52 | public String getSessionName() {
53 | return sessionName;
54 | }
55 |
56 | public void setSessionName(String sessionName) {
57 | this.sessionName = sessionName;
58 | }
59 |
60 | public String getSessionDescription() {
61 | return sessionDescription;
62 | }
63 |
64 | public void setSessionDescription(String sessionDescription) {
65 | this.sessionDescription = sessionDescription;
66 | }
67 |
68 | public Integer getSessionLength() {
69 | return sessionLength;
70 | }
71 |
72 | public void setSessionLength(Integer sessionLength) {
73 | this.sessionLength = sessionLength;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/models/Speaker.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.models;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnore;
4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5 | import org.hibernate.annotations.Type;
6 |
7 | import javax.persistence.*;
8 | import java.util.List;
9 |
10 | @Entity
11 | @Table(name = "speakers")
12 | @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
13 | public class Speaker {
14 | @Id
15 | @GeneratedValue(strategy = GenerationType.IDENTITY)
16 | @Column(name = "speaker_id")
17 | private Long speakerId;
18 |
19 | @Column(name = "first_name")
20 | private String firstName;
21 |
22 | @Column(name = "last_name")
23 | private String lastName;
24 |
25 | @Column(name = "title")
26 | private String title;
27 |
28 | @Column(name = "company")
29 | private String company;
30 |
31 | @Column(name = "speaker_bio")
32 | private String speakerBio;
33 |
34 | @Lob
35 | @Type(type="org.hibernate.type.BinaryType")
36 | @Column(name = "speaker_photo")
37 | private byte[] speakerPhoto;
38 |
39 | @ManyToMany(mappedBy = "speakers")
40 | @JsonIgnore
41 | private List sessions;
42 |
43 | public Speaker() {
44 | }
45 |
46 | public byte[] getSpeakerPhoto() {
47 | return speakerPhoto;
48 | }
49 |
50 | public void setSpeakerPhoto(byte[] speakerPhoto) {
51 | this.speakerPhoto = speakerPhoto;
52 | }
53 |
54 | public List getSessions() {
55 | return sessions;
56 | }
57 |
58 | public void setSessions(List sessions) {
59 | this.sessions = sessions;
60 | }
61 |
62 | public Long getSpeakerId() {
63 | return speakerId;
64 | }
65 |
66 | public void setSpeakerId(Long speakerId) {
67 | this.speakerId = speakerId;
68 | }
69 |
70 | public String getFirstName() {
71 | return firstName;
72 | }
73 |
74 | public void setFirstName(String firstName) {
75 | this.firstName = firstName;
76 | }
77 |
78 | public String getLastName() {
79 | return lastName;
80 | }
81 |
82 | public void setLastName(String lastName) {
83 | this.lastName = lastName;
84 | }
85 |
86 | public String getTitle() {
87 | return title;
88 | }
89 |
90 | public void setTitle(String title) {
91 | this.title = title;
92 | }
93 |
94 | public String getCompany() {
95 | return company;
96 | }
97 |
98 | public void setCompany(String company) {
99 | this.company = company;
100 | }
101 |
102 | public String getSpeakerBio() {
103 | return speakerBio;
104 | }
105 |
106 | public void setSpeakerBio(String speakerBio) {
107 | this.speakerBio = speakerBio;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/models/TicketPrice.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.models;
2 |
3 | import com.fasterxml.jackson.annotation.JsonInclude;
4 |
5 | import javax.persistence.*;
6 | import java.math.BigDecimal;
7 |
8 | @Entity
9 | @Table(name = "ticket_prices")
10 | @NamedQuery(
11 | name = "TicketPrice.namedFindTicketsByPricingCategoryName",
12 | query = "select tp from TicketPrice tp where tp.pricingCategory.pricingCategoryName = :name"
13 | )
14 | @NamedNativeQuery(
15 | name = "TicketPrice.nativeFindTicketsByCategoryWithWorkshop",
16 | query = "select tp.* from ticket_prices tp " +
17 | "left join ticket_types tt on tp.ticket_type_code = tt.ticket_type_code " +
18 | "left join pricing_categories pc on tp.pricing_category_code = pc.pricing_category_code " +
19 | "where tt.includes_workshop = true and pc.pricing_category_name = :name",
20 | resultClass = TicketPrice.class
21 | )
22 | public class TicketPrice {
23 | @Id
24 | @GeneratedValue(strategy = GenerationType.IDENTITY)
25 | @Column(name = "ticket_price_id")
26 | private Long ticketPriceId;
27 |
28 | @Column(name = "base_price")
29 | private BigDecimal basePrice;
30 |
31 | @ManyToOne
32 | @JoinColumn(name = "ticket_type_code", nullable = false, updatable = false)
33 | private TicketType ticketType;
34 |
35 | @ManyToOne
36 | @JoinColumn(name = "pricing_category_code", nullable = false, updatable = false)
37 | private PricingCategory pricingCategory;
38 |
39 | public TicketPrice() {
40 | }
41 |
42 | public Long getTicketPriceId() {
43 | return ticketPriceId;
44 | }
45 |
46 | public void setTicketPriceId(Long ticketPriceId) {
47 | this.ticketPriceId = ticketPriceId;
48 | }
49 |
50 | public BigDecimal getBasePrice() {
51 | return basePrice;
52 | }
53 |
54 | public void setBasePrice(BigDecimal basePrice) {
55 | this.basePrice = basePrice;
56 | }
57 |
58 | public TicketType getTicketType() {
59 | return ticketType;
60 | }
61 |
62 | public void setTicketType(TicketType ticketType) {
63 | this.ticketType = ticketType;
64 | }
65 |
66 | public PricingCategory getPricingCategory() {
67 | return pricingCategory;
68 | }
69 |
70 | public void setPricingCategory(PricingCategory pricingCategory) {
71 | this.pricingCategory = pricingCategory;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/models/TicketType.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.models;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnore;
4 |
5 | import javax.persistence.*;
6 | import java.util.List;
7 |
8 | @Entity
9 | @Table(name = "ticket_types")
10 | public class TicketType {
11 | @Id
12 | @Column(name = "ticket_type_code")
13 | private String ticketTypeCode;
14 |
15 | @Column(name = "ticket_type_name")
16 | private String ticketTypeName;
17 |
18 | @Column(name = "description")
19 | private String description;
20 |
21 | @Column(name = "includes_workshop")
22 | private Boolean includesWorkshop;
23 |
24 | @OneToMany(mappedBy = "ticketType")
25 | @JsonIgnore
26 | private List ticketPrices;
27 |
28 | public TicketType() {
29 | }
30 |
31 | public String getTicketTypeCode() {
32 | return ticketTypeCode;
33 | }
34 |
35 | public void setTicketTypeCode(String ticketTypeCode) {
36 | this.ticketTypeCode = ticketTypeCode;
37 | }
38 |
39 | public String getTicketTypeName() {
40 | return ticketTypeName;
41 | }
42 |
43 | public void setTicketTypeName(String ticketTypeName) {
44 | this.ticketTypeName = ticketTypeName;
45 | }
46 |
47 | public String getDescription() {
48 | return description;
49 | }
50 |
51 | public void setDescription(String description) {
52 | this.description = description;
53 | }
54 |
55 | public Boolean getIncludesWorkshop() {
56 | return includesWorkshop;
57 | }
58 |
59 | public void setIncludesWorkshop(Boolean includesWorkshop) {
60 | this.includesWorkshop = includesWorkshop;
61 | }
62 |
63 | public List getTicketPrices() {
64 | return ticketPrices;
65 | }
66 |
67 | public void setTicketPrices(List ticketPrices) {
68 | this.ticketPrices = ticketPrices;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/repositories/PricingCategoryRepository.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.repositories;
2 |
3 | import com.pluralsight.conferencedemo.models.PricingCategory;
4 | import org.springframework.stereotype.Repository;
5 |
6 | import javax.persistence.EntityManager;
7 | import javax.persistence.PersistenceContext;
8 |
9 | @Repository
10 | public class PricingCategoryRepository {
11 | @PersistenceContext
12 | private EntityManager entityManager;
13 |
14 | public PricingCategory find(String id) {
15 | return entityManager.find(PricingCategory.class, id);
16 | }
17 | }
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/repositories/SessionCustomJpaRepository.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.repositories;
2 |
3 | import com.pluralsight.conferencedemo.models.Session;
4 |
5 | import java.util.List;
6 |
7 | public interface SessionCustomJpaRepository {
8 | List customGetSessions();
9 | }
10 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/repositories/SessionCustomJpaRepositoryImpl.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.repositories;
2 |
3 | import com.pluralsight.conferencedemo.models.Session;
4 |
5 | import javax.persistence.EntityManager;
6 | import javax.persistence.PersistenceContext;
7 | import java.util.List;
8 |
9 | public class SessionCustomJpaRepositoryImpl implements SessionCustomJpaRepository {
10 | @PersistenceContext
11 | private EntityManager entityManager;
12 |
13 | public List customGetSessions(){
14 | return entityManager.createQuery("select s from Session s").getResultList();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/repositories/SessionJpaRepository.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.repositories;
2 |
3 | import com.pluralsight.conferencedemo.models.Session;
4 | import org.springframework.data.domain.Page;
5 | import org.springframework.data.domain.Pageable;
6 | import org.springframework.data.jpa.repository.JpaRepository;
7 | import org.springframework.data.jpa.repository.Query;
8 | import org.springframework.data.repository.query.Param;
9 |
10 | import java.util.List;
11 |
12 | public interface SessionJpaRepository extends JpaRepository, SessionCustomJpaRepository {
13 | List findBySessionNameContains(String name);
14 | List findBySessionNameNotLike(String name);
15 | List findBySessionLengthNot(Integer sessionLength);
16 | List findBySessionLengthLessThan(Integer sessionLength);
17 |
18 | @Query("select s from Session s where s.sessionName like %:name")
19 | Page getSessionsWithName(@Param("name") String name, Pageable pageable);
20 | }
21 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/repositories/SessionRepository.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.repositories;
2 |
3 | import com.pluralsight.conferencedemo.models.Session;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.stereotype.Repository;
6 |
7 | import javax.persistence.EntityManager;
8 | import javax.persistence.PersistenceContext;
9 | import java.util.List;
10 |
11 | @Repository
12 | public class SessionRepository {
13 | @Autowired
14 | private SessionJpaRepository jpaRepository;
15 |
16 | @PersistenceContext
17 | private EntityManager entityManager;
18 |
19 | public Session create(Session session) {
20 | return jpaRepository.saveAndFlush(session);
21 | }
22 |
23 | public Session update(Session session) {
24 | return jpaRepository.saveAndFlush(session);
25 | }
26 |
27 | public void delete(Long id) {
28 | jpaRepository.deleteById(id);
29 | }
30 |
31 | public Session find(Long id) {
32 | return jpaRepository.getOne(id);
33 | }
34 |
35 | public List list() {
36 | return jpaRepository.findAll();
37 | }
38 |
39 | public List getSessionsThatHaveName(String name) {
40 | return jpaRepository.findBySessionNameContains(name);
41 | }
42 | }
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/repositories/SpeakerJpaRepository.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.repositories;
2 |
3 | import com.pluralsight.conferencedemo.models.Speaker;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | import java.util.List;
7 |
8 | public interface SpeakerJpaRepository extends JpaRepository {
9 | List findByFirstNameAndLastName(String firstName, String lastName);
10 | List findByFirstNameOrLastName(String firstName, String lastName);
11 | List findBySpeakerPhotoNull();
12 | List findByCompanyIn(List companies);
13 | List findByCompanyIgnoreCase(String company);
14 | List findByLastNameOrderByFirstNameAsc(String lastName);
15 |
16 | Speaker findFirstByFirstName(String firstName);
17 | }
18 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/repositories/SpeakerRepository.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.repositories;
2 |
3 | import com.pluralsight.conferencedemo.models.Speaker;
4 | import org.springframework.stereotype.Repository;
5 |
6 | import javax.persistence.EntityManager;
7 | import javax.persistence.PersistenceContext;
8 | import java.util.List;
9 |
10 | @Repository
11 | public class SpeakerRepository {
12 | @PersistenceContext
13 | private EntityManager entityManager;
14 |
15 | public Speaker create(Speaker speaker) {
16 | entityManager.persist(speaker);
17 | entityManager.flush();
18 | return speaker;
19 | }
20 |
21 | public Speaker update(Speaker speaker) {
22 | speaker = entityManager.merge(speaker);
23 | entityManager.flush();
24 | return speaker;
25 | }
26 |
27 | public void delete(Long id) {
28 | entityManager.remove(find(id));
29 | entityManager.flush();
30 | }
31 |
32 | public Speaker find(Long id) {
33 | return entityManager.find(Speaker.class, id);
34 | }
35 |
36 | public List list() {
37 | return entityManager.createQuery("select s from Speaker s").getResultList();
38 | }
39 | }
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/repositories/TicketPriceJpaRepository.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.repositories;
2 |
3 | import com.pluralsight.conferencedemo.models.TicketPrice;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.Query;
6 | import org.springframework.data.repository.query.Param;
7 |
8 | import java.math.BigDecimal;
9 | import java.util.List;
10 |
11 | public interface TicketPriceJpaRepository extends JpaRepository {
12 | @Query("select tp from TicketPrice tp where tp.basePrice < ?1 " +
13 | "and tp.ticketType.includesWorkshop = true")
14 | List getTicketsUnderPriceWithWorkshops(BigDecimal maxPrice);
15 |
16 | List namedFindTicketsByPricingCategoryName(@Param("name") String name);
17 |
18 | List nativeFindTicketsByCategoryWithWorkshop(@Param("name") String name);
19 | }
20 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/repositories/TicketPriceRepository.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.repositories;
2 |
3 | import com.pluralsight.conferencedemo.models.Speaker;
4 | import com.pluralsight.conferencedemo.models.TicketPrice;
5 | import org.springframework.stereotype.Repository;
6 |
7 | import javax.persistence.EntityManager;
8 | import javax.persistence.PersistenceContext;
9 | import java.util.List;
10 |
11 | @Repository
12 | public class TicketPriceRepository {
13 | @PersistenceContext
14 | private EntityManager entityManager;
15 |
16 | public TicketPrice create(TicketPrice tp) {
17 | entityManager.persist(tp);
18 | entityManager.flush();
19 | return tp;
20 | }
21 |
22 | public TicketPrice update(TicketPrice tp) {
23 | tp = entityManager.merge(tp);
24 | entityManager.flush();
25 | return tp;
26 | }
27 |
28 | public void delete(Long id) {
29 | entityManager.remove(find(id));
30 | entityManager.flush();
31 | }
32 |
33 | public TicketPrice find(Long id) {
34 | return entityManager.find(TicketPrice.class, id);
35 | }
36 |
37 | public List list() {
38 | return entityManager.createQuery("select t from TicketPrice t").getResultList();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/repositories/TicketTypeJpaRepository.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.repositories;
2 |
3 | import com.pluralsight.conferencedemo.models.TicketType;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | import java.util.List;
7 |
8 | public interface TicketTypeJpaRepository extends JpaRepository {
9 | List findByIncludesWorkshopTrue();
10 | }
--------------------------------------------------------------------------------
/conference-demo/src/main/java/com/pluralsight/conferencedemo/repositories/TicketTypeRepository.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.repositories;
2 |
3 | import com.pluralsight.conferencedemo.models.TicketType;
4 | import org.springframework.stereotype.Repository;
5 |
6 | import javax.persistence.EntityManager;
7 | import javax.persistence.PersistenceContext;
8 |
9 | @Repository
10 | public class TicketTypeRepository {
11 | @PersistenceContext
12 | private EntityManager entityManager;
13 |
14 | public TicketType find(String id) {
15 | return entityManager.find(TicketType.class, id);
16 | }
17 | }
--------------------------------------------------------------------------------
/conference-demo/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | app.version=0.0.1
2 |
3 | spring.datasource.url=jdbc:postgresql:conference_app
4 | spring.datasource.username=
5 | spring.datasource.password=
6 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
7 | spring.jpa.hibernate.ddl-auto=none
8 |
9 | spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
10 | spring.jpa.show-sql=true
--------------------------------------------------------------------------------
/conference-demo/src/test/java/com/pluralsight/conferencedemo/ConferenceDemoApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class ConferenceDemoApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/conference-demo/src/test/java/com/pluralsight/conferencedemo/models/SessionTest.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.models;
2 |
3 | import com.pluralsight.conferencedemo.repositories.SessionJpaRepository;
4 | import com.pluralsight.conferencedemo.repositories.SessionRepository;
5 | import org.junit.jupiter.api.Test;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.data.domain.Page;
9 | import org.springframework.data.domain.PageRequest;
10 | import org.springframework.data.domain.Pageable;
11 | import org.springframework.data.domain.Sort;
12 |
13 | import java.util.List;
14 |
15 | import static org.junit.jupiter.api.Assertions.assertTrue;
16 |
17 | @SpringBootTest
18 | public class SessionTest {
19 | @Autowired
20 | private SessionRepository repository;
21 |
22 | @Autowired
23 | private SessionJpaRepository jpaRepository;
24 |
25 | @Test
26 | public void test() throws Exception {
27 | List sessions = repository.getSessionsThatHaveName("Java");
28 | assertTrue(sessions.size() > 0);
29 | }
30 |
31 | @Test
32 | public void testJpaNot() throws Exception {
33 | List sessions = jpaRepository.findBySessionLengthNot(30);
34 | assertTrue(sessions.size() > 0);
35 | }
36 |
37 | @Test
38 | public void testJpaNotLike() throws Exception {
39 | List sessions = jpaRepository.findBySessionNameNotLike("Python%");
40 | assertTrue(sessions.size() > 0);
41 | }
42 |
43 | @Test
44 | public void testJpaLessThan() throws Exception {
45 | List sessions = jpaRepository.findBySessionLengthLessThan(45);
46 | assertTrue(sessions.size() > 0);
47 | }
48 |
49 | @Test
50 | public void testPagingSorting() throws Exception {
51 | Page page = jpaRepository.getSessionsWithName("S", PageRequest.of(1, 5, Sort.by(Sort.Direction.DESC, "sessionLength")));
52 | assertTrue(page.getTotalElements() > 0);
53 | }
54 |
55 | @Test
56 | public void testCustomImpl() throws Exception {
57 | List sessions = jpaRepository.customGetSessions();
58 | assertTrue(sessions.size() > 0);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/conference-demo/src/test/java/com/pluralsight/conferencedemo/models/SpeakerTest.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.models;
2 |
3 | import com.pluralsight.conferencedemo.repositories.SpeakerJpaRepository;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.junit.jupiter.api.Test;
7 |
8 | import javax.persistence.EntityManager;
9 | import javax.persistence.PersistenceContext;
10 | import javax.transaction.Transactional;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | import static org.junit.jupiter.api.Assertions.*;
16 |
17 | @SpringBootTest
18 | public class SpeakerTest {
19 | @Autowired
20 | private SpeakerJpaRepository repository;
21 |
22 | @PersistenceContext
23 | private EntityManager entityManager;
24 |
25 | @Test
26 | public void testFind() throws Exception {
27 | Speaker speaker = repository.getOne(1L);
28 | assertNotNull(speaker);
29 | }
30 |
31 | @Test
32 | @Transactional
33 | public void testSaveAndGetAndDelete() throws Exception {
34 | Speaker s = new Speaker();
35 | s.setCompany("Pluralsight");
36 | s.setFirstName("Dan");
37 | s.setLastName("Bunker");
38 | s.setTitle("Author");
39 | s.setSpeakerBio("Consulting and mentoring");
40 | s = repository.saveAndFlush(s);
41 |
42 | // clear the persistence context so we don't return the previously cached location object
43 | // this is a test only thing and normally doesn't need to be done in prod code
44 | entityManager.clear();
45 |
46 | Speaker otherSpeaker = repository.getOne(s.getSpeakerId());
47 | assertEquals("Dan", otherSpeaker.getFirstName());
48 |
49 | repository.deleteById(otherSpeaker.getSpeakerId());
50 | }
51 |
52 | @Test
53 | public void testJpaAnd() throws Exception {
54 | List speakers = repository.findByFirstNameAndLastName("Justin", "Clark");
55 | assertTrue(speakers.size() > 0);
56 | }
57 |
58 | @Test
59 | public void testJpaOr() throws Exception {
60 | List speakers = repository.findByFirstNameOrLastName("Justin", "Clark");
61 | assertTrue(speakers.size() > 0);
62 | }
63 |
64 | @Test
65 | public void testJpaNull() throws Exception {
66 | List speakers = repository.findBySpeakerPhotoNull();
67 | assertTrue(speakers.size() > 0);
68 | }
69 |
70 | @Test
71 | public void testJpaIn() throws Exception {
72 | List companies = new ArrayList<>();
73 | companies.add("National Bank");
74 | companies.add("Contoso");
75 | List speakers = repository.findByCompanyIn(companies);
76 | assertTrue(speakers.size() > 0);
77 | }
78 |
79 | @Test
80 | public void testJpaIgnoreCase() throws Exception {
81 | List speakers = repository.findByCompanyIgnoreCase("national bank");
82 | assertTrue(speakers.size() > 0);
83 | }
84 |
85 | @Test
86 | public void testJpaOrderBy() throws Exception {
87 | List speakers = repository.findByLastNameOrderByFirstNameAsc("Clark");
88 | assertTrue(speakers.size() > 0);
89 | }
90 |
91 | @Test
92 | public void testJpaFirst() throws Exception {
93 | Speaker speaker = repository.findFirstByFirstName("James");
94 | assertTrue(speaker.getFirstName().equals("James"));
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/conference-demo/src/test/java/com/pluralsight/conferencedemo/models/TicketPriceTest.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.models;
2 |
3 | import com.pluralsight.conferencedemo.repositories.PricingCategoryRepository;
4 | import com.pluralsight.conferencedemo.repositories.TicketPriceJpaRepository;
5 | import com.pluralsight.conferencedemo.repositories.TicketTypeRepository;
6 | import org.junit.jupiter.api.Test;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 |
10 | import javax.persistence.EntityManager;
11 | import javax.persistence.PersistenceContext;
12 | import javax.transaction.Transactional;
13 |
14 | import java.math.BigDecimal;
15 | import java.util.List;
16 |
17 | import static org.junit.jupiter.api.Assertions.*;
18 |
19 | @SpringBootTest
20 | public class TicketPriceTest {
21 | @Autowired
22 | private TicketPriceJpaRepository repository;
23 |
24 | @Autowired
25 | private PricingCategoryRepository pcRepository;
26 |
27 | @Autowired
28 | private TicketTypeRepository ttRepository;
29 |
30 | @PersistenceContext
31 | private EntityManager entityManager;
32 |
33 | @Test
34 | public void testFind() throws Exception {
35 | TicketPrice ticket = repository.getOne(1L);
36 | assertNotNull(ticket);
37 | }
38 |
39 | @Test
40 | @Transactional
41 | public void testSaveAndGetAndDelete() throws Exception {
42 | TicketPrice tp = new TicketPrice();
43 | tp.setBasePrice(BigDecimal.valueOf(200, 2));
44 |
45 | tp.setPricingCategory(pcRepository.find("E"));
46 |
47 | tp.setTicketType(ttRepository.find("C"));
48 |
49 | tp = repository.saveAndFlush(tp);
50 |
51 | // clear the persistence context so we don't return the previously cached location object
52 | // this is a test only thing and normally doesn't need to be done in prod code
53 | entityManager.clear();
54 |
55 | TicketPrice otherTp = repository.getOne(tp.getTicketPriceId());
56 | assertEquals(BigDecimal.valueOf(200, 2), otherTp.getBasePrice());
57 |
58 | repository.deleteById(otherTp.getTicketPriceId());
59 | }
60 |
61 | @Test
62 | public void testQueryAnnotation() throws Exception {
63 | List tickets = repository.getTicketsUnderPriceWithWorkshops(BigDecimal.valueOf(1000));
64 | assertTrue(tickets.size() > 0);
65 | }
66 |
67 | @Test
68 | public void testNamedQuery() throws Exception {
69 | List tickets = repository.namedFindTicketsByPricingCategoryName("Regular");
70 | assertTrue(tickets.size() > 0);
71 | }
72 |
73 | @Test
74 | public void testNamedNativeQuery() throws Exception {
75 | List tickets = repository.nativeFindTicketsByCategoryWithWorkshop("Regular");
76 | assertTrue(tickets.size() > 0);
77 | }
78 | }
--------------------------------------------------------------------------------
/conference-demo/src/test/java/com/pluralsight/conferencedemo/models/TicketTypeTest.java:
--------------------------------------------------------------------------------
1 | package com.pluralsight.conferencedemo.models;
2 |
3 | import com.pluralsight.conferencedemo.repositories.SessionJpaRepository;
4 | import com.pluralsight.conferencedemo.repositories.SessionRepository;
5 | import com.pluralsight.conferencedemo.repositories.TicketTypeJpaRepository;
6 | import org.junit.jupiter.api.Test;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 |
10 | import java.util.List;
11 |
12 | import static org.junit.jupiter.api.Assertions.assertTrue;
13 |
14 | @SpringBootTest
15 | public class TicketTypeTest {
16 |
17 | @Autowired
18 | private TicketTypeJpaRepository jpaRepository;
19 |
20 | @Test
21 | public void testJpaTrue() throws Exception {
22 | List types = jpaRepository.findByIncludesWorkshopTrue();
23 | assertTrue(types.size() > 0);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/database/postgresql/README.md:
--------------------------------------------------------------------------------
1 | # Postgres Course Setup
2 |
3 | ## Docker Postgres Setup
4 |
5 | Create Docker container with Postgres database:
6 |
7 | docker create --name postgres-demo -e POSTGRES_PASSWORD=Welcome -p 5432:5432 postgres:11.5-alpine
8 |
9 | Start container:
10 |
11 | docker start postgres-demo
12 |
13 | Stop container:
14 |
15 | docker stop postgres-demo
16 |
17 | Connection Info:
18 |
19 | JDBC URL: `jdbc:postgresql://localhost:5432/conference_app`
20 |
21 | Username: `postgres`
22 |
23 | Password: `Welcome`
24 |
25 | Note: This stores the data inside the container - when you delete the container, the data is deleted as well.
26 |
27 | Connect to PSQL prompt from docker:
28 | docker exec -it postgres-demo psql -U postgres
29 |
30 | ## Application Database Setup
31 |
32 | Create the Database:
33 |
34 | psql> create database conference_app;
35 |
36 | Setup the Tables:
37 |
38 | psql -d conference_app -f create_tables.sql
39 |
40 | Install the Data:
41 |
42 | psql -d conference_app -f insert_data.sql
43 |
--------------------------------------------------------------------------------
/database/postgresql/create_tables.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE attendees
2 | (
3 | attendee_id SERIAL PRIMARY KEY,
4 | first_name varchar(30) NOT NULL,
5 | last_name varchar(30) NOT NULL,
6 | title varchar(40) NULL,
7 | company varchar(50) NULL,
8 | email varchar(80) NOT NULL,
9 | phone_number varchar(20) NULL
10 | );
11 |
12 | CREATE TABLE ticket_types
13 | (
14 | ticket_type_code varchar(1) PRIMARY KEY,
15 | ticket_type_name varchar(30) NOT NULL,
16 | description varchar(100) NOT NULL,
17 | includes_workshop boolean NOT NULL
18 | );
19 |
20 | CREATE TABLE pricing_categories
21 | (
22 | pricing_category_code varchar(1) PRIMARY KEY,
23 | pricing_category_name varchar(20) NOT NULL,
24 | pricing_start_date date NOT NULL,
25 | pricing_end_date date NOT NULL
26 | );
27 |
28 | CREATE TABLE ticket_prices
29 | (
30 | ticket_price_id SERIAL PRIMARY KEY,
31 | ticket_type_code varchar(1) NOT NULL REFERENCES ticket_types (ticket_type_code),
32 | pricing_category_code varchar(1) NOT NULL REFERENCES pricing_categories (pricing_category_code),
33 | base_price numeric(8, 2) NOT NULL
34 | );
35 |
36 | CREATE TABLE discount_codes
37 | (
38 | discount_code_id SERIAL PRIMARY KEY,
39 | discount_code varchar(20) NOT NULL,
40 | discount_name varchar(30) NOT NULL,
41 | discount_type varchar(1) NOT NULL,
42 | discount_amount numeric(8, 2) NOT NULL
43 | );
44 |
45 | CREATE TABLE attendee_tickets
46 | (
47 | attendee_ticket_id SERIAL PRIMARY KEY,
48 | attendee_id integer NOT NULL REFERENCES attendees (attendee_id),
49 | ticket_price_id integer NOT NULL REFERENCES ticket_prices (ticket_price_id),
50 | discount_code_id integer NULL REFERENCES discount_codes (discount_code_id),
51 | net_price numeric(8, 2) NOT NULL
52 | );
53 |
54 | CREATE TABLE time_slots
55 | (
56 | time_slot_id SERIAL PRIMARY KEY,
57 | time_slot_date date NOT NULL,
58 | start_time time without time zone NOT NULL,
59 | end_time time without time zone NOT NULL,
60 | is_keynote_time_slot boolean default false NOT NULL
61 | );
62 |
63 | CREATE TABLE sessions
64 | (
65 | session_id SERIAL PRIMARY KEY,
66 | session_name varchar(80) NOT NULL,
67 | session_description varchar(1024) NOT NULL,
68 | session_length integer NOT NULL
69 | );
70 |
71 | CREATE TABLE session_schedule
72 | (
73 | schedule_id SERIAL PRIMARY KEY,
74 | time_slot_id integer NOT NULL REFERENCES time_slots (time_slot_id),
75 | session_id integer NOT NULL REFERENCES sessions (session_id),
76 | room varchar(30) NOT NULL
77 | );
78 |
79 | CREATE TABLE tags
80 | (
81 | tag_id SERIAL PRIMARY KEY,
82 | description varchar(30) NOT NULL
83 | );
84 |
85 | CREATE TABLE session_tags
86 | (
87 | session_id integer NOT NULL REFERENCES sessions (session_id),
88 | tag_id integer NOT NULL REFERENCES tags (tag_id)
89 | );
90 |
91 | CREATE TABLE speakers
92 | (
93 | speaker_id SERIAL PRIMARY KEY,
94 | first_name varchar(30) NOT NULL,
95 | last_name varchar(30) NOT NULL,
96 | title varchar(40) NOT NULL,
97 | company varchar(50) NOT NULL,
98 | speaker_bio varchar(2000) NOT NULL,
99 | speaker_photo BYTEA NULL
100 | );
101 |
102 | CREATE TABLE session_speakers
103 | (
104 | session_id integer NOT NULL REFERENCES sessions (session_id),
105 | speaker_id integer NOT NULL REFERENCES speakers (speaker_id)
106 | );
107 |
108 | CREATE TABLE workshops
109 | (
110 | workshop_id SERIAL PRIMARY KEY,
111 | workshop_name varchar(60) NOT NULL,
112 | description varchar(1024) NOT NULL,
113 | requirements varchar(1024) NOT NULL,
114 | room varchar(30) NOT NULL,
115 | capacity integer NOT NULL
116 | );
117 |
118 | CREATE TABLE workshop_speakers
119 | (
120 | workshop_id integer NOT NULL REFERENCES workshops (workshop_id),
121 | speaker_id integer NOT NULL REFERENCES speakers (speaker_id)
122 | );
123 |
124 | CREATE TABLE workshop_registrations
125 | (
126 | workshop_id integer NOT NULL REFERENCES workshops (workshop_id),
127 | attendee_ticket_id integer NOT NULL REFERENCES attendee_tickets (attendee_ticket_id)
128 | );
129 |
--------------------------------------------------------------------------------
/database/postgresql/insert_data.sql:
--------------------------------------------------------------------------------
1 | INSERT INTO ticket_types (ticket_type_code,ticket_type_name,description,includes_workshop)
2 | VALUES ('P','Premium','Access to all conference events plus attend the workshop of your choice.',TRUE),
3 | ('S','Standard','Access to all conference keynotes,sessions,community open spaces and the exhibition hall',FALSE),
4 | ('C','Community','Access to keynotes,community open spaces and the exhibition hall',FALSE);
5 |
6 | INSERT INTO pricing_categories (pricing_category_code,pricing_category_name,pricing_start_date,pricing_end_date)
7 | VALUES ('E','Early Bird','2019-12-01','2020-01-15'),
8 | ('R','Regular','2020-01-16','2020-03-20'),
9 | ('L','Last Minute','2020-03-21','2020-04-07');
10 |
11 | INSERT INTO ticket_prices (ticket_price_id,ticket_type_code,pricing_category_code,base_price)
12 | VALUES (1,'P','E',800),
13 | (2,'P','R',1000),
14 | (3,'P','L',1200),
15 | (4,'S','E',500),
16 | (5,'S','R',700),
17 | (6,'S','L',1000),
18 | (7,'C','E',100),
19 | (8,'C','R',200),
20 | (9,'C','L',300);
21 |
22 | -- TODO: discount_codes
23 |
24 | INSERT INTO time_slots (time_slot_id,time_slot_date,start_time,end_time,is_keynote_time_slot)
25 | VALUES (1,'2020-04-09','9:00','9:45',TRUE),
26 | (2,'2020-04-09','10:00','11:00',FALSE),
27 | (3,'2020-04-09','11:15','11:45',FALSE),
28 | (4,'2020-04-09','12:45','13:45',FALSE),
29 | (5,'2020-04-09','14:00','15:00',FALSE),
30 | (6,'2020-04-09','15:15','15:45',FALSE),
31 | (7,'2020-04-09','16:00','17:00',FALSE),
32 | (8,'2020-04-10','9:00','10:00',FALSE),
33 | (9,'2020-04-10','10:15','11:15',FALSE),
34 | (10,'2020-04-10','11:30','12:00',FALSE),
35 | (11,'2020-04-10','13:00','14:00',FALSE),
36 | (12,'2020-04-10','14:15','15:00',TRUE);
37 |
38 | INSERT INTO sessions (session_id,session_name,session_length,session_description)
39 | VALUES (1,'Keynote - The Golden Age of Software',45,''),
40 | (2,'A Better Way to Access Data with Spring Data',60,''),
41 | (3,'A Deep Dive Into Spring IoC',60,''),
42 | (4,'Building RESTful APIs with Spring Data Rest',60,''),
43 | (5,'Spring Integration Quick Start',60,''),
44 | (6,'Building Microservices with Spring',60,''),
45 | (7,'Spring Cloud Primer',60,''),
46 | (8,'Spring Boot in 30 Minutes',30,''),
47 | (9,'Testing Spring Applications',30,''),
48 | (10,'Writing Your First Advice with Spring AOP',30,''),
49 | (11,'IntelliJ IDEA Tips and Tricks',30,''),
50 | (12,'Functional Programming in Java',60,''),
51 | (13,'Making the Switch from Java to Kotlin',60,''),
52 | (14,'Mastering Concurrency in Java',60,''),
53 | (15,'Mastering Object-Orientated Programming in Java',60,''),
54 | (16,'SOLID Principles in Java',60,''),
55 | (17,'The Most Important Java Design Patterns',60,''),
56 | (18,'Using EasyMock for Java Testing',30,''),
57 | (19,'IntelliJ IDEA Debugging Secrets',30,''),
58 | (20,'Getting Started with Java Flight Recorder',30,''),
59 | (21,'Clean Code Principls for Java Developers',30,''),
60 | (22,'Designing Large Scale ASP.NET Core Applications',60,''),
61 | (23,'Application Security in ASP.NET Core Apps',60,''),
62 | (24,'.NET''s HttpClient: The Missing Manual',60,''),
63 | (25,'Using Vue.js in ASP.NET and ASP.NET Core Applications',60,''),
64 | (27,'Modern Desktop Applications in .NET',60,''),
65 | (28,'SignalR Quickstart',30,''),
66 | (29,'Visual Studio Tips and Tricks',30,''),
67 | (30,'Logging in ASP.NET Core',30,''),
68 | (31,'A Quick Tour of MiniProfiler',30,''),
69 | (32,'Demystifying Dependency Injection in .NET',60,''),
70 | (26,'Clean Code Practices in C#',60,''),
71 | (33,'Microservices Architectures using ASP.NET Core',60,''),
72 | (34,'Advanced Techniques in Entity Framework Core',60,''),
73 | (35,'C# Language Features You May Not Know About',60,''),
74 | (36,'Asynchronous Programming in .NET',60,''),
75 | (37,'Advanced Entity Framework Core',60,''),
76 | (38,'A lap around the .NET Command Line Interface (CLI)',30,''),
77 | (39,'Deploying .NET Apps with Azure DevOps',30,''),
78 | (40,'Code Analysis for .NET Projects',30,''),
79 | (41,'Better Logging with Serilog',30,''),
80 | (42,'Deploying Web Applications to Azure',60,''),
81 | (43,'Getting Started with Azure Cognitive Services',60,''),
82 | (44,'Building Microservices with Azure Functions',60,''),
83 | (45,'Big Data and Analytics on the Azure Platform',60,''),
84 | (46,'Getting Started with CosmosDB',60,''),
85 | (47,'Securing Azure Services',60,''),
86 | (48,'Azure Event Grid Quickstart',30,''),
87 | (49,'Managing Azure with the Azure CLI',30,''),
88 | (50,'Migrating to Azure SQL',30,''),
89 | (51,'Understanding the Azure Blockchain Service',30,''),
90 | (62,'Building Hybrid Cloud Architectures in AWS',60,''),
91 | (63,'Migrating On-Premises Applications to AWS',60,''),
92 | (64,'IOT Solutions Using AWS',60,''),
93 | (65,'Getting Startedd with Machine Learning in AWS',60,''),
94 | (66,'DevOps on the AWS Platform',60,''),
95 | (67,'Serverless Computing on AWS',60,''),
96 | (68,'Amazon DynamoDB Quickstart',30,''),
97 | (69,'Understanding the Amazon Elastic Kubernetes Service',30,''),
98 | (70,'Creating Your First Data Lake in AWS',30,''),
99 | (71,'Migrating to Amazon Aurora',30,''),
100 | (82,'How Agile Are You Really?',60,''),
101 | (83,'Better Retrospectives',60,''),
102 | (84,'Developer to Leader',60,''),
103 | (85,'Selling Your Ideas to Leadership: A Guide for Technology Professionals',60,''),
104 | (86,'Creating a Culture of Learning',60,''),
105 | (87,'The Seven Habits of Highly Effective Developers',60,''),
106 | (88,'Writing Better User Stories',30,''),
107 | (89,'Techniques for Better Estimates',30,''),
108 | (90,'Communication Skills for the Technology Professional',30,''),
109 | (91,'Personal Kanban',30,'');
110 |
111 | INSERT INTO session_schedule (schedule_id,time_slot_id,session_id,room)
112 | VALUES (1,1,1,'Grand Ballroom'),
113 | (2,2,2,'Cedar'),
114 | (3,4,3,'Cedar'),
115 | (4,5,4,'Cedar'),
116 | (5,7,5,'Cedar'),
117 | (6,8,6,'Cedar'),
118 | (7,11,7,'Cedar'),
119 | (8,3,8,'Cedar'),
120 | (9,6,9,'Cedar'),
121 | (10,9,10,'Cedar'),
122 | (11,10,11,'Cedar'),
123 | (12,2,12,'Cherry'),
124 | (13,4,13,'Cherry'),
125 | (14,5,14,'Cherry'),
126 | (15,7,15,'Cherry'),
127 | (16,8,16,'Cherry'),
128 | (17,11,17,'Cherry'),
129 | (18,3,18,'Cherry'),
130 | (19,6,19,'Cherry'),
131 | (20,9,20,'Cherry'),
132 | (21,10,21,'Cherry'),
133 | (22,2,22,'Maple'),
134 | (23,4,23,'Maple'),
135 | (24,5,24,'Maple'),
136 | (25,7,25,'Maple'),
137 | (26,8,26,'Maple'),
138 | (27,11,27,'Maple'),
139 | (28,3,28,'Maple'),
140 | (29,6,29,'Maple'),
141 | (30,9,30,'Maple'),
142 | (31,10,31,'Maple'),
143 | (32,2,32,'Aspen'),
144 | (33,4,33,'Aspen'),
145 | (34,5,34,'Aspen'),
146 | (35,7,35,'Aspen'),
147 | (36,8,36,'Aspen'),
148 | (37,11,37,'Aspen'),
149 | (38,3,38,'Aspen'),
150 | (39,6,39,'Aspen'),
151 | (40,9,40,'Aspen'),
152 | (41,10,41,'Aspen'),
153 | (42,2,42,'Hickory'),
154 | (43,4,43,'Hickory'),
155 | (44,5,44,'Hickory'),
156 | (45,7,45,'Hickory'),
157 | (46,8,46,'Hickory'),
158 | (47,11,47,'Hickory'),
159 | (48,3,48,'Hickory'),
160 | (49,6,49,'Hickory'),
161 | (50,9,50,'Hickory'),
162 | (51,10,51,'Hickory'),
163 | (62,2,62,'Cottonwood'),
164 | (63,4,63,'Cottonwood'),
165 | (64,5,64,'Cottonwood'),
166 | (65,7,65,'Cottonwood'),
167 | (66,8,66,'Cottonwood'),
168 | (67,11,67,'Cottonwood'),
169 | (68,3,68,'Cottonwood'),
170 | (69,6,69,'Cottonwood'),
171 | (70,9,70,'Cottonwood'),
172 | (71,10,71,'Cottonwood'),
173 | (82,2,82,'Sycamore'),
174 | (83,4,83,'Sycamore'),
175 | (84,5,84,'Sycamore'),
176 | (85,7,85,'Sycamore'),
177 | (86,8,86,'Sycamore'),
178 | (87,11,87,'Sycamore'),
179 | (88,3,88,'Sycamore'),
180 | (89,6,89,'Sycamore'),
181 | (90,9,90,'Sycamore'),
182 | (91,10,91,'Sycamore');
183 |
184 | INSERT INTO tags (tag_id,description)
185 | VALUES (1,'.NET'),
186 | (2,'Java'),
187 | (3,'Python'),
188 | (4,'JavaScript'),
189 | (5,'Angular'),
190 | (6,'React'),
191 | (7,'Vue.js'),
192 | (8,'Web'),
193 | (9,'Architecture'),
194 | (10,'Soft Skills'),
195 | (11,'Agile'),
196 | (12,'Cloud');
197 |
198 | -- TODO: session_tags
199 |
200 | INSERT INTO speakers (speaker_id,first_name,last_name,title,company,speaker_bio,speaker_photo)
201 | VALUES (1,'Sergio','Becker','Senior Developer','MicroOcean Software','Test', null),
202 | (2,'James','Lowrey','Solutions Architect','Fabrikam Industries','Test', null),
203 | (3,'Gloria','Franklin','Enerprise Architect','Carved Rock Online','Test', null),
204 | (4,'Lori','Vanhoose','Java Technical Lead','National Bank','Test', null),
205 | (5,'Raymond','Hall','Senior Developer','City Power and Electric','Test', null),
206 | (6,'Sam','Vasquez','Software Analyst','Globalmantics Consulting','Test', null),
207 | (7,'Justin','Clark','Principal Engineer','Tangerine Hippopotamus Consulting','Test', null),
208 | (8,'Barbara','Williams','Senior DBA','Contoso','Test', null),
209 | (9,'James','Sharp','Technical Lead','Adventureworks','Test', null),
210 | (10,'Julie','Rowe','Software Architect','Northwind Trading','Test', null),
211 | (11,'Tonya','Burke','Senior Cloud Consultant','Big Data Consulting','Test', null),
212 | (12,'Nicole','Perry','Engineering Manager','World Wide Importers','Test', null),
213 | (13,'James','Curtis','Cloud Architect','Farmington Research','Test', null),
214 | (14,'Patti','White','Program Manager','State Investments','Test', null),
215 | (15,'Andrew','Graham','Software Architect','Property Insurance Group','Test', null),
216 | (16,'Lenn','van der Brug','Solutions Architect','Globalmantics Consulting','Test', null),
217 | (17,'Stephan','Leijtens','Application Development Manager','Bank Europe','Test', null),
218 | (18,'Anja','Koehler','Software Engineer','Contoso','Test', null),
219 | (19,'Petra','Holtzmann','Senior API Engineer','European Investment Partners','Test', null),
220 | (20,'Jens','Lundberg','Consultant','Aqua Sky Consulting','Test', null),
221 | (21,'Linda','Carver','Senior Developer','Chicago Technology Research','Test', null),
222 | (22,'Ronald','McMillian','Software Architect','National Bank','Test', null),
223 | (23,'Dustin','Finn','Software Engineer','Globalmantics Consulting','Test', null),
224 | (24,'Sharon','Johnson','Solutions Architect','National Aerospace Technologies','Test', null),
225 | (25,'Karen','McClure','.NET Architect','Adventureworks','Test', null),
226 | (26,'Matthew','Thompson','Technical Lead','Fabrikam Industries','Test', null),
227 | (27,'Chris','Moore','Solutions Architect','World Wide Importers','Test', null),
228 | (28,'Ken','Perry','Software Engineer','International Industrial Works','Test', null),
229 | (29,'Christie','Fournier','Application Architect','National Software Services','Test', null),
230 | (30,'Jenny','Lee','Azure Cloud Architect','Prairie Cloud Solutions','Test', null),
231 | (31,'Alicia','Peng','Senior Cloud Consultant','Cloud Management Partners','Test', null),
232 | (32,'Page','Reid','Lead Azure Engineer','State Investments','Test', null),
233 | (33,'Anke','Holzman','Senior AWS Consultant','Cloud Management Partners','Test', null),
234 | (34,'Dylan','Wilkinson','Principal AWS Engineer','Cloud Native Labs','Test', null),
235 | (35,'Henry','Duke','Engineering Lead','Wired Brain Coffee','Test', null),
236 | (36,'Cynthia','Crandall','Senior Business Analyst','Wired Brain Coffee','Test', null),
237 | (37,'Clara','Dawson','Agile Coach','Agile Coaches Inc','Test', null),
238 | (38,'Ann','Martinez','Senior AWS Consultant','Western Consulting Services','Test', null),
239 | (39,'James','King','Staff AWS Engineer','Northern States Bank','Test', null),
240 | (40,'Simon','Williams','Chief Technology Officer','NorthernSoft Systems','Test', null);
241 |
242 | INSERT INTO session_speakers (session_id,speaker_id)
243 | VALUES (1,40),
244 | (2,4),
245 | (3,5),
246 | (4,1),
247 | (5,15),
248 | (6,20),
249 | (7,21),
250 | (8,1),
251 | (9,4),
252 | (10,20),
253 | (11,5),
254 | (12,7),
255 | (13,23),
256 | (14,24),
257 | (15,22),
258 | (16,21),
259 | (17,22),
260 | (18,23),
261 | (19,7),
262 | (20,24),
263 | (21,15),
264 | (22,2),
265 | (23,3),
266 | (24,19),
267 | (25,25),
268 | (26,26),
269 | (27,27),
270 | (28,25),
271 | (29,9),
272 | (30,27),
273 | (31,16),
274 | (32,9),
275 | (33,16),
276 | (34,28),
277 | (35,29),
278 | (36,26),
279 | (37,28),
280 | (38,19),
281 | (39,3),
282 | (40,2),
283 | (41,29),
284 | (42,13),
285 | (43,30),
286 | (44,32),
287 | (45,31),
288 | (46,8),
289 | (47,31),
290 | (48,32),
291 | (49,13),
292 | (50,8),
293 | (51,30),
294 | (62,34),
295 | (63,39),
296 | (64,38),
297 | (65,33),
298 | (66,34),
299 | (67,38),
300 | (68,33),
301 | (69,39),
302 | (70,33),
303 | (71,33),
304 | (82,37),
305 | (83,17),
306 | (84,17),
307 | (85,14),
308 | (86,36),
309 | (87,35),
310 | (88,36),
311 | (89,37),
312 | (90,14),
313 | (91,35);
314 |
315 | INSERT INTO workshops (workshop_id,workshop_name,description,requirements,room,capacity)
316 | VALUES (1,'More Effective Agile Practices','','','Cedar',50),
317 | (2,'Azure DevOps One Day Bootcamp','','','Cherry',50),
318 | (3,'Level Up Your Architecure Skills','','','Maple',20),
319 | (4,'Building Microservices with Spring','','','Aspen',30),
320 | (5,'SQL Server Performance Tuning','','','Hickory',40),
321 | (6,'Serverless Architectures Using AWS','','','Cottonwood',30),
322 | (7,'Architecting Large Scale React Applications','','','Sycamore',30),
323 | (8,'Machine Learning Quick Start','','','Chestnut',40),
324 | (9,'Data Analytics with Tableau','','','Poplar',40),
325 | (10,'Python for Enterprise Developers','','','Birch',40),
326 | (11,'Hands on Vue.js','','','Ash',40),
327 | (12,'Building APIs in ASP.NET Core','','','Oak',30);
328 |
329 | -- TODO: workshop_speakers
330 |
331 |
332 | select setval('attendees_attendee_id_seq',COALESCE((select max(attendee_id) + 1 from attendees), 1));
333 | select setval('attendee_tickets_attendee_ticket_id_seq',COALESCE((select max(attendee_ticket_id) + 1 from attendee_tickets), 1));
334 | select setval('discount_codes_discount_code_id_seq',COALESCE((select max(discount_code_id) + 1 from discount_codes), 1));
335 | select setval('session_schedule_schedule_id_seq',COALESCE((select max(schedule_id) + 1 from session_schedule), 1));
336 | select setval('sessions_session_id_seq',COALESCE((select max(session_id) + 1 from sessions), 1));
337 | select setval('speakers_speaker_id_seq',COALESCE((select max(speaker_id) + 1 from speakers), 1));
338 | select setval('tags_tag_id_seq',COALESCE((select max(tag_id) + 1 from tags), 1));
339 | select setval('ticket_prices_ticket_price_id_seq',COALESCE((select max(ticket_price_id) + 1 from ticket_prices), 1));
340 | select setval('time_slots_time_slot_id_seq',COALESCE((select max(time_slot_id) + 1 from time_slots), 1));
341 | select setval('workshops_workshop_id_seq',COALESCE((select max(workshop_id) + 1 from workshops), 1));
342 |
--------------------------------------------------------------------------------