I have a folder with many json files. I need to process these files and store them in a mysql database. In order to do that, I am trying to create a grails cmd script (since the project is using Grails 2.5.6).
So, first thing I did was: grails create-script upload-json-files
, then grails created my script that looks like this:
includeTargets << grailsScript("_GrailsInit")
target(uploadJson: "The description of the script goes here!") {
doStuff()
}
target (doStuff: "The implementation task") {
}
setDefaultTarget(uploadJson)
I want my script to get in the args the directory path with all the JSON files, take each file and proccess it, storing it in a db. In my grails project I have some domain classes and I am using GORM to retrieve and persist new objects in my database. Is it feasible to access to my domain classes in my grails scripts and use GORM methods to persist them in my db? I already tried to import my domain classes and it didn't work. And I can't find anything in the grails 2.5 docs.