Repository

Return to Introduction  Previous page  Next page

public Class

The Repository is the main container of all structures such as models, packages and elements. You can iteratively begin accessing the model using the Models collection. Also has some convenience methods to directly access the structures without having to locate them in the hierarchy first.

Associated table in .EAP file: <none>

Repository Attributes

Attribute

Type

Notes

Models

Collection
of type Package

Read only. Models are of type package and belong to a collection of packages. This is the top level entry point to an Enterprise Architect project file. Each model is a root node in the Project Browser window and can contain items such as views and packages. 

A model is a special form of a package; it has a ParentID of 0. By iterating through all models, you can access all the elements within the project hierarchy. You can also use the AddNew function to create a new model. A model can also be deleted, but remember that everything contained in the model is deleted as well.

Terms

Collection

Read only. The project Glossary. Each Term object is an entry in the Glossary. Add, modify and delete Terms to maintain the Glossary.

Issues

Collection

Read only. The System Issues list. Contains Issue objects, each detailing a particular issue as it relates to the project as a whole.

Authors

Collection

Read only. The system Authors collection. Contains 0 or more Author objects, each of which can be associated with, for example, elements or diagrams as the item author or owner. Use AddNew, Delete and GetAt to manage Authors.

Clients

Collection

Read only. A list of Clients associated with the project. You can modify, delete and add new Client objects using this collection.

Tasks

Collection

Read only. A list of system tasks (to do list). Each entry is a Task Item; you can  modify, delete and add new tasks.

Datatypes

Collection

Read only. The Datatypes collection. Contains a list of Datatype objects, each representing a data type definition for either data modeling or code generation purposes.

Resources

Collection

Read only. A list of available resources to assign to work items within the project. Use the add new, modify and delete functions to manage resources.

Stereotypes

Collection

Read only. The Stereotypes collection. A list of Stereotype objects that contain information in a stereotype and which elements it can be applied to. 

PropertyTypes

Collection

Read only. Collection of Property Types available to the Repository.

LibraryVersion

Long

Read only. The build number of the Enterprise Architect runtime.

LastUpdate

String

Read only. The identifier string identifying the Enterprise Architect runtime session and the timestamp for when it was set.

FlagUpdate

Boolean

Read/Write. Instructs Enterprise Architect to update the Repository with the LastUpdate value.

InstanceGUID

String

Read only: The identifier string identifying the Enterprise Architect runtime session.

ConnectionString

String

Read only. The filename/connection string of the current Repository

ObjectType

ObjectType

Read only.  Distinguishes objects referenced through the Dispatch interface

EnableUIUpdates

Boolean

Read/Write. Set this property to false to improve the performance of changes to the model; eg. bulk addition of elements to a package. To reveal the changes to the user, call Repository.RefreshModelView().

BatchAppend

Boolean

Read/Write. Set this property to true when your automation client has to rapidly insert many elements, operations, attributes and/or operation parameters. Set to false when work is complete

This can result in 10- to 20-fold improvement in adding new elements in bulk.

SuppressEADialogs

Boolean

Read/Write. Set this property in the EA_OnPostNewElement or  EA_OnPostNewConnector broadcast events to control whether Enterprise Architect should suppress showing the default properties dialogs to the user when an element or connector is newly created.

ProjectGUID

String

Read only: Returns a unique ID for the project

EnableCache

Boolean

Read/Write: An optimization for pre-loading package objects when dealing with large sets of automation objects

Repository Methods

Method

Type

Notes

OpenFile (String Filename)

Boolean 

param: Filename [ String - in ]

The filename of the Enterprise Architect project to open.  This is the main point for opening an Enterprise Architect project file from an automation client. Provide the filename of a valid Enterprise Architect project and call this to open it and work with the contained objects.

If the required project is a DBMS repository, and you have created a shortcut .EAP file containing the database connection string, you can call this shortcut file to access the DBMS repository.

You can also connect to a SQL database by passing in the connection string itself  instead of a filename. A valid connection string can be obtained from the Open Project dialog by selecting a recently opened SQL repository.

[Open Project] == link to "open_a_project.htm" help page

GetElementByID (long ElementID)

Element

param: ElementID [ long - in ]

Get a pointer to an element using an absolute reference number (local ID). This is usually found using the ElementID property of an element, and stored for later use to open an element without using the collection GetAt() function.

GetPackageByID (long PackageID)

Package

param: PackageID [ long - in ]

Get a pointer to a package using an absolute reference number (local ID). This is usually found using the PackageID property of an package, and stored for later use to open a package without using the collection GetAt() function.

GetPackageByGUID (String GUID)

Package

Returns a pointer to a package in the repository using the package's GUID reference number (global ID). This is usually found using the PackageGUID property of the package. Each package in the model also has an associated Element with the same GUID, so if you have an element with Type="Package" then you can load the package by calling:

GetPackageByGuid(Element.ElementGUID).

GetLastError () 

String 

Returns a string value describing the most recent error that occurred in relation to this object.

This function is rarely used since an exception is thrown when an error occurs.

GetDiagramByID (long DiagramID)

Diagram

param: DiagramID [ long - in ]

Get a pointer to a diagram using an absolute reference number (local ID). This is usually found using the DiagramID property of an element, and stored for later use to open an Diagram without using the collection GetAt() function.

GetReferenceList (String Type)

Reference

param: Type [ String - in ]

The list type to Get a pointer to a Reference List object. The parameter specifies the list type to get. Valid lists are: Diagram, Element, Constraint, Requirement, Connector, Status, Cardinality, Effort, Metric, Scenario, Status and Test.

GetProjectInterface ()

Project

Return a pointer to the EA.Project interface (the XML-based automation server for Enterprise Architect). Use this interface to work with Enterprise Architect using XML, and also to access utility functions for loading diagrams, running reports and so on.

Exit

 

Shut down Enterprise Architect immediately. Used by DotNET programmers where the garbage collector does not immediately release all referenced COM objects.

OpenFile2 (string FilePath, string Username, string Password)

Boolean

As for OpenFile() except enables the specification of a password.

ShowWindow(long Show)

 

param: Show [ long - in ] 

Show or hides Enterprise Architect.

GetCurrentDiagram()

Diagram

Returns selected diagram.

GetConnectorByID(long ConnectorID)

Connector

param: ConnectorID [ long - in ]

Searches the repository for a connector with matching ID.

GetTreeSelectedItem(Object SelectedItem)

ObjectType

param: SelectedItem [ Object - in ]

Used to get an object variable and type corresponding to the currently selected item in the tree view.

To use this function, create a generic object variable and pass this as the parameter.  Depending on the return type, cast it to a more specific type.

This object passed back through the parameter can be a package, element, diagram, attribute or operation object.

GetTreeSelectedPackage()

Package

Returns the package in which the currently selected tree view object is contained.

CloseAddins()

 

Called by automation controllers to ensure that Add-Ins created in .NET do not linger after all controller references to Enterprise Architect have been cleared.

AdviseElementChange (long ObjectID)

Boolean

param: ObjectID [ long - in ] 

Provides an Add-In or automation client with the ability to advise the Enterprise Architect user interface that a particular element has changed and, if it is visible in any open diagram, to reload and refresh that element for the user.

AdviseConnectorChange (long ConnectorID)

Boolean

param: ConnectorID [ long - in ] 

Provides an Add-In or automation client with the ability to advise the Enterprise Architect user interface that a particular connector has changed and if it is visible in any open diagram, to reload and refresh that connector for the user.

OpenDiagram  (long DiagramID)

Boolean

param: DiagramID [ long - in ] 

Provides a method for an automation client or Add-In to open a diagram by its ID. The diagram is added to the tabbed list of open diagrams in the main Enterprise Architect view.

CloseDiagram (long DiagramID)

Boolean

param: DiagramID [ long - in ] 

Provides a method to close a diagram (if open) by its ID in the current list of diagrams Enterprise Architect has open.

ActivateDiagram (long DiagramID)

Boolean

param: DiagramID [ long - in ] 

Provides the means to activate an already open diagram (ie. make it the active tab) in the main Enterprise Architect user interface.

SaveDiagram(long DiagramID)

Boolean

param: DiagramID [ long - in ] 

Call this to save an open diagram by its ID number. Assumes the diagram is open in the main user interface Tab list.

ReloadDiagram(long DiagramID)

Boolean

param: DiagramID [ long - in ] 

Reloads the diagram specified by ID value. This would commonly be used to refresh a visible diagram after code import/export or other batch process where the diagram requires complete refreshing.

CloseFile()

 

Closes any open file

GetTreeSelectedItemType()

ObjectType

param: none

Returns the type of object currently selected in the tree. One of:

·otDiagram
·otElement
·otPackage
·otAttribute
·otMethod

GetTechnologyVersion (string ID)

String

param: ID [ string ]

Returns the version of the MDG Technology resource with the specified technology ID.

IsTechnologyLoaded (string ID)

Boolean

param: ID [ string ]

Returns True, if the MDG Technology resource with the specified technology ID is loaded into the repository. Returns False, otherwise.

ImportTechnology(string Technology)

Boolean

param: Technology [ string ]

Installs the given MDG Technology resource into the repository. The Technology parameter represents the contents of the Technology resource file.

Returns True, if the technology is successfully loaded into the model. Returns False, otherwise.

GetCounts()

 

Returns a set of counts from a number of tables within the base Enterprise Architect  repository. These can be used to determine whether records have been added or deleted from the tables for which information is retrieved.

GetElementSet()

Collection

Returns a set of elements as a collection based on an input of element ID numbers in comma separated form. eg. GetElementSet("34,56,21,5")

DeleteTechnology(string ID)

Boolean

param: ID [ string ]

Removes the MDG Technology resource with the specified technology ID from the repository.

Returns true, if the technology is successfully removed from the model. Returns false otherwise.

AddTab(string TabName, string ControlID)

activeX custom control

param: TabName [String - in]

param: ControlID [String - in]

Enables an ActiveX custom control to be added as a tabbed window.

TabName is used as the tab caption.

ControlID is the ProgID of the control.  eg. Project1.UserControl1

Enterprise Architect creates a control and if successful, returns its Unknown pointer, which can be used by the caller to manipulate the control.

CreateOutputTab (string Name)

 

param: Name [String in]

Creates a tab in the Output window with the specified name.

RemoveOutputTab (string Name)

 

param: Name [String in] 

Removes the tab in the Output window with the specified name.

WriteOutput (string Name, string String, long ID)

 

param: Name [String in]

param: String [String in]

param: ID [long in]

Writes the text in String to the tab in the Output window with the specified name. It also associates the text in the Output window with the specified ID.

ClearOutput(string Name)

 

param: Name [String in]

Removes all the text in the tab in the Output window with the specified name.

EnsureOutputVisible(string Name)

 

param: Name [String in]

Ensures that the tab in the Output window with the specified name is visible to the user. The Output window is made visible if it is hidden.

RefreshModelView(long PackageID)

 

param: PackageID [Long in]

Reloads the entire model, updating the user interface.  If PackageID is 0, the entire model is reloaded.  If PackageID represents a valid PackageID, only that package  is reloaded.

GetElementByGuid(string Guid)

Element

param: Guid [String - in]

Returns a pointer to an element in the repository using the element's GUID reference number ( global ID). This is usually found using the ElementGUID property of an element, and stored for later use to open an Element without using the collection GetAt() function.

GetConnectorByGuid(string Guid)

Connector

param: Guid [String - in]

Returns a pointer to a connector in the repository with matching GUID. This is usually found using the ConnectorGUID property of a connector.

ShowDynamicHelp(string Topic)

 

param: Topic [String - in]

Shows the help topic specified by the Topic parameter, as a view tab

GetContextItemType()

ObjectType

Returns the ObjectType of the item in context within Enterprise Architect. A ContextItem is defined as the item selected anywhere within the Enterprise Architect GUI including:

·An Item selected in the Project Browser tree
·An Item selected in an open diagram
·An Item selected in certain dialogs, such as the Attributes Properties dialog

The supported ObjectTypes can be any one of the following values:

·otElement
·otPackage
·otDiagram
·otAttribute
·otMethod
·otConnector

GetContextItem(Object Item)

ObjectType

param: Item [ Object - out ]

Sets Item as a pointer to the item in context within Enterprise Architect. as well as its corresponding ObjectType as a return value.

For additional information about Context Items and the supported ObjectTypes see the GetContextItemType method.

ActivateTab(string Name)

 

param: Name [String - in]

Activates the open Enterprise Architect tabbed view with the matching Name.

GetDiagramByGuid(string Guid)

Diagram

param: Guid [ String - in ]

Returns a pointer to a diagram using the global reference ID ( global ID). This is usually found using the diagram GUID property of an element, and stored for later use to open an diagram without using the collection GetAt() function.

GetCurrentLoginUser(boolean GetGuid = false)

String

If security is not enabled in the repository, an error is generated.
If GetGuid is True, a GUID generated by Enterprise Architect representing the user is returned, otherwise the text as entered in System Users/User Details/Login is returned.

ChangeLoginUser(string Name, string Password)

Boolean

param: Name [ String - in ]

param: Password [ String - in ]

Set the currently logged on user to be that specified by the Name parameter, with the provided Password value. This logs the user into the repository when security is enabled. If security is not enabled an exception (Security not enabled) is thrown.

GetTreeSelectedObject()

Object

The related method GetTreeSelectedItem() has an out parameter which is inaccessible by some scripting languages. As an alternative, this method provides the selected item through the return value.

ShowProfileToolbox(string Technology, string Profile, boolean Show)

 

param: Technology [ String - in ]

param: Profile [ String - in ]

param: Show [ Boolean - in ]

Shows/hides the contents of the specified Technology or Profile in Enterprise Architect UML Toolbox. To show/hide a profile in the Toolbox, specify the Profile's ID value in the Profile parameter and set the Technology parameter to a null string.

To show/hide a technology in the Toolbox, specify the Technology's ID in the Technology parameter and set the Profile parameter to a null string.

ActivatePerspective(string Perspective, long Options)

Boolean

Deprecated - no longer in use.

AddPerspective(string Perspective, long Options)

Boolean

Deprecated - no longer in use.

DeletePerspective(string Perspective, long Options)

Boolean

Deprecated - no longer in use.

GetActivePerspective()

String

Deprecated - no longer in use.

HasPerspective(string Perspective)

String

Deprecated - no longer in use.

IsTabOpen()

String

param: TabName [ String - in ]

Returns 2 to indicate that a tab is open and active (top-most), 1 to indicate that it is open but not top-most, or 0 to indicate that it is not visible at all.

Note that TabName is case-sensitive.

GetAttributeByGuid(string Guid)

Attribute

param: Guid [String - in]

Returns a pointer to an attribute in the repository with matching Guid. This is usually found using the AttributeGUID property of an attribute.

GetMethodByGuid(string Guid)

Method

param: Guid [String - in]

Returns a pointer to a method in the repository with matching Guid. This is usually found using the MethodGUID property of a method.

ShowInProjectView(Object Item)

 

param: Item [ Object - in ]

Selects the object referenced by the supplied parameter in the Project Browser window. Accepted object types are Package, Element, Diagram, Attribute, and Method. An exception is thrown if object is of an invalid type.

AddDefinedSearches(string sXML)

 

param: sXML [string - in]

Enables you to enter a set of defined searches that last in Enterprise Architect for the life of the application. When Enterprise Architect loads again they must be inserted again by your Add-In. You can get this xml by exporting the searches from the model search dialog in Enterprise Architect ([Ctrl]+[F], then click on the Advanced button).

GetElementsByQuery(string QueryName, string SearchTerm)

 

param: QueryName[string - in]

param: SearchTerm[string -in]

Enables you to run a search in Enterprise Architect returning the result as a collection. QueryName is the name of the search to run, for example 'Simple'. SearchTerm is what you are looking for, For example GetElementsByQuery('Simple','Class1'). Where results contain elements with 'Class1' in the Name and Notes field.

RunModelSearch(string 'QueryName', string 'SearchTerm', string 'SearchOptions', string 'SearchData')

 

param: sQueryName[string - in]

param: sSearchTerm[string - in]

param: sSearchOptions[string - in]

param: sSearchData[string - in]

Runs a search displaying the results in Enterprise Architect's search window. QueryName is the name of the search to run, for example 'Simple'. SearchTerm is what you are searching for. SearchOptions is currently not being used. The SearchData parameter enables you to supply a list of results in the form of XML which is appended onto the result list in Enterprise Architect.

See XML Format; this param is not required so pass in an empty string to run search as per normal.

ExecutePackageBuildScript(long ScriptOptions, string PackageGuid)

 

param: ScriptOptions, [long - in]

param: PackageGuid [string - in]

Enables you to run the active package build script based on your current selection in the Project Browser window. You can also run a script by passing in the package Guid.

ScriptOptions can be any one of these values: 1,2,3,4,5;

1 = Build; 2 = Test; 3 = Run; 4 = Create Workbench Instance; 5 = Debug

ActivateToolbox(string Toolbox, long Options)

Boolean

param: Toolbox [ String - in ]

param: Options [ long - in ]

Activates the toolbox page in the GUI, specified by its name in the Toolbox parameter. Returns true if the specified toolbox was successfully activated, false otherwise.

The Options parameter is reserved for future use.

ImportPackageBuildScripts(string PackageGuid, string BuildScriptXML)

String

param: PackageGuid [string - in]

param: BuildScriptXML [string - in]

Enables you to import build scripts into a package in Enterprise Architect. You can import your package build scripts by supplying a package GUID and the xml data which you can export from in Enterprise Architect.

RefreshOpenDiagrams(Boolean FullReload)

Boolean

param: FullReload [ Boolean - in ]

Refreshes the diagram contents for all diagrams open in Enterprise Architect.

If FullReload is false the displayed contents of elements and connectors are refreshed in each diagram. If FullReload is true each of the diagrams are completely reloaded from the repository.

SaveAuditLogs(string FilePath, Object StartDateTime, Object EndDateTime)

Boolean

param: FilePath [string - in]

param: StartDateTime [Variant [DateTime] - in]

param: EndDateTime [Variant [DateTime] - in]

Saves the Audit Logs contained within a model to the file specified by the FilePath parameter.

If StartDateTime and EndDateTime are not null then only log items that fall into this period are saved.

Returns true for success, false for failure.

Note: This might fail if the user logged into the model does not have the correct  access permission.

ClearAuditLogs(Object StartDateTime, Object EndDateTime)

Boolean

param: StartDateTime [Variant [DateTime] - in]

param: EndDateTime [Variant [DateTime] - in]

Clears all Audit Logs from the model.

If StartDateTime and EndDateTime are not null then only log items that fall into this period are cleared.

Note: This cannot be undone. It is strongly advised that you call SaveAuditLogs first to backup the logs.

Returns true for success, false for failure.

Note: This might fail if the user logged into the model does not have the  correct access permission.

SaveAllDiagrams()


Call this to save all open diagrams.