Create my own GORM implementation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

Create my own GORM implementation

barnesjd
I would like to create my own implementation of GORM to treat a resource that I have as a database.  I haven't successfully identified any guides or documentation on how to go about this.  The closest I have found is this supposed Step-by-Step guide.  I'm not confident that this is what I'm looking for.  

Have any of you guys written a GORM implementation that can help me out here?

Thanks!

Joe
Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

Jonathan Rosenberg-2
Without knowing any details, I'm thinking that what you really want to do is implement your own datasource (or jdbc driver) or other lower level abstraction and get GORM for free.

What is the underlying resource?

Jonathan Rosenberg
Founder & Executive Director
Tabby's Place, a Cat Sanctuary
http://www.tabbysplace.org/


On Jul 18, 2012, at 4:13 PM, barnesjd <[hidden email]> wrote:

> I would like to create my own implementation of GORM to treat a resource that
> I have as a database.  I haven't successfully identified any guides or
> documentation on how to go about this.  The closest I have found is this
> supposed
> http://springsource.github.com/grails-data-mapping/manual/guide/6.%20Creating%20a%20GORM%20implementatio%20Step%20by%20Step.html
> Step-by-Step guide .  I'm not confidthat this is what I'm looking for.  
>
> Have any of you guys written a GORM implementation that can help me out
> here?
>
> Thanks!
>
> Joe
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Create-my-own-GORM-implementation-tp4631780.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

barnesjd
You may be right.  It's definitely the data source that I want to implement.  The source of my data is a collection of network devices which communicate via CLI.  My grails application will basically be a CLI-to-HTML converter.  Initially I have played with handling the CLI in services, but I think it makes a little more sense to treat it as a database.
Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

barnesjd
Well... maybe that isn't enough.  My idea is much more like a NoSQL datasource.  After looking around at the APIs, I think the approach you suggested assumes that my datasource is SQL.  Help me understand if I am wrong.
Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

Jonathan Rosenberg-2
I was thinking the same thing after I sent the reply.  GORM uses Hibernate underneath, so you'd have to support SQL, unless I'm missing something.

--
Jonathan Rosenberg
Founder & Executive Director
Tabby's Place, a Cat Sanctuary
http://www.tabbysplace.org/


On Jul 18, 2012, at 4:47 PM, barnesjd <[hidden email]> wrote:

> Well... maybe that isn't enough.  My idea is much more like a NoSQL
> datasource.  After looking around at the APIs, I think the approach you
> suggested assumes that my datasource is SQL.  Help me understand if I am
> wrong.
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Create-my-own-GORM-implementation-tp4631780p4631787.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

barnesjd
I definitely don't want to do SQL.  That wouldn't make much sense at all.  

I'm going to play with those instructions and see if I'm headed down the right path.  I've used Grails a good bit to play with creating web applications, but I've not delved into anything this advanced yet.
Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

bksaville
The grails data mapping project is probably the right place to look, although it tends to me more complicated than you'd want to do for a simple GORM implementation I believe (from what I've seen).  I'd pick one implementation in there and go with it, such as Mongo or Redis, and copy out the portions that are relevant for grails itself.

My 2c
-Brian

On Wed, Jul 18, 2012 at 3:34 PM, barnesjd <[hidden email]> wrote:
I definitely don't want to do SQL.  That wouldn't make much sense at all.

I'm going to play with those instructions and see if I'm headed down the
right path.  I've used Grails a good bit to play with creating web
applications, but I've not delved into anything this advanced yet.

--
View this message in context: http://grails.1312388.n4.nabble.com/Create-my-own-GORM-implementation-tp4631780p4631794.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

barnesjd
bksaville wrote
[...] and copy out the portions that are relevant for grails itself.
Ah.... so there is more to GORM than Grails needs.  Good to know.
Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

bksaville
I should clarify - there is more to the grails data mapping project than grails needs.  GORM is an interface (as I understand it) including the methods and such to retrieve and query for objects.  All you need to do (I make it sound so simple, don't I?) is implement the interfaces and beans needed to register your implementation as another type of GORM implementation, so that you could you 'static mapWith = "myCustomGORM"' or something similar in your domain classes.

As I've seen things in the mongo plugin, you need not implement the entire GORM interface but can throw exceptions or mark things as unsupported somehow.  ie you probably do not want to support executeQuery since that depends on HQL, but you may want criteria queries.

HTH,
-Brian

On Wed, Jul 18, 2012 at 3:46 PM, barnesjd <[hidden email]> wrote:

bksaville wrote
>
> [...] and copy out the portions that are relevant for grails itself.
>

Ah.... so there is more to GORM than Grails needs.  Good to know.

--
View this message in context: http://grails.1312388.n4.nabble.com/Create-my-own-GORM-implementation-tp4631780p4631797.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

Graeme Rocher
Administrator
In reply to this post by barnesjd
The guide you point out is the correct process for creating a GORM
implementation. There are several sub projects at

https://github.com/SpringSource/grails-data-mapping

for mongodb, neo4j, redis etc. that should provide examples of how it
is done. Also see the plugins in the grails-plugins/ directory for how
to setup a GORM impl for use in a Grails application

Cheers

On Wed, Jul 18, 2012 at 10:13 PM, barnesjd <[hidden email]> wrote:

> I would like to create my own implementation of GORM to treat a resource that
> I have as a database.  I haven't successfully identified any guides or
> documentation on how to go about this.  The closest I have found is this
> supposed
> http://springsource.github.com/grails-data-mapping/manual/guide/6.%20Creating%20a%20GORM%20implementatio%20Step%20by%20Step.html
> Step-by-Step guide .  I'm not confident that this is what I'm looking for.
>
> Have any of you guys written a GORM implementation that can help me out
> here?
>
> Thanks!
>
> Joe
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Create-my-own-GORM-implementation-tp4631780.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource - A Division of VMware
http://www.springsource.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

barnesjd
Sorry for the late reply, but I just now got back to this project.  I've gone through the tutorial and stubbed out implementations of the required abstract classes.  I'm ready to begin running the tests but... the developer guide doesn't give any hints as to how to run the test suite.  Can one of you point me in the right direction?

Thanks,
Joe
Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

barnesjd
Ok, I think I found what I needed while stumbling through the code.  This appears to run the GORM test suite for neo4j (for instance):
gradlew grails-datastore-gorm-neo4j:test

Interesting to note that it has failed 2 tests thus far...

I'm still not solid on how to set up my plugin project, but at least I can get rolling with implementing GORM.
Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

barnesjd
I am under the impression that I am making progress now.  However, I'm still hung up on the plugin development.  I haven't figured out how to make my plugin project see my datasource code.  Any help will be much appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

sergiomichels
You mean use your datasource implementation as the datasource bean used by the application / plugin?

On Tue, Aug 14, 2012 at 4:34 PM, barnesjd <[hidden email]> wrote:
I am under the impression that I am making progress now.  However, I'm still
hung up on the plugin development.  I haven't figured out how to make my
plugin project /see/ my datasource code.  Any help will be much appreciated.



--
View this message in context: http://grails.1312388.n4.nabble.com/Create-my-own-GORM-implementation-tp4631780p4633203.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

barnesjd
Yeah, I think that's the problem.  It's possible that I am misunderstanding how this whole thing is put together.  There is a datasource project that gets built with gradle.  Then there is a separate plugin project that I think is supposed to package up the gorm/datasource implementation.  Finally, of course, I'll have an application which uses the plugin.

I'd say the biggest problem I'm facing is the ability to write tests for my datasource code.  There are loads of spock tests available for datasource development, but they're too coarse grained for me to make good progress.  I need to be able to define unit tests for each part that I have to implement so I can TDD my way through the implementation.   I was attempting to write JUnit tests (since I am not at all familiar with Spock) in my plugin project to exercise the datasource code.
Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

sergiomichels
I'm not familiar with the implementations, but looking at the mongoDB plugin I think that what will give you some light is the *GrailsPlugin.groovy. Particularly the "doWithSpring" and "doWithDynamicMethods".

def doWithSpring = new MongoSpringConfigurer().getConfiguration()

If you see the MongoSpringConfigurer class, you will find the custom spring beans. And MongoMethodsConfigurer I think will configure the methods to your classes.




On Tue, Aug 14, 2012 at 5:38 PM, barnesjd <[hidden email]> wrote:
Yeah, I think that's the problem.  It's possible that I am misunderstanding
how this whole thing is put together.  There is a datasource project that
gets built with gradle.  Then there is a separate plugin project that I
/think/ is supposed to package up the gorm/datasource implementation.
Finally, of course, I'll have an application which uses the plugin.

I'd say the biggest problem I'm facing is the ability to write tests for my
datasource code.  There are loads of spock tests available for datasource
development, but they're too coarse grained for me to make good progress.  I
need to be able to define unit tests for each part that I have to implement
so I can TDD my way through the implementation.   I was attempting to write
JUnit tests (since I am not at all familiar with Spock) in my plugin project
to exercise the datasource code.



--
View this message in context: http://grails.1312388.n4.nabble.com/Create-my-own-GORM-implementation-tp4631780p4633209.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

barnesjd
Cool I'll take a look at that.

Is it immediately apparent to you how I can add tests to the datastore code?  I know that I can add more spock specifications which will test my entire datastore, but I'd really like to add some JUnit tests for my code so I can break it down into smaller pieces.

Thanks for the help!
Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

sergiomichels
Sorry, I'm new in tests, but maybe the folks came with some idea. Let's wait and see if something comes.


On Tue, Aug 14, 2012 at 6:57 PM, barnesjd <[hidden email]> wrote:
Cool I'll take a look at that.

Is it immediately apparent to you how I can add tests to the datastore code?
I know that I can add more spock specifications which will test my entire
datastore, but I'd really like to add some JUnit tests for my code so I can
break it down into smaller pieces.

Thanks for the help!



--
View this message in context: http://grails.1312388.n4.nabble.com/Create-my-own-GORM-implementation-tp4631780p4633222.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Create my own GORM implementation

barnesjd
In reply to this post by barnesjd
I figured out how to add a Spock Specification.  It just needs to be dropped into the grails.gorm.tests package.  The Gradle script seems to pick it up from there.