company logo

Property :: changeAccessKey - Set Access Key

When different indexes (orders) have been defined for a collection, one of those can be selected as current access key. The access key refers to an index by the key name that is associated with the index.

Changing the access key will reset the selection in the property handle and no instance is selected when the function returns.

When one of the access key components is a generic attribute, the access key is called generic access key. When selecting a generic access key, the generic attribute type (e.g. language) has to be passed in addition to the key name, in order to select the proper index. The generic attribute type is defined as enumeration. Thus, the generic attribute type can be passed as string (name) or integer (code).

In order to reset the access key to the default value, the function might be called without parameters.

The default access key refers to the index, which is marked explicitly as main index in the property definition. When no index is marked as such, the primary key index (when an index for the primary key is defined for the collection) or the first unique index in the list of available indexes is considered as default index.

When the property handle is not valid or the access key passed does not refer to an index, the function throws an exception.

The function returns a property reference to itself in order to be able to use the function in a property path expression.

Return value:  Property reference ( odaba::Property & )

A property handle refers to a (usually) opened property. Invalid properties may cause an exception.

Implementation overview

Implementation details

  1. Select default access key
    odaba::Property & Property  :: changeAccessKey (  )

    The function set the default access key as current order key for the collection. The default key is the key for the index explicitly marked as main index for the collection. When no index has been marked as such, the default access key is the primary key, when there is a primary key index defined for the collection or the key of the first unique index for the collection.

  2. to list
  3. Set generic access key by type name
    odaba::Property & Property  :: changeAccessKey ( odaba::String &sKeyName, odaba::String &sGenericType )

    The function sets the current access key to the generic access key passed in sKeyName. The type of generic attribute to be selected is passed as string.

      changeAccessKey("sk_title","English");

    • sKeyName - Key name

      The key name must be the name of a key defined for the given structure. Thekey name is passed as string with maximum 40 characters.

      In order to pass no key name, an empty string ( String() ) has to be passed.

    • sGenericType - Generic type name

      The type for a generic attribute is a valid value from the basic enumeration of the generic attribute. The generic type name is a valid enumerator name. An empty string indicates an undefined generic type.

  4. to list
  5. Set generic access key by type number
    odaba::Property & Property  :: changeAccessKey ( odaba::String &sKeyName, int32 iGenericType )

    The function sets the current access key to the generic access key passed in sKeyName. The type of generic attribute to be selected is passed as integer value.

      changeAccessKey("sk_title",1); // one is the enumerator code for "English"

    • sKeyName - Key name

      The key name must be the name of a key defined for the given structure. Thekey name is passed as string with maximum 40 characters.

      In order to pass no key name, an empty string ( String() ) has to be passed.

    • iGenericType - Type of generic attribute

      The type for a generic attribute is a valid value from the basic enumeration of the generic attribute. 0 indicates an undefined generic type.

  6. to list
  7. Set access key
    odaba::Property & Property  :: changeAccessKey ( odaba::String &sKeyName )

    The function changes the access key to the key passed in sKeyName.

    When the access key is a generic access key, the generic attribute type will be taken from the current setting of the generic attribute of the access key.

    • sKeyName - Key name

      The key name must be the name of a key defined for the given structure. Thekey name is passed as string with maximum 40 characters.

      In order to pass no key name, an empty string ( String() ) has to be passed.

  8. to list