pax_global_header 0000666 0000000 0000000 00000000064 12337622273 0014521 g ustar 00root root 0000000 0000000 52 comment=bc995038eb0b16271b9d58a51318c3934ae4f0f2
intranet-csv-import-v4-1-0-0-0/ 0000775 0000000 0000000 00000000000 12337622273 0016126 5 ustar 00root root 0000000 0000000 intranet-csv-import-v4-1-0-0-0/catalog/ 0000775 0000000 0000000 00000000000 12337622273 0017540 5 ustar 00root root 0000000 0000000 intranet-csv-import-v4-1-0-0-0/catalog/intranet-csv-import.en_US.ISO-8859-1.xml 0000664 0000000 0000000 00000000424 12337622273 0026421 0 ustar 00root root 0000000 0000000
\n$err" ad_script_abort } # Extract the header line from the file set lines [split $lines_content "\n"] if {"" == $lines} { ad_return_complaint 1 "You didn't select a file in the screen before." } set separator [im_csv_guess_separator $lines] # ad_return_complaint 1 $separator set lines_len [llength $lines] set header [lindex $lines 0] set headers [im_csv_split $header $separator] set header_len [llength $headers] set values_lol [im_csv_get_values $lines_content $separator] # Check if there are lines with less then 4 elements # set error [im_csv_import_check_list_of_lists $values_lol] # if {"" != $error} { ad_return_complaint 1 $error } # Take a sample of max_row rows from the file and show set max_row 10 for {set i 1} {$i <= $max_row} {incr i} { set row_$i [im_csv_split [lindex $lines $i] $separator] } # Get the list of all available fields for the object_type set object_fields [im_csv_import_object_fields -object_type $object_type] # Determine the list of parsers for the object_type set parser_pairs [im_csv_import_parsers -object_type $object_type] # --------------------------------------------------------------------- # Create and fill the multirow # --------------------------------------------------------------------- # Setup the multirow with some sample rows multirow create mapping field_name column map parser parser_args for {set i 1} {$i < $max_row} {incr i} { multirow extend mapping "row_$i" } set object_type_pairs [list "" ""] foreach field $object_fields { lappend object_type_pairs [string tolower $field] [string tolower $field] } lappend object_type_pairs "hard_coded" "Hard Coded Functionality" set cnt 0 foreach header_name $headers { ns_log Notice "import-2: otype=$object_type, field_name=$header_name" # Column - Name of the CSV colum set column "" # Parser - convert the value from CSV values to ]po[ values set parser_sample_values [list] for {set i 1} {$i <= $max_row} {incr i} { set row_name "row_$i" set val [lindex [set $row_name] $cnt] if {"" != $val} { lappend parser_sample_values $val } } set defs [im_csv_import_guess_parser -object_type $object_type -field_name $header_name -sample_values $parser_sample_values] ns_log Notice "import-2: otype=$object_type, field_name=$header_name => parser=$defs" set default_parser [lindex $defs 0] set default_parser_args [lindex $defs 1] set override_map [lindex $defs 2] set parser [im_select parser.$cnt $parser_pairs $default_parser] set args "\n" # Mapping - Map to which object field? set default_map [im_csv_import_guess_map -object_type $object_type -field_name $header_name -sample_values $parser_sample_values] if {"" != $override_map} { set default_map $override_map } set map [im_select map.$cnt $object_type_pairs $default_map] ns_log Notice "import-2: header_name=$header_name, default_map=$default_map, override_map=$override_map, map=$map" if {"hard_coded" == $default_parser} { set map [im_select map.$cnt $object_type_pairs "hard_coded"] } multirow append mapping $header_name $column $map $parser $args [lindex $row_1 $cnt] [lindex $row_2 $cnt] [lindex $row_3 $cnt] [lindex $row_4 $cnt] [lindex $row_5 $cnt] incr cnt } # Redirect to a specific page for the import switch $object_type { im_timesheet_task - im_ticket { set redirect_object_type "im_project" } default { set redirect_object_type $object_type } } intranet-csv-import-v4-1-0-0-0/www/import-im_company.tcl 0000664 0000000 0000000 00000031105 12337622273 0023121 0 ustar 00root root 0000000 0000000 # /packages/intranet-csv-import/www/import-im_company.tcl ad_page_contract { Starts the analysis process for the file imported @author frank.bergmann@project-open.com @param mapping_name: Should we store the current mapping in the DB for future use? @param column: Name of the CSV column @param map: Name of the ]po[ object attribute @param parser: Converter for CSV data type -> ]po[ data type } { { return_url "" } { upload_file "" } { import_filename "" } { mapping_name "" } { ns_write_p 1 } column:array map:array parser:array parser_args:array } # --------------------------------------------------------------------- # Default & Security # --------------------------------------------------------------------- set current_user_id [ad_maybe_redirect_for_registration] set page_title [lang::message::lookup "" intranet-cvs-import.Upload_Objects "Upload Objects"] set context_bar [im_context_bar "" $page_title] # --------------------------------------------------------------------- # Check and open the file # --------------------------------------------------------------------- if {![file readable $import_filename]} { ad_return_complaint 1 "Unable to read the file '$import_filename'.
\n$err" ad_script_abort } # Extract the header line from the file set lines [split $lines_content "\n"] set separator [im_csv_guess_separator $lines] set lines_len [llength $lines] set header [lindex $lines 0] set header_fields [im_csv_split $header $separator] set header_len [llength $header_fields] set values_list_of_lists [im_csv_get_values $lines_content $separator] # ad_return_complaint 1 "
[array get column]" # ------------------------------------------------------------ # Get DynFields # Determine the list of actually available fields. set mapped_vars [list "''"] foreach k [array names map] { lappend mapped_vars "'$map($k)'" } set dynfield_sql " select distinct aa.attribute_name, aa.object_type, aa.table_name, w.parameters, w.widget as tcl_widget, substring(w.parameters from 'category_type \"(.*)\"') as category_type from im_dynfield_widgets w, im_dynfield_attributes a, acs_attributes aa where a.widget_name = w.widget_name and a.acs_attribute_id = aa.attribute_id and aa.object_type in ('im_company') and (also_hard_coded_p is null OR also_hard_coded_p = 'f') and -- Only overwrite DynFields specified in the mapping aa.attribute_name in ([join $mapped_vars ","]) " set attribute_names [db_list attribute_names " select distinct attribute_name from ($dynfield_sql) t order by attribute_name "] # ------------------------------------------------------------ # Render Result Header if {$ns_write_p} { ad_return_top_of_page " [im_header] [im_navbar] " } # ------------------------------------------------------------ set cnt 1 foreach csv_line_fields $values_list_of_lists { incr cnt if {$ns_write_p} { ns_write "
[array get map]
[array get parser]
[array get parser_args]
$header_fields
$err\n" } } } err_msg]} { if {$ns_write_p} { ns_write "
$err_msg" } } } set $target_var_name $var_value } # ------------------------------------------------------- # Specific field transformations # company_name needs to be there if {"" == $company_name} { if {$ns_write_p} { ns_write "
$err_msg\n" } continue } } else { if {$ns_write_p} { ns_write "
$err_msg" } continue } # ------------------------------------------------------- # Import DynFields set company_dynfield_updates {} set task_dynfield_updates {} array unset attributes_hash array set attributes_hash {} db_foreach store_dynfiels $dynfield_sql { ns_log Notice "import-im_company: name=$attribute_name, otype=$object_type, table=$table_name" # Avoid storing attributes multipe times into the same table. # Sub-types can have the same attribute defined as the main type, so duplicate # DynField attributes are OK. set key "$attribute_name-$table_name" if {[info exists attributes_hash($key)]} { ns_log Notice "import-im_company: name=$attribute_name already exists." continue } set attributes_hash($key) $table_name lappend company_dynfield_updates "$attribute_name = :$attribute_name" } if {$ns_write_p} { ns_write "
$err_msg" } } } if {$ns_write_p} { ns_write "
\n"
ns_write "Return to Company Page\n"
}
# ------------------------------------------------------------
# Render Report Footer
if {$ns_write_p} {
ns_write [im_footer]
}
intranet-csv-import-v4-1-0-0-0/www/import-im_project.tcl 0000664 0000000 0000000 00000045353 12337622273 0023133 0 ustar 00root root 0000000 0000000 # /packages/intranet-csv-import/www/import-im_project.tcl
#
ad_page_contract {
Starts the analysis process for the file imported
@author frank.bergmann@project-open.com
@param mapping_name: Should we store the current mapping in the DB for future use?
@param column: Name of the CSV column
@param map: Name of the ]po[ object attribute
@param parser: Converter for CSV data type -> ]po[ data type
} {
{ return_url "" }
{ upload_file "" }
{ import_filename "" }
{ mapping_name "" }
{ ns_write_p 1 }
column:array
map:array
parser:array
parser_args:array
}
# ---------------------------------------------------------------------
# Default & Security
# ---------------------------------------------------------------------
set current_user_id [ad_maybe_redirect_for_registration]
set page_title [lang::message::lookup "" intranet-cvs-import.Upload_Objects "Upload Objects"]
set context_bar [im_context_bar "" $page_title]
set admin_p [im_is_user_site_wide_or_intranet_admin $current_user_id]
if {!$admin_p} {
ad_return_complaint 1 "Only administrators have the right to import objects"
ad_script_abort
}
# ---------------------------------------------------------------------
# Check and open the file
# ---------------------------------------------------------------------
if {![file readable $import_filename]} {
ad_return_complaint 1 "Unable to read the file '$import_filename'.
Please check the file permissions or contact your system administrator.\n"
ad_script_abort
}
set encoding "utf-8"
if {[catch {
set fl [open $import_filename]
fconfigure $fl -encoding $encoding
set lines_content [read $fl]
close $fl
} err]} {
ad_return_complaint 1 "Unable to open file $import_filename:
\n$err" ad_script_abort } # Extract the header line from the file set lines [split $lines_content "\n"] set separator [im_csv_guess_separator $lines] set lines_len [llength $lines] set header [lindex $lines 0] set header_fields [im_csv_split $header $separator] set header_len [llength $header_fields] set values_list_of_lists [im_csv_get_values $lines_content $separator] # ------------------------------------------------------------ # Get DynFields # Determine the list of actually available fields. set mapped_vars [list "''"] foreach k [array names map] { lappend mapped_vars "'$map($k)'" } set dynfield_sql " select distinct aa.attribute_name, aa.object_type, aa.table_name, w.parameters, w.widget as tcl_widget, substring(w.parameters from 'category_type \"(.*)\"') as category_type from im_dynfield_widgets w, im_dynfield_attributes a, acs_attributes aa where a.widget_name = w.widget_name and a.acs_attribute_id = aa.attribute_id and aa.object_type in ('im_project', 'im_timesheet_task') and (also_hard_coded_p is null OR also_hard_coded_p = 'f') and -- Only overwrite DynFields specified in the mapping aa.attribute_name in ([join $mapped_vars ","]) " set attribute_names [db_list attribute_names " select distinct attribute_name from ($dynfield_sql) t order by attribute_name "] # ------------------------------------------------------------ # Render Result Header if {$ns_write_p} { ad_return_top_of_page " [im_header] [im_navbar] " } # ------------------------------------------------------------ set cnt 1 foreach csv_line_fields $values_list_of_lists { incr cnt if {$ns_write_p} { ns_write "
$err\n" } } set $target_varname $res } } err_msg]} { if {$ns_write_p} { ns_write "
$err_msg" } } } } incr i } # ------------------------------------------------------- # Specific field transformations # project_name needs to be there if {"" == $project_name} { if {$ns_write_p} { ns_write "
\n$err_msg" } continue } set parent_id [lindex $result 0] set err [lindex $result 1] if {"" != $err} { if {$ns_write_p} { ns_write "
$err\n" } continue } # Status is a required field set project_status_id [im_id_from_category $project_status "Intranet Project Status"] if {"" == $project_status_id} { if {$ns_write_p} { ns_write "
$err_msg\n" } continue } } else { if {$ns_write_p} { ns_write "
$err_msg" } continue } # Add the project lead to the list of project members if {"" != $project_lead_id} { set role_id [im_biz_object_role_project_manager] im_biz_object_add_role $project_lead_id $project_id $role_id } # ------------------------------------------------------- # Make sure there is an entry in im_timesheet_tasks if the project is of type task if {$project_type_id == [im_project_type_task]} { set material_id "" if {"" != $material} { set material_id [db_string material_lookup " select min(material_id) from im_materials where ( lower(trim(material_nr)) = lower(trim(:material)) OR lower(trim(material_name)) = lower(trim(:material)) ) " -default ""] if {"" == $material_id} { if {$ns_write_p} { ns_write "
$err_msg" } } } if {$ns_write_p} { ns_write "
$err_msg" } } } if {$ns_write_p} { ns_write "
\n"
ns_write "Return to Project Page\n"
}
# ------------------------------------------------------------
# Render Report Footer
if {$ns_write_p} {
ns_write [im_footer]
}
intranet-csv-import-v4-1-0-0-0/www/import-im_risk.tcl 0000664 0000000 0000000 00000025630 12337622273 0022431 0 ustar 00root root 0000000 0000000 # /packages/intranet-csv-import/www/import-im_risk.tcl
#
ad_page_contract {
Starts the analysis process for the file imported
@author frank.bergmann@project-open.com
@param mapping_name: Should we store the current mapping in the DB for future use?
@param column: Name of the CSV column
@param map: Name of the ]po[ object attribute
@param parser: Converter for CSV data type -> ]po[ data type
} {
{ return_url "" }
{ upload_file "" }
{ import_filename "" }
{ mapping_name "" }
{ ns_write_p 1 }
column:array
map:array
parser:array
parser_args:array
}
# ---------------------------------------------------------------------
# Default & Security
# ---------------------------------------------------------------------
set current_user_id [ad_maybe_redirect_for_registration]
set page_title [lang::message::lookup "" intranet-cvs-import.Upload_Objects "Upload Objects"]
set context_bar [im_context_bar "" $page_title]
# ---------------------------------------------------------------------
# Check and open the file
# ---------------------------------------------------------------------
if {![file readable $import_filename]} {
ad_return_complaint 1 "Unable to read the file '$import_filename'.
Please check the file permissions or contact your system administrator.\n"
ad_script_abort
}
set encoding "utf-8"
if {[catch {
set fl [open $import_filename]
fconfigure $fl -encoding $encoding
set lines_content [read $fl]
close $fl
} err]} {
ad_return_complaint 1 "Unable to open file $import_filename:
\n$err" ad_script_abort } # Extract the header line from the file set lines [split $lines_content "\n"] set separator [im_csv_guess_separator $lines] set lines_len [llength $lines] set header [lindex $lines 0] set header_fields [im_csv_split $header $separator] set header_len [llength $header_fields] set values_list_of_lists [im_csv_get_values $lines_content $separator] # ad_return_complaint 1 "
[array get column]" # ------------------------------------------------------------ # Get DynFields # Determine the list of actually available fields. set mapped_vars [list "''"] foreach k [array names map] { lappend mapped_vars "'$map($k)'" } set dynfield_sql " select distinct aa.attribute_name, aa.object_type, aa.table_name, w.parameters, w.widget as tcl_widget, substring(w.parameters from 'category_type \"(.*)\"') as category_type from im_dynfield_widgets w, im_dynfield_attributes a, acs_attributes aa where a.widget_name = w.widget_name and a.acs_attribute_id = aa.attribute_id and aa.object_type in ('im_risk') and (also_hard_coded_p is null OR also_hard_coded_p = 'f') and -- Only overwrite DynFields specified in the mapping aa.attribute_name in ([join $mapped_vars ","]) " set attribute_names [db_list attribute_names " select distinct attribute_name from ($dynfield_sql) t order by attribute_name "] # ------------------------------------------------------------ # Render Result Header if {$ns_write_p} { ad_return_top_of_page " [im_header] [im_navbar] " } # ------------------------------------------------------------ set cnt 1 foreach csv_line_fields $values_list_of_lists { incr cnt if {$ns_write_p} { ns_write "
[array get map]
[array get parser]
[array get parser_args]
$header_fields
$err\n" } } } err_msg]} { if {$ns_write_p} { ns_write "
$err_msg" } } } set $target_var_name $var_value } # ------------------------------------------------------- # Specific field transformations # risk_name needs to be there if {"" == $risk_name} { if {$ns_write_p} { ns_write "
$err_msg\n" } continue } } else { if {$ns_write_p} { ns_write "
$err_msg" } continue } # ------------------------------------------------------- # Import DynFields set risk_dynfield_updates {} set task_dynfield_updates {} array unset attributes_hash array set attributes_hash {} db_foreach store_dynfiels $dynfield_sql { ns_log Notice "import-im_risk: name=$attribute_name, otype=$object_type, table=$table_name" # Avoid storing attributes multipe times into the same table. # Sub-types can have the same attribute defined as the main type, so duplicate # DynField attributes are OK. set key "$attribute_name-$table_name" if {[info exists attributes_hash($key)]} { ns_log Notice "import-im_risk: name=$attribute_name already exists." continue } set attributes_hash($key) $table_name lappend risk_dynfield_updates "$attribute_name = :$attribute_name" } if {$ns_write_p} { ns_write "
$err_msg" } } } if {$ns_write_p} { ns_write "
\n"
ns_write "Return to Risk Page\n"
}
# ------------------------------------------------------------
# Render Report Footer
if {$ns_write_p} {
ns_write [im_footer]
}
intranet-csv-import-v4-1-0-0-0/www/index.adp 0000664 0000000 0000000 00000002160 12337622273 0020546 0 ustar 00root root 0000000 0000000
intranet-csv-import-v4-1-0-0-0/www/index.tcl 0000775 0000000 0000000 00000002065 12337622273 0020573 0 ustar 00root root 0000000 0000000 # /package/intranet-core/companies/upload-companies.tcl
#
# Copyright (C) 2004 ]project-open[
#
# This program is free software. You can redistribute it
# and/or modify it under the terms of the GNU General
# Public License as published by the Free Software Foundation;
# either version 2 of the License, or (at your option)
# any later version. This program is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
ad_page_contract {
Serve the user a form to upload a new file or URL
@author Frank Bergmann (frank.bergmann@project-open.com)
@creation-date July 2003
} {
{ return_url "" }
{ object_type "" }
}
set user_id [ad_maybe_redirect_for_registration]
set page_title [lang::message::lookup "" intranet-csv-import.Upload_file "Upload File"]
set context_bar [im_context_bar "" $page_title]
set main_navbar_label [im_csv_import_label_from_object_type -object_type $object_type]
We espect that the import file contains the column names in the first row.