Commit b39e58a7 authored by Frank Bergmann's avatar Frank Bergmann

- Improved conf_item import

parent 0598fa6e
......@@ -445,9 +445,18 @@ ad_proc -public im_csv_import_parser_project_parent_nrs {
set arg [string tolower [string trim $arg]]
set parent_id ""
# Shortcut: Accept the name of a project if it's found
set project_ids [db_list project_ids "select project_id from im_projects where lower(project_name) = :arg"]
if {"" ne $project_ids} {
if {1 eq [llength $project_ids]} {
return [list [lindex $project_ids 0] ""]
} else {
return [list "" "Found multiple projects with name '$arg': Please use a space separated list of project_nrs."]
}
}
# Loop through the list of parent_nrs
foreach parent_nr $arg {
set parent_sql "parent_id = $parent_id"
if {"" eq $parent_id} { set parent_sql "parent_id is null" }
set project_id [db_string pid "select project_id from im_projects where $parent_sql and lower(project_nr) = :parent_nr" -default ""]
......@@ -469,9 +478,18 @@ ad_proc -public im_csv_import_parser_conf_item_parent_nrs {
set arg [string tolower [string trim $arg]]
set parent_id ""
# Shortcut: Accept the name of a conf_item if it's found
set conf_item_ids [db_list conf_item_ids "select conf_item_id from im_conf_items where lower(conf_item_name) = :arg"]
if {"" ne $conf_item_ids} {
if {1 eq [llength $conf_item_ids]} {
return [list [lindex $conf_item_ids 0] ""]
} else {
return [list "" "Found multiple conf_items with name '$arg': Please use a space separated list of conf_item_nrs."]
}
}
# Loop through the list of parent_nrs
foreach parent_nr $arg {
set parent_sql "conf_item_parent_id = $parent_id"
if {"" eq $parent_id} { set parent_sql "conf_item_parent_id is null" }
set project_id [db_string pid "select conf_item_id from im_conf_items where $parent_sql and lower(conf_item_nr) = :parent_nr" -default ""]
......
......@@ -328,11 +328,14 @@ ad_proc -public im_csv_import_guess_im_conf_item { } {} {
{conf_item_nr "Conf Item Nr" no_change ""}
{conf_item_code "Conf Item Code" no_change ""}
{conf_item_parent_id "Parent Conf Item Nr" conf_item_parent_nrs ""}
{conf_item_parent_id "Conf Item Parent Nrs" conf_item_parent_nrs ""}
{conf_item_cost_center_id "Conf Item Cost Center Code" cost_center ""}
{conf_item_status_id "Conf Item Status" category "Intranet Conf Item Status"}
{conf_item_type_id "Conf Item Type" category "Intranet Conf Item Type"}
{conf_item_owner_id "Conf Item Owner" user_name ""}
{conf_item_owner_id "Conf Item Owner Email" user_name ""}
{conf_item_project_id "Project" project_parent_nrs ""}
{conf_item_project_id "Conf Item Project Parent Nrs" project_parent_nrs ""}
{conf_item_version "Conf Item Version" no_change ""}
{description "Description" no_change ""}
{note "Note" no_change ""}
......
......@@ -137,6 +137,7 @@ foreach csv_line_fields $values_list_of_lists {
set conf_item_cost_center_code ""
set conf_item_cost_center_id ""
set conf_item_version ""
set conf_item_project_id ""
set description ""
set note ""
......@@ -369,6 +370,12 @@ foreach csv_line_fields $values_list_of_lists {
set role_id [im_biz_object_role_full_member]
im_biz_object_add_role $conf_item_owner_id $conf_item_id $role_id
}
if {"" != $conf_item_project_id} {
if {$ns_write_p} { ns_write "<li>Adding to project #$conf_item_project_id.\n" }
im_conf_item_new_project_rel -project_id $conf_item_project_id -conf_item_id $conf_item_id
}
# -------------------------------------------------------
......
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