company logo

ObjectSpace :: importData - Import data from XML or OIF

The function imports data to the object space for one or more extents. Data can be imported from XML or OIF file. The import format type will be derived from the file extension.

  • oif - import object interchange format (OIF)
  • xml - import from an XML file

CSV (. csv file extension) or ESDF (. esdf file extension) file format cannot be imported into an object space, since those cannot provide extent names. In this case the ObjectSpace function importData() does nothing. If such a file contains instances of exactly one well defined collection (not weak-typed), one may import it into the collection ( Property ::importData() ).

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 object space instance, i.e. an instance definition according to the corresponding syntax with extents as properties. Passing invalid import files may damage the data. Data will be imported for all extents referenced in the import file.

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, only) remain unchanged.

// OIF import file

DATA { Extent1 { ... instances ... }, Extent2 { ... } ... };

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 data into object space
    ObjectSpace  :: importData ( odaba::String &sFilePath )

    The function imports the data from the file passed in sFileName . The intention of the function is to re-import data for an object space, which had been exported calling exportData() without copy option or CopyAll . The object space should be empty. Otherwise, existing data will be overwritten.

    Data is copied in two phases. In the first phase, object instances are imported without links to other instances. In the second phase, links are imported by using key date stored for relationships.

    In order to perform proper import for the object space, only primary relationships are imported. Database context functions should be switched off: force CONTEXT_ENABLED = NO by setting the Option before opening the DataSource or use the Database :: open () function to pass the parameter bEnableContext = false .

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

    This function might be used in order to copy reduced amount of data into the object space by passing an appropriate copy type on 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 extents. It does not copy any data for instances referenced in references (except text references) and relationships.

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

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

    Calling the import function twice, first with copy type CopyLocal and with CopyRelationships afterwards will perform the two phase copy, which is executed when using CopyAll .

    • sFilePath - Complete file path
    • eCopyType - Copy type

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

  4. to list