import com.agiledeveloper.Author
import com.agiledeveloper.Book

class BootStrap {

    def init = { servletContext ->
      def burt = new Author(firstName: 'Burt', lastName: 'Beckwith', emailAddress: 'burt@example.com')
      def jeff = new Author(firstName: 'Jeff', lastName: 'Brown', emailAddress: 'jeff@example.com')
      def graeme = new Author(firstName: 'Graeme', lastName: 'Rocher', emailAddress: 'graeme@example.com')
      def book1 = new Book(title: 'The Definitive Guide to Grails 2', isbn: '1430243775')
      def book2 = new Book(title: 'Programming Grails', isbn: '1449323936')
      burt.save()
      jeff.save()
      graeme.save()
      book1.addToAuthors(jeff)
      book1.addToAuthors(graeme)
      book2.addToAuthors(burt)
      book1.save()
      book2.save()
    }
    def destroy = {
    }
}

