{"action":"created","comment":{"url":"https://api.github.com/repos/axelor/axelor-business-suite/pulls/comments/207533545","pull_request_review_id":143166389,"id":207533545,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNzUzMzU0NQ==","diff_hunk":"@@ -0,0 +1,104 @@\n+/*\n+ * Axelor Business Solutions\n+ *\n+ * Copyright (C) 2018 Axelor (<http://axelor.com>).\n+ *\n+ * This program is free software: you can redistribute it and/or  modify\n+ * it under the terms of the GNU Affero General Public License, version 3,\n+ * as published by the Free Software Foundation.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU Affero General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Affero General Public License\n+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+ */\n+package com.axelor.apps.base.service.app;\n+\n+import com.axelor.data.csv.CSVBind;\n+import com.axelor.data.csv.CSVInput;\n+import java.io.File;\n+import java.io.FileNotFoundException;\n+import java.io.FileOutputStream;\n+import java.io.OutputStream;\n+import java.io.OutputStreamWriter;\n+import java.io.UnsupportedEncodingException;\n+import java.util.List;\n+import javax.xml.parsers.FactoryConfigurationError;\n+import javax.xml.stream.XMLOutputFactory;\n+import javax.xml.stream.XMLStreamException;\n+import javax.xml.stream.XMLStreamWriter;\n+\n+public class GenerateXmlService {\n+\n+  /* Generate Config XML and Return configFile Name */\n+  public String generateConfig(String dirPath, List<CSVInput> csvInputs) {\n+    try {\n+      String xmlFileName = DataBackupServiceImpl.configFileName;\n+      OutputStream outputStream =\n+          new FileOutputStream(new File(dirPath + File.separator + xmlFileName));\n+      XMLStreamWriter out =\n+          XMLOutputFactory.newInstance()\n+              .createXMLStreamWriter(new OutputStreamWriter(outputStream, \"utf-8\"));\n+      out.writeStartDocument();\n+      out.writeStartElement(\"csv-inputs\");\n+      out.writeAttribute(\"xmlns\", \"http://axelor.com/xml/ns/data-import\");\n+      out.writeAttribute(\"xmlns:xsi\", \"http://www.w3.org/2001/XMLSchema-instance\");\n+      out.writeAttribute(\n+          \"xsi:schemaLocation\",\n+          \"http://axelor.com/xml/ns/data-import http://axelor.com/xml/ns/data-import/data-import_5.0.xsd\");\n+      for (CSVInput csvInput : csvInputs) {\n+        generateXmlTag(out, \"input\", csvInput);\n+      }\n+      out.writeEndElement();\n+      out.writeEndDocument();\n+      out.close();\n+      return xmlFileName;\n+    } catch (FileNotFoundException\n+        | UnsupportedEncodingException\n+        | XMLStreamException\n+        | FactoryConfigurationError e) {\n+      e.printStackTrace();\n+      return null;\n+    }\n+  }\n+\n+  private void generateXmlTag(XMLStreamWriter out, String tagName, Object innerTag)\n+      throws XMLStreamException {\n+    out.writeStartElement(tagName);\n+    try {\n+      CSVInput csvInput = (CSVInput) innerTag;\n+      out.writeAttribute(\"type\", csvInput.getTypeName());\n+      out.writeAttribute(\"file\", csvInput.getFileName());\n+      if (csvInput.getSearch() != null && csvInput.getSearch().length() > 0) {\n+        out.writeAttribute(\"search\", csvInput.getSearch());\n+      }\n+      if (csvInput.isUpdate()) {\n+        out.writeAttribute(\"update\", csvInput.isUpdate() + \"\");\n+      }\n+      if (csvInput.getBindings() != null && csvInput.getBindings().size() > 0) {\n+        for (CSVBind csvBind : csvInput.getBindings()) {\n+          if (csvBind != null) {\n+            generateXmlTag(out, \"bind\", csvBind);\n+          }\n+        }\n+      }\n+    } catch (Exception e) {\n+      CSVBind csvBind = (CSVBind) innerTag;\n+      out.writeAttribute(\"column\", csvBind.getColumn());\n+      out.writeAttribute(\"to\", csvBind.getField());\n+      if (csvBind.getSearch() != null && csvBind.getSearch().length() > 0) {","path":"axelor-admin/src/main/java/com/axelor/apps/base/service/app/GenerateXmlService.java","position":92,"original_position":92,"commit_id":"cc76696c5e9f0c13172ff2c0f84f3785c44f8f8a","original_commit_id":"cc76696c5e9f0c13172ff2c0f84f3785c44f8f8a","user":{"login":"beuss","id":3670731,"node_id":"MDQ6VXNlcjM2NzA3MzE=","avatar_url":"https://avatars0.githubusercontent.com/u/3670731?v=4","gravatar_id":"","url":"https://api.github.com/users/beuss","html_url":"https://github.com/beuss","followers_url":"https://api.github.com/users/beuss/followers","following_url":"https://api.github.com/users/beuss/following{/other_user}","gists_url":"https://api.github.com/users/beuss/gists{/gist_id}","starred_url":"https://api.github.com/users/beuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beuss/subscriptions","organizations_url":"https://api.github.com/users/beuss/orgs","repos_url":"https://api.github.com/users/beuss/repos","events_url":"https://api.github.com/users/beuss/events{/privacy}","received_events_url":"https://api.github.com/users/beuss/received_events","type":"User","site_admin":false},"body":"isBlank","created_at":"2018-08-03T12:49:00Z","updated_at":"2018-08-03T12:49:29Z","html_url":"https://github.com/axelor/axelor-business-suite/pull/2238#discussion_r207533545","pull_request_url":"https://api.github.com/repos/axelor/axelor-business-suite/pulls/2238","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/axelor/axelor-business-suite/pulls/comments/207533545"},"html":{"href":"https://github.com/axelor/axelor-business-suite/pull/2238#discussion_r207533545"},"pull_request":{"href":"https://api.github.com/repos/axelor/axelor-business-suite/pulls/2238"}}},"pull_request":{"url":"https://api.github.com/repos/axelor/axelor-business-suite/pulls/2238","id":206012765,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2MDEyNzY1","html_url":"https://github.com/axelor/axelor-business-suite/pull/2238","diff_url":"https://github.com/axelor/axelor-business-suite/pull/2238.diff","patch_url":"https://github.com/axelor/axelor-business-suite/pull/2238.patch","issue_url":"https://api.github.com/repos/axelor/axelor-business-suite/issues/2238","number":2238,"state":"open","locked":false,"title":"Feature RM#12733: Add data backup and restore","user":{"login":"rch-axelor","id":40492957,"node_id":"MDQ6VXNlcjQwNDkyOTU3","avatar_url":"https://avatars3.githubusercontent.com/u/40492957?v=4","gravatar_id":"","url":"https://api.github.com/users/rch-axelor","html_url":"https://github.com/rch-axelor","followers_url":"https://api.github.com/users/rch-axelor/followers","following_url":"https://api.github.com/users/rch-axelor/following{/other_user}","gists_url":"https://api.github.com/users/rch-axelor/gists{/gist_id}","starred_url":"https://api.github.com/users/rch-axelor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rch-axelor/subscriptions","organizations_url":"https://api.github.com/users/rch-axelor/orgs","repos_url":"https://api.github.com/users/rch-axelor/repos","events_url":"https://api.github.com/users/rch-axelor/events{/privacy}","received_events_url":"https://api.github.com/users/rch-axelor/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-08-03T12:15:25Z","updated_at":"2018-08-03T12:49:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f7b8372e99e1d457a9d539291c63c5105b3992c7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/axelor/axelor-business-suite/pulls/2238/commits","review_comments_url":"https://api.github.com/repos/axelor/axelor-business-suite/pulls/2238/comments","review_comment_url":"https://api.github.com/repos/axelor/axelor-business-suite/pulls/comments{/number}","comments_url":"https://api.github.com/repos/axelor/axelor-business-suite/issues/2238/comments","statuses_url":"https://api.github.com/repos/axelor/axelor-business-suite/statuses/cc76696c5e9f0c13172ff2c0f84f3785c44f8f8a","head":{"label":"rch-axelor:dev-12733","ref":"dev-12733","sha":"cc76696c5e9f0c13172ff2c0f84f3785c44f8f8a","user":{"login":"rch-axelor","id":40492957,"node_id":"MDQ6VXNlcjQwNDkyOTU3","avatar_url":"https://avatars3.githubusercontent.com/u/40492957?v=4","gravatar_id":"","url":"https://api.github.com/users/rch-axelor","html_url":"https://github.com/rch-axelor","followers_url":"https://api.github.com/users/rch-axelor/followers","following_url":"https://api.github.com/users/rch-axelor/following{/other_user}","gists_url":"https://api.github.com/users/rch-axelor/gists{/gist_id}","starred_url":"https://api.github.com/users/rch-axelor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rch-axelor/subscriptions","organizations_url":"https://api.github.com/users/rch-axelor/orgs","repos_url":"https://api.github.com/users/rch-axelor/repos","events_url":"https://api.github.com/users/rch-axelor/events{/privacy}","received_events_url":"https://api.github.com/users/rch-axelor/received_events","type":"User","site_admin":false},"repo":{"id":142134166,"node_id":"MDEwOlJlcG9zaXRvcnkxNDIxMzQxNjY=","name":"axelor-business-suite","full_name":"rch-axelor/axelor-business-suite","owner":{"login":"rch-axelor","id":40492957,"node_id":"MDQ6VXNlcjQwNDkyOTU3","avatar_url":"https://avatars3.githubusercontent.com/u/40492957?v=4","gravatar_id":"","url":"https://api.github.com/users/rch-axelor","html_url":"https://github.com/rch-axelor","followers_url":"https://api.github.com/users/rch-axelor/followers","following_url":"https://api.github.com/users/rch-axelor/following{/other_user}","gists_url":"https://api.github.com/users/rch-axelor/gists{/gist_id}","starred_url":"https://api.github.com/users/rch-axelor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rch-axelor/subscriptions","organizations_url":"https://api.github.com/users/rch-axelor/orgs","repos_url":"https://api.github.com/users/rch-axelor/repos","events_url":"https://api.github.com/users/rch-axelor/events{/privacy}","received_events_url":"https://api.github.com/users/rch-axelor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rch-axelor/axelor-business-suite","description":"The Axelor Business Suite based on Axelor Development Kit","fork":true,"url":"https://api.github.com/repos/rch-axelor/axelor-business-suite","forks_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/forks","keys_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/teams","hooks_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/hooks","issue_events_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/issues/events{/number}","events_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/events","assignees_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/assignees{/user}","branches_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/branches{/branch}","tags_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/tags","blobs_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/git/refs{/sha}","trees_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/statuses/{sha}","languages_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/languages","stargazers_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/stargazers","contributors_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/contributors","subscribers_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/subscribers","subscription_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/subscription","commits_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/commits{/sha}","git_commits_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/git/commits{/sha}","comments_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/comments{/number}","issue_comment_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/issues/comments{/number}","contents_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/contents/{+path}","compare_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/merges","archive_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/downloads","issues_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/issues{/number}","pulls_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/pulls{/number}","milestones_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/milestones{/number}","notifications_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/labels{/name}","releases_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/releases{/id}","deployments_url":"https://api.github.com/repos/rch-axelor/axelor-business-suite/deployments","created_at":"2018-07-24T09:12:30Z","updated_at":"2018-07-24T09:12:41Z","pushed_at":"2018-08-03T12:14:29Z","git_url":"git://github.com/rch-axelor/axelor-business-suite.git","ssh_url":"git@github.com:rch-axelor/axelor-business-suite.git","clone_url":"https://github.com/rch-axelor/axelor-business-suite.git","svn_url":"https://github.com/rch-axelor/axelor-business-suite","homepage":"http://axelor.com","size":97251,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"axelor:dev","ref":"dev","sha":"9c75cb37263d4f6345c28e097a2359a2e30543bf","user":{"login":"axelor","id":5383628,"node_id":"MDEyOk9yZ2FuaXphdGlvbjUzODM2Mjg=","avatar_url":"https://avatars1.githubusercontent.com/u/5383628?v=4","gravatar_id":"","url":"https://api.github.com/users/axelor","html_url":"https://github.com/axelor","followers_url":"https://api.github.com/users/axelor/followers","following_url":"https://api.github.com/users/axelor/following{/other_user}","gists_url":"https://api.github.com/users/axelor/gists{/gist_id}","starred_url":"https://api.github.com/users/axelor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axelor/subscriptions","organizations_url":"https://api.github.com/users/axelor/orgs","repos_url":"https://api.github.com/users/axelor/repos","events_url":"https://api.github.com/users/axelor/events{/privacy}","received_events_url":"https://api.github.com/users/axelor/received_events","type":"Organization","site_admin":false},"repo":{"id":25205317,"node_id":"MDEwOlJlcG9zaXRvcnkyNTIwNTMxNw==","name":"axelor-business-suite","full_name":"axelor/axelor-business-suite","owner":{"login":"axelor","id":5383628,"node_id":"MDEyOk9yZ2FuaXphdGlvbjUzODM2Mjg=","avatar_url":"https://avatars1.githubusercontent.com/u/5383628?v=4","gravatar_id":"","url":"https://api.github.com/users/axelor","html_url":"https://github.com/axelor","followers_url":"https://api.github.com/users/axelor/followers","following_url":"https://api.github.com/users/axelor/following{/other_user}","gists_url":"https://api.github.com/users/axelor/gists{/gist_id}","starred_url":"https://api.github.com/users/axelor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axelor/subscriptions","organizations_url":"https://api.github.com/users/axelor/orgs","repos_url":"https://api.github.com/users/axelor/repos","events_url":"https://api.github.com/users/axelor/events{/privacy}","received_events_url":"https://api.github.com/users/axelor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/axelor/axelor-business-suite","description":"The Axelor Business Suite based on Axelor Development Kit","fork":false,"url":"https://api.github.com/repos/axelor/axelor-business-suite","forks_url":"https://api.github.com/repos/axelor/axelor-business-suite/forks","keys_url":"https://api.github.com/repos/axelor/axelor-business-suite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/axelor/axelor-business-suite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/axelor/axelor-business-suite/teams","hooks_url":"https://api.github.com/repos/axelor/axelor-business-suite/hooks","issue_events_url":"https://api.github.com/repos/axelor/axelor-business-suite/issues/events{/number}","events_url":"https://api.github.com/repos/axelor/axelor-business-suite/events","assignees_url":"https://api.github.com/repos/axelor/axelor-business-suite/assignees{/user}","branches_url":"https://api.github.com/repos/axelor/axelor-business-suite/branches{/branch}","tags_url":"https://api.github.com/repos/axelor/axelor-business-suite/tags","blobs_url":"https://api.github.com/repos/axelor/axelor-business-suite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/axelor/axelor-business-suite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/axelor/axelor-business-suite/git/refs{/sha}","trees_url":"https://api.github.com/repos/axelor/axelor-business-suite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/axelor/axelor-business-suite/statuses/{sha}","languages_url":"https://api.github.com/repos/axelor/axelor-business-suite/languages","stargazers_url":"https://api.github.com/repos/axelor/axelor-business-suite/stargazers","contributors_url":"https://api.github.com/repos/axelor/axelor-business-suite/contributors","subscribers_url":"https://api.github.com/repos/axelor/axelor-business-suite/subscribers","subscription_url":"https://api.github.com/repos/axelor/axelor-business-suite/subscription","commits_url":"https://api.github.com/repos/axelor/axelor-business-suite/commits{/sha}","git_commits_url":"https://api.github.com/repos/axelor/axelor-business-suite/git/commits{/sha}","comments_url":"https://api.github.com/repos/axelor/axelor-business-suite/comments{/number}","issue_comment_url":"https://api.github.com/repos/axelor/axelor-business-suite/issues/comments{/number}","contents_url":"https://api.github.com/repos/axelor/axelor-business-suite/contents/{+path}","compare_url":"https://api.github.com/repos/axelor/axelor-business-suite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/axelor/axelor-business-suite/merges","archive_url":"https://api.github.com/repos/axelor/axelor-business-suite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/axelor/axelor-business-suite/downloads","issues_url":"https://api.github.com/repos/axelor/axelor-business-suite/issues{/number}","pulls_url":"https://api.github.com/repos/axelor/axelor-business-suite/pulls{/number}","milestones_url":"https://api.github.com/repos/axelor/axelor-business-suite/milestones{/number}","notifications_url":"https://api.github.com/repos/axelor/axelor-business-suite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/axelor/axelor-business-suite/labels{/name}","releases_url":"https://api.github.com/repos/axelor/axelor-business-suite/releases{/id}","deployments_url":"https://api.github.com/repos/axelor/axelor-business-suite/deployments","created_at":"2014-10-14T12:27:13Z","updated_at":"2018-07-31T09:32:29Z","pushed_at":"2018-08-03T12:37:54Z","git_url":"git://github.com/axelor/axelor-business-suite.git","ssh_url":"git@github.com:axelor/axelor-business-suite.git","clone_url":"https://github.com/axelor/axelor-business-suite.git","svn_url":"https://github.com/axelor/axelor-business-suite","homepage":"http://axelor.com","size":97608,"stargazers_count":90,"watchers_count":90,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":74,"mirror_url":null,"archived":false,"open_issues_count":81,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":74,"open_issues":81,"watchers":90,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/axelor/axelor-business-suite/pulls/2238"},"html":{"href":"https://github.com/axelor/axelor-business-suite/pull/2238"},"issue":{"href":"https://api.github.com/repos/axelor/axelor-business-suite/issues/2238"},"comments":{"href":"https://api.github.com/repos/axelor/axelor-business-suite/issues/2238/comments"},"review_comments":{"href":"https://api.github.com/repos/axelor/axelor-business-suite/pulls/2238/comments"},"review_comment":{"href":"https://api.github.com/repos/axelor/axelor-business-suite/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/axelor/axelor-business-suite/pulls/2238/commits"},"statuses":{"href":"https://api.github.com/repos/axelor/axelor-business-suite/statuses/cc76696c5e9f0c13172ff2c0f84f3785c44f8f8a"}},"author_association":"NONE"}}
{"actor":{"display_login":"beuss"}}