6.5.5 Import

Import is used to import a set of Landmarks. It accepts a set of input parameters that define the Type and data for performing the operation. It is available only in synchronous mode.

The following is an example for using Import:

getlist_output = landmark_handle.call('GetList', {'Type': u'Landmark', 
                                                 'Filter': {'LandmarkName': u'land1'}})

The following table summarizes the specification of Import:

Interface IDataSource
Description Imports a set of Landmarks.
Response Model Synchronous
Pre-condition IDataSource interface is loaded.
Post-condition The default or active database is opened for reading landmarks and categories. A default database is created, if it does not exist and is set as active.

The iterator points to the first item in the list of imported objects.
Updates the Database with the list of imported landmarks.


Input Parameters

Input parameter specifies the Type and Data of the particular landmark to import.

Table 6.102: Input parameters for Import
Name Type Range Description
Type unicode string Landmark Performs operation based on the specified content types.
Data map
[DatabaseURI]: unicode string
SourceFile: unicode string
MimeType: unicode string
NA DatabaseURI: Import landmarks to the database. If this is not specified landmarks / categories is imported to the default database.

SourceFile: Import landmarks from this file.

MimeType: Encoding algorithm.

You must specify the Mime type of the landmark content that must be parsed. Mime enables the inclusion of media other than plain text and the inclusion of several entities in one single message.

Supported Mime types:

application/vnd.nokia.landmarkcollection+xml.


Output Parameters

Output parameters contain ReturnValue. It also ErrorCode, and ErrorMessage if the operation fails. ReturnValue is an iterator to an array of Landmarks.

Table 6.103: Output parameters for Import
Name Type Range (Type: string) Description
ErrorCode int NA Service specific error code on failure of the operation.
ErrorMessage string NA Error description in Engineering English.
ReturnValue Iterable
To maps of imported Landmark.
map
Landmark. For more information, refer Key Values 6.5.8 section.
Iterator to the list of imported landmarks. For map, see Landmark in the Key Values 6.5.8 section.


Errors

The following table lists the error codes and their values:

Table 6.104: Error codes
Error code value Description
1002 Bad argument type
1003 Missing argument
1004 Service not supported
1010 Entry exists
1011 Access denied
1012 Item not found
1013 Unknown format
1017 Path not found


Error Messages

The following table lists the error messages and their description:


Table 6.105: Error messages
Error messages Description
Landmarks:Import:Type or Data is missing Indicates Type is missing or data type of Type is mismatched.
Landmarks:Import:Type is invalid Indicates that Type is not a value in the given range.
Landmarks:Import:Data is missing Indicates Data is missing or data type of Data is mismatched.
Landmarks:Import:MimeType is missing Indicates MimeType is missing or data type of MimeType is mismatched.
Landmarks:Import:SourceFile is missing Indicates SourceFile is missing or data type of SourceFile is mismatched.


Example

The following sample code illustrates how to import a set of landmarks:

import scriptext

landmark_handle = scriptext.load('Service.Landmarks', 'IDataSource')
try:
    import_output = landmark_handle.call('Import', {'Type': u'Landmark',
                                         'Data': {'SourceFile': u'c:\data\land_import.txt',
                                         'MimeType': 
                                          u'application/vnd.nokia.landmarkcollection+xml'}})
    error = import_output['ErrorCode']
    if error != 0:
        print "Error in importing landmark"
    else:
        print "Landmark imported"

except scriptext.ScriptextError, err:
    print "Error performing the operation : ", err

See About this document... for information on suggesting changes.