Source

Texa / grails-app / services / ImportProjectService.groovy

import com.koyanainc.bc.Project

class ImportProjectService {

    boolean transactional = true

    def importXML(projects) {

    projects.project.each{project->

      def projectMap = XMLUtil.xmlToGorm(project.children())

      //These keys are indigestible by GORM as-is
      "todoLists,attachmentCategories,company,timeEntries,posts,postCategories,milestones,participants".split(',').each{
        //log.warn "\nRemoving key $it"
        projectMap.remove(it)
      }
      projectMap.each{k,v->
      log.warn "\n\tProject entry has k $k = $v"
      }


      def p  = new Project(projectMap)
      p.id = projectMap.id
      p.save(flush:true)
      //log.warn "\n\t Errors ${p.errors}"

    }
  }
}