From c10faceaf68895b040d66f190e2a00e3a900e8ae Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 27 Jan 2017 23:53:27 +0100 Subject: [PATCH] Better log message during import. Fixed SQL storage for comments. --- modules/blog/cms_blog_module.e | 4 +- .../persistence/cms_comments_storage_sql.e | 5 ++- .../node/import/cms_import_node_utilities.e | 42 ++++++------------- .../node/submodules/page/cms_page_module.e | 4 +- src/service/cms_api_import_imp.e | 2 +- 5 files changed, 22 insertions(+), 35 deletions(-) diff --git a/modules/blog/cms_blog_module.e b/modules/blog/cms_blog_module.e index 9534e7d..7c03921 100644 --- a/modules/blog/cms_blog_module.e +++ b/modules/blog/cms_blog_module.e @@ -287,9 +287,9 @@ feature -- Hooks -- Blog Already exists! -- FIXME/TODO l_entity := l_blogs.first - a_import_ctx.log (l_node_type.name + " %"" + fp.utf_8_name + "%" skipped (already exists for user #" + l_author.id.out + ")!") + a_import_ctx.log (l_node_type.name + " %"" + fp.utf_8_name + "%" SKIPPED (already exists for user #" + l_author.id.out + ")!") else - a_import_ctx.log (l_node_type.name + " %"" + fp.utf_8_name + "%" imported for user #" + l_author.id.out + ".") + a_import_ctx.log (l_node_type.name + " #" + l_entity.id.out + " imported from %"" + fp.utf_8_name + "%" for user #" + l_author.id.out + ".") l_blog_api.import_blog (l_entity) apply_taxonomy_to_node (j, l_entity, l_blog_api.cms_api) if attached {CMS_LOCAL_LINK} l_entity.link as l_link then diff --git a/modules/comments/persistence/cms_comments_storage_sql.e b/modules/comments/persistence/cms_comments_storage_sql.e index 6ce4639..374a979 100644 --- a/modules/comments/persistence/cms_comments_storage_sql.e +++ b/modules/comments/persistence/cms_comments_storage_sql.e @@ -88,6 +88,8 @@ feature -- Change if attached a_comment.parent as p then l_parameters.put (p.id, "parent") + else + l_parameters.put (0, "parent") end if attached a_comment.entity as l_entity then @@ -102,8 +104,10 @@ feature -- Change if a_comment.has_id then l_parameters.put (a_comment.id, "cid") sql_modify (sql_update_comment, l_parameters) + sql_finalize else sql_insert (sql_insert_comment, l_parameters) + sql_finalize if not has_error then a_comment.set_id (last_inserted_comment_id) end @@ -113,7 +117,6 @@ feature -- Change else sql_commit_transaction end - sql_finalize end feature {NONE} -- Implementation diff --git a/modules/node/import/cms_import_node_utilities.e b/modules/node/import/cms_import_node_utilities.e index a01d1b8..406302e 100644 --- a/modules/node/import/cms_import_node_utilities.e +++ b/modules/node/import/cms_import_node_utilities.e @@ -27,40 +27,24 @@ feature -- Comments helpers local s: STRING jp: JSON_PARSER - f: RAW_FILE l_comment: CMS_COMMENT l_log: STRING_8 do if attached {CMS_COMMENTS_API} api.module_api ({CMS_COMMENTS_MODULE}) as l_comments_api then - create f.make_with_path (fn) - if f.exists and then f.is_access_readable then - f.open_read - from - create s.make (0) - until - f.exhausted or f.end_of_file - loop - f.read_stream (1_024) - s.append (f.last_string) - end - f.close - create jp.make_with_string (s) - jp.parse_content - if jp.is_valid and then attached jp.parsed_json_value as j_comments then - if attached json_to_comments (j_comments, a_entity, l_comments_api) as l_comments then - across - l_comments as ic - loop - l_comment := ic.item - l_comments_api.save_recursively_comment (l_comment) - l_log := "comment #" + l_comment.id.out + " (count="+ l_comment.count.out +") %"" + f.path.utf_8_name + "%" imported" - l_log.append (" into " + a_entity.content_type) - if attached a_entity.identifier as l_id then - l_log.append (" #" + l_id) - end - l_log.append (" .") - a_import_ctx.log (l_log) + if attached json_value_from_location (fn) as j_comments then + if attached json_to_comments (j_comments, a_entity, l_comments_api) as l_comments then + across + l_comments as ic + loop + l_comment := ic.item + l_comments_api.save_recursively_comment (l_comment) + l_log := "comment #" + l_comment.id.out + " (count="+ l_comment.count.out +") imported from %"" + fn.utf_8_name + "%"" + l_log.append (" into " + a_entity.content_type) + if attached a_entity.identifier as l_id then + l_log.append (" #" + l_id.out) end + l_log.append (" .") + a_import_ctx.log (l_log) end end end diff --git a/modules/node/submodules/page/cms_page_module.e b/modules/node/submodules/page/cms_page_module.e index f177235..68a2d4c 100644 --- a/modules/node/submodules/page/cms_page_module.e +++ b/modules/node/submodules/page/cms_page_module.e @@ -286,7 +286,7 @@ feature -- Hooks -- Page Already exists! -- FIXME/TODO l_entity := l_pages.first - a_import_ctx.log (l_node_type.name + " %"" + fp.utf_8_name + "%" skipped (already exists for user #" + l_author.id.out + ")!") + a_import_ctx.log (l_node_type.name + " from %"" + fp.utf_8_name + "%" SKIPPED (already exists for user #" + l_author.id.out + ")!") else if attached l_entity.parent as l_parent and then @@ -298,7 +298,7 @@ feature -- Hooks l_page_api.import_page (l_entity) apply_taxonomy_to_node (j, l_entity, l_page_api.cms_api) l_new_pages.force (l_entity, l_node_api.node_path (l_entity)) - a_import_ctx.log (l_node_type.name + " %"" + fp.utf_8_name + "%" imported as "+ l_entity.id.out +" for user #" + l_author.id.out + ".") + a_import_ctx.log (l_node_type.name + " #" + l_entity.id.out + " imported from %"" + fp.utf_8_name + "%" for user #" + l_author.id.out + ".") if attached {CMS_LOCAL_LINK} l_entity.link as l_link then loc := l_node_api.node_path (l_entity) if not l_link.location.starts_with_general ("node/") then diff --git a/src/service/cms_api_import_imp.e b/src/service/cms_api_import_imp.e index fb49164..4aa47a9 100644 --- a/src/service/cms_api_import_imp.e +++ b/src/service/cms_api_import_imp.e @@ -111,7 +111,7 @@ feature -- Import if a_response.has_permissions (<<"import files">>) then - a_import_ctx.log ("Importing files roles...") + a_import_ctx.log ("Importing files ...") -- From "core" location p := a_import_ctx.location.extended ("files") if attached files_from_location (p, True) as l_files then