ePages 6.11.0 - DE_EPAGES/CSVExportImport/API/CSV/ObjectImportHandler.pm

Package DE_EPAGES::CSVExportImport::API::CSV::ObjectImportHandler

This module implements a handler to import objects

Base
DE_EPAGES::Presentation::API::CSV::MonitoredImportHandler
Example
use DE_EPAGES::CSVExportImport::API::CSV::ObjectImportHandler;
DE_EPAGES::CSVExportImport::API::CSV::ObjectImportHandler->importCSV($FileName, $hFileFormat, $ViewObject);

Functions

analyzeHeaderLine
attributes
baseAttributeClassAlias
drive
getUsedAttribute
headerColumn
importCSV
importLine
importObject
languages
locale
modifyUsedAttributes
readLines
startMonitor
testHeaderColumn
testMissingFields

analyzeHeaderLine

analyzes the headerline, gets the header columns via function $self->header Calls for each column function getUsedAttribute, modifyUsedAttributes. Calls function testMissingFields.

Syntax
my $hUsedAttributes = $self->analyzeHeaderLine();
Return
$hUsedAttributes (ref.hash)
properties of columns of CSV file with following keys
  • ColumnIndex | integer | index of column
    • Attribute | attribute object | object
    • Alias | alias of the attribute | string
    • AliasString | alias string of the column e.g Shoe/ShoeWeight/en | string
    • ClassAlias | alias of the attribute class e.g. Shoe | string
    • HeaderString | header string of the column e.g 'Schuh/Gewicht/English [Shoe/ShoeWeight/en]' | string
    • IsBaseClassAttribute | 0 or 1, set to 1 if attribute is from base class | boolean
    • IsObject | 0 or 1, set to 1 if Attribute IsObject | boolean
    • Type | Attribute type, e.g. LocalizedString | String
    • LanguageID | only set if Type =~ /Localized/ | Integer
    • CurrencyID | only set if Type eq 'Price' | String
    • TaxModel | 0 (==net) or 1, only set if Type eq 'Price' | Integer
    • ... additional keys may be added by function modifyUsedAttributes
    | ref.hash
  • ... additional keys may be added by function modifyUsedAttributes

attributes

return the possible Attributes

Syntax
$hhAttributes = $self->attributes;
Return
$hhAttributes (hash.hash)
Attributes

baseAttributeClassAlias

return Base AttributeClass Alias, here : 'Object'

Syntax
$self->baseAttributeClassAlias();
Return
$BaseAttributeClassAlias (string)
attribute class alias of normal attributes

drive

starts the monitor 'CSVImportMonitor', set Monitor 'Total' to $self->linesCount and starts the import of data via $self->SUPER::drive()

Syntax
$self->drive();

getUsedAttribute

return attribute info, called by analyzeHeaderLine throws Error 'UNKNOWN_ATTR' if $hHeader->{'AliasString'} isn't a key of $self->attributes call function testHeaderColumn before return $hAttribute

Syntax
$self->getUsedAttribute($HeaderString, $ColumnIndex);
Input
$HeaderString (string)
header string
$ColumnIndex (integer)
index of current column
Return
$hAttribute (ref.hash)
properties of column of CSV file with following keys
  • Attribute | attribute object | object
  • Alias | alias of the attribute | string
  • AliasString | alias string of the column e.g Shoe/ShoeWeight/en | string
  • ClassAlias | alias of the attribute class e.g. Shoe | string
  • HeaderString | header string of the column e.g 'Schuh/Gewicht/English [Shoe/ShoeWeight/en]' | string
  • IsBaseClassAttribute | 0 or 1, set to 1 if attribute is from base class | boolean
  • IsObject | 0 or 1, set to 1 if Attribute IsObject | boolean
  • Type | Attribute type, e.g. LocalizedString | String
  • LanguageID | only set if Type =~ /Localized/ | Integer
  • CurrencyID | only set if Type eq 'Price' | String
  • TaxModel | 0 (==net) or 1, only set if Type eq 'Price' | Integer

headerColumn

returns everything between[] eg: Jacket/InstructionManual/de $aHeaderParts='ARRAY(0x9943360)' [0] => 'Jacket' [1] => 'InstructionManual' [2] => 'de' used by function getUsedAttribute

Syntax
my $hHeaderInfo = $self->headerColumn($HeaderString, $Index);
Input
$HeaderString (string)
header string
$Index (integer)
index of column used for error
Return
$hHeaderInfo (ref.hash)
properties of each column of CSV file
  • HeaderParts - ref.array
  • HeaderString - header string
  • AliasString - alias string

importCSV

imports data (2 dim. array) into a file.

Syntax
$importer->importCSV($FileName, $hFormat, $aAttributes, $ViewObject);
Input
$FileName (string)
import file
$hFormat (ref.hash)
import file format, monitor
$aAttributes (ref.array of hashes)
column attributes (used for header and values)
$ViewObject (object)
object to view monitor
$aObjects (ref.array.object)
list of objects

importLine

imports one data line via function importObject, increments the monitor if $self->monitor is defined

Syntax
$self->importLine();

importObject

dummy function which have to be overwritten, gets the current line with $self->topID('Item');

Syntax
$self->importObject();

languages

return the languages for attributes

Syntax
$ahLanguages = $self->languages;
Return
$ahLanguages (array.hash)
Languages

locale

return the current Locale

Syntax
$Locale = $self->locale;
Return
$Locale (hash)
Locale

modifyUsedAttributes

possibility to change $hUsedAttributes, called by analyzeHeaderLine only dummy function here

Syntax
$self->modifyUsedAttributes($hUsedAttributes, $ColumnIndex);
Input
$hUsedAttributes (ref.hash)
used attributes
$ColumnIndex (integer)
current column

readLines

reads the content lines

Syntax
$self->readLines();

startMonitor

starts the monitor

Syntax
$self->startMonitor($PageTypeName);
Input
$PageTypeName (string)
name of pagetype

testHeaderColumn

possibility to test $hHeader, called by getUsedAttribute only dummy function here

Syntax
$self->testHeaderColumn($hAttribute, $hHeader, $ColumnIndex);
Input
$hAttribute (ref.hash)
used attribute
$hHeader (ref.hash)
current header info
$ColumnIndex (integer)
current column

testMissingFields

possibility to test for mandatory columns, called by analyzeHeaderLine only dummy function here

Syntax
$self->testMissingFields($hUsedAttributes);
Input
$hUsedAttributes (ref.hash)
used attributes