coryhacking / gorm-couchdb

CouchDB plugin for Grails.
Apache License 2.0
16 stars 3 forks source link

grails generate-all <DomainClass> not working with @CouchEntity #1

Open indoos opened 14 years ago

indoos commented 14 years ago

generate-all is currently not generating the views/controller for domain classes with @CouchEntity. You can use generate-all only after commenting out @CouchEntity. The javascript CouchDB views then need to be manually created. It would be good to have generate-all generate the scaffold including the javascripts.

Also, could not get dynamic finders working. I could only run existing finders/list for javascript queries alerady existing in couchdb

env- grails 1.1.1, trip-planner download

BTW, great work!!

jkuehn commented 14 years ago

Possible solution with scripts/_Events.groovy:

/**
 * Make generate-* work
 */
def doinGenerateAction = false // hacky hack
def tweakForGenerate = {
  doinGenerateAction = true
}
// use following two events to mark that we are currently generating
eventUberGenerateStart = tweakForGenerate
eventGenerateForOneStart = tweakForGenerate

/**
 * register artefacts as Domains here, so that we are modifying the same
 * grailsApp that is used to find domainClasses for generation
 */
eventConfigureAppEnd = {
  if (doinGenerateAction) {
    grailsApp.CouchDomainClasses.each {
      grailsApp.addArtefact(DomainClassArtefactHandler.TYPE, it)
    }
  }
}