Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-csv-import
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-csv-import
Commits
f532697d
Commit
f532697d
authored
Feb 20, 2013
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- CSV Import of im_risk information:
Working on the importer
parent
ffeeb79d
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
655 additions
and
3 deletions
+655
-3
intranet-csv-import-procs.tcl
tcl/intranet-csv-import-procs.tcl
+79
-1
import-2.tcl
www/import-2.tcl
+6
-1
import-im_risk.tcl
www/import-im_risk.tcl
+563
-0
index.adp
www/index.adp
+7
-1
No files found.
tcl/intranet-csv-import-procs.tcl
View file @
f532697d
...
...
@@ -212,7 +212,7 @@ ad_proc -public im_csv_import_parsers {
Returns the list of available parsers
}
{
switch
$object
_type
{
im_project - im_timesheet_task - im_ticket
{
im_project - im_
risk - im_
timesheet_task - im_ticket
{
set parsers
{
no_change
"No Change"
hard_coded
"Hard Coded Functionality"
...
...
@@ -347,6 +347,84 @@ ad_proc -public im_csv_import_guess_parser {
}
# ---------------------------------------------------------------------
# Guess the most probable DynField for a column
# ---------------------------------------------------------------------
ad_proc -public im_csv_import_guess_map
{
-object_type:required
-field_name:required
{
-sample_values
{}}
}
{
Returns the best guess for a DynField for the field.
}
{
set field_name_lower
[
string
tolower
$field
_name
]
ns_log Notice
"im_csv_import_guess_map: trying to guess attribute_name for field_name=
$field
_name_lower"
set dynfield_sql
"
select lower(aa.attribute_name) as attribute_name,
lower(aa.pretty_name) as pretty_name,
w.widget as tcl_widget,
w.widget_name as dynfield_widget
from im_dynfield_attributes a,
im_dynfield_widgets w,
acs_attributes aa
where a.widget_name = w.widget_name and
a.acs_attribute_id = aa.attribute_id and
aa.object_type = '
$object
_type'
order by aa.sort_order, aa.attribute_id
"
# Check if the header name is the attribute_name of a DynField
set dynfield_attribute_names
[
util_memoize
[
list
db_list otype_dynfields
"select attribute_name from (
$dynfield
_sql) t"
]]
ns_log Notice
"im_csv_import_guess_map: attribute_names=
$dynfield
_attribute_names"
if
{[
lsearch
$dynfield
_attribute_names
$field
_name_lower
]
>= 0
}
{
ns_log Notice
"im_csv_import_guess_map: found attribute_name match with field_name=
$field
_name"
return
$field
_name_lower
}
# Check for a pretty_name of a DynField
set dynfield_pretty_names
[
util_memoize
[
list
db_list otype_dynfields
"select pretty_name from (
$dynfield
_sql) t"
]]
ns_log Notice
"im_csv_import_guess_map: pretty_names=
$dynfield
_pretty_names"
set idx
[
lsearch
$dynfield
_pretty_names
$field
_name_lower
]
if
{
$idx
>= 0
}
{
ns_log Notice
"im_csv_import_guess_map: found pretty_name match with field_name=
$field
_name"
return
[
lindex
$dynfield
_attribute_names
$idx
]
}
# set static_mapping_lol {
}
catch
{
}
set static_mapping_lol
[
im_csv_import_guess_map_$object_type
]
ns_log Notice
"im_csv_import_guess_map: static_mapping=
$static
_mapping_lol"
foreach tuple
$static
_mapping_lol
{
set attribute_name
[
lindex
$tuple
0
]
set pretty_name
[
lindex
$tuple
1
]
if
{
$field
_name_lower ==
[
string
tolower
$pretty
_name
]}
{
ns_log Notice
"im_csv_import_guess_map: found statically encoded match with field_name=
$field
_name"
return
$attribute
_name
}
else
{
ns_log Notice
"im_csv_import_guess_map:
$pretty
_name!=
$field
_name_lower"
}
}
ns_log Notice
"im_csv_import_guess_map: Did not find any match with a DynField for field_name=
$field
_name"
ns_log Notice
"im_csv_import_guess_map:"
return
""
}
ad_proc -public im_csv_import_guess_map_im_risk
{
}
{}
{
set mapping
{
{
risk_name
"Risk Name"
no_change
""
}
{
risk_project_id
"Project"
parser
""
}
{
risk_status_id
"Status"
category_parser
"Intranet Risk Status"
}
{
risk_type_id
"Type"
category_parser
"Intranet Risk Type"
}
{
risk_description
"Description"
no_change
""
}
{
risk_impact
"Impact"
parser
""
}
{
risk_probability_percent
"Probability"
parser
""
}
}
return
$mapping
}
# ---------------------------------------------------------------------
# Convert the list of parent_nrs into the parent_id
# ---------------------------------------------------------------------
...
...
www/import-2.tcl
View file @
f532697d
...
...
@@ -146,11 +146,16 @@ foreach header_name $headers {
set args
"<input type=text name=parser_args.
$cnt
value=
\"
$default
_parser_args
\"
>
\n
"
# Mapping - Map to which object field?
set default_map
[
string
tolower
$header
_name
]
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
...
...
www/import-im_risk.tcl
0 → 100644
View file @
f532697d
This diff is collapsed.
Click to expand it.
www/index.adp
View file @
f532697d
...
...
@@ -11,7 +11,13 @@
<tr>
<td>
#intranet-csv-import.Object_Type#
</td>
<td>
<
%=
[
im_select
object_type
[
list
im_project
"
Project
"
im_timesheet_task
"
Timesheet
Task
"
im_company
"
Company
"
person
"
User
"]
$
object_type
]
%
>
<
%=
[
im_select
object_type
[
list
\
im_company
"
Company
"
\
im_project
"
Project
"
\
im_risk
"
Risk
"
\
im_timesheet_task
"
Timesheet
Task
"
\
person
"
User
"
\
]
$
object_type
]
%
>
</td>
</tr>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment