Anonymous avatar Anonymous committed 4d57638

Added import for posts and comments.

Comments (0)

Files changed (1)

grails-app/services/ImportProjectService.groovy

         p.addToParticipants(rp)
       }
 
+      //Insert project posts and comments into db
+      project.posts.post.each{postXml->
+
+        def postMap = XMLUtil.xmlToGorm(postXml.children())
+        postMap.remove('comments')
+log.error "\n\tpostMap = ${postMap}"
+        def rp = ResponsibleParty.findById(postMap.authorId)
+
+        postMap['author'] = rp
+        def po = new Post(postMap)
+
+        po.id = postMap.id
+        po.save()
+
+        log.error("\n\tpost erorrs:${po.errors}")
+
+        postXml.comments.comment.each{commentXml->
+
+          def commentMap = XMLUtil.xmlToGorm(commentXml.children())
+log.error "\n\tComment map = >${commentMap}<"
+
+          def commentAuth = ResponsibleParty.findById(commentMap.authorId)
+if(null == commentAuth) log.error "\n\n** Null author for ${commentMap}"
+
+          commentMap['author'] = commentAuth
+
+          def co = new Comment(commentMap)
+          co.id = commentMap.id
+          co.save()
+          log.error("\n\tcomment erorrs:${co.errors}")
+
+
+          po.addToComments(co)
+        }
+
+        po.save()
+      }
+
     }
   }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.