Package Class

A Package object corresponds to a Package element in the Enterprise Architect Project Browser. Packages can be accessed either through the Repository Models collection (a Model is a special form of Package) or through the Package Packages collection.

Note that a Package has an Element object as an attribute; this corresponds to an Enterprise Architect Package element in the t_object table and is used to associate additional information (such as scenarios and constraints) with the logical package.

To set additional information for a package, reference the Element object directly. Also note that if you add a Package to a diagram, you should add an instance of the element (not the Package itself) to the DiagramObject Class for a diagram.

Associated table in .EAP file     t_package

Package Attributes

Attribute

Type

Notes

Alias

String

Read only

Alias

 

BatchLoad

Long

Read/Write

Flag to indicate that the package is batch loaded during batch import from controlled packages.

Not currently used.

 

BatchSave

Long

Read/Write

Boolean value to indicate whether the package is included in the batch XMI export list or not.

 

CodePath

String

Read/Write

The path where associated source code is found.

Not currently used.

 

Connectors

Collection

Read only

The collection of connectors.

 

Created

Date

Read/Write

Date the package was created.

 

Diagrams

Collection

Read only

A collection of diagrams contained in this package.

 

Element

Element

Read only

The associated element object; use to get/set common information such as Stereotype, Complexity, Alias, Author, Constraints, Tagged Values and Scenarios.

 

Elements

Collection

Read only

A collection of elements that belong to this package.

 

Flags

String

Read/Write

Extended information about the package.

 

IsControlled

Boolean

Read/Write

Indicates if the package has been marked as Controlled.

 

IsModel

Boolean

Read only

Indicates if the package is a model or a package.

 

IsNamespace

Boolean

Read/Write

True indicates that 'package is a Namespace root'.

Use 0 and 1 to set False and True.

 

IsProtected

Boolean

Read/Write

Indicates if the package has been marked as Protected.

 

IsVersionControlled

Boolean

Read only

Indicates whether or not this package is under version control.

 

LastLoadDate

Date

Read/Write

The date XML was last loaded for the package.

 

LastSaveDate

Date

Read/Write

The date XML was last saved from the package.

 

LogXML

Boolean

Read/Write

Indicates if XMI export information is to be logged.

 

Modified

Date

Read/Write

Date the package was last modified.

 

Name

String

Read/Write

The name of the package.

 

Notes

String

Read/Write

Notes about this package.

 

ObjectType

ObjectType

Read only

Distinguishes objects referenced through a Dispatch interface.

 

Owner

String

Read/Write.

The package owner when using controlled packages.

 

PackageGUID

Variant

Read only

The global Package ID; valid across models.

 

PackageID

Long

Read only

The local Package ID number.

Valid only in this model file.

 

Packages

Collection

Read only

A collection of contained packages that can be walked through.

 

ParentID

Long

Read/Write

The ID of the package that is the parent of this one.

0 indicates this package is a model (that is, it has no parent).

 

TreePos

Long

Read/Write

The relative position in the tree compared to other packages (use to sort packages).

 

UMLVersion

String

Read/Write

The UML version for XMI export purposes.

 

UseDTD

Boolean

Read/Write

Indicates if a DTD is to be used when exporting XMI.

 

Version

String

Read/Write

The version of the package.

 

XMLPath

String

Read/Write

The path to which the XML is saved when using controlled packages.

 

Package Methods

Method

Type

Notes

ApplyGroupLock (
string aGroupName)

Boolean

Applies a group lock to the package object, for the specified group, on behalf of the current user.

Returns true if the operation is successful; returns false if the operation is unsuccessful. Use GetLastError() to retrieve error information.

Parameters:

aGroupName: String - The name of the security group for which to apply the lock

 

ApplyUserLock ()

Boolean

Applies a user lock to the package object for the current user.

Returns true if the operation is successful; returns false if the operation is unsuccessful. Use GetLastError() to retrieve error information.

 

Clone

LDISPATCH

Inserts a copy of the package into the same parent as the original package.

Returns the newly-created package.

 

FindObject (
string DottedID)

LPDISPATCH

Returns a package, element, attribute or operation matching the parameter DottedID.

If the DottedID is not found, an error is returned: Can't find matching object.

Parameters:

DottedID: String - Is in the form object.object.object where object is replaced by the name of a package, element attribute or operation; examples include MyNamespace.Class1, CStudent.m_Name, MathClass.DoubleIt(int)

 

GetLastError ()

String

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

 

ReleaseUserLock ()

Boolean

Removes an existing User or Group lock from the package object.

Returns true if the operation is successful; returns false if the operation is unsuccessful. Use GetLastError() to retrieve error information.

 

SetReadOnly (
boolean ReadOnly,
boolean IncludeSubPkgs)

Void

Sets a Package Flag to mark a package as ReadOnly=1.

If Project Security is enabled, the user must have Configure Packages permission to use this method.

Throws an exception if the operation fails due to the user not having Configure Packages permission; use GetLastError( ) to retrieve error information.

Parameters;

ReadOnly: Boolean - Sets or clears the Read Only flag on the package(s); if:
False, any Read Only flag is removed from the package
True, a Read Only flag is applied to the package
 
IncludeSubPkgs: Boolean - Indicates whether to set/reset the Read Only flag on just the object package, or on the object package and all of the nested sub-packages that it contains; if:
False, only the flag on the object package is set or cleared
True, flags are set (or cleared, according to the ReadOnly parameter) for the object package plus all of the nested sub-packages that it contains

 

When working with version controlled packages, the Read Only flag can be applied to packages whether they are checked-in or checked-out.

User Security applies to setting this flag - if you are prevented from editing the package, you are also prevented from setting the flag.

 

Update ()

Boolean

Updates the current package object after modification or appending a new item.

If false is returned, check the GetLastError function for more information.

Note that a package object also has an element component that must be taken into account; the package object contains information about the package attributes such as hierarchy or contents.

The element attribute contains information about, for example, Stereotype, Constraints or Files - all the attributes of a typical element.

 

VersionControlAdd (
string ConfigGuid,
string XMLFile,
string Comment,
boolean KeepCheckedOut)

Void

Places the package under version control, using the specified Version Control Configuration and the specified XMI filename.

Throws an exception if the operation fails; use GetLastError( ) to retrieve error information.

It is recommended that the package be saved using Update() before calling VersionControlAdd(), so that any outstanding changes are not lost.

Parameters:

ConfigGuid: String - Name corresponding to the Unique ID of the version control configuration to use
XMLFile: String - Name of the XML file to use for this package; this filename is relative to the Working Copy folder specified for the Config
Comment: String - Log message that is added to the version controlled file's history (where applicable)
KeepCheckedOut: Boolean - Specify True to add to version control and keep package checked-out

 

VersionControlCheckin (
string Comment)

Void

Perform checkin of the version controlled package (also see VersionControlCheckinEx, below).

Throws an exception if the operation fails; use GetLastError( ) to retrieve error information.

Parameters:

Comment: String - Log message that is added to the version controlled file's history (where applicable)

 

VersionControlCheckinEx (
string Comment,
boolean PreserveCrossPkgRefs)

Void

Perform checkin of the version controlled package.

Throws an exception if the operation fails; use GetLastError( ) to retrieve error information.

Parameters:

Comment: String - Log message that is added to the version controlled file's history (where applicable)
PreserveCrossPkgRefs: Boolean - Flag to indicate whether to preserve or discard pre-existing Cross Package References when checking-in; this parameter overrides the setting in the Options dialog, XML Specifications page
 
Unsatisfied cross package references are preserved or discarded according to this setting, without prompting the user; see Learn more below

 

VersionControlCheckout (
string Comment)

Void

Perform checkout of the version controlled package.

Throws an exception if the operation fails; use GetLastError( ) to retrieve error information.

Parameters:

Comment: String - Log message that is added to the version controlled file's history (where applicable)

 

When working in an environment that uses a Private Model deployment and your model contains a significant number of cross-package references, it is recommended that you invoke the Repository.ScanXMIAndReconcile( ) method from time to time, following the re-importation of controlled packages - for example, after using Package.VersionControlGetLatest( ) to update a number of packages, or after performing a number of package check-outs.

 

VersionControlGetLatest (
boolean ForceImport)

Void

Updates the local working copy of the package file associated with the object package, before re-importing the package data from the package file.

Parameters:

ForceImport: Boolean - Used if the package data in the model is found to be up-to-date with respect to the version controlled package file; if:
False, the package data that exists in the model is accepted as being up-to-date and no attempt is made to re-import data from the package file
True, Enterprise Architect re-imports the package from the package file regardless

 

See also the version control menu option Get Latest.

When working in an environment that uses a Private Model deployment and your model contains a significant number of cross-package references, it is recommended that you invoke the Repository.ScanXMIAndReconcile( ) method from time to time, following the re-importation of controlled packages - for example, after using Package.VersionControlGetLatest( ) to update a number of packages, or after performing a number of package check-outs.

 

VersionControlGetStatus ()

Long

Returns the version control status of the package, as recorded in the current Enterprise Architect project database.

Throws an exception if the operation fails; use GetLastError( ) to retrieve error information.

Return value maps to the following enumerated type:

 

enum EnumCheckOutStatus
{
    csUncontrolled = 0,
    csCheckedIn,
    csCheckedOutToThisUser,
    csReadOnlyVersion,
    csCheckedOutToAnotherUser,
    csOfflineCheckedIn,
    csCheckedOutOfflineByUser,
    csCheckedOutOfflineByOther,
    csDeleted,
};

 

csUncontrolled - Either unable to communicate with the version control provider associated with the package or the package file is unknown to the provider.

csCheckedIn - The package is not checked-out to anybody in the current project database.

csCheckedOutToThisUser - The package is marked as checked-out to the current user, in the current project database.

csReadOnlyVersion - Package is marked as read-only; an earlier revision of the package has been retrieved from version control.

csCheckedOutToAnotherUser - The package is marked as checked-out in the current project database, by a user other than the current user.

csOfflineCheckedIn - The package is not checked-out to anybody in the current project database; however, the version control configuration associated with the package was unable to connect to the VC server.

csCheckedOutOfflineByUser - Indicates that the package was 'checked out' in this database, by this user, whilst disconnected from version control.

csCheckedOutOfflineByOther - Indicates that the package was checked out in this project database, by another user, whilst disconnected from version control.

csDeleted - The package file has been deleted from version control.

 

VersionControlPutLatest (
string CheckInComment)

Void

Perform a checkin of the version controlled package, whilst keeping the package checked-out.

Throws an exception if the operation fails; use GetLastError( ) to retrieve error information.

When a package that was previously marked as Checked Out Offline, is successfully 'Put' (checkedin) to version control, that package's flags are updated to clear the Checked Out Offline indicator.

Parameters:

Comment: String - Log message added to the version controlled file's history (where applicable)
 

VersionControlRemove ()

Void

Removes version control from the package.

Throws an exception if the operation fails; use GetLastError( ) to retrieve error information.

 

VersionControlResynchPkgStatus(
boolean ClearSettings)

 

Synchronizes the version control status of the single object package recorded in your current model with the package status reported by your version control provider.

Parameters:

ClearSettings: Boolean - used if the package file associated with the specified package is reported by the version control provider as uncontrolled; if ClearSettings is:
True, the version control settings are cleared from the package
False, the version control settings remain unchanged
 

Learn more