QPR Knowledge Base 2017.1

ImportElementType

ImportElementType

Previous topic Next topic No directory for this topic  

ImportElementType

Previous topic Next topic Topic directory requires JavaScript Mail us feedback on this topic!  

Revision history:

Introduced in QPR 2012.2

Last changed in QPR 2016.1

 

Imports a single element type from the source model to the currently open model. If the element type doesn't exist in the current model, it is created. If the element type exists, the functionality depends on the additional parameters. In addition, copies the model license information from the source model to the target model.

 

Synopsis:

 

PGModel.ImportElementType(Model, ElementTypeSymbol, Parameters, out Log)

 

Parameters:

 

Model: Variant. Server model ID (integer), server model name (string), or a file name (string). File name can have an absolute or a relative path. If no path is given, function tries to load the import model from the current Modeling Client default path. Also server models require the path information to be visible in the case the model is identified by a name string, so for example \\ModelName or \\folder\ModelName are valid values.

ElementTypeSymbol: String. Symbol of the imported element type in the source model. If an element type with the same symbol doesn't exist in the target model, the element type will be created and values will be set according to the parameters. If an element type with the same symbol exists, the existing one will be updated according to the parameters. The symbols for fixed types are: ET_ORGANIZATION, ET_RESOURCE, ET_GROUP, ET_CASE, ET_STORE, ET_MEASURE, ET_DOCUMENT, and ET_NOTE.

Parameters: A semicolon-separated list. Supported parameters:

UpdateProperties: Boolean. If true, the basic properties (name, description, behavior options when possible, stencil, relation definitions of a relation flow, validation settings) of the element type are updated. Default value is false.

AddAttributes: Boolean. If true, the missing custom attribute types are added to the element type. The custom attribute types that do not exist in the target model are ignored unless the "CreateMissingAttributeTypes" parameter is also used. Custom attribute types are identified by name and data type. Note that all custom attribute types must be uniquely identifiable in both the source model and the target model. Otherwise attribute types will not be correctly updated, i.e. only the first matching type is updated. "Uniquely identifiable" means that the custom attribute type names must be unique inside a data type, for example all Text attribute types names must be unique, but for example Text and Memo types can have same names. Name matching is case insensitive. If models use multilingual modeling, name matching is done using the models' default language translations. Default value is false.

SynchronizeAttributes: Boolean. If true, the target element type's custom attribute types are set to match the source element type. Attribute types that don't exist in the target model are ignored unless the "CreateMissingAttributeTypes" parameter is also used. Default value is false.

CreateMissingAttributeTypes: Boolean. If true, the custom attribute types that need to be added to the element type are added to the model if they don't exist. Default value is false.

AddHierarchies: Boolean. If true, the target model element type is added to the new hierarchies of the source model element type. If a source model hierarchy doesn't exist in the target model, it is ignored unless "CreateMissingHierarchies" parameter is also used. Default value is false.

SynchronizeHierarchies: Boolean. If true, the target model element type's custom hierarchy definitions are synchronized to match the source model element type's hierarchy definitions. If a source model hierarchy doesn't exist in the target model, it is ignored unless the "CreateMissingHierarchies" parameter is also used. Default value is false.

CreateMissingHierarchies: Boolean. If true, the hierarchies that need to be added to the element type are added to the target model if they don't exist. Default value is false.

GenerateChangeList: Boolean. If true, the out Log array is generated on all imported element types. The description is empty for those element types that have no conflict. Default value is false.

out Log: Variant array. Log is a two-dimensional variant array containing one entry for each conflict encountered in import. Each entry contains the following information:

oElement type ID in the currently open model. Integer.

oElement type ID in the imported model. Integer.

oElement type name. String.

oElement type symbol. String.

oConflict description. String.

 

Required Rights:

 

System or model administrator.

 

Return Values:

Below are listed the return values that this function can return:

 

RV_SUCCESS

RV_APPLICATION_QUIT_CALLED

RV_MODEL_NOT_OPEN

RV_NOT_ENOUGH_RIGHTS

RV_READ_ONLY_TYPES_CANNOT_MODIFY

RV_MODEL_DOES_NOT_EXIST

RV_UNSUPPORTED_FILE_TYPE

RV_CANNOT_OPEN_MODEL

RV_LOGIN_FAILED

RV_UNKNOWN_ERROR

RV_MODEL_CANNOT_BE_OPENED_WITH_CURRENT_EDITION

RV_NO_LICENSE_FOR_MODEL

RV_ELEMENT_TYPE_NOT_FOUND

RV_ELEMENT_OF_ANOTHER_TYPE_WITH_SAME_SYMBOL_EXISTS

RV_FUNCTION_CANNOT_BE_USED_IN_VALIDATION_SCRIPT

RV_CANNOT_IMPORT_FROM_DEMO_MODEL

 

Example Procedure:

 

Sub main()

 Dim i, iResult, aoLog, sLog

 iResult = PGModel.ImportElementType("G:\temp\models\source.qprdam", "SYMBOL", "UpdateProperties=True;SynchronizeAttributes=True;CreateMissingAttributeTypes=True;SynchronizeHierarchies=True;CreateMissingHierarchies=True", aoLog)

 If iResult <> 0 Then

   MsgBox "ImportElementType failed: " + PGApplication.GetErrorMessage(iResult)

 ElseIf Not (IsEmpty(aoLog) or IsNull(aoLog)) Then

   sLog = ""

   For i = 0 To ubound(aoLog)

     sLog = sLog + "Element: """ + aoLog(i,2) + """, Symbol: """ + aoLog(i,3) + """ - " + aoLog(i,4) + vbCrLf

   Next

   MsgBox "Conflicts:" + vbCrLf + sLog

 Else

   MsgBox "ImportElementType successful"

 End If

End Sub