Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
redmine-sync
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
redmine-sync
Commits
24c29623
Commit
24c29623
authored
8 years ago
by
Gerhard Gonter
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:gonter/redmine-sync
parents
c4f77371
889bee0a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.textile
+0
-0
0 additions, 0 deletions
README.textile
lib/Redmine/DB/CTX.pm
+1
-1
1 addition, 1 deletion
lib/Redmine/DB/CTX.pm
lib/Redmine/DB/MySQL.pm
+42
-1
42 additions, 1 deletion
lib/Redmine/DB/MySQL.pm
lib/Redmine/Wrapper.pm
+123
-0
123 additions, 0 deletions
lib/Redmine/Wrapper.pm
with
166 additions
and
2 deletions
README.
md
→
README.
textile
+
0
−
0
View file @
24c29623
File moved
This diff is collapsed.
Click to expand it.
lib/Redmine/DB/CTX.pm
+
1
−
1
View file @
24c29623
...
...
@@ -109,7 +109,7 @@ sub get_DDL { return ($TABLE_sync_contexts, $TABLE_syncs); }
=head2 $context->init_translation()
Read the known translation table for the give synchronisation context
Read the known translation table for the give
n
synchronisation context
and keep it around.
=cut
...
...
This diff is collapsed.
Click to expand it.
lib/Redmine/DB/MySQL.pm
+
42
−
1
View file @
24c29623
...
...
@@ -98,6 +98,47 @@ sub get_all_x
$tt
;
}
sub
fetch_custom
{
my
$db
=
shift
;
my
$cfid
=
shift
;
my
$cfty
=
shift
||
'
Issue
';
my
$res
=
$db
->
get_all_x
('
custom_values
',
[
"
custom_field_id=? and customized_type=?
",
$cfid
,
$cfty
]);
$res
;
}
sub
change_custom_value
{
my
$db
=
shift
;
my
$cfid
=
shift
;
my
$cfty
=
shift
||
'
Issue
';
my
$cfref
=
shift
;
# ticket number or whatever
my
$cfrid
=
shift
;
# record id
my
$cfval
=
shift
;
my
$data
=
{
customized_type
=>
$cfty
,
customized_id
=>
$cfref
,
custom_field_id
=>
$cfid
,
value
=>
$cfval
};
print
"
change_custom_value: cfrid=[
$cfrid
]
",
join
('
',
%$data
),
"
\n
";
# return 0; # TODO: add flag to supress changes
my
$res
;
if
(
defined
(
$cfrid
))
{
$db
->
update
('
custom_values
',
$cfrid
,
$data
);
$res
=
$cfrid
;
}
else
{
$res
=
$db
->
insert
('
custom_values
',
$data
);
}
$res
;
}
sub
insert
{
my
$self
=
shift
;
...
...
@@ -153,7 +194,7 @@ sub update
}
push
(
@vals
,
$id
);
my
$ssu
=
"
UPDATE `
$table
` SET
"
.
join
('
',
map
{
$_
.
'
=?
'
}
@vars
)
.
'
WHERE id=?
';
my
$ssu
=
"
UPDATE `
$table
` SET
"
.
join
('
,
',
map
{
$_
.
'
=?
'
}
@vars
)
.
'
WHERE id=?
';
print
"
ssu=[
$ssu
]
\n
";
print
"
vals:
",
join
('
,
',
@vals
),
"
\n
";
my
$sth
=
$dbh
->
prepare
(
$ssu
);
...
...
This diff is collapsed.
Click to expand it.
lib/Redmine/Wrapper.pm
0 → 100644
+
123
−
0
View file @
24c29623
package
Redmine::
Wrapper
;
use
strict
;
use
WebService::
Redmine
;
sub
new
{
my
$class
=
shift
;
my
$obj
=
{};
bless
$obj
,
$class
;
$obj
->
set
(
@
_
);
$obj
;
}
sub
set
{
my
$obj
=
shift
;
my
%par
=
@_
;
my
%res
;
foreach
my
$par
(
keys
%par
)
{
$res
{
$par
}
=
$obj
->
{
$par
};
$obj
->
{
$par
}
=
$par
{
$par
};
}
(
wantarray
)
?
%res
:
\
%res
;
}
# TODO: attach or connect are not really good names
sub
attach
{
my
$self
=
shift
;
return
$self
->
{
_rm
}
if
(
exists
(
$self
->
{
_rm
}));
my
$rm
=
new
WebService::
Redmine
(
%
{
$self
->
{'
cfg
'}
->
{'
redmine
'}});
# print "rm: ", Dumper ($rm);
$self
->
{
_rm
}
=
$rm
;
}
sub
fixup_issue
{
my
$self
=
shift
;
my
$issue
=
shift
;
my
$par
=
shift
;
foreach
my
$key
(
keys
%$par
)
{
if
(
$key
eq
'
custom_fields
')
{
transcribe_custom_fields
(
$self
->
{'
cfg
'}
->
{'
custom_field_ids
'},
$issue
,
$par
->
{'
custom_fields
'});
}
}
}
=head1 INTERNAL FUNCTIONS
=head2 transcribe_custom_fields ($custom_field_id_mapping_table, $issue, $key_value_hashref)
transcribe custom fields from a simple key/value list in
$key_value_hashref into a hash_ref representing an issue
($issue) using a mapping table for custom field ids stored in
$custom_filed_id_mapping_table.
=cut
sub
transcribe_custom_fields
{
my
$ids
=
shift
;
my
$issue
=
shift
;
my
$kv
=
shift
;
print
"
ids:
",
main::
Dumper
(
$ids
);
$issue
->
{
custom_fields
}
=
[]
unless
(
defined
(
$issue
->
{
custom_fields
}));
my
$cf
=
$issue
->
{
custom_fields
};
my
%idx
;
for
(
my
$i
=
0
;
$i
<=
$#$cf
;
$i
++
)
{
my
$cf_i
=
$cf
->
[
$i
];
$idx
{
$cf_i
->
{'
name
'}}
=
$i
;
}
print
"
cf:
",
main::
Dumper
(
$cf
);
# update incoming custom fields
AN:
foreach
my
$an
(
keys
%$kv
)
{
unless
(
exists
(
$ids
->
{
$an
}))
{
print
"
an=[
$an
] not present in id mapping table
\n
";
next
AN
;
}
my
$new_val
=
{
'
value
'
=>
$kv
->
{
$an
},
'
id
'
=>
$ids
->
{
$an
},
'
name
'
=>
$an
,
};
if
(
exists
(
$idx
{
$an
}))
{
$cf
->
[
$idx
{
$an
}]
=
$new_val
;
}
else
{
push
(
@$cf
,
$new_val
);
# TODO: maybe we should update %idx here as well
}
}
print
"
issue:
",
main::
Dumper
(
$issue
);
}
1
;
__END__
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment