Grails a bootstrap process that runs whenever your app starts. Its nifty; you can configure it to do different things in different environments.
One approach is to do the following in bootstrap:
1) Read the csv file, creating Domain objects as you go.
2) For each domain object, check to see if it exists, and if not do youDomainObject.save()
thats it.
for code, something like
new File(filePath).splitEachLine(',') {fields ->
def domainObject = new YouDomainObject(
id: fields[0].trim(),
name: fields[1].trim()
)
if (domainObject.hasErrors() || domainObject.save(flush: true) == null) {
log.error("Could not import domainObject ${domainObject.errors}")
}
log.debug("Importing domainObject ${domainObject.toString()}")
}