Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 218aeb17

Von Bernd Bleßmann vor mehr als 10 Jahren hinzugefügt

  • ID 218aeb17c2e1259e60a0c9e216f3bb45404d68dd
  • Vorgänger 99601196
  • Nachfolger 964cc586

CsvImport: Feldlängen aus den Metadaten auslesen, nicht fest codieren.

Unterschiede anzeigen:

SL/Controller/CsvImport/Base.pm
465 465
}
466 466

  
467 467
sub field_lengths {
468
  return ();
468
  my ($self) = @_;
469

  
470
  return map { $_->name => $_->length } grep { $_->type eq 'varchar' } @{$self->class->meta->columns};
469 471
}
470 472

  
471 473
sub fix_field_lengths {
SL/Controller/CsvImport/BaseMulti.pm
250 250
                                     @{ $self->cvar_configs_by->{row_ident}->{$row_ident} });
251 251
}
252 252

  
253
sub field_lengths {
254
  my ($self) = @_;
255

  
256
  my %field_lengths_by_ri = ();
257

  
258
  foreach my $p (@{ $self->profile }) {
259
    my %field_lengths = map { $_->name => $_->length } grep { $_->type eq 'varchar' } @{ $p->{class}->meta->columns };
260
    $field_lengths_by_ri{ $p->{row_ident} } = \%field_lengths;
261
  }
262

  
263
  return %field_lengths_by_ri;
264
}
265

  
266
sub fix_field_lengths {
267
  my ($self) = @_;
268

  
269
  my %field_lengths_by_ri = $self->field_lengths;
270
  foreach my $entry (@{ $self->controller->data }) {
271
    next unless @{ $entry->{errors} };
272
    my %field_lengths = %{ $field_lengths_by_ri{ $entry->{raw_data}->{datatype} } };
273
    map { $entry->{object}->$_(substr($entry->{object}->$_, 0, $field_lengths{$_})) if $entry->{object}->$_ } keys %field_lengths;
274
  }
275

  
276
  return;
277
}
278

  
253 279
sub is_multiplexed { 1 }
254 280

  
255 281
1;
SL/Controller/CsvImport/Contact.pm
126 126
  };
127 127
}
128 128

  
129
sub field_lengths {
130
  return ( cp_title     => 75,
131
           cp_givenname => 75,
132
           cp_name      => 75,
133
           cp_phone1    => 75,
134
           cp_phone2    => 75,
135
           cp_gender    =>  1,
136
         );
137
}
138

  
139 129
sub setup_displayable_columns {
140 130
  my ($self) = @_;
141 131

  
SL/Controller/CsvImport/CustomerVendor.pm
214 214
  $self->SUPER::save_objects(data => $without_number);
215 215
}
216 216

  
217
sub field_lengths {
218
  return ( name           => 75,
219
           department_1   => 75,
220
           department_2   => 75,
221
           street         => 75,
222
           zipcode        => 10,
223
           city           => 75,
224
           country        => 75,
225
           contact        => 75,
226
           fax            => 30,
227
           account_number => 15,
228
           bank_code      => 10,
229
           language       => 5,
230
           username       => 50,
231
           ustid          => 14,
232
           iban           => 100,
233
           bic            => 100,
234
         );
235
}
236

  
237 217
sub init_profile {
238 218
  my ($self) = @_;
239 219

  
SL/Controller/CsvImport/Shipto.pm
88 88
  };
89 89
}
90 90

  
91
sub field_lengths {
92
  return ( shiptoname         => 75,
93
           shiptodepartment_1 => 75,
94
           shiptodepartment_2 => 75,
95
           shiptostreet       => 75,
96
           shiptozipcode      => 75,
97
           shiptocity         => 75,
98
           shiptocountry      => 75,
99
           shiptocontact      => 75,
100
           shiptophone        => 30,
101
           shiptofax          => 30,
102
         );
103
}
104

  
105 91
sub init_profile {
106 92
  my ($self) = @_;
107 93

  

Auch abrufbar als: Unified diff