company logo

Property :: importData - Import data from external file

The function imports data to the current property from an external file. Data can be imported as XML, CSV (ESDF) or OIF file. The import format type will be derived from the file extension.

  • . xml - import from an XML file
  • . csv - import data from comma separated file (CSV)
  • . esdf - import data from extended self delimiter format (ESDF)
  • . oif - import object interchange format (OIF)

The data structure provided with the import file can be described in the file header. All file formats allow preceding the file by built-in file description and assignment rules. When the extension differs from the extensions above, the file content is analyzed in order to determine the file type. This is nearly save, but it cannot be guaranteed that it works properly, always.

The structure of the import file must define an instance collection, i.e. a set of one or more instance definitions according to the syntax of the import format. Passing invalid import files may damage the data. Data will be imported for the current collection. When the collection is weak-typed, instances have to be preceded by type name. In this case, one must not use CSV or ESDF format.

Only data passed in the import file will be overwritten. Properties not contained in the import file or not containing a value in the import file (OIF and XML) remain unchanged.

The function uses standard data exchange functionality for importing data, i.e. it should mainly be used for importing files that have been created with exportData() . More sophisticated data exchange facilities are provided with the fromFile OSI operation or the Property ::storeData() function.

// OIF import file

DATA { instance1, instance2, ... };

Notes:

When running import/export in a client/server environment, the file name passed in sFilePath has to be a symbolic file name which is defined in the file catalog on client and server side. The export/import is executed on server. The source is transferred before to the server location defined in the server's file catalog.

Implementation overview

Implementation details

  1. Import all data
    Property  :: importData ( odaba::String &sFilePath )

    The function imports all data passed in the import file. This includes data for instance attributes, but also data referenced in instance collections (references or relationships). When the file contains instances linked to relationships of other instances, a two phase import should be started in order to create instances before creating links, which may cause problems in some cases.

    In order to perform a two phase copy, the function needs to be called twice with different copy options:

    importData( sFilePath , CopyLocal );

    importData( sFilePath , CopyRelationships );

    • sFilePath - Complete file path
  2. to list
  3. Import data by copy type
    Property  :: importData ( odaba::String &sFilePath, odaba::CopyTypes eCopyType )

    In order to limit the amount of data to be imported, a copy type might be passed in eCopyType . Passing CopyAll or CopyDeep works exactly the same way as calling the function without copy type.

    Passing CopyInstances copies instance data (attributes and text references) for instances directly stored in collection. It does not copy any data for instances referenced in references (except text references) and relationships.

    Passing CopyLocal will import instance data for collection instances, but also for instances in referenced and owning relationships (recursively).

    CopyRelationships might be passed in order to copy links in not owning relationships (recursively).

    Calling the import function twice, first with copy type CopyLocal and with CopyRelationships afterwards will perform the two phase copy,

    • sFilePath - Complete file path
    • eCopyType - Copy type

      The copy type defines the amount of data to be copied or exported.

  4. to list