Revision 0674bc84
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/DB/Helper/Mappings.pm | ||
---|---|---|
11 | 11 |
|
12 | 12 |
# these will not be managed as Rose::DB models, because they are not normalized, |
13 | 13 |
# significant changes are needed to get them done, or they were done by CRM. |
14 |
my @lxoffice_blacklist_permanent = qw(
|
|
14 |
my @kivitendo_blacklist_permanent = qw(
|
|
15 | 15 |
leads |
16 | 16 |
); |
17 | 17 |
|
18 | 18 |
# these are not managed _yet_, but will hopefully at some point. |
19 | 19 |
# if you are confident that one of these works, remove it here. |
20 |
my @lxoffice_blacklist_temp = qw(
|
|
20 |
my @kivitendo_blacklist_temp = qw(
|
|
21 | 21 |
); |
22 | 22 |
|
23 | 23 |
# tables created by crm module |
... | ... | |
29 | 29 |
ekartikel ekbon ekkunde ektext erptasten |
30 | 30 |
); |
31 | 31 |
|
32 |
my @lxoffice_blacklist = (@lxoffice_blacklist_permanent, @lxoffice_blacklist_temp, @crm_blacklist, @cash_register_blacklist);
|
|
32 |
my @kivitendo_blacklist = (@kivitendo_blacklist_permanent, @kivitendo_blacklist_temp, @crm_blacklist, @cash_register_blacklist);
|
|
33 | 33 |
|
34 | 34 |
# map table names to their models. |
35 | 35 |
# unlike rails we have no singular<->plural magic. |
36 | 36 |
# remeber: tables should be named as the plural of the model name. |
37 |
my %lxoffice_package_names = (
|
|
37 |
my %kivitendo_package_names = (
|
|
38 | 38 |
acc_trans => 'acc_transaction', |
39 | 39 |
audittrail => 'audit_trail', |
40 | 40 |
'auth.clients' => 'auth_client', |
... | ... | |
112 | 112 |
vendor => 'vendor', |
113 | 113 |
); |
114 | 114 |
|
115 |
my (%lxoffice_tables_to_packages, %lxoffice_tables_to_manager_packages, %lxoffice_packages_to_tables);
|
|
115 |
my (%kivitendo_tables_to_packages, %kivitendo_tables_to_manager_packages, %kivitendo_packages_to_tables);
|
|
116 | 116 |
|
117 | 117 |
sub get_blacklist { |
118 |
return LXOFFICE => \@lxoffice_blacklist;
|
|
118 |
return KIVITENDO => \@kivitendo_blacklist;
|
|
119 | 119 |
} |
120 | 120 |
|
121 | 121 |
sub get_package_names { |
122 |
return LXOFFICE => \%lxoffice_package_names;
|
|
122 |
return KIVITENDO => \%kivitendo_package_names;
|
|
123 | 123 |
} |
124 | 124 |
|
125 | 125 |
sub get_package_for_table { |
126 |
%lxoffice_tables_to_packages = map { ($_ => "SL::DB::" . camelify($lxoffice_package_names{$_})) } keys %lxoffice_package_names
|
|
127 |
unless %lxoffice_tables_to_packages;
|
|
126 |
%kivitendo_tables_to_packages = map { ($_ => "SL::DB::" . camelify($kivitendo_package_names{$_})) } keys %kivitendo_package_names
|
|
127 |
unless %kivitendo_tables_to_packages;
|
|
128 | 128 |
|
129 |
return $lxoffice_tables_to_packages{ $_[0] };
|
|
129 |
return $kivitendo_tables_to_packages{ $_[0] };
|
|
130 | 130 |
} |
131 | 131 |
|
132 | 132 |
sub get_manager_package_for_table { |
133 |
%lxoffice_tables_to_manager_packages = map { ($_ => "SL::DB::Manager::" . camelify($lxoffice_package_names{$_})) } keys %lxoffice_package_names
|
|
134 |
unless %lxoffice_tables_to_manager_packages;
|
|
133 |
%kivitendo_tables_to_manager_packages = map { ($_ => "SL::DB::Manager::" . camelify($kivitendo_package_names{$_})) } keys %kivitendo_package_names
|
|
134 |
unless %kivitendo_tables_to_manager_packages;
|
|
135 | 135 |
|
136 |
return $lxoffice_tables_to_manager_packages{ $_[0] };
|
|
136 |
return $kivitendo_tables_to_manager_packages{ $_[0] };
|
|
137 | 137 |
} |
138 | 138 |
|
139 | 139 |
sub get_table_for_package { |
140 |
get_package_for_table('dummy') if !%lxoffice_tables_to_packages;
|
|
141 |
%lxoffice_packages_to_tables = reverse %lxoffice_tables_to_packages unless %lxoffice_packages_to_tables;
|
|
140 |
get_package_for_table('dummy') if !%kivitendo_tables_to_packages;
|
|
141 |
%kivitendo_packages_to_tables = reverse %kivitendo_tables_to_packages unless %kivitendo_packages_to_tables;
|
|
142 | 142 |
|
143 | 143 |
my $package = $_[0] =~ m/^SL::DB::/ ? $_[0] : "SL::DB::" . $_[0]; |
144 |
return $lxoffice_packages_to_tables{ $package };
|
|
144 |
return $kivitendo_packages_to_tables{ $package };
|
|
145 | 145 |
} |
146 | 146 |
|
147 | 147 |
sub db { |
148 | 148 |
my $string = $_[0]; |
149 |
my $lookup = $lxoffice_package_names{$_[0]} ||
|
|
150 |
plurify($lxoffice_package_names{singlify($_[0])});
|
|
149 |
my $lookup = $kivitendo_package_names{$_[0]} ||
|
|
150 |
plurify($kivitendo_package_names{singlify($_[0])});
|
|
151 | 151 |
|
152 | 152 |
for my $thing ($string, $lookup) { |
153 | 153 |
|
Auch abrufbar als: Unified diff
Vorkommen von "LxOffice" (und andere Schreibweisen) durch "kivitendo" ersetzen