Source

Texa / grails-app / services / ImportClientService.groovy

Full commit
import com.koyanainc.bc.Client
import com.koyanainc.bc.Person


class ImportClientService {
    boolean transactional = true

    def importXML(clients) {
    
    clients.client.each{client->

      def clientMap = XMLUtil.xmlToGorm(client.children())
      clientMap.remove('people')    //We have to remove the 'people' key and it's associated data - not digestible by GORM

      def c  = new Client(clientMap)
      c.id = clientMap.id
      c.save(flush:true)

      client.people.person.each{person->
        def personMap = XMLUtil.xmlToGorm(person.children())

        def p = new Person(personMap)
        p.id = personMap.id
log.info "Saving person under id ${p.id} using personMap id ${personMap.id}"
        p.save(flush:true)
        c.addToPeople(p)
      }

    }
  }
}