Commit bdb58f1c authored by Kevin Deldycke's avatar Kevin Deldycke

Fix ID handling in category importing tool. Now the 4 category tree...

Fix ID handling in category importing tool. Now the 4 category tree representation (described in the openoffice example file) can be imported.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11006 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f5ae9193
...@@ -127,7 +127,7 @@ for table_name in spreadsheets.keys():\n ...@@ -127,7 +127,7 @@ for table_name in spreadsheets.keys():\n
\n \n
# Get the header of the table\n # Get the header of the table\n
columns_header = spreadsheets[table_name][0]\n columns_header = spreadsheets[table_name][0]\n
# Get the mapping to help us to know the property according a cell index\n # Get the mapping to help us know the property according a cell index\n
property_map = {}\n property_map = {}\n
column_index = 0\n column_index = 0\n
path_index = 0\n path_index = 0\n
...@@ -192,13 +192,15 @@ for table_name in spreadsheets.keys():\n ...@@ -192,13 +192,15 @@ for table_name in spreadsheets.keys():\n
# Returned cell_id can be None or \'\' (empty string). Both have different meaning:\n # Returned cell_id can be None or \'\' (empty string). Both have different meaning:\n
# None : no data was inputed by the user.\n # None : no data was inputed by the user.\n
# \'\' : data entered by the user, but no good transformation of the string to a safe ID.\n # \'\' : data entered by the user, but no good transformation of the string to a safe ID.\n
# In case of an empty string, we should use the title as path id if present.\n
\n \n
# If the cell_id tranformation return anything, and if the cell is a path item,\n # If the cell_id tranformation return an empty string, and if the cell is a path item,\n
# we should try to use the line title (if exist) as basic info to get the safe id.\n # we should try to use other line data to get a safe id.\n
if cell_id == \'\' and property_id.startswith(\'path_\'):\n if cell_id == \'\' and property_id.startswith(\'path_\'):\n
if line_data.has_key(\'title\'):\n for alt_id_source in [\'id\', \'title\']:\n
cell_id = getIDFromString(line_data[\'title\'])\n if line_data.has_key(alt_id_source):\n
cell_id = getIDFromString(line_data[alt_id_source])\n
if cell_id not in (\'\', None):\n
break\n
\n \n
# Ignore empty cells\n # Ignore empty cells\n
if cell_id not in (\'\', None):\n if cell_id not in (\'\', None):\n
...@@ -223,9 +225,11 @@ for table_name in spreadsheets.keys():\n ...@@ -223,9 +225,11 @@ for table_name in spreadsheets.keys():\n
break\n break\n
category_properties[\'path\'] = \'/\'.join([base_category_id,] + absolut_path_element_list[::-1])\n category_properties[\'path\'] = \'/\'.join([base_category_id,] + absolut_path_element_list[::-1])\n
\n \n
# If no title, get it from raw cell value\n # Save the current raw path item value as title if no title column defined\n
if \'title\' not in category_properties.keys():\n if \'title\' not in category_properties.keys():\n
clean_title = cell_data.strip()\n clean_title = cell_data.strip()\n
# Only set title if it look like a title\n
# (i.e. its tranformation to ID is not the same as the original value)\n
if clean_title != cell_id:\n if clean_title != cell_id:\n
category_properties[\'title\'] = clean_title\n category_properties[\'title\'] = clean_title\n
\n \n
...@@ -269,7 +273,7 @@ for table_name in spreadsheets.keys():\n ...@@ -269,7 +273,7 @@ for table_name in spreadsheets.keys():\n
\n \n
# Set the category properties\n # Set the category properties\n
for key in keys:\n for key in keys:\n
if key != \'path\':\n if key not in [\'path\', \'id\']:\n
setter_method_id = "set" + convertToUpperCase(key)\n setter_method_id = "set" + convertToUpperCase(key)\n
getter_method_id = "get" + convertToUpperCase(key)\n getter_method_id = "get" + convertToUpperCase(key)\n
value = category[key]\n value = category[key]\n
...@@ -384,6 +388,7 @@ return context.REQUEST.RESPONSE.redirect(\n ...@@ -384,6 +388,7 @@ return context.REQUEST.RESPONSE.redirect(\n
<string>category_properties</string> <string>category_properties</string>
<string>cell_data</string> <string>cell_data</string>
<string>cell_id</string> <string>cell_id</string>
<string>alt_id_source</string>
<string>path_element_id</string> <string>path_element_id</string>
<string>absolut_path_element_list</string> <string>absolut_path_element_list</string>
<string>int</string> <string>int</string>
......
...@@ -201,7 +201,7 @@ ...@@ -201,7 +201,7 @@
<key> <string>default</string> </key> <key> <string>default</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
<ul><li>An OpenOffice file is available at <a href="portal_skins/erp5_core/erp5_import_category_tree_examples.sxc">/portal_skins/erp5_core/erp5_import_category_tree_examples.sxc</a> . It contain different examples of how to input a tree of categories.</li><li>Do not merge cells in the uploaded spreadsheet: this will confuse the parser and produce unpredictible results.</li><li>Do not use category IDs which are defined in Property Sheets as property. ERP5 is currently not able to make the difference between a subobject ID and a property ID. This bug must be fixed.</li><li>Even if this tool was designed to import OpenOffice v1.x documents, OASIS OpenDocument files seems to work as well.</li></ul> <ul><li>An OpenOffice file is available at <a href="portal_skins/erp5_core/erp5_import_category_tree_examples.sxc">/portal_skins/erp5_core/erp5_import_category_tree_examples.sxc</a> . It contain different examples of how to input a tree of categories. Each sheet title will be used as Base Category.</li><li>Do not merge cells in the uploaded spreadsheet: this will confuse the parser and produce unpredictible results.</li><li>Do not use category IDs which are defined in Property Sheets as property. ERP5 is currently not able to make the difference between a subobject ID and a property ID. This bug must be fixed.</li><li>Even if this tool was designed to import OpenOffice v1.x documents, OASIS OpenDocument files seems to work as well.</li><li>This tool is not intrusive: if an existing category tree is found, it will update each category but will not try to remove any one.</li></ul>
]]></string> </value> ]]></string> </value>
</item> </item>
......
2006-10-30 Kevin
* Fix ID handling in category importing tool. Now the 4 category tree representation (described in the openoffice example file) can be imported.
2006-10-04 Kevin 2006-10-04 Kevin
* Add Tips on category import fast input screen to help user. * Add Tips on category import fast input screen to help user.
......
126 128
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment