diff options
author | Vitaly Takmazov | 2016-09-01 16:51:24 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-09-01 16:51:24 +0300 |
commit | d97bfe93f5f886ec4e85e0ac71889942d76511f8 (patch) | |
tree | 4170ea19525ebddd323f6b0300a47fa00f35f079 | |
parent | e6962670c778966b49620d6166581986fa54cf34 (diff) |
juick-demo: fill some data for test purposes
-rw-r--r-- | juick-demo/build.gradle | 23 | ||||
-rw-r--r-- | juick-demo/src/main/java/com/juick/demo/Demo.java | 39 | ||||
-rw-r--r-- | settings.gradle | 2 |
3 files changed, 63 insertions, 1 deletions
diff --git a/juick-demo/build.gradle b/juick-demo/build.gradle new file mode 100644 index 00000000..8dfb596b --- /dev/null +++ b/juick-demo/build.gradle @@ -0,0 +1,23 @@ +buildscript { + repositories { + mavenCentral() + } +} + +apply plugin: 'java' +apply plugin: 'application' +apply plugin: 'com.github.ben-manes.versions' + +repositories { + mavenCentral() +} + +mainClassName = "com.juick.demo.Demo" + +dependencies { + compile project(':juick-core') + compile 'org.apache.commons:commons-lang3:3.4' + compile 'org.springframework:spring-jdbc:4.3.2.RELEASE' + compile 'mysql:mysql-connector-java:5.1.39' +} +compileJava.options.encoding = 'UTF-8'
\ No newline at end of file diff --git a/juick-demo/src/main/java/com/juick/demo/Demo.java b/juick-demo/src/main/java/com/juick/demo/Demo.java new file mode 100644 index 00000000..6940bfd0 --- /dev/null +++ b/juick-demo/src/main/java/com/juick/demo/Demo.java @@ -0,0 +1,39 @@ +package com.juick.demo; + +import com.juick.Tag; +import com.juick.server.MessagesQueries; +import com.juick.server.PMQueries; +import com.juick.server.TagQueries; +import com.juick.server.UserQueries; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.datasource.DriverManagerDataSource; + +import java.util.ArrayList; +import java.util.logging.Logger; + +/** + * Created by vitalyster on 30.08.2016. + */ +public class Demo { + private static final Logger logger = Logger.getLogger(Demo.class.getName()); + public static void main(String ...args) { + DriverManagerDataSource dataSource = new DriverManagerDataSource("jdbc:mysql://localhost/juick?user=root"); + JdbcTemplate jdbc = new JdbcTemplate(dataSource); + logger.info("initializing demo database"); + + Integer ugnich_id = UserQueries.createUser(jdbc, "ugnich", "secret"); + Integer ugn_mid = MessagesQueries.createMessage(jdbc, ugnich_id, "Hi, I am ugnich", null, + new ArrayList<Tag>() {{add(TagQueries.getTag(jdbc, "yo", true)); add(TagQueries.getTag(jdbc, "people", true));}}); + + Integer juick_id = UserQueries.createUser(jdbc, "juick", "secret"); + MessagesQueries.createMessage(jdbc, juick_id, "New demo juick was created", null, + new ArrayList<Tag>() {{add(TagQueries.getTag(jdbc, "yo", true)); add(TagQueries.getTag(jdbc, "readonly", true));}}); + Integer freefd_id = UserQueries.createUser(jdbc, "freefd", "secret"); + MessagesQueries.createReply(jdbc, ugn_mid, 0, freefd_id, "I am freefd and this is my reply", null); + MessagesQueries.recommendMessage(jdbc, ugn_mid, freefd_id); + MessagesQueries.recommendMessage(jdbc, ugn_mid, juick_id); + MessagesQueries.setMessagePopular(jdbc, ugn_mid, 1); + PMQueries.createPM(jdbc, freefd_id, ugnich_id, "Hi ugnich!"); + jdbc.execute("UPDATE tags SET top=1"); + } +} diff --git a/settings.gradle b/settings.gradle index 96f2c888..aa3962b0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':deps:com.juick.xmpp', ':juick-core', 'juick-api', 'juick-www', 'juick-rss', 'juick-ws' +include ':deps:com.juick.xmpp', ':juick-core', ':juick-api', ':juick-www', ':juick-rss', ':juick-ws', ':juick-demo' |