~fabiocbalbuquerque/sahana-agasti/web-services

« back to all changes in this revision

Viewing changes to apps/frontend/lib/util/agImportHelper.class.php

  • Committer: Chad Heuschober
  • Date: 2011-07-27 20:28:27 UTC
  • mto: (1.26.1 push-trunk)
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: chad.heuschober@mail.cuny.edu-20110727202827-8i86niktz4ua1k2s
Merged event actions. Added specStrLength comparison for ints into ImportHelper

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
  $tempTable,
24
24
  $tempTableOptions = array(),
25
25
  $importSpec = array(),
 
26
  $specStrLengths = array(),
26
27
  $requiredImportColumns = array(),
27
28
  $successColumn = '_import_success',
28
29
  $idColumn = 'id',
132
133
    $this->setImportSpec();
133
134
 
134
135
    // now add some records-keeping fields we'll need across usages
135
 
    $this->requiredImportColumns[$this->idColumn] = array('type' => 'integer',
 
136
    $this->requiredImportColumns[$this->idColumn] = array('type' => 'integer', 'length' => 20,
136
137
      'autoincrement' => true, 'primary' => true);
137
138
    $this->requiredImportColumns[$this->successColumn] = array('type' => "boolean");
138
139
 
148
149
            'your import spec declaration.';
149
150
        $this->eh->logWarning($eventMsg);
150
151
      }
 
152
 
 
153
      // string length comparison auto-magic
 
154
      if (isset($value['type']) && isset($value['length'])) {
 
155
        switch($value['type']) {
 
156
          case 'integer':
 
157
          case 'int':
 
158
            $this->specStrLengths[$cleanColumn] = 256^$value['length'];
 
159
            break;
 
160
          default:
 
161
            $this->specStrLengths[$cleanColumn] = $value['length'];
 
162
            break;
 
163
        }
 
164
      }
151
165
    }
152
166
  }
153
167
 
356
370
            $val = trim($val);
357
371
            if ($val == '' || is_null($val)) {
358
372
              $val = NULL;
359
 
            } elseif (strlen(strval($val)) > $this->importSpec[$currentSheetHeaders[$col]]['length']) {
 
373
            } elseif (strlen(strval($val)) > $this->specStrLengths[$currentSheetHeaders[$col]]) {
360
374
              $eventMsg = 'Value in sheet {' . $sheet . '} row {' . $row . '} column {' .
361
375
                  $currentSheetHeaders[$col] . '} is too long and was set to NULL.';
362
376
              $this->eh->logWarning($eventMsg);