Commits

Anonymous committed c387bc0

Moved calls to import services into controller. Service transactions now occur per-domain object. Faster with less memory footprint.

  • Participants
  • Parent commits a909584

Comments (0)

Files changed (2)

File grails-app/controllers/ImportController.groovy

+import grails.converters.XML
+import java.io.FileInputStream
 class ImportController {
 
-    def importXMLService
-
+    def importFirmService
+    def importClientService
+    def importProjectService
+    
+    def importTodoListsService
+    def importTimeEntryService
 
     def index = {
 
        //importXMLService.importFromFile("/Users/rmacgreg/Dropbox/Projects/basecamp/db/xml/rapportinc-20090721001012.xml")
 
 
-      //importXMLService.importFromFile()
 			log.warn "Importing from:$importFile"
-      importXMLService.importFromFile(importFile)
+      def accountXML = XML.parse(new FileInputStream(importFile), "UTF-8")
+
+      def ts = new Date(); println "Start at $ts"
+      
+      log.info "Importing Firm";      importFirmService.importXML(accountXML.firm)
+      log.info "Importing Clients";   importClientService.importXML(accountXML.clients)
+      log.info "Importing Projects";  importProjectService.importXML(accountXML.projects)
+
+      log.info "Importing TodoLists"; importTodoListsService.importXML(accountXML.projects)
+      log.info "Importing TimeEntry"; importTimeEntryService.importXML(accountXML.projects)
+
+      def te = new Date(); println "End at $te"
 
     }
 }

File grails-app/services/ImportXMLService.groovy

 
 class ImportXMLService {
 
-    boolean transactional = true
+    boolean transactional = false
 
     def importFirmService
     def importClientService