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() {{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() {{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"); } }