Please enable JavaScript to view this site.

QPR Knowledge Base 2019.1

Navigation: Developer's Guide > QPR API > The Object Model > QPR Modeling > PGModel Commands

ImportTypes

Scroll Prev Top Next More

Revision history:

Introduced in QPR 2012.2

Last changed in QPR 2016.1

 

Imports element types, custom attribute types, and custom hierarchies from a source model to the currently open model. In addition, copies the model license information from the source model to the target model.

 

Synopsis:

 

PGModel.ImportTypes(Model, 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.

Parameters: A semicolon-separated list. Supported parameters:

ElementTypes: Boolean. If true, imports element types, identified by symbol and meta type. Default value false.

AttributeTypes: Boolean. If true, imports custom attribute types, identified by name and data type. Default value false. 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.

Hierarchies: Boolean. If true, imports custom hierarchy definitions, identified by symbol. Default value is false.

Add: Boolean. If true, the missing types or hierarchies are added to the meta model. Default value is false.

Update: Boolean. If true, existing types or hierarchies in the target model are updated. Default value is false. Type properties are updated (name, description, behavior options when possible, stencil, etc.). Custom attribute types linked to element types are synchronized. Hierarchy definitions are synchronized (basic properties and element types belonging to hierarchies). Note that when hierarchies are updated, if an element type that does not exist in the source model belongs to the hierarchy in the target model, the element type will not be removed from the hierarchy.

Delete: Boolean. If true, types or hierarchies that do not exist in the source meta-model are deleted from the target meta-model. Default value is false. All elements of the deleted type are also deleted from the target model. The only exception is that if current model is a base model and the deleted type is a diagram type, the elements (in this model and all child models) are changed to be the default diagram type or the first found type with Diagram behavior if this is an element type. The last diagram process step type, or the last element type with Diagram behavior cannot be removed from a base model that has child models.

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/Custom attribute type/Hierarchy ID in the currently open model. Integer.

oElement type/Custom attribute type/Hierarchy ID in the imported model. Integer.

oElement type/Custom Attribute type/Hierarchy name. String.

oElement type/Hierarchy symbol. String.

oConflict description. String.

 

Note that using the "Add", "Update", and "Delete" options at the same time with "ElementTypes", "AttributeTypes", and "Hierarchies" options, will synchronize the meta-models.

In addition, if the model is a base model that has child models, and diagram element types are deleted from the model, the model will be saved automatically.

 

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_CANNOT_IMPORT_TO_CHECKED_OUT_BASE_MODEL

RV_MODEL_HAS_TO_BE_OPEN_FOR_EXCLUSIVE_EDITING

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_FUNCTION_CANNOT_BE_USED_IN_VALIDATION_SCRIPT

RV_CANNOT_IMPORT_FROM_DEMO_MODEL

 

Example Procedure:

 

Sub main()

 Dim i, iResult, aoLog, sLog

 iResult = PGModel.ImportTypes("G:\temp\models\source.qprdam", "ElementTypes=True;AttributeTypes=True;Hierarchies=True;Add=True;Update=True;Delete=True", aoLog)

 If iResult <> 0 Then

   MsgBox "ImportTypes 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 "ImportTypes successful"

 End If

End Sub