mikevoxcap / pluralsight-camel-intro

Repository for projects related to the Pluralsight.com Apache Camel introduction
44 stars 86 forks source link

DerbyDatabaseBean.java is missing #1

Open vkumar3646 opened 7 years ago

vkumar3646 commented 7 years ago

Hi Michael, DerbyDatabaseBean.java is missing in pluralsight-camel-intro/src/test/java/com/pluralsight/orderfulfillment/test/

jordling commented 5 years ago

package com.pluralsight.orderfulfillment.test;

import org.springframework.jdbc.core.JdbcTemplate;

public class DerbyDatabaseBean { private JdbcTemplate jdbcTemplate;

private void create() throws Exception {
    try {
        jdbcTemplate.execute("drop table orders.orderitem");
        jdbcTemplate.execute("drop table orders.\"order\"");
        jdbcTemplate.execute("drop table orders.catalogitem");
        jdbcTemplate.execute("drop table orders.customer");
        jdbcTemplate.execute("drop schema orders");

    } catch (Throwable throwable) {
        jdbcTemplate.execute("create schema  orders");
        jdbcTemplate.execute("create table orders.customer (" +
                "id int PRIMARY KEY," +
                "firstName varchar(50)," +
                "lastName varchar(50)," +
                "email varchar(50))");

        jdbcTemplate.execute("create table orders.catalogitem (" +
                "id int PRIMARY KEY," +
                "itemNumber varchar(50)," +
                "itemName varchar(80)," +
                "itemType varchar(50))");

        jdbcTemplate.execute("create table orders.\"order\" (" +
                "id int PRIMARY KEY," +
                "customer_id int," +
                "orderNumber varchar(50)," +
                "timeOrderPlaced timestamp," +
                "lastUpdate timestamp," +
                "status varchar(50))");

        jdbcTemplate.execute("alter table orders.\"order\" add constraint orders_fk_1 foreign key (customer_id) references orders.customer (id)");

        jdbcTemplate.execute("create table orders.orderItem (" +
                "id int PRIMARY KEY," +
                "order_id int," +
                "catalogitem_id int," +
                "status varchar(50)," +
                "price decimal(20,5) ," +
                "lastUpdate timestamp ," +
                "quantity int)");

        jdbcTemplate.execute("alter table orders.orderItem add constraint orderItem_fk_1 foreign key (order_id) references orders.\"order\" (id)");
        jdbcTemplate.execute("alter table orders.orderItem add constraint orderItem_fk_2 foreign key (catalogitem_id) references orders.catalogitem (id)");
    }

}

public void destroy() throws Exception {
    try {

        jdbcTemplate.execute("drop table orders.orderitem");
        jdbcTemplate.execute("drop table orders.\"order\"");
        jdbcTemplate.execute("drop table orders.catalogitem");
        jdbcTemplate.execute("drop table orders.customer");
        jdbcTemplate.execute("drop schema orders");

    } catch (
            Throwable t) {
        //Ignore
    }
}

public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
    this.jdbcTemplate = jdbcTemplate;
}

}