Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a02abd3394 | ||
|
ea817b2520 | ||
|
d954557000 | ||
|
7d7f2eed87 | ||
|
a6a68a5320 |
@ -11,4 +11,4 @@ global:
|
|||||||
repository: null
|
repository: null
|
||||||
sc: git
|
sc: git
|
||||||
deploy:
|
deploy:
|
||||||
artifact: build/ROOT.war
|
artifact: service/build/ROOT.war
|
||||||
|
102
build.gradle
@ -1,92 +1,24 @@
|
|||||||
import org.apache.tools.ant.filters.ReplaceTokens
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
maven { url 'https://mvn.jdb-labs.com/repo' }
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'com.jdbernard:gradle-exec-util:0.2.0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins { id 'com.palantir.git-version' version '0.5.2' }
|
plugins { id 'com.palantir.git-version' version '0.5.2' }
|
||||||
|
|
||||||
apply plugin: "groovy"
|
allprojects {
|
||||||
apply plugin: "maven"
|
group = "com.jdbernard"
|
||||||
apply plugin: "war"
|
|
||||||
|
|
||||||
group = "com.jdbernard"
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
jcenter()
|
||||||
|
maven { url 'https://mvn.jdb-labs.com/repo' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
import static com.jdbernard.gradle.ExecUtil.*
|
repositories {
|
||||||
|
|
||||||
version = gitVersion()
|
|
||||||
|
|
||||||
// webAppDirName = "build/webapp/main"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
jcenter()
|
||||||
|
maven { url "https://mvn.jdb-labs.com/repo" }
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.palantir.git-version'
|
||||||
|
version = gitVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile 'ch.qos.logback:logback-classic:1.1.8'
|
|
||||||
compile 'ch.qos.logback:logback-core:1.1.8'
|
|
||||||
compile 'com.impossibl.pgjdbc-ng:pgjdbc-ng:0.6'
|
|
||||||
compile 'com.lambdaworks:scrypt:1.4.0'
|
|
||||||
compile 'com.zaxxer:HikariCP:2.5.1'
|
|
||||||
compile 'javax:javaee-api:7.0'
|
|
||||||
compile 'javax.ws.rs:javax.ws.rs-api:2.0.1'
|
|
||||||
compile 'joda-time:joda-time:2.7'
|
|
||||||
compile 'org.codehaus.groovy:groovy-all:2.4.7'
|
|
||||||
compile 'org.slf4j:slf4j-api:1.7.22'
|
|
||||||
runtime 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.3.2'
|
|
||||||
runtime 'org.glassfish.jersey.containers:jersey-container-servlet:2.16'
|
|
||||||
runtime 'org.glassfish.jersey.media:jersey-media-json-jackson:2.16'
|
|
||||||
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
|
|
||||||
|
|
||||||
testCompile 'junit:junit:4.12'
|
|
||||||
testRuntime 'com.h2database:h2:1.4.186'
|
|
||||||
}
|
|
||||||
|
|
||||||
war {
|
|
||||||
from "resources/webapp"
|
|
||||||
from "build/webapp"
|
|
||||||
filter(ReplaceTokens, tokens: [version: version])
|
|
||||||
rename '(.+)(\\..*(css|js))', '$1-' + version + '$2'
|
|
||||||
webInf { from 'resources/main/WEB-INF' }
|
|
||||||
exclude "**/.*.swp", "**/.sass-cache"
|
|
||||||
}
|
|
||||||
|
|
||||||
test { testLogging { events 'failed' } }
|
|
||||||
|
|
||||||
task testWar(type: War) {
|
|
||||||
from 'resources/webapp'
|
|
||||||
filter(ReplaceTokens, tokens: [version: version])
|
|
||||||
rename '(.+)(\\..*(css|js))', '$1-' + version + '$2'
|
|
||||||
webInf { from 'resources/test/WEB-INF' }
|
|
||||||
classifier 'test' }
|
|
||||||
|
|
||||||
task compileScss(
|
|
||||||
group: 'build',
|
|
||||||
description: 'Compile SCSS files into CSS.',
|
|
||||||
type: Exec
|
|
||||||
) {
|
|
||||||
executable "scss"
|
|
||||||
args "--update", "src/main/webapp/css:build/webapp/css"
|
|
||||||
}
|
|
||||||
|
|
||||||
war.dependsOn compileScss
|
|
||||||
testWar.dependsOn compileScss
|
|
||||||
|
|
||||||
task deployProd(dependsOn: ['build']) { doLast {
|
|
||||||
def warName = "${project.name}-${version}.war"
|
|
||||||
def artifactName = "ROOT.war"
|
|
||||||
|
|
||||||
copy {
|
|
||||||
from "build/libs"
|
|
||||||
into "build"
|
|
||||||
include warName
|
|
||||||
rename warName, artifactName }
|
|
||||||
|
|
||||||
exec("eb", "deploy", "-l", "${project.name}-${version}")
|
|
||||||
} }
|
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
INSERT INTO SERVICES (date, service_type) values
|
|
||||||
('2015-02-01', 'SUN_AM'),
|
|
||||||
('2015-02-01', 'SUN_PM'),
|
|
||||||
('2015-02-04', 'WED'),
|
|
||||||
('2015-02-08', 'SUN_AM'),
|
|
||||||
('2015-02-08', 'SUN_PM'),
|
|
||||||
('2015-02-11', 'WED'),
|
|
||||||
('2015-02-15', 'SUN_AM'),
|
|
||||||
('2015-02-15', 'SUN_PM');
|
|
||||||
|
|
||||||
INSERT INTO songs (name, artists) VALUES
|
|
||||||
('Breathe On Us', 'Kari Jobe'),
|
|
||||||
('How Great Is Our God', 'Chris Tomlin'),
|
|
||||||
('Glorious', 'Martha Munizzi'),
|
|
||||||
('Rez Power', 'Israel Houghton');
|
|
||||||
|
|
||||||
INSERT INTO performances (service_id, song_id, pianist, organist, bassist, drummer, guitarist, leader) VALUES
|
|
||||||
(1, 1, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'),
|
|
||||||
(1, 2, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'),
|
|
||||||
(1, 3, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'),
|
|
||||||
(2, 2, 'Trevor Delano', 'Connie Bernard', 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood'),
|
|
||||||
(2, 3, 'Trevor Delano', 'Connie Bernard', 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood'),
|
|
||||||
(2, 4, 'Trevor Delano', 'Connie Bernard', 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood'),
|
|
||||||
(3, 1, 'Rachel Wood', 'Krista Hatcher', 'Jonathan Bernard', 'Jared Wood', 'Tony Bagliore', 'Rachel Wood'),
|
|
||||||
(3, 2, 'Rachel Wood', 'Krista Hatcher', 'Jonathan Bernard', 'Jared Wood', 'Tony Bagliore', 'Rachel Wood'),
|
|
||||||
(4, 3, 'Trevor Delano', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood'),
|
|
||||||
(5, 4, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Tony Bagliore', 'Rachel Wood'),
|
|
||||||
(6, 1, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'),
|
|
||||||
(7, 2, 'Trevor Delano', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'),
|
|
||||||
(8, 3, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood');
|
|
||||||
|
|
||||||
INSERT INTO users (username, pwd, role) VALUES
|
|
||||||
('admin', '', 'admin'),
|
|
||||||
('test', '', '');
|
|
79
service/build.gradle
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
import org.apache.tools.ant.filters.ReplaceTokens
|
||||||
|
|
||||||
|
apply plugin: "groovy"
|
||||||
|
apply plugin: "maven"
|
||||||
|
apply plugin: "war"
|
||||||
|
|
||||||
|
// webAppDirName = "build/webapp/main"
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.jdbernard:gradle-exec-util:0.2.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
import static com.jdbernard.gradle.ExecUtil.*
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile localGroovy()
|
||||||
|
compile 'ch.qos.logback:logback-classic:1.1.8'
|
||||||
|
compile 'ch.qos.logback:logback-core:1.1.8'
|
||||||
|
compile 'org.slf4j:slf4j-api:1.7.22'
|
||||||
|
compile 'com.impossibl.pgjdbc-ng:pgjdbc-ng:0.6'
|
||||||
|
compile 'com.lambdaworks:scrypt:1.4.0'
|
||||||
|
compile 'com.zaxxer:HikariCP:2.5.1'
|
||||||
|
compile 'javax:javaee-api:7.0'
|
||||||
|
compile 'javax.ws.rs:javax.ws.rs-api:2.0.1'
|
||||||
|
compile 'joda-time:joda-time:2.7'
|
||||||
|
runtime 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.3.2'
|
||||||
|
runtime 'org.glassfish.jersey.containers:jersey-container-servlet:2.16'
|
||||||
|
runtime 'org.glassfish.jersey.media:jersey-media-json-jackson:2.16'
|
||||||
|
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
|
||||||
|
|
||||||
|
testCompile 'junit:junit:4.12'
|
||||||
|
testCompile 'com.jdblabs:db-migrate.groovy:0.2.5'
|
||||||
|
testRuntime 'com.h2database:h2:1.4.186'
|
||||||
|
}
|
||||||
|
|
||||||
|
war {
|
||||||
|
from "resources/webapp"
|
||||||
|
from "build/webapp"
|
||||||
|
filter(ReplaceTokens, tokens: [version: version])
|
||||||
|
rename '(.+)(\\..*(css|js))', '$1-' + version + '$2'
|
||||||
|
webInf { from 'resources/main/WEB-INF' }
|
||||||
|
exclude "**/.*.swp", "**/.sass-cache"
|
||||||
|
}
|
||||||
|
|
||||||
|
test { testLogging { events 'failed' } }
|
||||||
|
|
||||||
|
task testWar(type: War) {
|
||||||
|
from 'resources/webapp'
|
||||||
|
filter(ReplaceTokens, tokens: [version: version])
|
||||||
|
rename '(.+)(\\..*(css|js))', '$1-' + version + '$2'
|
||||||
|
webInf { from 'resources/test/WEB-INF' }
|
||||||
|
classifier 'test' }
|
||||||
|
|
||||||
|
task compileScss(
|
||||||
|
group: 'build',
|
||||||
|
description: 'Compile SCSS files into CSS.',
|
||||||
|
type: Exec
|
||||||
|
) {
|
||||||
|
executable "scss"
|
||||||
|
args "--update", "src/main/webapp/css:build/webapp/css"
|
||||||
|
}
|
||||||
|
|
||||||
|
war.dependsOn compileScss
|
||||||
|
testWar.dependsOn compileScss
|
||||||
|
|
||||||
|
task deployProd(dependsOn: ['build']) { doLast {
|
||||||
|
def warName = "${project.name}-${version}.war"
|
||||||
|
def artifactName = "ROOT.war"
|
||||||
|
|
||||||
|
copy {
|
||||||
|
from "build/libs"
|
||||||
|
into "build"
|
||||||
|
include warName
|
||||||
|
rename warName, artifactName }
|
||||||
|
|
||||||
|
exec("eb", "deploy", "-l", "${parent.name}-${project.name}-${version}")
|
||||||
|
} }
|
34
service/resources/test/testdb.init.sql
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
INSERT INTO SERVICES (date, service_type) values
|
||||||
|
('2015-02-01', 'SUN_AM'),
|
||||||
|
('2015-02-01', 'SUN_PM'),
|
||||||
|
('2015-02-04', 'WED'),
|
||||||
|
('2015-02-08', 'SUN_AM'),
|
||||||
|
('2015-02-08', 'SUN_PM'),
|
||||||
|
('2015-02-11', 'WED'),
|
||||||
|
('2015-02-15', 'SUN_AM'),
|
||||||
|
('2015-02-15', 'SUN_PM');
|
||||||
|
|
||||||
|
INSERT INTO songs (name, artists) VALUES
|
||||||
|
('Breathe On Us', 'Kari Jobe'),
|
||||||
|
('How Great Is Our God', 'Chris Tomlin'),
|
||||||
|
('Glorious', 'Martha Munizzi'),
|
||||||
|
('Rez Power', 'Israel Houghton');
|
||||||
|
|
||||||
|
INSERT INTO performances (service_id, song_id, rank, pianist, organist, bassist, drummer, guitarist, leader) VALUES
|
||||||
|
(1, 1, 1, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'),
|
||||||
|
(1, 2, 2, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'),
|
||||||
|
(1, 3, 3, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'),
|
||||||
|
(2, 2, 1, 'Trevor Delano', 'Connie Bernard', 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood'),
|
||||||
|
(2, 3, 2, 'Trevor Delano', 'Connie Bernard', 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood'),
|
||||||
|
(2, 4, 3, 'Trevor Delano', 'Connie Bernard', 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood'),
|
||||||
|
(3, 1, 0, 'Rachel Wood', 'Krista Hatcher', 'Jonathan Bernard', 'Jared Wood', 'Tony Bagliore', 'Rachel Wood'),
|
||||||
|
(3, 2, 0, 'Rachel Wood', 'Krista Hatcher', 'Jonathan Bernard', 'Jared Wood', 'Tony Bagliore', 'Rachel Wood'),
|
||||||
|
(4, 3, 0, 'Trevor Delano', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood'),
|
||||||
|
(5, 4, 1, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Tony Bagliore', 'Rachel Wood'),
|
||||||
|
(6, 1, 1, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'),
|
||||||
|
(7, 2, 1, 'Trevor Delano', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'),
|
||||||
|
(8, 3, 1, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood');
|
||||||
|
|
||||||
|
INSERT INTO users (username, pwd, role) VALUES
|
||||||
|
('admin', '', 'admin'),
|
||||||
|
('test', '', '');
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
@ -152,10 +152,10 @@ public class NLSongsDB {
|
|||||||
public Performance create(Performance perf) {
|
public Performance create(Performance perf) {
|
||||||
// TODO: handle constraint violation (same service and song ids)
|
// TODO: handle constraint violation (same service and song ids)
|
||||||
sql.executeInsert(
|
sql.executeInsert(
|
||||||
"INSERT INTO performances (service_id, song_id, pianist, " +
|
"INSERT INTO performances (service_id, song_id, rank, pianist, " +
|
||||||
"organist, bassist, drummer, guitarist, leader) VALUES " +
|
"organist, bassist, drummer, guitarist, leader) VALUES " +
|
||||||
"(?, ?, ?, ?, ?, ?, ?, ?)", [perf.serviceId, perf.songId,
|
"(?, ?, ?, ?, ?, ?, ?, ?)", [perf.serviceId, perf.songId,
|
||||||
perf.pianist, perf.organist, perf.bassist, perf.drummer,
|
perf.rank, perf.pianist, perf.organist, perf.bassist, perf.drummer,
|
||||||
perf.guitarist, perf.leader])
|
perf.guitarist, perf.leader])
|
||||||
return perf }
|
return perf }
|
||||||
|
|
||||||
@ -163,10 +163,11 @@ public class NLSongsDB {
|
|||||||
// TODO: handle constraint violation (same service and song ids)
|
// TODO: handle constraint violation (same service and song ids)
|
||||||
return sql.executeUpdate(
|
return sql.executeUpdate(
|
||||||
"UPDATE performances SET pianist = ?, organist = ?, " +
|
"UPDATE performances SET pianist = ?, organist = ?, " +
|
||||||
"bassist = ?, drummer = ?, guitarist = ?, leader = ? " +
|
"bassist = ?, drummer = ?, guitarist = ?, leader = ?, " +
|
||||||
"WHERE service_id = ? AND song_id = ?",
|
"rank = ? WHERE service_id = ? AND song_id = ?",
|
||||||
[perf.pianist, perf.organist, perf.bassist, perf.drummer,
|
[perf.pianist, perf.organist, perf.bassist, perf.drummer,
|
||||||
perf.guitarist, perf.leader, perf.serviceId, perf.songId]) }
|
perf.guitarist, perf.leader, perf.rank, perf.serviceId,
|
||||||
|
perf.songId]) }
|
||||||
|
|
||||||
public int delete(Performance perf) {
|
public int delete(Performance perf) {
|
||||||
sql.execute(
|
sql.execute(
|
@ -4,6 +4,7 @@ public class Performance implements Serializable {
|
|||||||
|
|
||||||
int serviceId
|
int serviceId
|
||||||
int songId
|
int songId
|
||||||
|
int rank
|
||||||
String pianist
|
String pianist
|
||||||
String organist
|
String organist
|
||||||
String bassist
|
String bassist
|
||||||
@ -19,6 +20,7 @@ public class Performance implements Serializable {
|
|||||||
|
|
||||||
return (this.serviceId == that.serviceId &&
|
return (this.serviceId == that.serviceId &&
|
||||||
this.songId == that.songId &&
|
this.songId == that.songId &&
|
||||||
|
this.rank == that.rank &&
|
||||||
this.pianist == that.pianist &&
|
this.pianist == that.pianist &&
|
||||||
this.organist == that.organist &&
|
this.organist == that.organist &&
|
||||||
this.bassist == that.bassist &&
|
this.bassist == that.bassist &&
|
||||||
@ -27,5 +29,5 @@ public class Performance implements Serializable {
|
|||||||
this.leader == that.leader) }
|
this.leader == that.leader) }
|
||||||
|
|
||||||
@Override String toString() {
|
@Override String toString() {
|
||||||
return "($serviceId, $songId): $leader - $pianist" }
|
return "($serviceId, $songId)-$rank: $leader - $pianist" }
|
||||||
}
|
}
|
@ -11,7 +11,8 @@ public class NLSongsContext {
|
|||||||
public static String mediaBaseUrl
|
public static String mediaBaseUrl
|
||||||
|
|
||||||
public static String makeUrl(Service service, Song song) {
|
public static String makeUrl(Service service, Song song) {
|
||||||
return mediaBaseUrl + '/' + service.localDate.toString('yyyy-MM-dd') + '_' +
|
return mediaBaseUrl + '/' + service.localDate.toString('yyyy') + "/" +
|
||||||
|
service.localDate.toString('yyyy-MM-dd') + '_' +
|
||||||
service.serviceType.name().toLowerCase() + '_' +
|
service.serviceType.name().toLowerCase() + '_' +
|
||||||
song.name.replaceAll(/[\s'"\\\/\?!]/, '') + '.mp3' }
|
song.name.replaceAll(/[\s'"\\\/\?!]/, '') + '.mp3' }
|
||||||
}
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
-- # New Life Songs DB
|
||||||
|
-- @author Jonathan Bernard <jdb@jdb-labs.com>
|
||||||
|
--
|
||||||
|
-- PostgreSQL database un-creation sript.
|
||||||
|
DROP TABLE performances;
|
||||||
|
DROP TABLE services;
|
||||||
|
DROP TABLE songs;
|
||||||
|
DROP TABLE tokens;
|
||||||
|
DROP TABLE users;
|
@ -4,8 +4,7 @@
|
|||||||
-- PostgreSQL database creation sript.
|
-- PostgreSQL database creation sript.
|
||||||
|
|
||||||
-- Services table
|
-- Services table
|
||||||
DROP TABLE IF EXISTS services;
|
CREATE TABLE services (
|
||||||
CREATE TABLE IF NOT EXISTS services (
|
|
||||||
id SERIAL,
|
id SERIAL,
|
||||||
date DATE NOT NULL,
|
date DATE NOT NULL,
|
||||||
service_type VARCHAR(16) DEFAULT NULL,
|
service_type VARCHAR(16) DEFAULT NULL,
|
||||||
@ -13,10 +12,8 @@ CREATE TABLE IF NOT EXISTS services (
|
|||||||
CONSTRAINT uc_serviceTypeAndDate UNIQUE (date, service_type),
|
CONSTRAINT uc_serviceTypeAndDate UNIQUE (date, service_type),
|
||||||
PRIMARY KEY (id));
|
PRIMARY KEY (id));
|
||||||
|
|
||||||
|
|
||||||
-- Songs table
|
-- Songs table
|
||||||
DROP TABLE IF EXISTS songs;
|
CREATE TABLE songs (
|
||||||
CREATE TABLE IF NOT EXISTS songs (
|
|
||||||
id SERIAL,
|
id SERIAL,
|
||||||
name VARCHAR(128) NOT NULL,
|
name VARCHAR(128) NOT NULL,
|
||||||
artists VARCHAR(256) DEFAULT NULL,
|
artists VARCHAR(256) DEFAULT NULL,
|
||||||
@ -25,8 +22,7 @@ CREATE TABLE IF NOT EXISTS songs (
|
|||||||
|
|
||||||
|
|
||||||
-- performances table
|
-- performances table
|
||||||
DROP TABLE IF EXISTS performances;
|
CREATE TABLE performances (
|
||||||
CREATE TABLE IF NOT EXISTS performances (
|
|
||||||
service_id INTEGER NOT NULL,
|
service_id INTEGER NOT NULL,
|
||||||
song_id INTEGER NOT NULL,
|
song_id INTEGER NOT NULL,
|
||||||
pianist VARCHAR(64) DEFAULT NULL,
|
pianist VARCHAR(64) DEFAULT NULL,
|
||||||
@ -40,16 +36,16 @@ CREATE TABLE IF NOT EXISTS performances (
|
|||||||
FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE CASCADE);
|
FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE CASCADE);
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS users;
|
-- Users table
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
CREATE TABLE users (
|
||||||
id SERIAL,
|
id SERIAL,
|
||||||
username VARCHAR(64) UNIQUE NOT NULL,
|
username VARCHAR(64) UNIQUE NOT NULL,
|
||||||
pwd VARCHAR(80),
|
pwd VARCHAR(80),
|
||||||
role VARCHAR(16) NOT NULL,
|
role VARCHAR(16) NOT NULL,
|
||||||
PRIMARY KEY (id));
|
PRIMARY KEY (id));
|
||||||
|
|
||||||
DROP TABLE IF EXISTS tokens;
|
-- Tokens table
|
||||||
CREATE TABLE IF NOT EXISTS tokens (
|
CREATE TABLE tokens (
|
||||||
token VARCHAR(64),
|
token VARCHAR(64),
|
||||||
user_id INTEGER NOT NULL,
|
user_id INTEGER NOT NULL,
|
||||||
expires TIMESTAMP NOT NULL,
|
expires TIMESTAMP NOT NULL,
|
@ -0,0 +1,5 @@
|
|||||||
|
-- # New Life Songs DB
|
||||||
|
-- @author Jonathan Bernard <jdb@jdb-labs.com>
|
||||||
|
--
|
||||||
|
-- Remove performances.rank
|
||||||
|
ALTER TABLE performances DROP COLUMN rank;
|
@ -0,0 +1,6 @@
|
|||||||
|
-- # New Life Songs DB
|
||||||
|
-- @author Jonathan Bernard <jdb@jdb-labs.com>
|
||||||
|
--
|
||||||
|
-- Add performances.rank: the rank of the performance in the service, aka. the
|
||||||
|
-- "track number" if the service were an album.
|
||||||
|
ALTER TABLE performances ADD COLUMN rank integer NOT NULL DEFAULT 0;
|
@ -64,7 +64,7 @@ if (!service) { response.sendError(response.SC_NOT_FOUND); return }
|
|||||||
<tbody>
|
<tbody>
|
||||||
<% songsDB.findPerformancesForServiceId(service.id).
|
<% songsDB.findPerformancesForServiceId(service.id).
|
||||||
collect { [perf: it, song: songsDB.findSong(it.songId)] }.
|
collect { [perf: it, song: songsDB.findSong(it.songId)] }.
|
||||||
sort { it.song.name }.each { row -> %>
|
sort { it.song.name }.sort { it.perf.rank }.each { row -> %>
|
||||||
<tr><td class=actions><a href="<%= NLSongsContext.makeUrl(service, row.song) %>"><i class="fa fa-download"></i></a></td>
|
<tr><td class=actions><a href="<%= NLSongsContext.makeUrl(service, row.song) %>"><i class="fa fa-download"></i></a></td>
|
||||||
<td class=song-name><a href='../song/<%= row.song.id %>'><%=
|
<td class=song-name><a href='../song/<%= row.song.id %>'><%=
|
||||||
row.song.name %></a></td>
|
row.song.name %></a></td>
|
@ -3,6 +3,7 @@ package com.jdbernard.nlsongs.service
|
|||||||
import com.jdbernard.nlsongs.db.NLSongsDB
|
import com.jdbernard.nlsongs.db.NLSongsDB
|
||||||
import com.jdbernard.nlsongs.model.*
|
import com.jdbernard.nlsongs.model.*
|
||||||
import com.jdbernard.nlsongs.servlet.NLSongsContext
|
import com.jdbernard.nlsongs.servlet.NLSongsContext
|
||||||
|
import com.jdblabs.dbmigrate.DbMigrate
|
||||||
import com.zaxxer.hikari.HikariConfig
|
import com.zaxxer.hikari.HikariConfig
|
||||||
import com.zaxxer.hikari.HikariDataSource
|
import com.zaxxer.hikari.HikariDataSource
|
||||||
|
|
||||||
@ -24,8 +25,9 @@ import org.slf4j.LoggerFactory
|
|||||||
|
|
||||||
public class NLSongsDBTest {
|
public class NLSongsDBTest {
|
||||||
|
|
||||||
static NLSongsDB songsDB;
|
static NLSongsDB songsDB
|
||||||
static Sql sql
|
static Sql sql
|
||||||
|
static DbMigrate dbmigrate
|
||||||
static Logger log = LoggerFactory.getLogger(NLSongsDBTest)
|
static Logger log = LoggerFactory.getLogger(NLSongsDBTest)
|
||||||
|
|
||||||
def dateFormat
|
def dateFormat
|
||||||
@ -61,23 +63,23 @@ public class NLSongsDBTest {
|
|||||||
new Song(id: it[0], name: it[1], artists: it[2]) }
|
new Song(id: it[0], name: it[1], artists: it[2]) }
|
||||||
|
|
||||||
this.performances = [
|
this.performances = [
|
||||||
[1, 1, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'],
|
[1, 1, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood', 1],
|
||||||
[1, 2, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'],
|
[1, 2, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood', 2],
|
||||||
[1, 3, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'],
|
[1, 3, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood', 3],
|
||||||
[2, 2, 'Trevor Delano', 'Connie Bernard', 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood'],
|
[2, 2, 'Trevor Delano', 'Connie Bernard', 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood', 1],
|
||||||
[2, 3, 'Trevor Delano', 'Connie Bernard', 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood'],
|
[2, 3, 'Trevor Delano', 'Connie Bernard', 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood', 2],
|
||||||
[2, 4, 'Trevor Delano', 'Connie Bernard', 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood'],
|
[2, 4, 'Trevor Delano', 'Connie Bernard', 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood', 3],
|
||||||
[3, 1, 'Rachel Wood', 'Krista Hatcher', 'Jonathan Bernard', 'Jared Wood', 'Tony Bagliore', 'Rachel Wood'],
|
[3, 1, 'Rachel Wood', 'Krista Hatcher', 'Jonathan Bernard', 'Jared Wood', 'Tony Bagliore', 'Rachel Wood', 0],
|
||||||
[3, 2, 'Rachel Wood', 'Krista Hatcher', 'Jonathan Bernard', 'Jared Wood', 'Tony Bagliore', 'Rachel Wood'],
|
[3, 2, 'Rachel Wood', 'Krista Hatcher', 'Jonathan Bernard', 'Jared Wood', 'Tony Bagliore', 'Rachel Wood', 0],
|
||||||
[4, 3, 'Trevor Delano', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood'],
|
[4, 3, 'Trevor Delano', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser', 'Rachel Wood', 0],
|
||||||
[5, 4, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Tony Bagliore', 'Rachel Wood'],
|
[5, 4, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Tony Bagliore', 'Rachel Wood', 1],
|
||||||
[6, 1, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'],
|
[6, 1, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood', 1],
|
||||||
[7, 2, 'Trevor Delano', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'],
|
[7, 2, 'Trevor Delano', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood', 1],
|
||||||
[8, 3, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood'] ].collect {
|
[8, 3, 'Jared Wood', null, 'Jonathan Bernard', 'Christian Thompson', 'Andrew Fraiser; Tony Bagliore', 'Rachel Wood', 1] ].collect {
|
||||||
|
|
||||||
new Performance(serviceId: it[0], songId: it[1], pianist: it[2],
|
new Performance(serviceId: it[0], songId: it[1], pianist: it[2],
|
||||||
organist: it[3], bassist: it[4], drummer: it[5],
|
organist: it[3], bassist: it[4], drummer: it[5],
|
||||||
guitarist: it[6], leader: it[7]) }
|
guitarist: it[6], leader: it[7], rank: it[8]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@ -90,8 +92,13 @@ public class NLSongsDBTest {
|
|||||||
HikariDataSource dataSource = new HikariDataSource(hcfg)
|
HikariDataSource dataSource = new HikariDataSource(hcfg)
|
||||||
|
|
||||||
// Create NLSongsDB
|
// Create NLSongsDB
|
||||||
this.songsDB = new NLSongsDB(dataSource)
|
NLSongsDBTest.songsDB = new NLSongsDB(dataSource)
|
||||||
this.sql = new Sql(dataSource)
|
NLSongsDBTest.sql = new Sql(dataSource)
|
||||||
|
|
||||||
|
// Setup our DB migration tool
|
||||||
|
NLSongsDBTest.dbmigrate = new DbMigrate(
|
||||||
|
migrationsDir: new File('src/main/sql'),
|
||||||
|
sql: NLSongsDBTest.sql)
|
||||||
|
|
||||||
// Set NLSongsContext
|
// Set NLSongsContext
|
||||||
NLSongsContext.songsDB = songsDB }
|
NLSongsContext.songsDB = songsDB }
|
||||||
@ -103,18 +110,18 @@ public class NLSongsDBTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initData() {
|
public void initData() {
|
||||||
// Get the DB Schema and test data.
|
// Create the DB schema
|
||||||
File createSchemaSql = new File("src/main/sql/create-tables.sql")
|
dbmigrate.up()
|
||||||
File testDataSql = new File("resources/test/testdb.init.sql")
|
|
||||||
|
|
||||||
// Create the DB Schema
|
|
||||||
sql.execute(createSchemaSql.text)
|
|
||||||
|
|
||||||
// Populate the DB with test data.
|
// Populate the DB with test data.
|
||||||
|
File testDataSql = new File("resources/test/testdb.init.sql")
|
||||||
sql.execute(testDataSql.text) }
|
sql.execute(testDataSql.text) }
|
||||||
|
|
||||||
/// ### Services
|
@After
|
||||||
|
public void destroyData() {
|
||||||
|
dbmigrate.down(Integer.MAX_VALUE) }
|
||||||
|
|
||||||
|
/// ### Services
|
||||||
@Test public void shouldCreateService() {
|
@Test public void shouldCreateService() {
|
||||||
def service = new Service(
|
def service = new Service(
|
||||||
date: new Date(), serviceType: ServiceType.SUN_AM)
|
date: new Date(), serviceType: ServiceType.SUN_AM)
|
||||||
@ -178,8 +185,8 @@ public class NLSongsDBTest {
|
|||||||
assertCollectionsEqual(
|
assertCollectionsEqual(
|
||||||
performances.findAll { it.serviceId != 1 },
|
performances.findAll { it.serviceId != 1 },
|
||||||
songsDB.findAllPerformances()) }
|
songsDB.findAllPerformances()) }
|
||||||
/// ### Songs
|
|
||||||
|
|
||||||
|
/// ### Songs
|
||||||
@Test public void shoudCreateSong() {
|
@Test public void shoudCreateSong() {
|
||||||
def song = new Song(name: "Test Song", artists: ["Bob Sam"])
|
def song = new Song(name: "Test Song", artists: ["Bob Sam"])
|
||||||
def newSong = songsDB.create(song)
|
def newSong = songsDB.create(song)
|
||||||
@ -247,5 +254,10 @@ public class NLSongsDBTest {
|
|||||||
log.info("C2: $c2")
|
log.info("C2: $c2")
|
||||||
assertEquals(c1.size(), c2.size())
|
assertEquals(c1.size(), c2.size())
|
||||||
|
|
||||||
|
c1.each {
|
||||||
|
def isPresent = c2.contains(it)
|
||||||
|
if (!isPresent) log.info("$it is not within $c2.")
|
||||||
|
assertTrue(isPresent) }
|
||||||
|
|
||||||
assertTrue(c1.every { c2.contains(it) }) }
|
assertTrue(c1.every { c2.contains(it) }) }
|
||||||
}
|
}
|
1
settings.gradle
Normal file
@ -0,0 +1 @@
|
|||||||
|
include 'service', 'uploader'
|
@ -1,8 +0,0 @@
|
|||||||
-- DROP DATABASE IF EXISTS nlsongs;
|
|
||||||
CREATE DATABASE nlsongs
|
|
||||||
ENCODING = 'UTF8'
|
|
||||||
LC_COLLATE = 'en_US.UTF-8'
|
|
||||||
LC_CTYPE = 'en_US.UTF-8'
|
|
||||||
CONNECTION LIMIT = 1;
|
|
||||||
|
|
||||||
\c nlsongs
|
|
@ -1,5 +0,0 @@
|
|||||||
DROP TABLE tokens;
|
|
||||||
DROP TABLE users;
|
|
||||||
DROP TABLE performances;
|
|
||||||
DROP TABLE songs;
|
|
||||||
DROP TABLE services;
|
|
24
uploader/build.gradle
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
apply plugin: 'groovy'
|
||||||
|
apply plugin: 'application'
|
||||||
|
|
||||||
|
mainClassName = 'com.jdbernard.nlsongs.NLSongsUploader'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile localGroovy()
|
||||||
|
compile 'ch.qos.logback:logback-classic:1.1.8'
|
||||||
|
compile 'ch.qos.logback:logback-core:1.1.8'
|
||||||
|
compile 'org.slf4j:slf4j-api:1.7.22'
|
||||||
|
compile 'com.impossibl.pgjdbc-ng:pgjdbc-ng:0.6'
|
||||||
|
compile 'com.zaxxer:HikariCP:2.5.1'
|
||||||
|
compile 'com.miglayout:miglayout-swing:5.0'
|
||||||
|
compile project(':service')
|
||||||
|
}
|
||||||
|
|
||||||
|
task writeVersionFile(
|
||||||
|
group: 'build',
|
||||||
|
description: 'Write the version to VERSION.txt') { doLast {
|
||||||
|
|
||||||
|
(new File("${buildDir}/classes/main/VERSION.txt")).text = version
|
||||||
|
} }
|
||||||
|
|
||||||
|
build.dependsOn writeVersionFile
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.jdbernard.nlsongs
|
||||||
|
|
||||||
|
import groovy.beans.Bindable
|
||||||
|
import groovy.swing.SwingBuilder
|
||||||
|
import javax.swing.JFrame
|
||||||
|
import net.miginfocom.swing.MigLayout
|
||||||
|
|
||||||
|
public class NLSongsUploader {
|
||||||
|
|
||||||
|
public static final String VERSION =
|
||||||
|
NLSongsUploader.getResourceAsStream('/VERSION.txt').text
|
||||||
|
|
||||||
|
// GUI Elements (View)
|
||||||
|
SwingBuilder swing = new SwingBuilder()
|
||||||
|
JFrame rootFrame
|
||||||
|
|
||||||
|
public static void main(String[] args) { def inst = new NLSongsUploader() }
|
||||||
|
|
||||||
|
public NLSongsUploader() {
|
||||||
|
|
||||||
|
initGui()
|
||||||
|
rootFrame.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initGui() {
|
||||||
|
|
||||||
|
swing.edtBuilder {
|
||||||
|
this.rootFrame = frame(title: "New Life Songs Uploader ${VERSION}",
|
||||||
|
iconImages: [imageIcon('/icon.png').image],
|
||||||
|
preferredSize: [1024, 768], pack: true,
|
||||||
|
layout: new MigLayout("ins 0, fill"),
|
||||||
|
defaultCloseOperation: JFrame.EXIT_ON_CLOSE) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
uploader/src/main/resources/icon.png
Normal file
After Width: | Height: | Size: 6.2 KiB |