Skip to content

Commit

Permalink
remove GORM-without-Grails package
Browse files Browse the repository at this point in the history
  • Loading branch information
sdelamo committed Jul 31, 2017
1 parent 43ac273 commit 875ee9b
Show file tree
Hide file tree
Showing 29 changed files with 104 additions and 96 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.GORMwithoutGrails
package demo

import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package demo.GORMwithoutGrails.controller
package demo.controller

import demo.GORMwithoutGrails.service.MakeService
import demo.service.MakeService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package demo.GORMwithoutGrails.controller
package demo.controller

import demo.GORMwithoutGrails.service.ModelService
import demo.service.ModelService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package demo.GORMwithoutGrails.controller
package demo.controller

import demo.GORMwithoutGrails.service.VehicleService
import demo.service.VehicleService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.GORMwithoutGrails.domain
package demo.domain

import grails.gorm.annotation.Entity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.GORMwithoutGrails.domain
package demo.domain

import grails.gorm.annotation.Entity
import org.grails.datastore.gorm.GormEntity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.GORMwithoutGrails.domain
package demo.domain

import grails.gorm.annotation.Entity
import org.grails.datastore.gorm.GormEntity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.GORMwithoutGrails.domain
package demo.domain

import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.GORMwithoutGrails.domain
package demo.domain

import grails.gorm.annotation.Entity
import org.grails.datastore.gorm.GormEntity
Expand Down
7 changes: 7 additions & 0 deletions complete/src/main/groovy/demo/service/MakeService.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package demo.service

import demo.domain.Make

interface MakeService {
List<Make> list()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package demo.GORMwithoutGrails.service
package demo.service

import demo.GORMwithoutGrails.domain.Make
import demo.domain.Make
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

Expand Down
7 changes: 7 additions & 0 deletions complete/src/main/groovy/demo/service/ModelService.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package demo.service

import demo.domain.Model

interface ModelService {
List<Model> list()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package demo.GORMwithoutGrails.service
package demo.service

import demo.GORMwithoutGrails.domain.Model
import demo.domain.Model
import demo.domain.Model
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

Expand Down
7 changes: 7 additions & 0 deletions complete/src/main/groovy/demo/service/VehicleService.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package demo.service

import demo.domain.Vehicle

interface VehicleService {
List<Vehicle> list()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package demo.GORMwithoutGrails.service
package demo.service

import demo.GORMwithoutGrails.domain.Vehicle
import demo.domain.Vehicle
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package demo.GORMwithoutGrails.domain
package demo.domain

import grails.gorm.transactions.Rollback
import demo.domain.Driver
import org.grails.orm.hibernate.HibernateDatastore
import spock.lang.Specification
import grails.gorm.transactions.Rollback
import spock.lang.AutoCleanup
import spock.lang.Shared
import spock.lang.Specification


class DriverSpec extends Specification {

@Shared @AutoCleanup HibernateDatastore datastore = new HibernateDatastore(getClass().getPackage())
@Shared @AutoCleanup
HibernateDatastore datastore = new HibernateDatastore(getClass().getPackage())

@Rollback
def "Driver created with name"() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package demo.GORMwithoutGrails.domain
package demo.domain

import demo.domain.Make
import grails.gorm.transactions.Rollback
import org.grails.orm.hibernate.HibernateDatastore
import spock.lang.AutoCleanup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package demo.GORMwithoutGrails.domain
package demo.domain

import demo.domain.Model
import grails.gorm.transactions.Rollback
import org.grails.orm.hibernate.HibernateDatastore
import spock.lang.AutoCleanup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package demo.GORMwithoutGrails.domain
package demo.domain

import demo.domain.Make
import demo.domain.Model
import demo.domain.Vehicle
import grails.gorm.transactions.Rollback
import org.grails.orm.hibernate.HibernateDatastore
import spock.lang.AutoCleanup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.GORMwithoutGrails
package demo

import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package demo.GORMwithoutGrails
package demo

import org.junit.Test
import org.junit.runner.RunWith
Expand Down
16 changes: 8 additions & 8 deletions src/main/docs/guide/creatingTheControllers.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ Finally lets create some controllers so we can have basic UI access to our data.

[source,bash]
----
$ cd src/main/groovy/demo/GORMwithoutGrails/controller
$ cd src/main/groovy/demo/controller
$ touch MakeController
$ touch ModelController
$ touch VehicleController
----

Now let’s edit our controllers under src/main/groovy/demo/GORMwithoutGrails/controller.
Now let’s edit our controllers under src/main/groovy/demo/controller.
We will import one of our services and update our index method. The controllers will have
the following annotations

Expand All @@ -18,21 +18,21 @@ the following annotations
- @RequestMapping("/") [on the method] - Sets the url mapping for the method, beyond the base url

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/controller/MakeController.groovy
./src/main/groovy/demo/controller/MakeController.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/controller/MakeController.groovy[]
include::{sourceDir}/src/main/groovy/demo/controller/MakeController.groovy[]
----

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/controller/ModelController.groovy
./src/main/groovy/demo/controller/ModelController.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/controller/ModelController.groovy[]
include::{sourceDir}/src/main/groovy/demo/controller/ModelController.groovy[]
----

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/controller/VehicleController.groovy
./src/main/groovy/demo/controller/VehicleController.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/controller/VehicleController.groovy[]
include::{sourceDir}/src/main/groovy/demo/controller/VehicleController.groovy[]
----

Now that we have controllers with url mappings we have everything we need to test our
Expand Down
24 changes: 12 additions & 12 deletions src/main/docs/guide/creatingTheDomain.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feel free to use your favorite IDE to create these or execute the following

[source,bash]
----
$ cd complete/src/main/groovy/demo/GORMwithoutGrails/domain/
$ cd complete/src/main/groovy/demo/domain/
$ touch Driver.groovy
$ touch Make.groovy
$ touch Model.groovy
Expand All @@ -24,7 +24,7 @@ Next lets do the same thing to setup our testing files.

[source,bash]
----
$ cd complete/src/test/groovy/demo/GORMwithoutGrails/domain/
$ cd complete/src/test/groovy/demo/domain/
$ touch DriverSpec.groovy
$ touch MakeSpec.groovy
$ touch ModelSpec.groovy
Expand All @@ -34,37 +34,37 @@ $ touch VehicleSpec.groovy
Now that all our class stubs are in place lets go ahead and edit them.

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/domain/Make.groovy
./src/main/groovy/demo/domain/Make.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/domain/Make.groovy[]
include::{sourceDir}/src/main/groovy/demo/domain/Make.groovy[]
----

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/domain/Model.groovy
./src/main/groovy/demo/domain/Model.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/domain/Model.groovy[]
include::{sourceDir}/src/main/groovy/demo/domain/Model.groovy[]
----

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/domain/Vehicle.groovy
./src/main/groovy/demo/domain/Vehicle.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/domain/Vehicle.groovy[]
include::{sourceDir}/src/main/groovy/demo/domain/Vehicle.groovy[]
----

There is a bit more to our `Driver.groovy` than meets the eye versus the first 3 classes. That's
because we are actually extending our `User.groovy class with driver. This will grant us
some extra flexibility in the future as we grow our application.

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/domain/Driver.groovy
./src/main/groovy/demo/domain/Driver.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/domain/Driver.groovy[]
include::{sourceDir}/src/main/groovy/demo/domain/Driver.groovy[]
----

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/domain/User.groovy
./src/main/groovy/demo/domain/User.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/domain/User.groovy[]
include::{sourceDir}/src/main/groovy/demo/domain/User.groovy[]
----

Unlike standard GORM we annotate our domain classes with the `@Entity` annotation so that
Expand Down
28 changes: 14 additions & 14 deletions src/main/docs/guide/creatingTheServices.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Next lets create our service layer for our application.

[source,bash]
----
$ cd src/main/groovy/demo/GORMwithoutGrails/service
$ cd src/main/groovy/demo/service
$ touch MakeService
$ touch MakeServiceImpl
$ touch ModelService
Expand All @@ -11,45 +11,45 @@ Next lets create our service layer for our application.
$ touch VehicleServiceImpl
----

Now let’s edit our service classes under src/main/groovy/demo/GORMwithoutGrails/service.
Now let’s edit our service classes under src/main/groovy/demo/service.
We’ll add a `list()` method to all of the classes. This method will have the following additional annotation.

- @Transactional(readOnly = true) - good practice to have on methods that only return data
[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/service/MakeService.groovy
./src/main/groovy/demo/service/MakeService.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/service/MakeService.groovy[]
include::{sourceDir}/src/main/groovy/demo/service/MakeService.groovy[]
----

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/service/MakeServiceImpl.groovy
./src/main/groovy/demo/service/MakeServiceImpl.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/service/MakeServiceImpl.groovy[]
include::{sourceDir}/src/main/groovy/demo/service/MakeServiceImpl.groovy[]
----

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/service/ModelService.groovy
./src/main/groovy/demo/service/ModelService.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/service/ModelService.groovy[]
include::{sourceDir}/src/main/groovy/demo/service/ModelService.groovy[]
----

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/service/ModelServiceImpl.groovy
./src/main/groovy/demo/service/ModelServiceImpl.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/service/ModelServiceImpl.groovy[]
include::{sourceDir}/src/main/groovy/demo/service/ModelServiceImpl.groovy[]
----

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/service/VehicleService.groovy
./src/main/groovy/demo/service/VehicleService.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/service/VehicleService.groovy[]
include::{sourceDir}/src/main/groovy/demo/service/VehicleService.groovy[]
----

[source,groovy]
./src/main/groovy/demo/GORMwithoutGrails/service/VehicleServiceImpl.groovy
./src/main/groovy/demo/service/VehicleServiceImpl.groovy
----
include::{sourceDir}/src/main/groovy/demo/GORMwithoutGrails/service/VehicleServiceImpl.groovy[]
include::{sourceDir}/src/main/groovy/demo/service/VehicleServiceImpl.groovy[]
----

Additionally all our service classes make use of the `@Service('someName')` annotation.
Expand Down
Loading

0 comments on commit 875ee9b

Please sign in to comment.