0% found this document useful (0 votes)
23 views224 pages

Erwin API Ref

The AllFusion ERwin Data Modeler API Reference Guide provides comprehensive documentation for users regarding the API's features, components, and tasks. It includes details on accessing and modifying model data, managing sessions, and handling errors, along with appendices for API interfaces and metamodel information. The documentation is proprietary and subject to change, with specific usage rights outlined for licensed users.

Uploaded by

fabianokuerten
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views224 pages

Erwin API Ref

The AllFusion ERwin Data Modeler API Reference Guide provides comprehensive documentation for users regarding the API's features, components, and tasks. It includes details on accessing and modifying model data, managing sessions, and handling errors, along with appendices for API interfaces and metamodel information. The documentation is proprietary and subject to change, with specific usage rights outlined for licensed users.

Uploaded by

fabianokuerten
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

AllFusion ERwin Data Modeler

 

API Reference Guide


r7.1
This documentation and related computer software program (hereinafter referred to as the “Documentation”) is for
the end user’s informational purposes only and is subject to change or withdrawal by Computer Associates
International, Inc. (“CA”) at any time.

This documentation may not be copied, transferred, reproduced, disclosed or duplicated, in whole or in part,
without the prior written consent of CA. This documentation is proprietary information of CA and protected by the
copyright laws of the United States and international treaties.

Notwithstanding the foregoing, licensed users may print a reasonable number of copies of this documentation for
their own internal use, provided that all CA copyright notices and legends are affixed to each reproduced copy.
Only authorized employees, consultants, or agents of the user who are bound by the confidentiality provisions of
the license for the software are permitted to have access to such copies.

This right to print copies is limited to the period during which the license for the product remains in full force and
effect. Should the license terminate for any reason, it shall be the user’s responsibility to return to CA the
reproduced copies or to certify to CA that same have been destroyed.

To the extent permitted by applicable law, CA provides this documentation “as is” without warranty of any kind,
including without limitation, any implied warranties of merchantability, fitness for a particular purpose or
noninfringement. In no event will CA be liable to the end user or any third party for any loss or damage, direct or
indirect, from the use of this documentation, including without limitation, lost profits, business interruption,
goodwill, or lost data, even if CA is expressly advised of such loss or damage.

The use of any product referenced in this documentation and this documentation is governed by the end user’s
applicable license agreement.

The manufacturer of this documentation is Computer Associates International, Inc.

Provided with “Restricted Rights” as set forth in 48 C.F.R. Section 12.212, 48 C.F.R. Sections 52.227-19(c)(1) and
(2) or DFARS Section 252.227-7013(c)(1)(ii) or applicable successor provisions.

Copyright  2006 CA. All rights reserved.


All trademarks, trade names, service marks, and logos referenced herein belong to their respective companies.
Contents

Chapter 1: Introduction
Major Features ............................................................................... 1-1
Typical Use Cases............................................................................. 1-2
Standalone Client ......................................................................... 1-3
Add-in Component or Script ............................................................... 1-4

Chapter 2: API Components


Overview .................................................................................... 2-1
Application Tier .......................................................................... 2-1
Model Directory Tier ...................................................................... 2-3
Sessions Tier.............................................................................. 2-4
Model Data Tier .......................................................................... 2-5
Access to Model Data ......................................................................... 2-7
Object Identifiers ............................................................................. 2-8
Object Identifiers and Type Codes .......................................................... 2-9
Collections and Automation .................................................................. 2-10
_NewEnum Property of a Collection Object................................................. 2-11
Default Properties ........................................................................ 2-12
Optional Parameter ...................................................................... 2-12
API Sample Client ........................................................................... 2-12
Installing the API Sample Client ........................................................... 2-12
Using the API Sample Client .............................................................. 2-12
Register the Add-in Component ....................................................... 2-13
ERwin Spy .................................................................................. 2-14
How the ERwin Spy Application Works .................................................... 2-14

Contents iii
Chapter 3: API Tasks
Getting Started ................................................................................ 3-1
API Environment .......................................................................... 3-1
Creating the ISCApplication Object ......................................................... 3-2
Application Properties ......................................................................... 3-3
ISCApplication Interface ................................................................... 3-3
ISCApplicationEnvironment ................................................................ 3-4
Accessing a Model ............................................................................ 3-7
Using the API as an Add-in Tool ............................................................ 3-7
ISCApplication Interface ............................................................... 3-8
ISCPersistenceUnitCollection Interface ................................................... 3-8
ISCPersistenceUnit Interface ............................................................ 3-9
ISCPropertyBag Interface .............................................................. 3-11
Using the API as a Standalone Executable ................................................... 3-13
Creating a Model ......................................................................... 3-14
ISCPersistenceUnitCollection Interface .................................................. 3-14
ISCPropertyBag Interface .............................................................. 3-15
Opening an Existing Model ................................................................ 3-16
ISCPersistenceUnitCollection Interface .................................................. 3-16
Opening a Session ........................................................................ 3-17
ISCSessionCollection Interface ......................................................... 3-17
ISCSession Interface................................................................... 3-18
Accessing a Model Set .................................................................... 3-19
ISCPersistenceUnit Interface ........................................................... 3-19
ISCModelSet Interface ................................................................. 3-20
ISCModelSetCollection Interface ....................................................... 3-20
ISCSession Interface................................................................... 3-21
Accessing Objects in a Model .................................................................. 3-23
Interfaces Used to Access Model Objects .................................................... 3-23
ISCSession Interface................................................................... 3-23
ISCModelObjectCollection Interface .................................................... 3-23
ISCModelObject Interface.............................................................. 3-24
Accessing a Specific Object ................................................................ 3-27
ISCModelObjectCollection Interface .................................................... 3-27
Filtering Object Collections ................................................................ 3-28
ISCModelObjectCollection Interface .................................................... 3-28
Object Type Filter ..................................................................... 3-30
Depth Filter .......................................................................... 3-30
MustBeOn/MustBeOff Filter ........................................................... 3-31

iv AllFusion ERwin Data Modeler API Reference Guide


Accessing Object Properties ................................................................... 3-31
Iteration of Properties .................................................................... 3-32
ISCModelObject Interface ............................................................. 3-32
ISCModelPropertyCollection Interface ................................................. 3-32
ISCModelProperty Interface ........................................................... 3-32
Accessing Scalar and Non-Scalar Property Values ........................................... 3-34
ISCModelProperty Interface ........................................................... 3-34
Iterating Over Non-Scalar Property Values ................................................. 3-36
ISCModelProperty Interface ........................................................... 3-36
ISCPropertyValueCollection Interface .................................................. 3-37
ISCPropertyValue Interface ........................................................... 3-38
Accessing a Specific Property ............................................................. 3-41
ISCPropertyValueCollection Interface .................................................. 3-41
Filtering Properties ....................................................................... 3-42
ISCModelObject Interface ............................................................. 3-43
Modifying the Model—Using Session Transactions ............................................. 3-45
Begin Transaction ........................................................................ 3-46
ISCSession Interface .................................................................. 3-46
Commit Transaction...................................................................... 3-47
ISCSession Interface .................................................................. 3-47
Creating Objects ............................................................................. 3-49
Interfaces Used to Create a New Object .................................................... 3-49
ISCModelObjectCollection Interface .................................................... 3-49
Setting Property Values ...................................................................... 3-51
Setting Scalar Property Values ............................................................. 3-51
ISCModelProperty Interface ........................................................... 3-51
Setting Non-Scalar Property Values ........................................................ 3-52
ISCModelProperty Interface ........................................................... 3-53
Deleting Objects ............................................................................. 3-54
Interfaces Used to Delete Objects .......................................................... 3-54
ISCModelObjectCollection Interface .................................................... 3-54
Deleting Properties and Property Values ....................................................... 3-55
Interfaces Used to Delete Properties and Property Values .................................... 3-55
ISCModelPropertyCollection Interface ................................................. 3-55
ISCModelProperty Interface ........................................................... 3-56
Deleting Scalar Properties ................................................................. 3-56
Deleting Non-Scalar Property Values ...................................................... 3-56
Saving the Model ............................................................................ 3-57
ISCPersistenceUnit Interface .............................................................. 3-57

Contents v
Accessing Metamodel Information ............................................................. 3-58
ISCApplicationEnvironment Interface ...................................................... 3-59
ISCSession Interface ...................................................................... 3-60
Closing the API .............................................................................. 3-62
Closing the Session ....................................................................... 3-62
ISCSession Interface................................................................... 3-62
ISCSessionCollection Interface ......................................................... 3-62
Clearing Persistence Units ................................................................. 3-63
ISCPersistenceUnitCollection Interface .................................................. 3-64
Error Handling............................................................................... 3-65
ISCApplicationEnvironment ............................................................... 3-66
Advanced Tasks ............................................................................. 3-69
Creating User-Defined Properties .......................................................... 3-69
History Tracking ......................................................................... 3-73
ISCSession Interface................................................................... 3-73

Appendix A: API Interfaces Reference


API Interfaces ................................................................................ A-1
ISCApplication ........................................................................... A-1
ISCApplicationEnvironment ............................................................... A-2
ISCApplicationEnvironment::PropertyBag Arguments ................................... A-3
ISCModelDirectory ....................................................................... A-4
ISCModelDirectory::CopyDirectory Arguments ......................................... A-6
ISCModelDirectory::CopyDirectoryUnit Arguments ..................................... A-7
ISCModelDirectory::CreateDirectory Arguments ........................................ A-8
ISCModelDirectory::DeleteDirectory Arguments......................................... A-9
ISCModelDirectory::DeleteDirectoryUnit Arguments ................................... A-10
ISCModelDirectory::DirectoryExists Arguments ........................................ A-11
ISCModelDirectory::DirectoryUnitExists Arguments .................................... A-11
ISCModelDirectory::IsOfType Arguments .............................................. A-12
ISCModelDirectory::LocateDirectory Arguments ....................................... A-12
ISCModelDirectory::LocateDirectoryUnit Arguments ................................... A-13
ISCModelDirectory::MoveDirectory Arguments ........................................ A-14
ISCModelDirectory::MoveDirectoryUnit Arguments .................................... A-15
ISCModelDirectory::PropertyBag Arguments (Get Function) ............................. A-17
ISCModelDirectory::PropertyBag Arguments (Set Function) ............................. A-18
ISCModelDirectoryCollection ............................................................. A-18
ISCModelDirectoryCollection::Add Arguments ......................................... A-19
ISCModelDirectoryCollection::Item Arguments ......................................... A-19
ISCModelDirectoryCollection::Remove Arguments ..................................... A-20

vi AllFusion ERwin Data Modeler API Reference Guide


ISCModelDirectoryUnit .................................................................. A-20
ISCModelDirectoryUnit::IsOfType Arguments .......................................... A-21
ISCModelDirectoryUnit::PropertyBag Arguments (Get Function) ......................... A-22
ISCModelDirectoryUnit::PropertyBag Arguments (Set Function) .......................... A-23
ISCModelObject ......................................................................... A-23
ISCModelObject::CollectProperties Arguments .......................................... A-25
ISCModelObject::IsInstanceOf Arguments .............................................. A-27
ISCModelObjectCollection ................................................................ A-27
ISCModelObjectCollection::Add Arguments ............................................ A-29
ISCModelObjectCollection::Collect Arguments .......................................... A-30
ISCModelObjectCollection::Item Arguments ............................................ A-32
ISCModelObjectCollection::Remove Arguments ......................................... A-33
ISCModelProperty ....................................................................... A-34
ISCModelProperty::DataType Arguments .............................................. A-35
ISCModelProperty::RemoveValue Arguments .......................................... A-36
ISCModelProperty::Value Arguments (Get Function) .................................... A-36
ISCModelProperty::Value Arguments (Set Function)..................................... A-37
ISCModelPropertyCollection .............................................................. A-38
ISCModelPropertyCollection::Add Arguments .......................................... A-40
ISCModelPropertyCollection::HasProperty Arguments .................................. A-41
ISCModelPropertyCollection::Item Arguments .......................................... A-42
ISCModelPropertyCollection::Remove Arguments ...................................... A-43
ISCModelSet ............................................................................ A-44
ISCModelSet::PropertyBag Arguments (Get Function) ................................... A-45
ISCModelSet::PropertyBag Arguments (Set Function) .................................... A-46
ISCModelSetCollection ................................................................... A-47
ISCModelSetCollection::Item Arguments ............................................... A-47
ISCPersistenceUnit ....................................................................... A-48
ISCPersistenceUnit::PropertyBag Arguments (Get Function) .............................. A-50
ISCPersistenceUnit::PropertyBag Arguments (Set Function) .............................. A-51
ISCPersistenceUnit::Save Arguments ................................................... A-52
ISCPersistenceUnitCollection ............................................................. A-53
ISCPersistenceUnitCollection::Add Arguments.......................................... A-54
ISCPersistenceUnitCollection::Create Arguments ........................................ A-55
ISCPersistenceUnitCollection::Item Arguments ......................................... A-56
ISCPersistenceUnitCollection::Remove Arguments ...................................... A-56
ISCPropertyBag .......................................................................... A-57
ISCPropertyBag::Add Arguments ...................................................... A-58
ISCPropertyBag::Name Arguments .................................................... A-58
ISCPropertyBag::Value Arguments (Get Function)....................................... A-58
ISCPropertyBag::Value Arguments (Set Function) ....................................... A-59

Contents vii
ISCPropertyValue ....................................................................... A-59
ISCPropertyValue::ValueId Arguments ................................................ A-60
ISCPropertyValue::Value Arguments .................................................. A-61
ISCPropertyValueCollection .............................................................. A-62
ISCPropertyValueCollection::Item Arguments .......................................... A-62
ISCSession .............................................................................. A-63
ISCSession::BeginNamedTransaction Arguments ....................................... A-65
ISCSession::CommitTransaction Arguments ............................................ A-66
ISCSession::IsTransactionEmpty Arguments............................................ A-66
ISCSession::Open Arguments ......................................................... A-67
ISCSession::RollbackTransaction Arguments ........................................... A-68
ISCSessionCollection..................................................................... A-68
ISCSessionCollection::Item Arguments................................................. A-69
ISCSessionCollection::Remove Arguments ............................................. A-69
Enumerations ............................................................................... A-70
SC_ModelDirectoryFlags ................................................................. A-70
SC_ModelDirectoryType ................................................................. A-70
SC_ModelObjectFlags .................................................................... A-70
SC_ModelPropertyFlags ................................................................. A-71
SC_SessionFlags ......................................................................... A-72
SC_SessionLevel......................................................................... A-72
SC_ValueTypes ......................................................................... A-72
Property Bag Reference ...................................................................... A-74
Property Bag for Application Environment................................................. A-74
ISCApplicationEnvironment::PropertyBag ............................................. A-74
Category Parameter Contains an Empty String ......................................... A-75
Application Category ................................................................ A-75
[Link] Category ............................................................ A-76
[Link] Category .................................................... A-76
[Link] Category ................................................ A-77
[Link] Category ....................................................... A-80
[Link] Category ............................................... A-80
[Link] Category...................................................... A-80
[Link] Category ........................................... A-80
[Link].................................................... A-81
Property Bag for Model Directory and Model Directory Unit ................................ A-81
Property Bag for Persistence Units and Persistence Unit Collections .......................... A-85
ISCPersistenceUnit::PropertyBag Arguments (Get Function) ............................. A-86
ISCPersistenceUnit::PropertyBag Arguments (Set Function).............................. A-86
Property Bag Contents for Persistence Unit and Persistence Unit Collection ............... A-87
Property Bag for Session ................................................................. A-90

viii AllFusion ERwin Data Modeler API Reference Guide


Location and Disposition in Model Directories and Persistence Units ............................. A-92
Locator Property ......................................................................... A-92
Disposition Property ..................................................................... A-94

Appendix B: AllFusion ERwin DM Metamodel


Metadata Organization ........................................................................ B-1
Metamodel Elements ...................................................................... B-1
Metadata Tags ............................................................................ B-3
Abstract Metadata Objects ................................................................. B-6
Metamodel Classes ........................................................................ B-6
Metadata Reports ............................................................................. B-7
Metamodel Document ..................................................................... B-7
XML Schema ............................................................................. B-9
ERwin Spy .............................................................................. B-11
Conversion from AllFusion ERwin DM Version 4.1.4 ............................................ B-11
User-Defined Property (UDP) ............................................................. B-11
Changes in Type Names .................................................................. B-12
Additions and Deprecations in Metadata ................................................... B-12
Datatype Changes........................................................................ B-13

Index

Contents ix
Chapter

Introduction
1
The Script Client API that is part of AllFusion® ERwin® Data Modeler (hereafter
referred to as AllFusion ERwin DM) provides advanced customization
capabilities that enable you to access and manipulate modeling data in AllFusion
ERwin DM memory at runtime, as well as models persisted in files and in the
AllFusion® Model Manager repository. The AllFusion ERwin DM API interfaces
are automation-compatible and provide extensive design and runtime facilities
for third-party integrators as well as users of script-based environments.

The AllFusion ERwin DM API enables you to complement the original modeling
tool with custom components when you use scripts, add-ins, and COM-based
API technologies. Because of its flexibility, the AllFusion ERwin DM API
promotes the seamless integration of the modeling tool in a client development
cycle.

Major Features
The AllFusion ERwin DM API is essentially a group of interfaces that include the
following functionality:
■ Active Model Data Objects (AMDO)—Allows a third-party client to access
model data through a COM automation-compatible API. This feature is the
major component in the AllFusion ERwin DM API functionality. All
interfaces that comprise the AllFusion ERwin DM API are automation-based,
and are therefore dual. These dual interfaces allow you faster access to
methods and properties. Using dual interfaces, you can directly call the
functions without using an Invoke() function.
■ Collections and enumerators—Facilitates programming constructions in
script languages that target the AMDO automation features.
■ Connection points—Supporting the sync event facilities of languages, the
AllFusion ERwin DM API delivers a collection of connection points interfaces
and support for the ITypeInfo2 interface.
■ Automation-rich error handling—The AllFusion ERwin DM API supports
automation-rich error handling through IErrorInfo interfaces exposed by the
AllFusion ERwin DM API components.

Introduction 1–1
Typical Use Cases

■ Active Model Directory—A set of features that allows a client to navigate


available model storage, including AllFusion Model Manager. The AllFusion
ERwin DM API delivers the ability for a client to open or to create a model in
a file as well as from an AllFusion Model Manager repository.
■ Active Scripting—Hosts a scripting environment and provides an
invocation mechanism for script and add-in components. A mechanism is
provided to register add-ins and scriplets with the Active Scripting
environment.

Typical Use Cases


The AllFusion ERwin DM API provides a wide range of integration solutions for
using AllFusion ERwin DM functionality with complex business processes.

Many users of the AllFusion ERwin DM API are automation and script-based
clients. These clients have very specific interface design requirements imposed
by COM automation standards. For instance, they are often limited to a single
incoming and outgoing interface exposed by any particular COM object. This
limitation is due to the fact that the only recognizable interface type for pure
automation is IDispatch and it renders the use of QueryInterface functionality
unfit. The common technique to address the problem includes Alternate
Identities and read-only properties that expose secondary interfaces.

Another example of a targeted domain customer is one using alternative (not


C++) languages to implement a client. The list includes Visual Basic, VB Script,
Java Script, and so on. The list includes specially tailored language idioms to
encapsulate language—COM binding, such as collections of objects, connection
points, rich error handling, and so on.

The AllFusion ERwin DM API combines number of components and presents


them as a set of interfaces accessible using COM.

1–2 AllFusion ERwin Data Modeler API Reference Guide


Typical Use Cases

The list of integrated components includes AllFusion ERwin Data Modeler,


AllFusion Model Manager, and Microsoft Internet Explorer.

AllFusion Model Manager AllFusion ERwin DM

Web AllFusion ERwin DM API Layer


Browser
Control Active Active Model Data Objects
Script
Scripting
Host

Active Model Directory

AllFusion ERwin DM API

Standalone Client

One of the ways the AllFusion ERwin DM API is typically used is as a


standalone client. A third-party client activates the AllFusion ERwin DM API as
an in-process server. The API component does not have visual representation,
that is, it does not expose a user interface. The AllFusion ERwin DM API
provides Active Model Directory facilities to specify a target model from a list of
available models. Active Model Data Objects provide session-based access to
model data.

There can be times when AllFusion ERwin DM API clients compete with other
parties over access to model data. Using AllFusion Model Manager provides
advanced model sharing facilities to prevent other parties from accessing the
model during your session.

Introduction 1–3
Typical Use Cases

Add-in Component or Script

Another way the AllFusion ERwin DM API is typically used is as an add-in


component or script. AllFusion ERwin DM hosts third-party add-in modules and
scripts. The Active Scripting component in the AllFusion ERwin DM API
provides a mechanism for registering modules with a host tool, arranging
representation in the host user interface, creating add-in menus, and invoking
them on the host menu selection or event.

The add-in module is a client DLL, activated in-process.

The script is a VBScript or JScript procedure embedded in a DHTML document,


activated using a menu or a model event. This Active Scripting provides hosting
for web browser control and makes the AllFusion ERwin DM API objects
available through the [Link] property of the DHTML object model.

You can observe changes in a model on the screen and can activate a pause to
investigate the state of a model by accessing the modeling tool user interface.

1–4 AllFusion ERwin Data Modeler API Reference Guide


Chapter

API Components
2
This chapter describes the AllFusion ERwin DM API components.

Overview
The AllFusion ERwin DM API is a collection of interfaces that represent
AllFusion ERwin DM functionality. The application exports the top-level
interface, from which the client obtains lower-level interfaces as needed.
Interfaces are logically grouped into tiers, where each tier includes interfaces that
represent the functionality of the application. Each tier is represented in the
following sections, with a table describing the interfaces grouped into that tier.

Application Tier

The Application Tier represents AllFusion ERwin DM functionality, establishes


access to models in persistent storage, and controls the exchange between models
in memory and models in persistent storage. The following table describes the
interfaces of the Application Tier:

Interface Role
ISCApplication Represents application-wide
functionality, and serves as the entry
point for the interface hierarchy of the
AllFusion ERwin DM API. Holds a list
of available persistence units and
connections between the client and
persistence units.
ISCApplicationEnvironment Provides information about the
runtime environment.
ISCApplicationServiceCollection Provides access to a variety of
application services, such as Forward
Engineering, Reverse Engineering,
Complete Compare, and so on.

API Components 2–1


Overview

Interface Role
ISCPersistenceUnitCollection Collects all active persistence units
known to the application.
ISCPersistenceUnit Represents an active persistence unit
(such as an AllFusion ERwin DM
model) within the application. A
persistence unit groups data in the
form of model sets. Clients can connect
to persistence units to manipulate them
and the data they contain.
ISCModelSetCollection Represents model sets associated with
a persistence unit.
ISCModelSet Represents a model set (such as EMX or
EM2 classes of model data) within a
single persistence unit.
ISCPropertyBag Represents an array of properties for
application tier interface calls.

The following is a graphical representation of the relationships of the Application


Tier:

<<Interface>> <<Interface>> Assumes <<Interface>>


ISCPropertyBag ISCApplication ISCApplicationEnvironment
1

Has Provides

1 1
<<Interface>> <<Interface>>
ISCPersistenceUnitCollection ISCApplicationServicesCollection
Employs
1

Consists of

0..*
<<Interface>> Top 1 <<Interface>>
ISCPersistenceUnit ISCModelSet

0..*

Consists of Owns
1

1 <<Interface>>
ISCModelSetCollection

2–2 AllFusion ERwin Data Modeler API Reference Guide


Overview

Model Directory Tier

The Model Directory Tier accesses and manipulates the persistence storage
directories, such as a file system directory or an AllFusion Model Manager
directory. The following table describes the interfaces of the Model Directory
Tier:

Interface Role
ISCModelDirectoryCollection Enumerates all top-level model
directories available for the AllFusion
ERwin DM API client.
ISCModelDirectory Encapsulates information on a single
model directory entry.
ISCModelDirectoryUnit Encapsulates information on a single
directory unit.

The following is a graphical representation of the relationships of the Model


Directory Tier:

<<Interface>> Has <<Interface>>


ISCApplication
ISCModelDirectoryCollection
(from Application Tier)

Has 1
Consists of
0..*
<<Interface>>
ISCModelDirectory

Lists
0..*
<<Interface>> Describes <<Interface>>
ISCPersistenceUnit ISCModelDirectoryUnit
(from Application Tier)
1 1

API Components 2–3


Overview

Sessions Tier

The Sessions Tier establishes access to model data in memory. The following
table describes the interfaces of the Sessions Tier:

Interface Role
ISCSessionCollection Collects all active sessions between the
AllFusion ERwin DM API client and
the persistence units.
ISCSession Represents an active connection
between the client and a model. Clients
create sessions, and then open them
against model sets of persistence units.
An open session exposes a single level
(such as data, metadata, and so on) of a
model set.

The following is a graphical representation of the relationships of the Sessions


Tier:

<<Interface>> Has <<Interface>>


ISCApplication
ISCSessionCollection
(from Application Tier)
1

Consists Of

0..*
<<Interface>>
ISCSession

0..*
Accesses

1
<<Interface>>
ISCPersistenceUnit
(from Application Tier)

2–4 AllFusion ERwin Data Modeler API Reference Guide


Overview

Model Data Tier

The Model Data Tier accesses and manipulates model data. The following table
describes the interfaces of the Model Data Tier:

Interface Role
ISCModelObjectCollection Represents objects available for
manipulation. Membership in this
collection can be limited by
establishing filter criteria.
ISCModelObject Accesses and manipulates a single
object within a model.
ISCModelPropertyCollection Represents a list of properties owned
by a single object. The list can be
limited by using filters.
ISCModelProperty Accesses and manipulates a single
property. Note that properties may
contain multiple values. Values within
a multi-valued property are accessed
by keys. The current multi-valued
property implementation treats the
value list as an array, and the key is the
array index.
ISCPropertyValueCollection Represents a list of single property
values.
ISCPropertyValue Data and a key are contained within a
single value.

API Components 2–5


Overview

The following is a graphical representation of the relationships of the Model Data


Tier:

<<Interface>> Accesses
ISCSession
(from Sessions Tier)

1
<<Interface>>
ISCModelObjectCollection
0..*
Produces
Consists Of

Owned By

0..*
<<Interface>> Has 0..* <<Interface>>
ISCModelObject ISCModelPropertyCollection
1

Consists Of

0..*
<<Interface>> Has <<Interface>>
ISCPropertyValueCollection ISCModelProperty

Consists Of

0..*
<<Interface>>
ISCPropertyValue

2–6 AllFusion ERwin Data Modeler API Reference Guide


Access to Model Data

Access to Model Data


The AllFusion ERwin DM API allows API clients to manipulate models. An API
client locates models in persistence storage by using the Model Directory
Collection, Model Directory, and the Model Directory Unit components. By
using its properties, the Model Directory Unit provides the information
necessary to register the unit with the pool of available persistence units by using
the Persistence Units collection. Then the API client can specify access attributes
such as read-only or ignore locks. A new model can be created and registered
with a persistence unit collection. AllFusion ERwin DM can add or remove
models from the pool as a response to user interface actions.

A persistence unit maintains a set of properties to control visibility in the


application user interface, access attributes, and so on. A persistence unit
organizes data as a group of linked model sets. The model sets are arranged in a
tree-like hierarchy with a single model set at the top. The top model set in the
persistence unit contains the bulk of the modeling data. The AllFusion ERwin
DM API uses the abbreviation EMX to identify the top model set. The EMX
model set owns a secondary model set, abbreviated as EM2, that contains user
options and user interface settings.

The API clients access the model data by constructing a session and connecting it
to a model set using the Session component. A model set contains several levels
of data. It contains the data the application manipulates, such as entity instances,
attribute instances, or relationship instances.

The model set also contains metadata: a description of the objects and properties
that may occur within the application’s data. In AllFusion ERwin DM, metadata
includes object and property classes, object aggregations, and property
associations. The metadata defines each object class that may occur within a
model, for example, an entity class, an attribute class, or a relationship class.
Object aggregations identify an ownership relationship between classes of
objects. For example, a model owns entities, entities own attributes, and so on.
The property associations define property usage by object classes. For instance,
the metadata includes property associations for every object class that has the
Name property.

Clients specify the necessary level of model data at the same time as connecting a
session to a model set.

When a new model is created it acquires a set of default objects, such as model
object, main subject area, and stored display.

API Components 2–7


Object Identifiers

The initial AllFusion ERwin DM API implementation supports the following


levels:

Name Description Supported Actions


SCD_SL_ M0 Model Level Access model data, create
and delete objects
(including the entire
model), and set property
values.
SCD_SL_ M1 Metamodel Level Access object and
property definitions,
along with other
metadata. Create and
delete user-defined
properties and user-
defined object definitions.

Levels are identified by long integer values. Values have symbolic definitions.

Object Identifiers
The AllFusion ERwin DM API presents data in object/property form. In an
AllFusion ERwin DM model, for example, an attribute is represented by an
instance of an attribute object. The name of the attribute is contained in the Name
property of the attribute object.

Each object must bear an identifier—a value that uniquely identifies the object
instance. Internally, object identifiers are 20 bytes long. They contain two
components: a GUID (also known as a UUID) in the first 16 bytes, and a 32-bit
unsigned integer suffix in the last 4 bytes.

A GUID contains the following components:


■ One 32-bit unsigned integer
■ Two 16-bit unsigned integers
■ Eight 8-bit unsigned integers (represented as unsigned characters)

These components total of 128 bits, or 16 bytes. Therefore, an object identifier


contains an extra 32-bit unsigned integer (the 4 byte suffix) at the end for a total
of 160 bits, or 20 bytes.

2–8 AllFusion ERwin Data Modeler API Reference Guide


Object Identifiers

To simplify working with object identifiers and due to COM automation


limitations on datatypes, the AllFusion ERwin DM API uses a string to represent
object identifiers.

The following table lists aliases used in this guide and in the interface definitions:

Type Name Format Use


SC_OBJID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}+suffix Object identifier
SC_CLSID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}+suffix Class (object, property
type, and so on) identifier
SC_MODELTYPEID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}+suffix Model type identifier
SC_CREATORID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} Creator identifier

One set of object identifiers is predefined—those identifiers whose GUID


component contains zero. If the final 4 bytes of the identifier also contain zero,
the identifier represents a null identifier. Other values of the offset are reserved
for future use.

Object Identifiers and Type Codes

Consider the relationship between object instances in the SCD_SL_ M0 layer and
object instances in the SCD_SL_ M1 layer. An instance in the SCD_SL_ M0 layer
is described by an instance in the SCD_SL_ M1 layer. For instance, a single object
in the SCD_SL_ M1 layer describes every entity instance in the SCD_SL_ M0
layer.

Since all type codes are also object identifiers, they must have the same format.

API Components 2–9


Collections and Automation

Collections and Automation


Automation defines the IEnumVARIANT interface to provide a standard way
for the API clients to iterate over collections. Every collection interface in the API
exposes a read-only property named _NewEnum to let the API clients know that
the collection supports iteration. The _NewEnum property returns a pointer on
the IEnumVARIANT interface.

IDispatch IEnumVARIANT

Collection Enumerator
_NewEnum Property

The IEnumVARIANT interface provides a way to iterate through the items


contained by a collection. This interface is supported by an enumerator interface
that is returned by the _NewEnum property of the collection.

The IEnumVARIANT interface defines these member functions:


■ Next—Retrieves one or more elements in a collection, starting with the
current element.
■ Skip—Skips over one or more elements in a collection.
■ Reset—Resets the current element to the first element in the collection.
■ Clone—Copies the current state of the enumeration so you can return to the
current element after using Skip or Reset.

2–10 AllFusion ERwin Data Modeler API Reference Guide


Collections and Automation

The IEnumVARIANT collection implements a Rogue Wave Software, Inc. style


“advance and return” iteration. For this reason, they have the following life
cycle:

Create

Created

Create OK

Reset Next
Reset Next

Next End
BeforeStart In List At End

Delete

Delete Delete
Deleted

When the iterator is created, it enters the Created state. It then forces itself into the
BeforeStart state. A successful advance drives the iterator into the InList state,
while an unsuccessful advance drives it into the AtEnd state. A Reset drives the
iterator back to the BeforeStart state, and deletion drives it into the Deleted state.

The iterator is positioned over a member of the collection (that is, is associated
with a current member) if and only if it is in the InList state.

_NewEnum Property of a Collection Object

The _NewEnum property identifies support for iteration through the


IEnumVARIANT interface. The _NewEnum property has the following
requirements:
■ It is named _NewEnum
■ It returns a pointer to the enumerator IUnknown interface
■ The Dispatch identification for the property is:
DISPID = DISPID_NEWENUM (-4)

API Components 2–11


API Sample Client

Default Properties

For automation, a default property is the property that is accessed when the
object is referred to without any explicit property or method call. The property
dispatch identifier is DISPID_VALUE.

Optional Parameter

To support automation client requirements, all optional parameters are


represented as VARIANT. For that reason, a parameter type in an interface
description is only to document an expected type in the VARIANT structure.

API Sample Client


Two Visual Basic 6.0 sample projects are provided with the API:
ERwinSpy_Sample.vbp and ErwinSpy_Addin_Sample.vbp.

Installing the API Sample Client

If you run the Custom Setup type of installation, select ERwin API Sample Client
when prompted to select the program features you want to install. After
installation, you can access the two sample Visual Basic 6.0 projects from the
Sample Client subdirectory. The path is AllFusion ERwin Data Modeler
r7\Samples\ERwin API\Sample Client.

Using the API Sample Client

This section describes how to utilize the AllFusion ERwin DM API sample client
as a standalone version and as an add-in component.

ERwinSpy_Sample.vbp—This is the standalone version of the sample program.


You can build ERwinSpy_Sample.vbp to create the ERwinSpy_Sample.exe
program. This program is an AllFusion ERwin DM model data browser that you
can use to research AllFusion ERwin DM data internals, such as the AllFusion
ERwin DM metamodel, AllFusion ERwin DM model data, and model objects and
their properties.

2–12 AllFusion ERwin Data Modeler API Reference Guide


API Sample Client

Using ERwinSpy_Sample.exe, you can open an *.ERWIN file by choosing File


Open from the File menu. When a model is opened or selected from Models
menu, model objects from the model are displayed in the left pane. You can view
a model object’s hierarchy (parents and children) by double-clicking on the
object. You can view the properties of an object by clicking the button that is
between the left and right panes of the program screen.

The Models menu shows in-memory models that are currently open. You can use
the upper part of the menu to access model data, and you can use the lower part
to access the metamodel information associated with the model.

ErwinSpy_Addin_Sample.vbp—This is the add-in version of the sample


program. You can build ERwinSpy_Addin_Sample.vbp to create an add-in
component that runs from the AllFusion ERwin DM Tools/Add-Ins menu.

After you build the add-in component by using the


ErwinSpy_Addin_Sample.vbp project, you must register the component.

Register the Add-in Component

To register the add-in component, do the following:


1. From the AllFusion ERwin DM Tools menu, select Add-ins and then
Customize.
The Add-In Manager dialog opens.
2. Click the Add New Menu Item button on the toolbar.
The Add New Menu Item dialog opens.
3. Set Name to AddIn Sample.
4. Set COM ProgId to ERwinSpy_AddIn_Sample.ErwinSpy.
5. Set Function Name to Run.
6. In the Menu Type box, select Com Object.
7. Click Save to save your settings.

When the sequence is executed, a new menu item is created in the AllFusion
ERwin DM Tools menu under Add-Ins. The name of the item matches the text
that was typed in Name field of the Add New Menu Item dialog, which in this
case is AddIn Sample. You can select this new menu item to activate the add-in
sample component. The Models menu of the add-in shows the models opened in
AllFusion ERwin DM.

API Components 2–13


ERwin Spy

ERwin Spy
The ERwin Spy application visualizes metadata information and provides
intrinsic and model-specific metadata. It demonstrates the API functionality and
provides a set of useful features to study how AllFusion ERwin DM stores model
data. ERwin Spy reads the AllFusion ERwin DM metamodel and simplifies the
task of comprehending the intricate details of any AllFusion ERwin DM model,
which can be a complicated net of model objects, properties, and
cross-references. When you install AllFusion ERwin DM, you can choose to
install the optional ERwin Spy utility.

There are two versions of the utility available in the ERwin Spy folder:
■ Standalone version—[Link]
■ Add-in version—ERwinSpy_AddIn.[Link]

These versions are identical in functionality and vary only in how you wish to
launch the application. The standalone version runs without AllFusion ERwin
DM present and can access models stored in .erwin files, while the add-in
version launches within AllFusion ERwin DM from the Tools menu and can
access models in AllFusion ERwin DM memory and .erwin files.

How the ERwin Spy Application Works

To see how ERwin Spy can help you visualize metadata information, do the
following:
■ Start with an empty logical-physical model.
■ Run ERwin Spy by selecting it from the Tools/Add-Ins menu.
■ In ERwin Spy, select the top item from the Models menu, which should be
your empty model.
■ The left panel of ERwin Spy is the Objects list. Double-click the Model object
to expand it. You should see a picture similar to the following:

2–14 AllFusion ERwin Data Modeler API Reference Guide


ERwin Spy

As you can see, there are quite a number of objects listed by ERwin Spy. Even
though the model is empty, you will still see objects there that represent
AllFusion ERwin DM defaults, such as Domains, Main Subject Area, Trigger
Templates, and so on. All default objects are marked with a { Default; } flag to the
right of the type of the model object.

The right panel of ERwin Spy displays object properties. To see a specific object’s
properties, select the object, click the button located in the center of the screen,
and the selected object’s properties display in the right panel. The following
graphic shows the properties of a specific entity that was added to this model:

API Components 2–15


ERwin Spy

The first column shows property names, such as Name, Long ID, Type, Physical
Name, and so on.

The second column, DT, shows property datatypes, such as Str for a string, I4 for
a number, Bool for Boolean, Id for a reference to another object, and so on.

The third column, Value, displays the property value in native format.

The fourth column, As String, displays the property value reinterpreted as a


string. To understand this better, look at Physical Name in the left column. Its
value in the Value column is %EntityName(), which is a macro, while As String
holds the macro expansion, Entity_1.

The rest of the columns in the right panel represent property flags. You may have
to scroll to the right in order to see them. The following describes the meaning of
these columns:
■ NL—Properties with NULL/no value (the flag is never on for ERwin Spy)
■ UD—User-defined properties
■ VC—Vector properties
■ TL—Properties that are maintained by AllFusion ERwin DM and that cannot
be changed directly using the API
■ RO—Read-only properties
■ DR—Derived properties whose value was inherited (from a parent domain,
for instance)
■ OP—Property is optional and can be removed

In the previous graphic, we had added a primary key attribute named ATTR01
to Entity_1. It was migrated to Entity_2 by creating an identifying relationship.
To see how ERwin Spy displays the information, double-click Entity_2, and then
select ATTR01. Click the button in the center of the screen to view its properties
on the right.

2–16 AllFusion ERwin Data Modeler API Reference Guide


ERwin Spy

One point of interest is the Parent Relationship property. Since the attribute is a
product of foreign-key migration, this property shows which relationship object
is used to store data about it. The value Id in the DT column shows that the
property is a reference, which just means that the value is a unique ID of the
involved relationship object.

In order to traverse back to the relationship object, look at the name in the As
String column or locate an object by its unique ID. In order to see objects IDs,
enable this option by selecting Show Ids from the File/Options menu. With this
option enabled, when the cursor is positioned over an object in the left panel, that
object’s unique ID is displayed in a popup window.

Now, compare the Parent Relationship property with the Parent Attribute Ref
and the Master Attribute properties. Note that the Master Attribute property is
read-only. This means that it is displayed for informational purposes only and
cannot be changed using the API. As you build your model, you can expand
objects in the model to see how AllFusion ERwin DM uses their properties to
represent different relationships in the model.

API Components 2–17


ERwin Spy

Take advantage of the ERwin Spy utility to see and understand the details of the
data in an AllFusion ERwin DM model that is available through the API. If you
need to learn how particular data is represented in an AllFusion ERwin DM
model, you can use the scenarios that were just described. Start with an empty
model, create the minimum model that is necessary to represent the feature in
question, and then use ERwin Spy to look at the details of the data
representation.

2–18 AllFusion ERwin Data Modeler API Reference Guide


Chapter

API Tasks
3
This chapter describes how to perform basic tasks using the AllFusion ERwin
DM API. Each task is documented with a table that lists the interfaces and
methods needed for that task. In most cases, the table shows a subset of all the
methods for the given interface. For a complete list of API interfaces and their
respective methods, see the appendix “API Interfaces Reference.”

Getting Started
This section describes what you need to begin using the AllFusion ERwin DM
API.

API Environment

The API is packaged as a set of COM Dynamic Link Libraries (DLL) and works
as a part of a customer process. [Link] is responsible for launching the API
environment. When AllFusion ERwin DM is installed, [Link] and the rest of the
API components are copied to the Binaries directory, (a subdirectory of the
install directory) and the installer registers the API with the System Registry.

To use the API in a development environment, use the API Type Library
embedded as a resource in the [Link] file. This operation is language specific.
Consult your development environment documentation for details.

The AllFusion ERwin DM API works in two different modes: standalone mode
and add-in mode. In the standalone mode, the API is activated and controlled by
a client application that hosts its own process.

In the add-in mode, the API is also activated and controlled by a client
application, but the client application is implemented as a COM DLL. The
AllFusion ERwin DM executable owns a process and all the client application
DLLs run inside of that process. To be available for the add-in mode activation,
COM DLLs must be registered with the System Registry and with the AllFusion
ERwin DM Add-In Manager.

API Tasks 3–1


Getting Started

Behavior of the API components in both modes is the same with a few
exceptions that are discussed further in this section.

The AllFusion ERwin DM API is implemented as a tree of COM interfaces. The


application exports the top-level interface, from which the client fetches
lower-level interfaces as needed.

Creating the ISCApplication Object

The entry point into the interface hierarchy of the API is through the
ISCApplication interface. The ISCApplication interface provides access to the
persistence units and sessions. You must create an instance of ISCApplication
prior to using any of the other interfaces in the API.

The following examples illustrate how to create the ISCApplication object:


Example 1

C++ #import "[Link]" using namespace SCAPI;

ISCApplicationPtr scAppPtr;
HRESULT hr;

hr = [Link](__uuidof(SCAPI::Application));

Visual Basic .NET Dim scApp As [Link]


scApp = New [Link]

// Or the alternative with the ProgId


Dim oApp As Object
oApp = CType(CreateObject("[Link]"), [Link])

3–2 AllFusion ERwin Data Modeler API Reference Guide


Application Properties

Application Properties
You can get information about the AllFusion ERwin DM application by using the
following tables.

ISCApplication Interface

The following table contains information on the ISCApplication interface:

Signature Description Valid Arguments


BSTR Name() Modeling Application Title None
BSTR Version() Modeling Application Version None
BSTR ApiVersion() API version None
ISCApplicationEnvironment Reports attributes of runtime None
ApplicationEnvironment() environment and available
features such as add-in mode,
user interface visibility, and so
on
ISCPersistenceUnitCollection Returns a collection of all None
* PersistenceUnits() persistence units loaded in the
application.
ISCSessionCollection * Returns a collection of sessions None
Sessions() created within the application

API Tasks 3–3


Application Properties

ISCApplicationEnvironment

The following table contains information on the ISCApplicationEnvironment


interface:

Signature Description Valid Arguments


ISCPropertyBag Populates a property bag Category:
PropertyBag(VARIANT with one or more property ■ Empty—Complete set of features from all
Category[optional], values as indicated by categories returned
VARIANT Name[optional], Category and Name
■ VT_BSTR—Features returned from the
VARIANT given category
AsString[optional])
Name:
■ Empty—All properties from the selected
category are returned
■ VT_BSTR—The property with the given
name and category returned
AsString:
■ Empty—All values in the property bag
are presented in their native type
■ VT_BOOL—If set to TRUE, all values in
the property bag are presented as strings

Feature categories in the Category parameter of the PropertyBag property are


hierarchical and use a dot (.) to define feature subsets. For instance, the
Application category populates a property bag with a complete set of AllFusion
ERwin DM features, while [Link] provides a subset related to the
AllFusion ERwin DM API.

If the Category parameter is not set, then the Property Bag property returns the
complete set of all the features from all the available categories.

3–4 AllFusion ERwin Data Modeler API Reference Guide


Application Properties

The following examples illustrate how to use the API to retrieve the Application
Features. The examples use the Application object created in Example 1 shown
previously:
Example 2

C++ void IteratePersistenceUnits(ISCApplicationPtr & scAppPtr)


{
ISCPropertyBagPtr scBag;

// Retrieve all of application environment properties in one call


scBag = scAppPtr ->GetApplicationEnvironment()->GetPropertyBag();
// Get an array with categories by using empty string as a category name
scBag = scAppPtr ->GetApplicationEnvironment()->GetPropertyBag("",
"Categories")

// Get Api Version value Application Api category


scBag = scAppPtr ->GetApplicationEnvironment()->GetPropertyBag
("[Link]",
"Api Version")
}

API Tasks 3–5


Application Properties

Visual Basic .NET Public Sub GetApplicationFeatures(ByRef scApp As [Link])


Dim scBag As [Link]
' Retrieve all of application environment properties in one call
scBag = [Link]
' Retrieve values
PrintPropertyBag(scBag)
' Get an array with categories by using empty string as a category name
scBag = [Link]("", "Categories")
' Retrieve a list of categories from the bag
Dim aCategories() As String
Dim CategoryName As Object
If IsArray([Link]("Categories")) Then
' Retrieve an array
aCategories = [Link]("Categories")
If [Link] > 0 Then
' Retrieve values on category basis
For Each CategoryName In aCategories
' Get a property bag with values for the category
scBag = [Link](CategoryName)
[Link](" Values for the " + CategoryName + " category:")
' Retrieve values
PrintPropertyBag(scBag)
Next CategoryName
End If
End If
' Get Api Version value Application Api category
scBag = [Link]("[Link]", "Api
Version")
' Retrieve values
PrintPropertyBag(oBag)
End Sub
' Retrieves and prints values from a property bag
Public Sub PrintPropertyBag(ByRef oBag As [Link])
Dim Idx As Short
Dim nIdx1 As Short
If Not (oBag Is Nothing) Then
For Idx = 0 To [Link] - 1
If IsArray([Link](Idx)) Then
' Retrieve an array
If [Link](Idx).Length > 0 Then
[Link](Str(Idx) + ") " + [Link](Idx) + " is an
array: ")
For nIdx1 = 0 To UBound([Link](Idx))
[Link](" " + [Link](Idx)(nIdx1).ToString)
Next nIdx1
End If
Else
' A single value
[Link](Str(Idx) + ") " + [Link](Idx) + " = " + _
[Link](Idx).ToString)
End If

Next Idx
End If
End Sub

3–6 AllFusion ERwin Data Modeler API Reference Guide


Accessing a Model

Accessing a Model
An API client accesses model data by working with a pool of available
persistence units. A persistence unit is the API concept that describes all data
related to a single model. A persistence unit can be accessed and saved to
persistence storage, such as a file or an AllFusion Model Manager model. A
client manipulates persistence units by using the Persistence Units collection.

The existence of some persistence units in the application is dictated by a context


in which an instance of the application was created. For example:
■ Standalone mode—None of the units exist at launch time. Methods from the
unit collection interface must be used to accumulate units in the collection.
■ Add-in component—The collection contains all the units known to the
AllFusion ERwin DM user interface at the time when the client component is
activated.

Similarly, when the client program is terminated, the arrangement for the
persistence units in memory is as follows:
■ Standalone mode—All units are closed.
■ Add-in component—After the client program has ended, the units are still
open and available in the AllFusion ERwin DM user interface with the
exception of those that were explicitly closed and removed from the
persistence unit collection before exiting the program.

Note: For AllFusion ERwin DM, the collection is a snapshot. The collection
includes only those units that exist at the moment of collection construction
(such as at the moment when the PersistenceUnits method of the ISCApplication
interface was called). An exception to this is units added or deleted from the
collection—these changes are reflected. All new collections reflect the changes as
well.

Using the API as an Add-in Tool

When the API client is a DLL that is invoked by selecting Add-Ins from the
AllFusion ERwin DM Tools menu, the client runs within the environment of
AllFusion ERwin DM. As a result, all the models that are currently open within
AllFusion ERwin DM are populated in the PersistenceUnits property of the
ISCApplication interface, when an instance of the interface is created.

To iterate through the models that are currently open in AllFusion ERwin DM,
you can use the ISCApplication interface, ISCPersistenceUnitCollection interface,
and the ISCPersistenceUnit interface, which are described in the sections that
follow.

API Tasks 3–7


Accessing a Model

ISCApplication Interface

The following table contains information on the ISCApplication interface:

Signature Description Valid Arguments


ISCPersistenceUnitCollection Returns a collection of all None
PersistenceUnits() persistence units loaded in
the application

ISCPersistenceUnitCollection Interface

The following table contains information on the ISCPersistenceUnitCollection


interface:

Signature Description Valid Arguments


ISCPersistenceUnit Passes back a pointer for nIndex:
Item(VARIANT nIndex) the PersistenceUnit ■ VT_UNKNOWN—A pointer to a session.
component identified by Retrieves the persistence unit associated
its ordered position with the session.
■ VT_I4—Index within the collection.
Collection index is from 0 to size-1.
Retrieves the persistence unit in the
collection with the given index.
■ VT_BSTR—Application-wide unique
persistence unit identifier.
long Count() Number of persistence None
units in the collection

3–8 AllFusion ERwin Data Modeler API Reference Guide


Accessing a Model

ISCPersistenceUnit Interface

The following table contains information on the ISCPersistenceUnit interface:

Signature Description Valid Arguments


BSTR Name() Returns the name of the None
persistence unit
SC_MODELTYPEID Returns an identifier for None
ObjectId() the persistence unit
ISCPropertyBag Returns a property bag List:
PropertyBag(VARIANT with the properties of the ■ VT_BSTR—Semicolon-separated list of
List[optional], VARIANT persistence unit property names. Returns a property bag
AsString[optional]) with the unit properties in the given list.
AsString:
■ VT_BOOL—Returns a property bag with
all values presented as strings if set to
TRUE. Otherwise, the values are
presented in its native format.
VARIANT_BOOL Returns TRUE if a unit has None
HasSession() one or more sessions
connected
VARIANT_BOOL IsValid() Returns TRUE is self is None
valid

Property Bag Members for a Persistence Unit

The following table shows some property names and descriptions for property
bag members of an existing persistence unit. Note: For the complete set of
available properties, see the appendix, “API Interfaces Reference.”

Property Name Type Description


Locator BSTR Returns the location of the persistence unit,
such as file name. Not available for models
without a persistence location, such as new
models that were never saved.
Disposition BSTR Returns the disposition of the persistence
unit, such as read-only.
Persistence Unit Id SC_MODELTYPEID Retrieves an identifier for the persistence
unit.

API Tasks 3–9


Accessing a Model

Property Name Type Description


Model Type Long Retrieves the type of the persistence unit,
such as logical, logical-physical, and
physical models.
Target Server Long Retrieves the target database properties for
Target Server Version physical and logical-physical models.
Target Server Minor Version
Active Model Boolean TRUE if the persistence unit represents the
current model and is active in the AllFusion
ERwin DM user interface. Not available for
the AllFusion ERwin DM API in standalone
mode.
Hidden Model Boolean TRUE if a model window with the
persistence unit data is not visible in the
AllFusion ERwin DM user interface. Not
available for the AllFusion ERwin DM API
in standalone mode.
Active Subject Area and SAFEARRAY(BSTR) Reports names of active Subject Area and
Stored Display Stored Display model objects. This indicates
the Subject Area and Stored Display that
AllFusion ERwin DM shows on the screen.
The returned value is a safe-array with two
elements. The first element is a name for the
active Subject Area and the second element
is for the Stored Display.

3–10 AllFusion ERwin Data Modeler API Reference Guide


Accessing a Model

ISCPropertyBag Interface

The following table contains information on the ISCPropertyBag interface:

Signature Description Valid Arguments


long Count() Returns the number of None
properties
VARIANT Value(VARIANT Retrieves the indicated Property:
Property) property in the bag ■ VT_BSTR—Name of property. Value
of the property with the given name in
the property bag.
■ VT_I4— Zero-based property index.
Value of the property with the given
index in the property bag.
BSTR Name(long Retrieves the indicated None
PropertyIdx) property name with the
given index. Range of
indices is from 0 to size-1.

API Tasks 3–11


Accessing a Model

The following examples illustrate how to use the API as an add-in tool to iterate
through the open models. The examples use the Application object created in
Example 1 previously:
Example 3

C++ void IteratePersistenceUnits(ISCApplicationPtr & scAppPtr)


{
ISCPersistenceUnitCollectionPtr scPUnitColPtr;
scPUnitColPtr = scAppPtr->GetPersistenceUnits();

ISCPersistenceUnitPtr scPUnit = 0;
long lCnt = scPUnitColPtr->GetCount();

for(long i = 0; i < lCnt; i++)


{
scPUnit = scPUnitColPtr->GetItem(i);
CString csName = scPUnit->GetName(); // name of model
ISCPropertyBagPtr scPropBag = scPUnit->GetPropertyBag("Locator;Active
Model");
long index = 0;
CComVariant vPathName = scPropBag->GetValue(ColeVariant(index)); // full
path of model
index = 1;
CComVariant cActiveModel = scPropBag->GetValue(COleVariant(index)); //
true if active model
// …
}
}

3–12 AllFusion ERwin Data Modeler API Reference Guide


Accessing a Model

Visual Basic .NET Public Sub IteratePersistenceUnits(ByRef scApp As [Link])

Dim scPersistenceUnitCol as [Link]

Dim numUnits As Integer


Dim scPUnit As [Link]

scPersistenceUnitCol = [Link]

' Count open units


numUnits = [Link]
If (numUnits > 0) Then
For Each scPUnit In scPersistenceUnitCol
Dim propBag As [Link]

propBag = [Link]("Locator")
[Link]( [Link] ) ' name of model
[Link]( [Link](0)) ' full path of model
' …
Next
End If
End Sub

Using the API as a Standalone Executable

When the API client is a standalone executable, the client runs outside the
AllFusion ERwin DM environment. As a result, when the ISCApplication
interface is created, the PersistenceUnits property is an empty collection. Even if
AllFusion ERwin DM is running and there are open models, the PersistenceUnits
property is still empty because the API environment is independent of the
AllFusion ERwin DM environment. To get a valid persistence unit, the API client
needs to either create a new model or open an existing model.

API Tasks 3–13


Accessing a Model

Creating a Model

To create a new model using the API, you first need to create a new instance of
ISCPropertyBag. The ISCPropertyBag interface is a property bag that is used to
hold the properties of the new model. The following properties are used in
creating a new model.

Note: For the complete set of properties, see the appendix “API Interfaces
Reference.”

Property Name Type Description


Model Type Long Sets the type of the persistence unit as follows:
■ 1—Logical (for logical models; this is the default if no

type is provided)
■ 2—Physical (for physical models)

■ 3—Combined (for logical/physical models)

Target Server Long Sets the target database properties for physical and
Target Server Version logical/physical models.
Target Server Minor Version For more details, see the appendix “API Interfaces
Reference.”

Once the property bag is created and populated, a new persistence unit must be
created within the persistence unit collection.

ISCPersistenceUnitCollection Interface

The following table contains information on the ISCPersistenceUnitCollection


interface:

Signature Description Valid Arguments


ISCPersistenceUnit * Creates a new unit, and ObjectId:
Create(ISCPropertyBag * registers the unit with ■ Empty—The AllFusion
PropertyBag, VARIANT the collection ERwin DM API
ObjectId [optional]) assigns an ID to the
new persistence unit.
■ VT_BSTR—The
AllFusion ERwin DM
API assigns the given
ID to the new
persistence unit.

3–14 AllFusion ERwin Data Modeler API Reference Guide


Accessing a Model

ISCPropertyBag Interface

The following table contains information on the ISCPropertyBag interface:

Signature Description Valid Arguments


VARIANT_BOOL Adds a new property to Value:
Add(BSTR Name, the bag All VARIANTs are valid.
VARIANT Value) The function returns
TRUE if the property was
added to the bag,
otherwise, it is FALSE.

The following examples illustrate how to create a new persistence unit. The
examples use the Application object created in Example 1 previously:
Example 4

C++ ISCPersistenceUnitPtr CreateNewModel(ISCApplicationPtr & scAppPtr)


{
ISCPersistenceUnitCollectionPtr scPUnitColPtr;
scPUnitColPtr = scAppPtr->GetPersistenceUnits();

ISCPropertyBagPtr propBag;
HRESULT hr =[Link](__uuidof(SCAPI::PropertyBag));
if (FAILED(hr))
return;
propBag->Add("Name", “Test Model”);
propBag->Add("ModelType", “Logical”);
ISCPersistenceUnitPtr scPUnitPtr = scPUnitColPtr->Create(propBag,vtMissing);
return scPUnitPtr;
}

Visual Basic .NET Public Function CreateNewModel(ByRef scApp As [Link]) As


[Link]
Dim scPersistenceUnitCol as [Link]
scPersistenceUnitCol = [Link]

Dim propBag As New [Link]

[Link]("Name", "Test Model")


[Link]("ModelType", 0)
CreateNewModel = [Link](propBag)
End Function

API Tasks 3–15


Accessing a Model

Opening an Existing Model

An existing AllFusion ERwin DM model is opened by adding a persistence unit


to the persistence unit collection (ISCPersistenceUnitCollection). When the API
client is an add-in tool, opening a model through the API also opens the model
in the AllFusion ERwin DM user interface.

ISCPersistenceUnitCollection Interface

The following table contains information on the ISCPersistenceUnitCollection


interface:

Signature Description Valid Arguments


ISCPersistenceUnit * Adds a new persistence Locator:
Add(VARIANT Locator, unit to the unit collection ■ VT_BSTR—Full path
VARIANT Disposition to the AllFusion
[optional]) ERwin DM model.
This is the model that
is loaded into the
persistence unit.
Disposition:
■ VT_BSTR— Arranges
access attributes, such
as read only.
For a detailed description
of the location and format
of disposition parameters,
see the appendix “API
Interfaces Reference.”

The following examples illustrate how to open an existing model. The examples
use the Application object created in Example 1 previously:
Example 5

C++ ISCPersistenceUnitPtr OpenModel(ISCApplicationPtr & scAppPtr, CString &


csFullPath)
{
ISCPersistenceUnitCollectionPtr scPUnitColPtr;
scPUnitColPtr = scAppPtr->GetPersistenceUnits();
ISCPersistenceUnitPtr scPUnitPtr = scPUnitColPtr-
>Add(COleVariant(csFullPath));
return scPUnitPtr;
}

3–16 AllFusion ERwin Data Modeler API Reference Guide


Accessing a Model

Visual Basic .NET Public Function OpenModel(ByRef scApp As [Link], _


fullModelPath As String) As [Link]
Dim scPersistenceUnitCol as [Link]
scPersistenceUnitCol = [Link]

OpenModel = [Link](fullModelPath)
End Sub

Opening a Session

Before the objects of a model can be accessed using the API, an ISCSession
instance must first be established for the ISCPersistenceUnit of the model. To
open a session for a persistence unit, add a new ISCSession to the
ISCSessionCollection, and then open the ISCPersistenceUnit in the new session.

ISCSessionCollection Interface

The following table contains information on the ISCSessionCollection interface:

Signature Description Valid Arguments


ISCSession * Add() Constructs a new, closed None
Session object, and adds
it to the collection

API Tasks 3–17


Accessing a Model

ISCSession Interface

The following table contains information on the ISCSession interface:

Signature Description Valid Arguments


VARIANT_BOOL Binds self to the Unit:
Open(IUnknown * Unit, persistence unit identified ■ Pointer to a persistence unit that was loaded.
VARIANT Level by the Unit parameter Attaches the persistence unit to the session.
[optional], VARIANT
Level:
Flags [optional])
■ Empty—Defaults to data level access
(SCD_SL_M0).
■ SCD_SL_M0—Data level access.
Flags:
■ Empty—Defaults to SCD_SF_NONE.
■ SCD_SF_NONE—Specifies that other
sessions can have access to the attached
persistence unit.
■ SCD_SF_EXCLUSIVE —Specifies that other
sessions cannot have access to the attached
persistence unit.

The following examples illustrate how to open a session. The examples use the
Application object created in Example 1 and the CreateNewModel function from
Example 4:
Example 6

C++ ISCSessionPtr OpenSession(ISCApplicationPtr & scAppPtr)


{
ISCSessionCollectionPtr scSessionColPtr = scAppPtr->GetSessions();
ISCSessionPtr scSessionPtr = scSessionColPtr->Add(); // add a new session
ISCPersistenceUnitPtr scPUnitPtr = CreateNewModel(scAppPtr); // From Example 4

CComVariant varResult = scSessionPtr->Open(scPUnitPtr, (long) SCD_SL_M0); //


open unit
if ([Link] == VT_BOOL && [Link] == FALSE)
return NULL;
return scSessionPtr;
}

3–18 AllFusion ERwin Data Modeler API Reference Guide


Accessing a Model

Visual Basic .NET Public Function OpenSession(ByRef scApp As [Link]) As [Link]


Dim scSessionCol As [Link]
Dim scPUnit As [Link]
scSessionCol = [Link]
OpenSession = [Link] 'new session

scPUnit = CreateNewModel(scApp) ‘ From Example 4


[Link](scPUnit, SCD_SL_M0) ' open the persistence unit
End Sub

Accessing a Model Set

A persistence unit contains data as a group of linked model sets. The model sets
are arranged in a tree-like hierarchy with a single model set at the top.

The top model set in a persistence unit contains the bulk of modeling data. The
AllFusion ERwin DM API uses the abbreviation EMX to identify the top model
set.

The EMX model set owns a secondary model set, abbreviated as EM2, that
contains user options and user interface settings.

The ISCSession interface allows you to open the top model set by simply
providing a pointer to the ISCPersistenceUnit interface in ISCSession::Open call.

It is possible to iterate over all model sets constituting a persistence unit. While
iterating, a pointer to the ISCModelSet interface can be used to open a session
with the particular model set. This is done by submitting the pointer to
ISCSession::Open call as the first parameter, instead of a persistence unit.

The ModelSet property of the ISCPersistenceUnit interface provides the starting


point for iteration over a persistence unit’s model sets. The use of the
OwnedModelSets property of ISCModelSet allows you to iterate over the next
level of model sets in the persistence unit.

ISCPersistenceUnit Interface

The following table contains information on the ISCPersistenceUnit interface:

Signature Description Valid Arguments


ISCModelSet * ModelSet() Passes back a pointer on None
the top model set in the
Persistence Unit.

API Tasks 3–19


Accessing a Model

ISCModelSet Interface

The following table contains information on the ISCModelSet interface:

Signature Description Valid Arguments


ISCModelSetCollection * Provides a collection None
OwnedModelSets() with directly owned
model sets.

ISCModelSetCollection Interface

The following table contains information on the ISCModelSetCollection


interface:

Signature Description Valid Arguments


ISCModelSet * Passes back a pointer for nIndex:
Item(VARIANT nIndex) a ModelSet component. ■ VT_I4 —Index of a model set in the model set
collection. The index is zero-based.
■ VT_BSTR—Model set identifier.
■ VT_BSTR—Class identifier for metadata
associated with a model set.
■ VT_BSTR—Class name for metadata
associated with a model set.
For information on metadata class identifiers and
names, see the appendix “AllFusion ERwin DM
Metamodel.”

3–20 AllFusion ERwin Data Modeler API Reference Guide


Accessing a Model

ISCSession Interface

The following table contains information on the ISCSession interface:

Signature Description Valid Arguments


VARIANT_BOOL Binds self to the model set ModelSet:
Open(IUnknown * identified by the ModelSet ■ Pointer to a model set from a persistence unit
ModelSet, VARIANT parameter that was loaded. Attaches the model set to
Level [optional], the session.
VARIANT Flags
Level:
[optional])
■ Empty—Defaults to data level access
(SCD_SL_M0).
■ SCD_SL_M0—Data level access.
Flags:
■ Empty—Defaults to SCD_SF_NONE.
■ SCD_SF_NONE—Specifies that other
sessions can have access to the attached
persistence unit.
■ SCD_SF_EXCLUSIVE —Specifies that other
sessions cannot have access to the attached
persistence unit.

API Tasks 3–21


Accessing a Model

The following examples illustrate how to open a session with the EM2 model of
a persistence unit. The examples use the Application object created in Example 1
and the CreateNewModel function from Example 4:
Example 7

C++ void OpenEM2(ISCApplicationPtr & scAppPtr)


{
ISCSessionCollectionPtr scSessionColPtr = scAppPtr->GetSessions();
ISCPersistenceUnitPtr scPUnitPtr = CreateNewModel(scAppPtr); // From Example 4

ISCModelSetPtr scEMXModelSetPtr = scPUnitPtr->ModelSet(); // Collect the top


model set
ISCModelSetPtr scEM2ModelSetPtr = scEMXModelSetPtr->GetOwnedModelSets()->

GetItem(COleVariant("EM2"));

if (scEM2ModelPtr != NULL)
{
ISCSessionPtr scSessionPtr = scSessionColPtr->Add(); // add a new session
CComVariant varResult = scSessionPtr->Open(scEM2ModelSetPtr);
if ([Link] == VT_BOOL && [Link] == FALSE)
return;

// …
}

Visual Basic .NET Public Sub OpenEM2(ByRef scApp As [Link] )

Dim scSession As [Link]


Dim scEMXModelSet As [Link]
Dim scEM2ModelSet As [Link]
Dim scPUnit As [Link]

scSessionCol = [Link]
scPUnit = CreateNewModel(scApp) ‘ From Example 4

' Access the top model set - of EMX type


scEMXModelSet = [Link]
' Access an owned EM2 model set by class name
scEM2ModelSet = [Link]("EM2")
[Link](vbTab + " Access EM2 Model Set by class name" +
[Link] + _
" Id " + [Link])
[Link](vbTab + vbTab + " Class Name " + [Link] + _
" Class id " + [Link])
scSession = [Link] ' new session
[Link](scEM2ModelSet, SCD_SL_M0) ' connect EM2 to a session
'…
End Sub

3–22 AllFusion ERwin Data Modeler API Reference Guide


Accessing Objects in a Model

Accessing Objects in a Model


You can access model objects through the ModelObjects property in an active
ISCSession instance. The ModelObjects property is a collection of all model
objects associated with the persistence unit of the session. The ModelObjects
property is an instance of the ISCModelObjectCollection. Iteration through an
instance of ISCModelObjectCollection is done in a depth-first fashion, and
returns instances of ISCModelObject.

Interfaces Used to Access Model Objects

The following sections describe the interfaces used to access model objects.

ISCSession Interface

The following table contains information on the ISCSession interface:

Signature Description Valid Arguments


ISCModelObjectCollection * Creates a ModelObject None
ModelObjects() collection for the session

ISCModelObjectCollection Interface

The following table contains information on the ISCModelObjectCollection


interface:

Signature Description Valid Arguments


long Count() Number of objects in the None
collection
IUnknown _NewEnum() Constructs an instance of None
the collection
enumerator object

API Tasks 3–23


Accessing Objects in a Model

ISCModelObject Interface

The following table contains information on the ISCModelObject interface:

Signature Description Valid Arguments


BSTR ClassName() Returns the class name of None
the current object
SC_OBJID ObjectId() Uniquely identifies the None
current object
BSTR Name() Returns the name or a None
string identifier of the
current object
SC_CLSID ClassId() Returns the class None
identifier of the current
object
ISCModelObject * Passes back the context None
Context() (parent) of the object

3–24 AllFusion ERwin Data Modeler API Reference Guide


Accessing Objects in a Model

The following examples illustrate how to access model objects. The examples use
the Application object created in Example 1 and the OpenSession function from
Example 6:
Example 8

C++ void IterateObjects(ISCApplicationPtr & scAppPtr)


{
ISCSessionPtr scSessionPtr = OpenSession( scAppPtr ); // From Example 6
//Make sure the Session Ptr is Open
if(!scSessionPtr->IsOpen())
{
AfxMessageBox("Session Not Opened");
return;
}

ISCModelObjectCollectionPtr scModelObjColPtr = scSessionPtr-


>GetModelObjects();
IUnknownPtr _NewEnum = NULL;
IEnumVARIANT* ObjCollection;

_NewEnum = scModelObjColPtr ->Get_NewEnum();


if (_NewEnum != NULL)
{
HRESULT hr = _NewEnum->QueryInterface(IID_IEnumVARIANT, (LPVOID*)
&ObjCollection);
if (!FAILED(hr))
{
COleVariant xObject;
while (S_OK == ObjCollection->Next(1,&xObject,NULL))
{
ISCModelObjectPtr pxItem = (V_DISPATCH (&xObject));
// ISCModelObject in xObject was AddRefed already. All we need is to
attach it
// to a smart pointer
[Link]();
// Process the Item
CString csName = (LPSTR) pxItem->GetName();
CString csID = (LPSTR) pxItem->GetObjectId();
CString csType = (LPSTR) pxItem->GetClassName();
// …
}
}
if (ObjCollection)
ObjCollection->Release();
}
}

API Tasks 3–25


Accessing Objects in a Model

Visual Basic .NET Public Sub IterateObjects(ByRef scApp As [Link])


Dim scSession As [Link]
Dim scModelObjects As [Link]
Dim scObj As [Link]

scSession = OpenSession( scApp ) ' From Example 6


' Make sure that the session is open
If [Link]() Them
scModelObjects = [Link]

For Each scObj In scModelObjects


[Link]( [Link] )
[Link]( [Link] )
[Link]( [Link] )
Next
End If
End Sub

3–26 AllFusion ERwin Data Modeler API Reference Guide


Accessing Objects in a Model

Accessing a Specific Object

You can directly access model objects in an ISCModelObjectCollection instance


by using the Item method of the interface.

ISCModelObjectCollection Interface

The following table contains information on the ISCModelObjectCollection


interface:

Signature Description Valid Arguments


ISCModelObject * Returns an IUnknown nIndex:
Item(VARIANT nIndex, pointer for a Model Object ■ VT_UNKNOWN—Pointer to the
VARIANT Class component identified by ISCModelObject interface. Given object is
[optional]) the nIndex parameter returned from the collection.
■ VT_BSTR—ID of an object. The object with

the given identifier is returned from the


collection.
■ VT_BSTR—Name of an object. If the name

of an object is used, the Class parameter


must also be used. The object with the given
name and given Class type is returned from
the collection.
Class:
■ Empty—The object specified by nIndex is

returned from the collection.


■ VT_BSTR—Name of a class. Must be used if

the nIndex parameter is the name of an


object. Returns the object with the given
name and given Class. For valid object class
names, see the appendix “AllFusion ERwin
DM Metamodel.”
■ VT_BSTR—Class ID of object type. Must be

used if the nIndex parameter is the name of


an object. Returns the object with the given
name and given Class identifier. For valid
object class identifiers, see the appendix
“AllFusion ERwin DM Metamodel.”

API Tasks 3–27


Accessing Objects in a Model

The following examples illustrate how to access a specific object. The examples
use a Session object from Example 6:
Example 9

C++ void GetObject(ISCSessionPtr & scSessionPtr, CString & csID)


{
ISCModelObjectCollectionPtr scModelObjColPtr = scSessionPtr-
>GetModelObjects();
ISCModelObjectPtr scObjPtr = scModelObjColPtr->GetItem(COleVariant(csID));
// …
}

Visual Basic .NET Public Sub GetObject(ByRef scSession As [Link], ByRef objID As String)
Dim scObjCol as [Link]
Dim scObj as [Link]

scObjCol = [Link]
scObj = [Link](objID) ' retrieves object with given object ID
End Sub

Filtering Object Collections

You can create subsets of a collection by using


ISCModelObjectCollection::Collect method. The Collect method creates a new
instance of the Model Objects collection component based on the filtering criteria
specified in the parameters of the method. The filtering criteria is optional, and
any number of combinations of criteria can be used.

ISCModelObjectCollection Interface

The following table contains information on the ISCModelObjectCollection


interface:

Signature Description Valid Arguments


ISCModelObjectCollection * Creates a Model Objects Root:
Collect(VARIANT Root, collection, which VT_UNKNOWN—ISCModelObject

VARIANT ClassId [optional], represents a subcollection pointer of the root object. Returns the
VARIANT Depth [optional], of itself. descendants of the given object.
■ VT_BSTR—The Object ID of the root
VARIANT MustBeOn The method creates a valid
[optional], VARIANT object. Returns the descendants of the
collection even though the
MustBeOff [optional]) object with the given object identifier.
collection may be empty.
ClassId:
■ VT_ARRAY|VT_BSTR—SAFEARRAY

of class IDs. Returns the descendants of


the root with the given object class

3–28 AllFusion ERwin Data Modeler API Reference Guide


Accessing Objects in a Model

Signature Description Valid Arguments


identifiers. For more information on valid
object identifiers, see the appendix
“AllFusion ERwin DM Metamodel.”
■ VT_ARRAY|VT_BSTR—SAFEARRAY
of class names. Returns the descendants
of the root with the given object class
name. For more information on valid
object class names, see the appendix
“AllFusion ERwin DM Metamodel.”
■ VT_BSTR—Class ID. Returns the
descendants of the root with the given
object class identifier.
■ VT_BSTR—Semicolon delimited list of
class IDs. Returns the descendants of the
root with the given class identifiers.
■ VT_BSTR—Class name. Returns the
descendants of the root with the given
class name.
■ VT_BSTR—Semicolon delimited list of
class names. Returns the descendants of
the root with the given class names.
■ Empty—Returns all descendants
regardless of class type.
Depth:
■ VT_I4—Maximum depth. Returns the

descendants of the root at a depth no


more than the given depth. A depth of –1
represents unlimited depth.
■ Empty—Returns all descendants of the

root (unlimited depth).


MustBeOn:
■ VT_I4 —Returns the descendants of the

root with the given object flags set. For


more information about
SC_ModelObjectFlags, see the
Enumerations section in the appendix
“API Interfaces Reference.”
■ Empty—Defaults to

SCD_MOF_DONT_CARE.
MustBeOff:
■ VT_I4 —Returns the descendants of the

root that do not have the given object


flags set.
■ Empty—Defaults to

SCD_MOF_DONT_CARE.

API Tasks 3–29


Accessing Objects in a Model

The following sections show the code examples for the different filters.

Object Type Filter

The following examples illustrate the Object Type filter. The examples use the
Session object from Example 6 and create a collection of objects of csType type,
owned by the rootObj object:
Example 10

C++ void FilterObjects(ISCSessionPtr scSessionPtr, ISCModelObjectPtr & rootObj,


CString & csType)
{
ISCModelObjectCollectionPtr scModelObjectsPtr;
scModelObjectsPtr = scSessionPtr->GetModelObjects()->Collect(rootObj-
>GetObjectId(), COleVariant(csType));
// …
}

Visual Basic .NET Public Sub FilterObjects(ByRef scSession As [Link], _


ByRef rootObj As [Link], ByRef objType as
String)

Dim scModelObjects As [Link]


scModelObjects = [Link](rootObj, objType)
' scModelObjects will contain only objects of type objType

End Sub

Depth Filter

The following examples illustrate the Depth filter:


Example 11

C++ void FilterObjects(ISCSessionPtr scSessionPtr, ISCModelObjectPtr & rootObj,


CString & csType, long depth)
{
ISCModelObjectCollectionPtr scModelObjectsPtr;
scModelObjectsPtr = scSessionPtr->GetModelObject()->
Collect(rootObj->GetObjectId(), COleVariant(csType),depth);
// …
}

3–30 AllFusion ERwin Data Modeler API Reference Guide


Accessing Object Properties

Visual Basic .NET Public Sub FilterObjects(ByRef scSession As [Link], _


ByRef rootObj As [Link], ByRef classID As String, depth As
Integer)

Dim scModelObjects As [Link]


scModelObjects = [Link](rootObj, classID, depth)

End Sub

MustBeOn/MustBeOff Filter

The following examples illustrate the MustBeOn/MustBeOff filter. The examples


use the Session object from Example 6:
Example 12

C++ void FilterObjects(ISCSessionPtr scSessionPtr, ISCModelObjectPtr & rootObj, long


depth)
{
ISCModelObjectCollectionPtr scModelObjectsPtr;
scModelObjectsPtr = scSessionPtr->GetModelObjects()->
Collect(rootObj->GetObjectId(), vtMissing, depth,
SCD_MOF_USER_DEFINED);
// …
}

Visual Basic .NET Public Sub FilterObjects(ByRef scSession As [Link], _


ByRef rootObj As [Link], depth As Integer)

Dim scModelObjects As [Link]


scModelObjects = [Link](rootObj, , depth,
SCD_MOF_USER_DEFINED)

End Sub

Accessing Object Properties


You can access the properties of an object through the Properties property of
ISCModelObject. The Properties property is an instance of
ISCModelPropertyCollection. The ISCModelPropertyCollection contains
instances of ISCModelProperty.

API Tasks 3–31


Accessing Object Properties

Iteration of Properties

This section describes the interfaces involved with the iteration of properties.

ISCModelObject Interface

The following table contains information on the ISCModelObject interface:

Signature Description Valid Arguments


ISCModelPropertyCollection Returns a property None
* Properties() collection of all
available properties

ISCModelPropertyCollection Interface

The following table contains information on the ISCModelPropertyCollection


interface:

Signature Description Valid Arguments


Long Count() Number of properties in None
the collection
IUnknown _NewEnum() Constructs an instance of None
the collection
enumerator object

ISCModelProperty Interface

The following table contains information on the ISCModelProperty interface:

Signature Description Valid Arguments


BSTR ClassName() Returns the class name of None
the property
SC_CLSID ClassId() Returns the class None
identifier of the property
Long Count() Contains the number of None
values in the property
BSTR FormatAsString() Formats the property None
value as a string

3–32 AllFusion ERwin Data Modeler API Reference Guide


Accessing Object Properties

The following examples illustrate the iteration of properties. The examples use a
Model Object object from Example 9:
Example 13

C++ void IterateObjectProperties(ISCModelObjectPtr & scObjPtr)


{
ISCModelPropertyCollectionPtr propColPtr = scObjPtr->GetProperties();

// Iterate over the Collection


IUnknownPtr _NewEnum = NULL;
IEnumVARIANT* propCollection;

_NewEnum = propColPtr->Get_NewEnum();
if (_NewEnum != NULL)
{
HRESULT hr = _NewEnum->QueryInterface(IID_IEnumVARIANT, (LPVOID*)
&propCollection);
if (!FAILED(hr))
{
COleVariant xObject;
while (S_OK == propCollection->Next(1,&xObject,NULL))
{
ISCModelPropertyPtr scObjPropPtr = (V_DISPATCH (&xObject));
[Link]();
if ([Link]())
{
CString csPropName = (LPSTR) scObjPropPtr->GetClassName();
CString csPropVal= (LPSTR) scObjPropPtr->FormatAsString();
// …
}
} // property iteration
}
if (propCollection)
propCollection->Release();
}
}

Visual Basic .NET Public Sub IterateObjectProperties(ByRef scObj As [Link])

Dim scObjProperties As [Link]


Dim scObjProp As [Link]
scObjProperties = [Link]
For Each scObjProp In scObjProperties
[Link]( [Link] )
[Link]( [Link] )
Next

End Sub

API Tasks 3–33


Accessing Object Properties

Accessing Scalar and Non-Scalar Property Values

A scalar property is a property that can be represented as a single value. The


properties that contain multiple values (either homogeneous or heterogeneous)
are non-scalar properties.

The type of a property can be recognized by reviewing the property flags. Scalar
properties have a SCD_MPF_SCALAR flag.

For more information about specific property flags, see the section Enumerations
in the appendix “API Interfaces Reference.”

The value of a scalar property or a single member of a non-scalar property is


accessed through the Value property of the ISCModelProperty interface.

Note: In r7, AllFusion ERwin DM does not support heterogeneous non-scalar


properties. Members in a non-scalar property always have the same datatype.

A property, either scalar or non-scalar, can have a special NULL value. The
properties with a NULL value have a SCD_MPF_NULL flag set.

ISCModelProperty Interface

The following table contains information on the ISCModelProperty interface:

Signature Description Valid Arguments


long Count() Contains the number of None
values in the property.
For scalar properties, the
number of values in the
property is always one.
It is possible to have a
non-scalar property with
no elements. In this case,
the number of values in
the property will be zero.
SC_ModelPropertyFlags Returns the flags of the None
Flags() property.
For information on
SC_ModelPropertyFlags,
see the Enumerations
section in the appendix
“API Interfaces
Reference.”

3–34 AllFusion ERwin Data Modeler API Reference Guide


Accessing Object Properties

Signature Description Valid Arguments


VARIANT Retrieves the indicated ValueId:
Value(VARIANT ValueId property value in the ■ Empty—Valid for a
[optional], VARIANT requested format. For scalar property only.
ValueType [optional]) information on property ■ VT_I4—Zero-based
datatypes, see index within a
SC_ValueTypes in the homogeneous array.
Enumerations section of The value of the
the appendix “API member indicated by
Interfaces Reference.” this index is returned.
ValueType:
■ Empty—Indicates a
native datatype for a
return value.
■ SCVT_DEFAULT—
Indicates a native
datatype for a
returned value.
■ SCVT_BSTR—
Requests conversion
to a string for a
returned value.

The following examples illustrate how to access scalar property values. The
examples use a Model Property object from Example 13:
Example 14

C++ void GetScalarProperty(ISCModelPropertyPtr & scObjPropPtr)


{
if (scObjPropPtr->GetCount() <= 1)
{
_bstr_t bstrPropVal= scObjPropPtr->FormatAsString();
// …
}
}

API Tasks 3–35


Accessing Object Properties

Visual Basic .NET Public Sub GetPropertyElement(ByRef scObjProp As [Link])

If ([Link] And SCAPI.SC_ModelPropertyFlags.SCD_MPF_NULL) Then


[Link]( "The value is Null" )
Else
If ([Link] And SCAPI.SC_ModelPropertyFlags.SCD_MPF_SCALAR) Then
[Link]( [Link]() )
Else
For j = 0 To [Link]-1
[Link]( [Link](j).ToString() )
Next
End If
End If

End Sub

Iterating Over Non-Scalar Property Values

The properties that contain multiple values (either homogeneous or


heterogeneous) are non-scalar properties. To access the individual values of a
non-scalar property, the PropertyValues member of the ISCModelProperty
interface is used. The PropertyValues member is an instance of
ICSPropertyValueCollection. Each member of ISCPropertyValueCollection is an
instance of ISCPropertyValue. The ValueId member of the ISCPropertyValue
interface identifies the individual property values in a non-scalar property.
ValueId can either be a zero-based index or the name of the non-scalar property
value member if the property type is a structure.

ISCModelProperty Interface

The following table contains information on the ISCModelProperty interface:

Signature Description Valid Arguments


ISCPropertyValueCollection Returns the values for None
* PropertyValues() the property

3–36 AllFusion ERwin Data Modeler API Reference Guide


Accessing Object Properties

ISCPropertyValueCollection Interface

The following table contains information on the ISCPropertyValueCollection


interface:

Signature Description Valid Arguments


long Count() Number of values in the None
collection
IUnknown _NewEnum() Constructs an instance of None
the collection
enumerator object

API Tasks 3–37


Accessing Object Properties

ISCPropertyValue Interface

The following table contains information on the ISCPropertyValue interface:

Signature Description Valid Arguments


VARIANT Uniquely identifies the ValueType:
ValueId(VARIANT value in a non-scalar ■ SCVT_I2—If the
ValueType [optional]) property. property is non-
scalar, the value of
the property index
is returned.
■ SCVT_I4—If the
property is non-
scalar, the value of
the property index
is returned.
■ SCVT_BSTR—The
name of the non-
scalar property
member if it is
available, or else
the index of the
member is
returned.

SCVT_DEFAULT
—If the property is
non-scalar, the
value of the
property index is
returned.
■ Empty—Defaults to
SCVT_DEFAULT.
SC_CLSID PropertyClassId() Returns the class None
identifier of the current
property
BSTR PropertyClassName() Returns the class name None
of the current property

3–38 AllFusion ERwin Data Modeler API Reference Guide


Accessing Object Properties

Signature Description Valid Arguments


VARIANT Value(VARIANT Converts the current ValueType:
ValueType [optional]) value to the passed ■ SCVT_DEFAULT—
value type. Indicates a value in
For information on the native format.
value datatypes, see ■ SCVT_BSTR—
SC_ValueTypes in the String
Enumerations section representation of
in the appendix “API the property value.
Interfaces Reference.” ■ Target Type—
Identifies a target
for a type
conversion.
■ Empty—Defaults to
SCVT_DEFAULT.
SC_ValueTypes ValueType() Passes back the None
identifier of the value
default type
SC_ValueTypes Passes back the None
ValueIdType() identifier of the value
identifier default type
SC_ValueTypes * Groups a list of None
GetSupportedValueTypes() supported value types
and returns it as a
SAFEARRAY
SC_ValueTypes * Groups a list of None
GetSupportedValueIdTypes() supported value types
for the current value
identifier and returns it
as a SAFEARRAY

API Tasks 3–39


Accessing Object Properties

The following examples illustrate how to access non-scalar property values. The
examples use a Model Property object from Example 13:
Example 15

C++ void IterateNonScalarProperties(ISCModelPropertyPtr & scObjPropPtr)


{
if (scObjPropPtr->GetCount() > 1)
{
ISCPropertyValueCollectionPtr propVals = scObjPropPtr->GetPropertyValues();
long numVals = propVals->GetCount();
for (long i = 0; i < numVals; i++)
{
ISCPropertyValuePtr propValPtr = propVals->GetItem(COleVariant(i));
VARIANT valType;
V_VT(&valType) = VT_I4;
V_I4(&valType) = SCVT_BSTR;
bstr_t bstrPropVal = propValPtr->GetValue(valType);

// …
}
}
}

Visual Basic .NET Public Sub IterateNonScalarProperties(ByRef scObjProp As [Link])


Dim scPropValue as [Link]

If ([Link] > 1) Then


For Each scPropValue In [Link]
If ([Link] = SCVT_BSTR) Then
[Link]( [Link](SCVT_BSTR),": ", _
[Link]())
Else
[Link] ([Link]())
End If
Next
End If
End Sub

3–40 AllFusion ERwin Data Modeler API Reference Guide


Accessing Object Properties

Accessing a Specific Property

For non-scalar properties, you can directly access individual values by using the
Item method of ISCPropertyValueCollection.

ISCPropertyValueCollection Interface

The following table contains information on the ISCPropertyValueCollection


interface:

Signature Description Valid Arguments


ISCPropertyValue * Returns a single value ValueId:
Item(VARIANT ValueId) from the property value ■ VT_I4—Index of the
collection member in a non-
scalar property.
■ VT_BSTR—Name of a
member in a non-
scalar property.

Note: For r7, AllFusion ERwin DM does not support naming of non-scalar
property members.

The following examples illustrate how to access a specific property. The


examples use a Model Object object from Example 9:
Example 16

C++ // This function retrieves a specific value with the given index from the
property with the
// given name.
ISCPropertyValuePtr GetPropValue(ISCModelObjectPtr & scObjPtr, CString & csName,
int index)
{
ISCModelPropertyCollectionPtr propColPtr = scObjPtr->GetProperties();
ISCModelPropertyPtr scObjPropPtr = propColPtr->GetItem(COleVariant(csName));
ISCPropertyValueCollectionPtr propVals = scObjPropPtr->GetPropertyValues();
return propVals->GetItem(COleVariant(index));
}

API Tasks 3–41


Accessing Object Properties

Visual Basic .NET ' This function retrieves a specific value with the given index from the property
with the
' given name.
Public Function GetPropValue(ByRef scObj As [Link], ByRef propName As
String, _
index As Integer) As [Link]

Dim scProp as [Link]


Set scProp = [Link](propName)
Set GetPropValue = [Link](index)

End Function

Filtering Properties

Subsets of an instance of ISCModelPropertyCollection can be created by using its


CollectProperties method of ISCModelObject. The CollectProperties method
creates a new instance of ISCModePropertyCollection based on the filtering
criteria specified in the parameters of the method. By filtering the property
collection, you can retrieve properties of a certain class, properties with specified
flags set, or properties that do not have specified flags set. The filtering criteria is
optional, and any number of combinations of criteria can be used. For more
information about identifiers used in property classes, see the appendix
“AllFusion ERwin DM Metamodel.” For more information about specific
property flags, see the section Enumerations in the appendix “API Interfaces
Reference.”

3–42 AllFusion ERwin Data Modeler API Reference Guide


Accessing Object Properties

ISCModelObject Interface

The following table contains information on the ISCModelObject interface:

Signature Description Valid Arguments


ISCModelPropertyCollection * Returns a property ClassIds:
CollectProperties(VARIANT collection of the type ■ Empty—All properties of the object are
ClassIds [optional], VARIANT that you require returned.
MustBeOn [optional], ■ VT_ARRAY|VT_BSTR—SAFEARRAY of
VARIANT MustBeOff property class IDs. Returns the properties
[optional]) with the given property class identifiers.
■ VT_ARRAY|VT_BSTR—SAFEARRAY of

property names. Returns the properties with


the given class names.
■ VT_BSTR—ID of a property class. Returns

the property with the given property class


identifier.
■ VT_BSTR—Name of a property. Returns the

property with the given class name.


■ VT_BSTR—List of property class IDs

delimited by semicolons. Returns the


properties with the given property class
identifiers.
■ VT_BSTR—List of property names delimited

by semicolons. Returns the properties with


the given class names.
MustBeOn:
■ Empty—Defaults to SCD_MPF_DONT_CARE
and returns all properties.
■ VT_I4—SC_ModelObjectFlags flags that must
be on. Returns the properties with the
specified flags set.
MustBeOff:
■ Empty—Defaults to SCD_MPF_NULL and
returns all properties.
■ VT_I4—SC_ModelObjectFlags flags that must
be off. Returns the properties that do not
have the specified flags set.

API Tasks 3–43


Accessing Object Properties

Note: Setting certain filter criteria can influence the effectiveness of data
retrieving. For example, setting the MustBeOn filter to SCD_MPF_DERIVED
builds a collection with only the calculated and derived properties. Requests to
evaluate the calculated and derived properties will reduce performance while
iterating over the collection. However, setting the MustBeOff filter to the same
value, SCD_MPF_DERIVED, which excludes the calculated and derived
properties, improves performance.

The following examples illustrate how to filter properties. The examples use a
Model Object object from Example 9:
Example 17

C++ void GetProperties(ISCModelObjectPtr & scObjPtr)


{

ISCModelPropertyCollectionPtr propColPtr;

propColPtr = scObjPtr->GetProperties(); // no filtering

VARIANT valFlags;
V_VT(&valFlags) = VT_I4;
V_I4(&valFlags) = SCD_MPF_SCALAR;

propColPtr = scObjPtr->CollectProperties(vtMissing, valFlags, vtMissing); //


scalar
//
properties only

propColPtr = scObjPtr->CollectProperties(vtMissing, vtMissing, valType); //


non-scalar
//
properties only
}

Visual Basic .NET Public Sub( ByRef scObj As [Link] )


Dim scObjProperties As [Link]

scObjProperties = [Link] ' no filtering

scObjProperties = [Link](, SCD_MPF_SCALAR) ' scalar


properties only

scObjProperties = [Link](, , SCD_MPF_SCALAR) ' non-scalar


properties only
End Sub

3–44 AllFusion ERwin Data Modeler API Reference Guide


Modifying the Model—Using Session Transactions

Modifying the Model—Using Session Transactions


In order to make modifications to a model, session transactions must be used.
Prior to making a modification, either BeginTransaction() or
BeginNamedTransaction() must be called. Once all the modifications are
completed, CommitTransaction() must be called.

Note: In r7, the nested transactions and rollbacks are supported with certain
limitations. The limitation is illustrated in the following state diagram:

Begin Outer Transaction

Data Modification
Data Modification

I II

Begin
Inner Transaction
Commit Inner Transaction

Commit Outer Transaction

T Commit Outer Transaction

After the beginning of an outer transaction, the API is in State I of the diagram. A
new nested transaction can be opened or the outer transaction can be closed.
Any operation other than the open or close of a transaction, such as creating,
modifying objects, properties, and so on, will transfer the API to State II. In that
state further modifications can continue, but no new nested transactions are
allowed. The API continues to be in that state until the current transaction is
committed or rolled back.

API Tasks 3–45


Modifying the Model—Using Session Transactions

Use of nested transactions allows better control over modification flow. The
following describes a few examples:

Commit Transaction A Commit transaction immediately carries out enlisted modifications.


Therefore, without closing the outer transaction, the small nested transactions
can reflect separate steps of the complex changes with the results of the
committed transaction instantly available for the consumption by the next step.

Rollback A rollback of the outer transaction cancels out the results of all nested
transactions, even the ones that were committed before the rollback.

Begin Transaction

To indicate that a modification to the model is about to occur, either the


BeginTransaction() or the BeginNamedTransaction() must be called.

ISCSession Interface

The following table contains information on the ISCSession interface:

Signature Description Valid Arguments


VARIANT BeginTransaction() Opens a transaction None
on the session.
Returns an identifier
of the transaction.
VARIANT Opens a transaction Name—Provides a
BeginNamedTransaction(BST on the session with the name for a new
R Name, VARIANT given name. Returns transaction.
PropertyBag [optional]) an identifier of the PropertyBag—
transaction. Collection of optional
parameters for the
transaction.

3–46 AllFusion ERwin Data Modeler API Reference Guide


Modifying the Model—Using Session Transactions

The following examples illustrate modifying the model using the Begin
Transaction. The examples use a Session object from Example 6:
Example 18
void OpenSession(ISCSessionPtr & scSessionPtr )
C++ {
variant_t transactionId; // transaction ID for the session

VariantInit(&transactionId);
transactionId = scSessionPtr->BeginTransaction();

// …
}

Visual Basic .NET Public Sub OpenSession( ByRef scSession As [Link] )


Dim m_scTransactionId As Variant

scTransactionId = [Link]("My Transaction")


End Sub

Commit Transaction

The CommitTransaction() is used to commit the modifications to the in-memory


model. Note that the Commit only applies to the in-memory model while the
API is running. To persist the modifications, the model must be explicitly saved
using the ISCPersistenceUnit::Save() function.

ISCSession Interface

The following table contains information on the ISCSession interface:

Signature Description Valid Arguments


VARIANT_BOOL Commits the None
CommitTransaction(VARIANT specified transaction
TransactionId)

API Tasks 3–47


Modifying the Model—Using Session Transactions

The following examples illustrate modifying the model using the Commit
Transaction. The examples use a Session object from Example 6:
Example 19

C++ void Transaction(ISCSessionPtr & scSessionPtr )


{
variant_t transactionId; // transaction ID for the session

VariantInit(&transactionId);
transactionId = scSessionPtr->BeginTransaction();

// Make modifications to the model here ….

scSessionPtr->CommitTransaction(transactionId);
}

Visual Basic .NET Public Sub Transaction(ByRef scSession As [Link] )


Dim scTransactionId As Variant

scTransactionId = [Link]

' make modifications here …

[Link]( scTransactionId )
End Sub

3–48 AllFusion ERwin Data Modeler API Reference Guide


Creating Objects

Creating Objects
The first step in creating a new object is to retrieve the ISCModelObject instance
of the parent of the new object. From the parent of the new object, retrieve its
child objects in an instance of ISCModelObjectCollection. You then need to add
the new object to the child objects collection. For information on valid object class
names and object class identifiers, see the appendix “AllFusion ERwin DM
Metamodel.”

Interfaces Used to Create a New Object

The following section describes the interfaces used when you create a new model
object.

ISCModelObjectCollection Interface

The following table contains information on the ISCModelObjectCollection


interface:

Signature Description Valid Arguments


ISCModelObjectCollection Creates a Model Root:
* Collect(VARIANT Root, Objects collection, ■ VT_UNKNOWN—The ISCModelObject pointer of
VARIANT ClassId which represents a the root object. Returns the descendants of the
[optional], VARIANT subcollection of given object.
Depth [optional], itself ■ VT_BSTR—The ID of the root object. Returns the

VARIANT MustBeOn descendants of the object with the given object


[optional], VARIANT identifier.
MustBeOff[optional]) ClassId:
■ Empty—Not needed when obtaining the children

of an object.
Depth:
■ VT_I4—Set depth to 1 when obtaining the

immediate children of an object.


MustBeOn:
■ Empty—Not needed when obtaining the children

of an object.
MustBeOff:
■ Empty—Not needed when obtaining the children

of an object.

API Tasks 3–49


Creating Objects

Signature Description Valid Arguments


ISCModelObject * Adds an object of Class:
Add(VARIANT Class, type Class to the ■ VT_BSTR—Name of a class. Creates an object of
VARIANT ObjectId model the given class name.
[optional]) ■ VT_BSTR—Class ID of an object type. Creates an
object of the class with the given identifier.
ObjectId:
■ Empty—The API assigns an object identifier for a
new object.
■ VT_BSTR—ID for a new object. The API assigns

the given object identifier to the new object.

The following examples illustrate how to create objects. The examples use a
Session object from Example 6:
Example 20

C++ // NOTE: ISCSession::BeginTransaction() must be called prior to calling this


function
// ISCSession::CommitTransaction() must be called upon returning from this
function
void CreateObject(ISCSessionPtr & scSessionPtr, CString & csType,
ISCModelObjectPtr &
parentObj)
{
variant_t transactionId; // transaction ID for the session

VariantInit(&transactionId);
transactionId = scSessionPtr->BeginTransaction();

ISCModelObjectCollectionPtr childObjColPtr = scSessionPtr->GetModelObject()-


>Collect
(parentObj->GetObjectId(),vtMissing,(long)1); // get child objects

// Add child object to collection


ISCModelObjectPtr childObjPtr = childObjColPtr->Add(COleVariant(csType));
// …
scSessionPtr->CommitTransaction(transactionId);

3–50 AllFusion ERwin Data Modeler API Reference Guide


Setting Property Values

Visual Basic .NET Public Sub AddNewObject(ByRef scSession As [Link], _


ByRef parentObj As [Link], type As String)
Dim scObj as [Link]
Dim scChildObjCol As [Link]
Dim transactionID as Variant

transactionID = [Link]
scChildObjCol = [Link](parentObj, , 1) ' child
objects collection
scObj = [Link](type) ' add new object to the child object
collection

[Link]( transactionID )
End Sub

Setting Property Values


To set a property value of a model object, use the Value member of an instance of
the ISCModelProperty interface.

Setting Scalar Property Values

The valid VARIANT types that can be used to set a scalar property value is
dependent on the type of the property. For information, see the appendix
“AllFusion ERwin DM Metamodel.”

ISCModelProperty Interface

The following table contains information on the ISCModelProperty interface:

Signature Description Valid Arguments


void Value(VARIANT Sets the indicated ValueId:
ValueId [optional], property value with the ■ Empty—Not used when setting scalar
VARIANT ValueType given value properties.
[optional], VARIANT Val )
ValueType:
■ Empty—Not used.
Val:
■ Dependent upon the property type—For
information on valid values, see the appendix
“AllFusion ERwin DM Metamodel.”

API Tasks 3–51


Setting Property Values

The following examples illustrate how to set scalar property values. The
examples use a Model Object object from Example 9 and assumes that a
transaction has opened:
Example 21

C++ // NOTE: ISCSession::BeginTransaction() must be called prior to calling this


function
// ISCSession::CommitTransaction() must be called upon returning from this
function
void SetNameProperty(ISCModelObjectPtr & scObjPtr, CString & csName)
{
ISCModelPropertyCollectionPtr propColPtr = scObjPtr->GetProperties();
CString csPropName = "Name";
ISCModelPropertyPtr nameProp = propColPtr->GetItem(COleVariant(csPropName));
if (nameProp != NULL)
nameProp->PutValue(vtMissing, (long) SCVT_BSTR, csName);
}

Visual Basic .NET ' NOTE: ISCSession::BeginTransaction() must be called prior to calling this
function
' ISCSession::CommitTransaction() must be called upon returning from this
function
Public Sub SetScalarPropValue(ByRef scObj As [Link], ByRef val As
Variant)
Dim modelProp As [Link]
modelProp = [Link](“Name”)
[Link] = val
End Sub

Setting Non-Scalar Property Values

To set a non-scalar property value, you must identify the specific value that you
want to set. This is done through the ValueId parameter. The ValueId can either
be the zero-based index of the property value collection or the name of the
member if the property is a structure.

Note: For r7, AllFusion ERwin DM does not support naming non-scalar
property members.

3–52 AllFusion ERwin Data Modeler API Reference Guide


Setting Property Values

ISCModelProperty Interface

The following table contains information on the ISCModelProperty interface:

Signature Description Valid Arguments


void Value(VARIANT Sets the indicated property ValueId:
ValueId [optional], VARIANT value with the given value ■ VT_I4—Index for a non-scalar
ValueType [optional], property of which the given value is
VARIANT Val ) set.
■ VT_BSTR—Name of a member in a
non-scalar property of which the
given value is set.
ValueType:
■ Empty—Not used.
Val:
■ Dependent upon the property
type—For valid values, see the
appendix “AllFusion ERwin DM
Metamodel.”

The following examples illustrate how to set non-scalar property values. The
examples use a Model Object object from Example 9 and assumes that a
transaction has opened:
Example 22

C++ // NOTE: ISCSession::BeginTransaction() must be called prior to calling this


function
// ISCSession::CommitTransaction() must be called upon returning from this
function
void SetNameProperty(ISCModelObjectPtr & scObjPtr, CString & csValue)
{
ISCModelPropertyCollectionPtr propColPtr = scObjPtr->GetProperties();
CString csPropName = "Non-Scalar";
ISCModelPropertyPtr nameProp = propColPtr->GetItem(COleVariant(csPropName));
if (nameProp != NULL)
// Setting the first element
nameProp->PutValue(COleVariant(0L), (long) SCVT_BSTR, csValue);
}

API Tasks 3–53


Deleting Objects

Visual Basic .NET ' NOTE: ISCSession::BeginTransaction() must be called prior to calling this
function
' ISCSession::CommitTransaction() must be called upon returning from this
function
Public Sub SetScalarPropValue(ByRef scObj As [Link], ByRef val As
Variant)
Dim modelProp As [Link]
modelProp = [Link](“Name”)
Dim index As Long
Index = 0 ‘ Setting index to zero
[Link](index) = val ' index is used to access non-scalar property
End Sub

Deleting Objects
You can delete an object by removing the ISCModelObject interface instance of
the object from the instance of ISCModelObjectCollection. You identify the object
that you want to delete either by its pointer to the interface or by its object
identifier.

Interfaces Used to Delete Objects

The following section describes the interface used to delete model objects.

ISCModelObjectCollection Interface

The following table contains information on the ISCModelObjectCollection


interface:

Signature Description Valid Arguments


VARIANT_BOOL Removes the specified Object:
Remove(VARIANT model object from a ■ VT_UNKNOWN—ISCModelObject * pointer to
Object) model the object that you want to delete. Removes the
given object.
■ VT_BSTR—ID of the object. Removes the object
with the given object identifier.

3–54 AllFusion ERwin Data Modeler API Reference Guide


Deleting Properties and Property Values

The following examples illustrate how to delete objects if there is a model objects
collection and that a transaction has opened:
Example 23

C++ CString csID; // ID of object to be removed


// …
CComVariant bRetVal = scObjColPtr->Remove(COleVariant(csID));

Visual Basic .NET bRetVal = [Link](objID)

Deleting Properties and Property Values


Properties are deleted by removing the property from the instance of the
ISCModelPropertyCollection interface. If the property is non-scalar, the
individual property value can be removed by using the RemoveValue method of
the ISCModelProperty interface. For more information on valid property names
and property IDs, see the appendix “AllFusion ERwin DM Metamodel.”

Interfaces Used to Delete Properties and Property Values

The following sections describe the interfaces used to delete model properties
and model property values.

ISCModelPropertyCollection Interface

The following table contains information on the ISCModelPropertyCollection


interface:

Signature Description Valid Arguments


VARIANT_BOOL Removes the indicated ClassId:
Remove(VARIANT ClassId) property from the bound ■ VT_UNKNOWN—ISCModelProperty
object pointer to the object that you want to
remove. Removes the given property.
■ VT_BSTR—Name of the property.
Removes the property with the given
class name.
■ VT_BSTR—ID of the property.
Removes the property with the given
class identifier.

API Tasks 3–55


Deleting Properties and Property Values

ISCModelProperty Interface

The following table contains information on the ISCModelProperty interface:

Signature Description Valid Arguments


VARIANT_BOOL Removes the specified ValueId:
RemoveValue(VARIANT value from the property ■ Empty—For scalar properties only.
ValueId [optional]) ■ VT_I4—Index of a non-scalar property.
Removes the value with the given index
in a non-scalar property.
■ VT_BSTR—Name of the property
member in a non-scalar property.
Removes the value of the non-scalar
property member with the given name.
VARIANT_BOOL Remove all values from the None
RemoveAllValues() property

Deleting Scalar Properties

The following examples illustrate how to delete scalar properties if there is a


model object and a transaction is open:
Example 24

C++ CString propName("Some Property Name");


// …
CComVariant bRetVal = scObjPtr->GetProperties()->Remove(COleVariant(propName));
Dim propName As String
Visual Basic .NET propName = "Some Property Name"
bRetVal = [Link](propName)

Deleting Non-Scalar Property Values

To remove all the values from a non-scalar property, remove the property itself
from the ISCModelPropertyCollection using the Remove method. To remove a
specific value from a non-scalar property, use the RemoveValue method of the
ISCModelProperty interface. As with accessing the non-scalar property values,
the property value is identified using the ValueId parameter. ValueId can either
be the zero-based index of the value, or the name of the member if the property
type is a structure.

Note: For r7, AllFusion ERwin DM does not support naming non-scalar
property members.

3–56 AllFusion ERwin Data Modeler API Reference Guide


Saving the Model

The following examples illustrate how to delete non-scalar property values if


there is a model object and a transaction is open:
Example 25

C++ ISCModelPropertyCollectionPtr propColPtr = scObjPtr->GetProperties();


CString csPropName = "Some Property Name";
ISCModelPropertyPtr scPropPtr = propColPtr->GetItem(COleVariant(csPropName));
long index; // index of a member in a non-scalar property
index = 0; // Set to the first element
// …
bRetVal = scPropPtr->RemoveValue(index); // remove single value from the
property
Dim scProp As [Link]
Visual Basic .NET scProp = [Link]("Some Property Name")
bRetVal = [Link](index) ' Remove single value from the property

Saving the Model


If modifications were made to the AllFusion ERwin DM model, the persistence
unit must be saved in order to persist the changes.

ISCPersistenceUnit Interface

The following table contains information on the ISCPersistenceUnit interface:

Signature Description Valid Arguments


VARIANT_BOOL Persists model data to Locator:
Save(VARIANT Locator external storage ■ VT_BSTR—Full path of the location to store the
[optional], VARIANT model. Provides a new location for the
Disposition [optional] persistence unit data source as a string with a file
or AllFusion Model Manager item location, along
with the attributes required for successful access
to storage.
■ Empty—Indicates the use of the original
persistence unit location.
Disposition:
Specifies changes in access attributes, such as read
only.

API Tasks 3–57


Accessing Metamodel Information

The following examples illustrate how to save a model. The examples use a
Persistence Unit object from Example 5:
Example 26

C++ void Save( ISCPersistenceUnitPtr & scPUnitPtr )


{
ISCPropertyBagPtr propBag = scPUnitPtr->GetPropertyBag ("Locator");
long index = 0;
_bstr_t bstrFileName = propBag->GetValue(COleVariant(index));

// Change bstrFileName to a new location


scPUnitPtr->Save(bstrFileName);
}
Public Sum Save( scPUnit As [Link] )
Visual Basic .NET Dim propBag as [Link]
propBag = [Link](“Locator”)
Dim sFileName As String
sFileName = [Link](“Locator”)
sFileName = sFileName + “.bak”
[Link](sFileName )
End Sub

Accessing Metamodel Information


You can obtain the metamodel of AllFusion ERwin DM by using the API. The
metamodel can be accessed in the same manner as an AllFusion ERwin DM
model. As in the case with model data, the ISCPersistenceUnit or ISCModelSet
pointer in an ISCSession::Open call indicates the model set with which you are
working.

There is a special case for the intrinsic metamodel. To obtain the intrinsic
metamodel for a specific class of metadata, you can use the Property Bag
component created with the PropertyBag method of the
ISCApplicationEnvironment interface. A Property Bag instance populated with
EMX Metadata Class or EM2 Metadata Class properties from the Application
category indicates the type of the intrinsic metamodel to access. The instance
must be submitted as the first parameter in an ISCSession::Open call, instead of
ISCPersistenceUnit or ISCModelSet pointers. If the first parameter in an
ISCSession::Open call is NULL, then the intrinsic metamodel for the top model
set in a persistence unit, the EMX class metadata, will be accessed.

To indicate that a session will access metamodel information, you set the Level
parameter of the Open method to SCD_SL_M1.

3–58 AllFusion ERwin Data Modeler API Reference Guide


Accessing Metamodel Information

For detailed information on metadata organization, see the appendix “AllFusion


ERwin DM Metamodel.”

ISCApplicationEnvironment Interface

The following table contains information on the ISCApplicationEnvironment


interface:

Signature Description Valid Arguments


ISCPropertyBag Populates a property bag Category:
PropertyBag(VARIANT with one or more property ■ VT_BSTR—Features returned from the
Category[optional], values as indicated by given category. Must be Application.
VARIANT Name[optional], Category and Name
Name:
VARIANT
■ VT_BSTR—The property with the given
AsString[optional])
name and category is returned. Must be
EMX Metadata Class for EMX metadata
and EM2 Metadata Class for EM2
metadata.
AsString:
■ Empty—All values in the property bag
are presented in their native type.

API Tasks 3–59


Accessing Metamodel Information

ISCSession Interface

The following table contains information on the ISCSession interface:

Signature Description Valid Arguments


VARIANT_BOOL Binds self to the intrinsic Unit:
Open(IUnknown * Unit, metamodel, persistence ■ NULL—The intrinsic metamodel for the
VARIANT Level [optional], unit, or model set top model set in a persistence unit. For
VARIANT Flags [optional]) identified by the Unit the current version this is EMX class
parameter metadata.
■ ISCPropertyBag—The intrinsic

metamodel defined by the metadata class


in the first property of the bag.
■ ISCPersistenceUnit—The metamodel for

the top model set in the persistence unit.


■ ISCModelSet—The metamodel for the

model set.
Level:
■ SCD_SL_M1—Metadata access.
Flags:
■ Empty—Defaults to SCD_SF_NONE.

3–60 AllFusion ERwin Data Modeler API Reference Guide


Accessing Metamodel Information

The following examples illustrate how to access an intrinsic metamodel. The


examples use an Application object from Example 1:
Example 27

C++ void AccessMetaModel( ISCApplicationPtr & scAppPtr )


{
ISCSessionPtr scSessionPtr = scAppPtr->GetSessions()->Add(); // add a new
session
// Open EMX intrinsic metamodel
CComVariant varResult = scSessionPtr->Open(NULL, (long) SCD_SL_M1); // meta-
model level
if ([Link] == VT_BOOL && [Link] == FALSE)
return;
// …
}

Visual Basic .NET Public Sub AccessMetaModel( ByRef scApp As [Link] )


Dim scBag As [Link]
Dim scSession As [Link]

' Get a property bag with the EM2 metadata class


scBag = [Link]("Application ", "EM2 Metadata
Class")

' Open EM2 intrinsic metamodel


scSession = [Link]
[Link]( scBag, SCD_SL_M1 )
End Sub

API Tasks 3–61


Closing the API

Closing the API


When the client of the API has finished accessing the model, the sessions that
were open must be closed, and the persistence unit collection must be cleared.

Closing the Session

This section describes how to close a session.

ISCSession Interface

The following table contains information on the ISCSession interface:

Signature Description Valid Arguments


VARIANT_BOOL Disconnects self from its None
Close() associated persistence
unit

ISCSessionCollection Interface

The following table contains information on the ISCSessionCollection interface:

Signature Description Valid Arguments


VARIANT_BOOL Removes a Session object SessionId:
Remove(VARIANT from the collection ■ VT_UNKNOWN—
SessionId) Pointer to the
ISCSession interface.
Removes the given
session from the
collection.
■ VT_I4—Zero-based

index in the session


collection. Removes
the session with the
given index from the
collection.

3–62 AllFusion ERwin Data Modeler API Reference Guide


Closing the API

The following examples illustrate how to close a session. It assumes that there is
a Session object and the session is open. The examples use an Application object
from Example 1:
Example 28

C++ void CloseSessions( ISCApplicationPtr & scAppPtr )


{
ISCSessionCollectionPtr scSessionColPtr = scAppPtr->GetSessions();
ISCSessionPtr scSessionPtr = scSessionColPtr->GetItem(COleVariant(0L))
// close the sessions
scSessionPtr->Close(); // close a single session
scSessionColPtr->Clear(); // clear the collection of sessions
}

Visual Basic .NET Public Sub CloseSessions( scApp As [Link] )


Dim scSessionCol As [Link]
scSessionCol = [Link]
Dim scSession As [Link]

For Each scSession In scSessionCol


[Link]
Next
While ([Link] > 0)
[Link] (0)
End
End Sub

Clearing Persistence Units

This section describes how to clear persistence units.

The effect of leaving persistence units in the Persistence Units collection is


dictated by a context in which an instance of the application is created. For
example:
■ Standalone mode—If a client is using the AllFusion ERwin DM API in the
standalone mode, all units are closed.
■ Add-in component—After the client program is over, units are still open
and available in the application user interface with the exception of those
that were explicitly closed and removed from the persistence unit collection
before exiting the program.

API Tasks 3–63


Closing the API

ISCPersistenceUnitCollection Interface

The following table contains information on the ISCPersistenceUnitCollection


interface:

Signature Description Valid Arguments


VARIANT_BOOL Clear() Purges all units from the None
collection

The following examples illustrate how to clear persistence units. It assumes that
there is an Application object from Example 1:
Example 29

C++ // remove the persistence units


scAppPtr->GetPersistenceUnits()->Clear();

Visual Basic .NET [Link]

3–64 AllFusion ERwin Data Modeler API Reference Guide


Error Handling

Error Handling
The AllFusion ERwin DM API uses a generic COM error object to handle errors.
Depending on the programming environment, languages have their own
protocols to retrieve errors from the generic error object. For example, C++ and
Visual Basic .NET use exception handling to handle errors. To ensure a stable
application, it is recommended that API clients use error handling to trap
potential errors such as attempting to access an object that was deleted, or
attempting to access an empty collection.

The following examples illustrate error handling. It assumes that there is a


Model Object object from Example 9:
Example 30

C++ long GetObjectProperties(ISCModelObjectPtr & scObjPtr)


{
// Get the collection of Properties
ISCModelPropertyCollectionPtr scPropColPtr;
try
{
scPropColPtr = scObjPtr->GetProperties();
if (![Link]())
{
AfxMessageBox("Unable to Get Properties Collection");
return FALSE;
}
// …
}
catch(_com_error &error)
{
AfxMessageBox([Link]());
}

Visual Basic .NET Public Sub GetObject(ByRef scSession As [Link], ByRef objID As String)
Dim scObjCol as [Link]
Dim scObj as [Link]

Try
scObjCol = [Link]
scObj = [Link](objID) ' retrieves object with given object ID
Catch ex As Exception
' Failed
[Link](" API Failed With Error message :" + [Link]())
End Try
End Sub

API Tasks 3–65


Error Handling

In addition to the generic error object, the API provides an extended error
handling mechanism with the Application Environment Message log. The
message log can handle a sequence of messages that is especially useful in a
context of complex operations like transactions.

For details on the Application Environment Message log organization, see the
section Property Bag for Application Environment in the appendix “API
Interfaces Reference.”

ISCApplicationEnvironment

The following table contains information on the ISCApplicationEnvironment


interface:

Signature Description Valid Arguments


ISCPropertyBag Populates a property bag Category:
PropertyBag(VARIANT with one or more property VT_BSTR—Must be [Link].
Category[optional], values as indicated by
Name:
VARIANT Name[optional], Category and Name
■ VT_BSTR—The property with the given
VARIANT
name and category is returned. Must be
AsString[optional])
Is Empty to determine if the message log
has messages. To retrieve the message
log content, it must be Log.
AsString:
■ Empty—All values in the property bag
are presented in their native type.
■ VT_BOOL—If set to TRUE, all values in
the property bag are presented as strings.

3–66 AllFusion ERwin Data Modeler API Reference Guide


Error Handling

The following examples illustrate how to use the API to check messages from the
API extended message log. It assumes that there is an Application object from
Example 1:
Example 32

C++ CString GetExtendedErrorInfo(ISCApplicationPtr & scAppPtr)


{
CString csExtendedErrors = "";
long index = 0;

// Do we have messages in the log?


variant_t val = scAppPtr->GetApplicationEnvironment()->
GetPropertyBag("[Link]","Is Empty")->
GetValue(COleVariant(index));

if ([Link] == VT_BOOL && [Link] == false)


{
// Retrieve the log
val = m_scAppPtr->GetApplicationEnvironment()->
GetPropertyBag("[Link]","Log")->
GetValue(COleVariant(index));
if ([Link] & VT_ARRAY)
{
// this is a SAFEARRAY

VARIANT HUGEP *pArray;


HRESULT hr;

// Get a pointer to the elements of the array.


hr = SafeArrayAccessData([Link], (void HUGEP**)&pArray);
if (FAILED(hr))
return csExtendedErrors;

long numErrors = 0;
VARIANT vValue = pArray[0]; // number of errors
if ([Link] == VT_I4)
numErrors = [Link];

// …
SafeArrayUnaccessData([Link]);
}
}
}

API Tasks 3–67


Error Handling

Visual Basic .NET Public Sub GetExtendedErrorInfo( ByRef scApp As [Link] )


Dim nSize As Integer
Dim nWarnings As Integer
Dim nErrors As Integer
Dim nIdx As Integer
Dim nMsgNumber As Integer
Dim aErrors() As Object
' Do we have messages in the log?
If [Link]("[Link]", _
"Is Empty").Value(0) = False Then
' Retrieve a log
aErrors = _
[Link]("[Link]", _
"Log").Value(0)
nSize = Int(aErrors(0))
nIdx = 1
nMsgNumber = 0
Do While nMsgNumber < nSize
[Link]("Error " & aErrors(nIdx) & " " + aErrors(nIdx + 2))
Select Case aErrors(nIdx + 1)
Case SCAPI.SC_MessageLogSeverityLevels.SCD_ESL_WARNING
nWarnings = nWarnings + 1
Case SCAPI.SC_MessageLogSeverityLevels.SCD_ESL_ERROR
nErrors = nErrors + 1
End Select
nIdx = nIdx + 8
nMsgNumber = nMsgNumber + 1
Loop

[Link]("Total number of errors in the transaction " & Str(nSize)


& " with: " _
& Str(nWarnings) & " warnings, " & Str(nErrors) & " errors.")

End If
End Sub

3–68 AllFusion ERwin Data Modeler API Reference Guide


Advanced Tasks

Advanced Tasks
The material in this section provides examples of some specific advanced tasks
and how they can be executed.

Creating User-Defined Properties

A User-Defined Property (UDP) is an example of a client expanding the


AllFusion ERwin DM metadata and involves creating and modifying objects on
the metadata level.

The structure of the UDP definition is similar to the definition of all native
properties. The following diagram shows the metamodel objects involved when
you define a UDP:

Property Type
+Name
+Data type : long = String
+Is Locally Defined : bool = True
+Definition
+IsLogical
Object Type +IsPhysical
+Name +Udp_Default_Value
+Udp_Datatype
+Udp_Owner_Type
+Udp_Values_List
* +Valid Properties

+Participating Object +Participating Property *


Association Type

1 1

In this diagram an instance of the Property Type object defines a UDP class, the
Object Type object defines an object class with which the UDP is associated, and
the Association Type object defines the association between object and property
classes.

API Tasks 3–69


Advanced Tasks

You are only required to create an instance of the Property Type object to define
a UDP. AllFusion ERwin DM populates the rest of the necessary data. The
following table describes the properties and tags of the Property Type object:

Property or Tag Name Description Valid Arguments


Name Property, UDP name AllFusion ERwin DM upholds the following
convention in naming UDPs to ensure their
uniqueness. The convention is a three part name
separated with dot (.) symbols:
<ObjectClassName>.<Logical/Physical>.<Name>
An example of this naming convention is:
[Link] UDP
The AllFusion ERwin DM editors display only the last
component.
Datatype Property, SCVT_BSTR The property is read-only and set by AllFusion ERwin
DM. All UDP values have a string datatype.
Is Locally Defined Property, TRUE The property is read-only and set to TRUE for all user-
defined metadata.
Definition Property, Optional Optional. Text that displays the UDP description.
IsLogical Tag, TRUE or FALSE Optional. The tag has a TRUE value for UDPs used in
logical modeling.
IsPhysical Tag, TRUE or FALSE Optional. The tag has a TRUE value for UDPs used in
physical modeling.
Udp_Default_Value Tag Optional. A string with the UDP default value.
Udp_Datatype Tag Defines the interpretation for the UDP value in the
AllFusion ERwin DM editors. The valid values are:
■ 1—Integer
■ 2—Text
■ 3—Date
■ 4—Command
■ 5—Real
■ 6—List
The property value can be:
■ VT_I4—Uses the numeric values listed above;
■ VT_BSTR—Uses the string values listed above;
Assumes the Text type if it is not specified.

3–70 AllFusion ERwin Data Modeler API Reference Guide


Advanced Tasks

Property or Tag Name Description Valid Arguments


Udp_Owner_Type Tag Required. Defines an object class to host instances of
the UDPs.
■ VT_BSTR—Name of an object class. Indicates the
host class by the given class name.
■ VT_BSTR—Class ID of an object class. Indicates
the host class by the given identifier.
Udp_Values_List Tag String with comma-separated values. Only values
from the list are valid values for a UDP.
Valid only if the Udp_Datatype tag is set to List.

API Tasks 3–71


Advanced Tasks

The following example illustrates how to use the API to define a UDP:
Example 33

Visual Basic .NET Public Sub Main()


Dim oAPI As New [Link]
Dim oPU As [Link]
Dim oSession As [Link]

' Create a new model with all defaults


oPU = [Link](Nothing)

' Add a new session


oSession = [Link]

' Start a session on the metadata level with the top (EMX) model set from
the model
[Link](oPU, SCAPI.SC_SessionLevel.SCD_SL_M1)

' Start a transaction


Dim TransId As Object
TransId = [Link]("Create UDP")

' Create a new UDP definition


Dim oUDP As [Link]
oUDP = [Link]("Property Type")

' Populate properties


[Link]("Name").Value = "[Link] UDP"
[Link]("Udp_Owner_Type").Value = "Entity"
[Link]("IsLogical").Value = True
[Link]("Udp_Datatype").Value = "Text"

' Commit changes


[Link](TransId)

' Report the result


Dim oProperty As [Link]

[Link](" --- Report the new User-Defined Property properties")


For Each oProperty In [Link]
[Link]([Link] + " '" +
[Link] + "'")
Next

[Link](" Press Entry to exit ")


[Link]()

' Release the session


[Link]()
oSession = Nothing
[Link]()

' Save to the file


[Link]("w:\[Link]", "OVF=Yes")

End Sub

3–72 AllFusion ERwin Data Modeler API Reference Guide


Advanced Tasks

History Tracking

AllFusion ERwin DM can save historical information for your model, entities,
attributes, tables, and columns. AllFusion ERwin DM uses History objects to
store the information in the model.

The AllFusion ERwin DM API provides functionality that allows you to


customize the process of history tracking without having to work with the
History objects directly. The BeginNamedTransaction function of the ISCSession
interface accepts a Property Bag instance populated with the history tracking
properties. The properties are in effect at the initiation of an outer transaction
and are confined to the scope of the transaction.

ISCSession Interface

The following table contains information on the ISCSession interface:

Signature Description Valid Arguments


VARIANT Opens a transaction on the session Name—Provides a name for a new
BeginNamedTransaction( with the given name. Returns an transaction.
BSTR Name, VARIANT identifier of the transaction. PropertyBag—Collection of
PropertyBag [optional] ) parameters for history tracking in
the transaction.

The following table describes the properties used in creating a new model:

Property Name Type Description


History Tracking Boolean TRUE—Indicates that all historical information generated
during the transaction will be marked as the API event.
The TRUE value is assumed if the property is not
provided.
FALSE—Uses the standard AllFusion ERwin DM
mechanism of history tracking.
History Description BSTR When the History Tracking property is TRUE, it provides
the content for the Description field of the history event .

Note: For the complete set of properties, see the appendix “API Interfaces
Reference.”

API Tasks 3–73


Advanced Tasks

The following example illustrates how to mark history records for entities and
attributes as API events, and how to mark history records with the API History
Tracking description:
Example 34

Visual Basic .NET Public Sub Main()


Sub Main()
Dim oApi As New [Link]
Dim oBag As New [Link]
Dim oPU As [Link]

' Construct a new logical-physical model. Accept the rest as defaults


[Link]("Model Type", "Combined")
oPU = [Link](oBag)

' Clear the bag for the future reuse


[Link]()

' Start a session


Dim oSession As [Link]

oSession = [Link]
[Link](oPU)

' Prepare a property bag with the transaction properties


[Link]("History Description", "API History Tracking")

' Start a transaction


Dim nTransId As Object

nTransId = [Link]("Create Entity and Attribute",


oBag)

' Create an entity and an attribute


Dim oEntity As [Link]
Dim oAttribute As [Link]

oEntity = [Link]("Entity")
oAttribute = [Link](oEntity).Add("Attribute")
[Link]("Name").Value = "Attr A"

' Commit
[Link](nTransId)

End Sub

3–74 AllFusion ERwin Data Modeler API Reference Guide


Advanced Tasks

You can select the history options for the model objects for which you want to
preserve history, as well as to control the type of events to track. This is done
within the History Options tab in the Model Properties dialog. For more
information on this procedure, see the section Preserve Model History in the
chapter “Working with Design Layers” in the AllFusion ERwin DM Getting
Started guide.

If the checkbox for API events is cleared (unchecked), then no historic events
from the API category are recorded. It is possible to control the status of that
checkbox, as well as the checkboxes for model object types from the API, by
controlling the value of properties in the model where the status of these
checkboxes is stored.

API Tasks 3–75


Appendix

API Interfaces Reference


A
This appendix lists the interfaces contained in the AllFusion ERwin DM API,
together with the methods and arguments associated with these interfaces. There
is also a section that contains information regarding enumerations and describes
various Property Bag components.

API Interfaces
This section describes each AllFusion ERwin DM API interface, and the methods
associated with them. Where applicable, signatures and valid arguments are also
described.

Note: Some parameters contain an [optional] designation—this means that this


particular part of the parameter is optional and not required.

ISCApplication

The ISCApplication interface is the entry point for the API client. Only one
instance of the component can be externally instantiated to activate the AllFusion
ERwin DM API. The client navigates the interface hierarchy by using interface
properties and methods to gain access to the rest of the AllFusion ERwin DM
API functionality.

The following table contains the methods for the ISCApplication interface:

Method Description
BSTR ApiVersion() The API version
ISCApplicationEnvironment * Reports attributes of runtime
ApplicationEnvironment() environment and available features,
such as add-in mode, user interface
visibility, and so on

API Interfaces Reference A–1


API Interfaces

Method Description
ISCApplicationServiceCollection * Provides access to a variety of
ApplicationServices() application services, such as Forward
Engineering, Reverse Engineering,
Complete Compare, and so on. Not
available in the current version of
AllFusion ERwin DM API.
ISCModelDirectoryCollection * Collects model directories accessible
ModelDirectories() from the current machine
BSTR Name() Modeling tool application name
ISCPersistenceUnitCollection * Returns a collection of all persistence
PersistenceUnits() units loaded in the application
ISCSessionCollection * Sessions() Returns a collection of sessions created
within the application
BSTR Version() Modeling tool application version

ISCApplicationEnvironment

The ISCApplicationEnvironment interface contains the information about the


runtime environment.

The following table contains the methods for the ISCApplicationEnvironment


interface:

Method Description
ISCPropertyBag * Populates a property bag with one or
PropertyBag(VARIANT Category more property values as indicated by
[optional], Category and Name.
VARIANT Name [optional], VARIANT
See Application Environment Property
AsString [optional])
Bag section for details.

A–2 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCApplicationEnvironment::PropertyBag Arguments

Here is the signature for the PropertyBag function:


ISCPropertyBag *PropertyBag(VARIANT Category, VARIANT Name, VARIANT AsString)

The following table contains the valid arguments for the PropertyBag function:

Parameter Valid Type/Value Description


Category [optional] Empty Complete set of features
from all categories are
returned
Category [optional] VT_BSTR—Name of Features from the given
category category are returned.
For information on
category names, see the
Property Bag for
Application Environment
section in this appendix.
Name [optional] Empty All properties from the
selected category are
returned
Name [optional] VT_BSTR—Property The property with the
name given name and category
is returned.
For information on
property names, see the
Property Bag for
Application Environment
section in this appendix.
AsString [optional] Empty All values in the property
bag are presented in
native type
AsString [optional] VT_BOOL—TRUE or If set to TRUE, all values
FALSE in the property bag are
presented as strings

API Interfaces Reference A–3


API Interfaces

ISCModelDirectory

The Model Directory encapsulates information on a single model directory entry.


Examples of the Model Directory are a file system directory or an AllFusion
Model Manager library.

The following table contains the methods for the ISCModelDirectory interface:

Method Description
VARIANT_BOOL CopyDirectory(BSTR Source, Recursively copies one or more model directories
BSTR Destination, VARIANT Disposition [optional], from one location to another.
VARIANT Overwrite [optional])
VARIANT_BOOL CopyDirectoryUnit(BSTR Source, Copies one or more model directory units from
BSTR Destination, VARIANT Disposition [optional], one location to another.
VARIANT Overwrite [optional])
VARIANT_BOOL CreateDirectory( BSTR Name) Creates a model directory.
VARIANT_BOOL DeleteDirectory( BSTR Locator, Deletes the specified model directories and their
VARIANT Force [optional]) contents.
VARIANT_BOOL DeleteDirectoryUnit( BSTR Deletes specified model directory units.
Locator, VARIANT Force [optional])
VARIANT_BOOL DirectoryExists( BSTR Locator) Returns TRUE if a specified directory exists.
VARIANT_BOOL DirectoryUnitExists( BSTR Returns TRUE if a specified directory unit exists.
Locator)
SC_ModelDirectoryFlags Flags() Model Directory flags. A 32-bit property flag
word.
VARIANT_BOOL IsOfType( ISCModelDirectory * Returns TRUE if Directory has the same type of
Directory) connection as self.
For example, directory entries from the same mart
and with the same login attributes, such as user,
password, and so on, are considered of the same
type.
ISCModelDirectory * LocateDirectory (BSTR Locator, Starts enumeration over the directory sub-entries.
VARIANT Filter [optional])
ISCModelDirectory * LocateDirectoryNext() Locates the next sub-entry in the directory
enumeration. Returns a NULL pointer if no more
model directory entries can be found.
ISCModelDirectoryUnit * LocateDirectoryUnit (BSTR Starts enumeration over the directory units.
Locator, VARIANT Filter [optional])

A–4 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Method Description
ISCModelDirectoryUnit * Locates the next unit in the directory enumeration.
LocateDirectoryUnitNext()
BSTR Locator() Location of the directory including the absolute
path and parameters. Does not include password
information.
VARIANT_BOOL MoveDirectory( BSTR Source, Recursively moves one or more directories from
BSTR Destination, VARIANT Disposition [optional], one location to another.
VARIANT Overwrite [optional])
VARIANT_BOOL MoveDirectoryUnit( BSTR Source, Moves one or more model directory units from
BSTR Destination, VARIANT Disposition [optional], one location to another.
VARIANT Overwrite [optional])
BSTR Name() Model Directory name. For example, the file
system directory name without path information.
ISCPropertyBag* PropertyBag( VARIANT List Returns a pointer on a property bag with the
[optional], VARIANT AsString [optional]) directory properties.
Note: A directory property is present in the
resulting bag only if it has a value. If the property
does not have any value set, the property bag will
not have the property listed.
void PropertyBag( VARIANT List [optional], Accepts a pointer on a property bag with the
VARIANT AsString [optional], ISCPropertyBag* directory properties.
Property Bag)
SC_ModelDirectoryType Type() Type of a directory.

API Interfaces Reference A–5


API Interfaces

ISCModelDirectory::CopyDirectory Arguments

Here is the signature for the CopyDirectory function:


VARIANT_BOOL CopyDirectory(BSTR Source, BSTR Destination, VARIANT Disposition,
VARIANT Overwrite)

The following table contains the valid arguments for the CopyDirectory function:

Parameter Valid Type/Value Description


Source BSTR—String with a Provides a directory path
directory path that can include wildcard
characters in the last path
component, for the
location of one or more
model directories from
which to copy.
For an absolute path, the
AllFusion Model
Manager database
information and access
parameters are ignored.
Source Empty Denotes self as a subject
for the operation.
Destination BSTR—String with a Provides a string with a
directory path relative or absolute
location to identify where
to copy the model
directory from Source.
Wildcard characters are
not allowed.

Disposition [optional] Empty


Disposition [optional] VT_BSTR—Semicolon Arranges access
separated keyword attributes, such as resume
parameters session, for Destination.
In combination with the
absolute location, this
allows for Source and
Destination to be in
different marts.

A–6 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Parameter Valid Type/Value Description


Overwrite [optional] Empty Indicates if it is to
override existing
directories. By default,
directories are
overwritten.
Overwrite [optional] VT_BOOL—TRUE or Indicates if it is to
FALSE override existing
directories. If TRUE,
directories are
overwritten.

ISCModelDirectory::CopyDirectoryUnit Arguments

Here is the signature for the CopyDirectoryUnit function:


VARIANT_BOOL CopyDirectoryUnit(BSTR Source, BSTR Destination, VARIANT
Disposition, VARIANT Overwrite)

The following table contains the valid arguments for the CopyDirectoryUnit
function:

Parameter Valid Type/Value Description


Source BSTR—String with a Provides a directory path
directory path that can include wildcard
characters in the last path
component, for the
location of one or more
model directory units
from which to copy.
For an absolute path, the
AllFusion Model
Manager database
information and access
parameters are ignored.
Source Empty Denotes self as a subject
for the operation.

API Interfaces Reference A–7


API Interfaces

Parameter Valid Type/Value Description


Destination BSTR—String with a Provides a string with a
directory path relative or absolute
location to identify where
to copy the model
directory from Source.
Wildcard characters are
not allowed.

Disposition [optional] Empty


Disposition [optional] VT_BSTR—Semicolon Arranges access
separated keyword attributes, such as resume
parameters session, and so on, for
Destination. In
combination with the
absolute location, this
allows for Source and
Destination to be in
different marts.
Overwrite [optional] Empty Indicates if it is to
override existing
directory units. By
default, directory units
are overwritten.
Overwrite [optional] VT_BOOL—TRUE or Indicates if it is to
FALSE override existing
directory units. If TRUE,
directory units are
overwritten.

ISCModelDirectory::CreateDirectory Arguments

Here is the signature for the CreateDirectory function:


VARIANT_BOOL CreateDirectory( BSTR Name)

The following table contains the valid arguments for the CreateDirectory
function:

Parameter Valid Type/Value Description


Name BSTR—String with a Identifies a name of a
directory name directory to create

A–8 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCModelDirectory::DeleteDirectory Arguments

Here is the signature for the DeleteDirectory function:


VARIANT_BOOL DeleteDirectory( BSTR Locator, VARIANT Force)

The following table contains the valid arguments for the DeleteDirectory
function:

Parameter Valid Type/Value Description


Locator BSTR—String with a Identifies a directory path
directory name that can contain wildcard
characters in the last path
component.
For an absolute path, the
AllFusion Model
Manager database
information and access
parameters are ignored.
Locator Empty Denotes self as a subject
for the operation.
Force [optional] Empty Instructs to avoid
enforcing of overriding.
Force [optional] VT_BOOL—TRUE or Contains TRUE if the
FALSE operation overrides
certain locks, such as
read-only, in a file
system.

API Interfaces Reference A–9


API Interfaces

ISCModelDirectory::DeleteDirectoryUnit Arguments

Here is the signature for the DeleteDirectoryUnit function:


VARIANT_BOOL DeleteDirectoryUnit( BSTR Locator, VARIANT Force)

The following table contains the valid arguments for the DeleteDirectoryUnit
function:

Parameter Valid Type/Value Description


Locator BSTR—String with a Identifies a directory unit
directory name path that can contain
wildcard characters in the
last path component.
For an absolute path, the
AllFusion Model
Manager database
information and access
parameters are ignored.
Force [optional] Empty Instructs to avoid the
enforcing of overrides.
Force [optional] VT_BOOL—TRUE or Contains TRUE if the
FALSE operation overrides
certain locks, such as
read-only, in a file
system.

A–10 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCModelDirectory::DirectoryExists Arguments

Here is the signature for the DirectoryExists function:


VARIANT_BOOL DirectoryExists( BSTR Locator)

The following table contains the valid arguments for the DirectoryExists
function:

Parameter Valid Type/Value Description


Locator BSTR—String with a Identifies a directory
directory name path.
For an absolute path, the
AllFusion Model
Manager database
information and access
parameters are ignored.

ISCModelDirectory::DirectoryUnitExists Arguments

Here is the signature for the DirectoryUnitExists function:


VARIANT_BOOL DirectoryUnitExists( BSTR Locator)

The following table contains the valid arguments for the DirectoryUnitExists
function:

Parameter Valid Type/Value Description


Locator BSTR-String with a Identifies a directory unit
directory name path.
For an absolute path, the
AllFusion Model
Manager database
information and access
parameters are ignored.

API Interfaces Reference A–11


API Interfaces

ISCModelDirectory::IsOfType Arguments

Here is the signature for the IsOfType function:


VARIANT_BOOL IsOfType(ISCModelDirectory * Directory)

The following table contains the valid arguments for the IsOfType function:

Parameter Valid Type/Value Description


Directory ISCModelDirectory *– Identifies a directory.
Model Directory
component pointer

ISCModelDirectory::LocateDirectory Arguments

Here is the signature for the LocateDirectory function:


ISCModelDirectory * LocateDirectory (BSTR Locator, VARIANT Filter)

The following table contains the valid arguments for the LocateDirectory
function:

Parameter Valid Type/Value Description


Locator BSTR—String with a Identifies a directory path
directory location that can contain wildcard
characters in the last path
component in order to
search for sub-entries.
If the path provides an
exact location, it can also
be used to return to a
single model directory
entry.
For an absolute path, the
AllFusion Model
Manager database
information and access
parameters are ignored.
Filter [optional] VT_BSTR—Options Specifies a set of options
to narrow a search.

A–12 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCModelDirectory::LocateDirectoryUnit Arguments

Here is the signature for the LocateDirectoryUnit function:


ISCModelDirectoryUnit * LocateDirectoryUnit (BSTR Locator, VARIANT Filter)

The following table contains the valid arguments for the LocateDirectoryUnit
function:

Parameter Valid Type/Value Description


Locator BSTR—String with a Identifies a directory path
directory or unit location that can contain wildcard
characters in the last path
component in order to
search for units.
If the path provides an
exact location, it can also
be used to return to a
single model directory
unit.
For an absolute path, the
AllFusion Model
Manager database
information and access
parameters are ignored.
Filter [optional] VT_BSTR—Options Specifies a set of options
to narrow a search.

API Interfaces Reference A–13


API Interfaces

ISCModelDirectory::MoveDirectory Arguments

Here is the signature for the MoveDirectory function:


VARIANT_BOOL MoveDirectory(BSTR Source, BSTR Destination, VARIANT Disposition,
VARIANT Overwrite)

The following table contains the valid arguments for the MoveDirectory
function:

Parameter Valid Type/Value Description


Source BSTR—String with a Provides a directory path
directory path that can include wildcard
characters in the last path
component, for the
location of one or more
model directories from
which to move one or
more model directories.
For an absolute path, the
AllFusion Model
Manager database
information and access
parameters are ignored.
Source Empty Denotes self as a subject
for the operation.
Destination BSTR—String with a Provides a string with a
directory path relative or absolute
location to identify where
to move the model
directory from Source.
Wildcard characters are
not allowed.

Disposition [optional] Empty


Disposition [optional] VT_BSTR—Semicolon Arranges access
separated keyword attributes, such as resume
parameters session, for Destination.
In combination with the
absolute location, this
allows for Source and
Destination to be in
different marts.

A–14 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Parameter Valid Type/Value Description


Overwrite [optional] Empty Indicates if it is to
override existing
directories. By default,
directories are
overwritten.
Overwrite [optional] VT_BOOL—TRUE or Indicates if it is to
FALSE override existing
directories. If TRUE,
directories are
overwritten.

ISCModelDirectory::MoveDirectoryUnit Arguments

Here is the signature for the MoveDirectoryUnit function:


VARIANT_BOOL MoveDirectoryUnit(BSTR Source, BSTR Destination, VARIANT
Disposition, VARIANT Overwrite)

The following table contains the valid arguments for the MoveDirectory
function:

Parameter Valid Type/Value Description


Source BSTR—String with a Provides a directory path
directory path that can include wildcard
characters in the last path
component, for the
location of one or more
model directory units
from which to move one
or more model directory
units.
For an absolute path, the
AllFusion Model
Manager database
information and access
parameters are ignored.
Source Empty Denotes self as a subject
for the operation.

API Interfaces Reference A–15


API Interfaces

Parameter Valid Type/Value Description


Destination BSTR—String with a Provides a string with a
directory path relative or absolute
location to identify where
to move the model
directory units from
Source. Wildcard
characters are not
allowed.
Disposition [optional] Empty
Disposition [optional] VT_BSTR—Semicolon Arranges access
separated keyword attributes, such as resume
parameters session, and so on, for
Destination. In
combination with the
absolute location, this
allows for Source and
Destination to be in
different marts.
Overwrite [optional] Empty Indicates if it is to
override existing model
directory units. By
default, model directory
units are overwritten.
Overwrite [optional] VT_BOOL—TRUE or Indicates if it is to
FALSE override existing model
directory units. If TRUE,
model directory units are
overwritten.

A–16 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCModelDirectory::PropertyBag Arguments (Get Function)

Here is the signature for the PropertyBag (Get) function:


ISCPropertyBag * PropertyBag(VARIANT List, VARIANT AsString)

The following table contains the valid arguments for the PropertyBag (Get)
function:

Parameter Valid Type/Value Description


List [optional] VT_BSTR—Semicolon Provides a list of the
separated list of property model directory
names properties. If the list is
provided, only listed
properties are placed in
the returned property
bag.
For information on valid
property names, see the
Property Bag for Model
Directory and
ModelDirectory Unit
section in this appendix.
List [optional] Empty Requests a complete set of
properties.
AsString [optional] VT_BOOL—TRUE or If set to TRUE, requests
FALSE that all values in the bag
to be presented as strings.
The default is FALSE
with all values in their
native format.
AsString [optional] Empty All values in the property
bag are presented in
native type.

API Interfaces Reference A–17


API Interfaces

ISCModelDirectory::PropertyBag Arguments (Set Function)

Here is the signature for the PropertyBag (Set) function:


void PropertyBag(VARIANT List, VARIANT AsString, ISCPropertyBag * propBag)

The following table contains the valid arguments for the PropertyBag (Set)
function:

Parameter Valid Type/Value Description


List [optional] Not used
AsString [optional] Not used
propBag ISCPropertyBag * A pointer on a property
bag with the directory
properties to process.
For information on valid
property names and
format, see the Property
Bag for Model Directory
and ModelDirectory Unit
section in this appendix.

ISCModelDirectoryCollection

The Model Directory Collection lists all top-level Model Directories available
including the one made available with the application user interface. A client can
register new Model Directories with this collection.

Method Description
IUnknown _NewEnum() Constructs an instance of the collection
enumerator object.
ISCModelDirectory * Add(BSTR Adds a new top-level directory on the
Locator, VARIANT Disposition list of available directories.
[optional])
VARIANT_BOOL Clear() Removes all the top-level directories
from a collection and disconnects the
directories from associated marts.
long Count() The number of ModelDirectory
components in the collection.

A–18 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Method Description
ISCModelObject * Item(long nIndex) Returns an IUnknown interface pointer
identified by its ordered position.
VARIANT_BOOL Remove(VARIANT Removes a top-level directory from the
Selector, list of available directories.
VARIANT_BOOL Disconnect
[optional])

ISCModelDirectoryCollection::Add Arguments

Here is the signature for the Add function:


ISCModelDirectory * Add(BSTR Locator, VARIANT Disposition)

The following table contains the valid arguments for the Add function:

Parameter Valid Type/Value Description


Locator BSTR—A model Identifies a model
directory location directory location along
with the attributes
required for successful
access to storage
Disposition [optional] VT_BSTR—List of Arranges access
keywords parameters attributes, such as resume
session

ISCModelDirectoryCollection::Item Arguments

Here is the signature for the Item function:


ISCModelDirectory * Item(long nIndex)

The following table contains the valid arguments for the Item function:

Parameter Valid Type/Value Description


nIndex A long number Identifies an ordered
position of a Model
Directory item. The index
is zero-based.
Class [optional] Empty Returns the object
specified by nIndex

API Interfaces Reference A–19


API Interfaces

ISCModelDirectoryCollection::Remove Arguments

Here is the signature for the Remove function:


VARIANT_BOOL Remove(VARIANT Selector, VARIANT_BOOL Disconnect [optional])

The following table contains the valid arguments for the Remove function:

Parameter Valid Type/Value Description


Selector VT_UNKNOWN— An object pointer for the
ISCModelDirectory Model Directory to
pointer remove.
Selector VT_I4—Numeric index Identifying a model
directory for removal
with a zero-based index.

ISCModelDirectoryUnit

The Model Directory Unit encapsulates information on a single directory unit. A


file system file and an AllFusion Model Manager model are examples of the
Model Directory Unit

The following table contains the methods for the ISCModelDirectoryUnit


interface:

Method Description
SC_ModelDirectoryFlags Flags() Model directory unit flags. A 32-bit
property flag word.
For information on Model Directory
flags, see the Enumerations section in
this appendix.
VARIANT_BOOL IsOfType( Returns TRUE if directory has the
ISCModelDirectory * Directory) same type of connection as self.
For example, directory entries from
the same mart and with the same
login attributes, such as user,
password, and so on, are considered
of the same type.
BSTR Locator() Location of the directory unit
including the absolute path and
parameters. Does not include
password information.

A–20 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Method Description
BSTR Name() Model directory unit name. For
example, the file system file name
without path information.
ISCPropertyBag* PropertyBag( Returns a pointer on a property bag
VARIANT List [optional], VARIANT with the directory unit properties.
AsString [optional])
Note: A directory unit property is
present in the resulting bag only if it
has a value. If the property does not
have any value set, the property bag
will not have the property listed.
void PropertyBag( VARIANT List Accepts a pointer on a property bag
[optional], VARIANT AsString with the directory unit properties.
[optional], ISCPropertyBag* Property
Bag)
SC_ModelDirectoryType Type() Type of a directory.

ISCModelDirectoryUnit::IsOfType Arguments

Here is the signature for the IsOfType function:


VARIANT_BOOL IsOfType(ISCModelDirectory * Directory)

The following table contains the valid arguments for the IsOfType function:

Parameter Valid Type/Value Description


Directory ISCModelDirectory *— Identifies a directory.
Model Directory
component pointer

API Interfaces Reference A–21


API Interfaces

ISCModelDirectoryUnit::PropertyBag Arguments (Get Function)

Here is the signature for the PropertyBag (Get) function:


ISCPropertyBag * PropertyBag(VARIANT List, VARIANT AsString)

The following table contains the valid arguments for the PropertyBag (Get)
function:

Parameter Valid Type/Value Description


List [optional] VT_BSTR—Semicolon Provides a list of the
separated list of property model directory unit
names properties. If the list is
provided, only listed
properties are placed in
the returned property
bag.
For information on valid
property names, see the
Property Bag for Model
Directory and Model
Directory Unit section in
this appendix.
List [optional] Empty Requests a complete set of
properties.
AsString [optional] VT_BOOL—TRUE or If set to TRUE, requests
FALSE that all values in the bag
to be presented as strings.
The default is FALSE
with all values in their
native format.
AsString [optional] Empty All values in the property
bag are presented in
native type.

A–22 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCModelDirectoryUnit::PropertyBag Arguments (Set Function)

Here is the signature for the PropertyBag (Set) function:


void PropertyBag(VARIANT List, VARIANT AsString, ISCPropertyBag * propBag)

The following table contains the valid arguments for the PropertyBag (Set)
function:

Parameter Valid Type/Value Description


List [optional] Not used
AsString [optional] Not used
propBag ISCPropertyBag * A pointer on a property
bag with the unit
properties to process.
For information on valid
property names and
format, see the Property
Bag for Model Directory
and Model Directory Unit
section in this appendix.

ISCModelObject

The ISCModelObject interface represents an object in a model.

The following table contains the methods for the ISCModelObject interface:

Method Description
SC_ModelObjectFlags Flags() Returns the flags of the object.
For information on
SC_ModelObjectFlags, see the
Enumerations section in this appendix.
SC_CLSID ClassId() Returns the class identifier of the
current object.
BSTR ClassName() Returns the class name of the current
object.

API Interfaces Reference A–23


API Interfaces

Method Description
ISCModelPropertyCollection * Returns a property collection of the
CollectProperties(VARIANT ClassIds type that you want. This method
[optional], VARIANT MustBeOn always returns a valid collection even if
[optional], VARIANT MustBeOff the collection is empty.
[optional])
ISCModelObject * Context() Passes back the context (parent) of the
object in the model’s object tree. Passes
back NULL if the current object is the
tree root.
VARIANT_BOOL Returns TRUE if self is an instance of
IsInstanceOf(VARIANT ClassId) the passed class. This method respects
inheritance. If ClassId contains an
ancestor class, the method returns
TRUE.
VARIANT_BOOL IsValid() Returns TRUE if self is valid. This
method is used to detect if the
referenced object is deleted.
BSTR Name() Returns the name or a string identifier
of the current object.
SC_OBJID ObjectId() Uniquely identifies the current object.
ISCModelPropertyCollection * Returns a property collection of all
Properties() available properties.

A–24 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCModelObject::CollectProperties Arguments

Here is the signature for the CollectProperties function:


ISCModelPropertyCollection * CollectProperties(VARIANT ClassIds, VARIANT
MustBeOn, VARIANT MustBeOff)

The following table contains the valid arguments for the CollectProperties
function:

Parameter Valid Type/Value Description


ClassIds [optional] Empty All properties of the
object are returned.
ClassIds [optional] VT_ARRAY|VT_BSTR— Provides a list of property
SAFEARRAY of property class identifiers.
IDs
For information on valid
property class identifiers,
see the appendix
“AllFusion ERwin DM
Metamodel.”
ClassIds [optional] VT_ARRAY|VT_BSTR— Provides a list of property
SAFEARRAY of property class names.
names
For information on valid
property class names, see
the appendix “AllFusion
ERwin DM Metamodel.”
ClassIds [optional] VT_BSTR—ID of a Identifies a property
property class.
For information on valid
property class identifiers,
see the appendix
“AllFusion ERwin DM
Metamodel.”
ClassIds [optional] VT_BSTR—Name of a Identifies a property
property class.
For information on valid
property class names, see
the appendix “AllFusion
ERwin DM Metamodel.”

API Interfaces Reference A–25


API Interfaces

Parameter Valid Type/Value Description


ClassIds [optional] VT_BSTR—List of IDs Provides a list of property
delimited by semicolons class identifiers.
For information on valid
IDs, see the appendix
“AllFusion ERwin DM
Metamodel.”
ClassIds [optional] VT_BSTR—List of Provides a list of property
property names class names.
delimited by semicolons
For information on valid
property class names, see
the appendix “AllFusion
ERwin DM Metamodel.”
MustBeOn [optional] Empty Defaults to
SCD_MPF_DONT_CARE
– which indicates no
filtering.
MustBeOn [optional] VT_I4— Identifies the properties
SC_ModelObjectFlags with the specified flags
flags that must be on set.
For information on
SC_ModelObjectFlags,
see the Enumerations
section in this appendix.
MustBeOff [optional] Empty Defaults to
SCD_MPF_DONT_CARE
– which indicates no
filtering
MustBeOff [optional] VT_I4— Identifies the properties
SC_ModelObjectFlags that do not have the
flags that must be off specified flags.
For information on
SC_ModelObjectFlags,
see the Enumerations
section in this appendix.

A–26 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCModelObject::IsInstanceOf Arguments

Here is the signature for the IsInstanceOf function:


VARIANT_BOOL IsInstanceOf(VARIANT ClassId)

The following table contains the valid arguments for the IsInstanceOf function:

Parameter Valid Type/Value Description


ClassId VT_BSTR—ID of an Identifies a target object
object class class by the given
identifier.
For information on valid
class identifiers, see the
appendix “AllFusion
ERwin DM Metamodel.”
ClassId VT_BSTR—Name of an Identifies an object class
object class by the given name.
For information on valid
object class names, see the
appendix “AllFusion
ERwin DM Metamodel.”

ISCModelObjectCollection

The ISCModelObjectCollection interface is a collection of objects in the model


that is connected to the active session. Membership in this collection can be
limited by establishing filter criteria.

The following table contains the methods for the ISCModelObjectCollection


interface:

Method Description
IUnknown _NewEnum() Constructs an instance of the collection
enumerator object.
ISCModelObject * Add(VARIANT Adds an object of type Class to the
Class, VARIANT ObjectId) model.

API Interfaces Reference A–27


API Interfaces

Method Description
SC_CLSID * ClassIds() Returns a SAFEARRAY of class
identifiers (such as object type IDs).
Represents a value of the Model Object
collection attribute that limited the
membership in the collection at the
time when this collection was created
and can be used for reference purposes.
ClassIds contains a list of acceptable
class identifiers (such as object types). If
this list is non-empty, the collection
includes only those objects whose class
identifier appears in the list. If the list is
empty or returns a NULL pointer, then
all objects are included.
For information on object class
identifiers, see the appendix “AllFusion
ERwin DM Metamodel.”
BSTR * ClassNames() Similar to ClassIds except that it
returns a SAFEARRAY of class names
(such as object type names).
For information on object class names,
see the appendix “AllFusion ERwin
DM Metamodel.”
ISCModelObjectCollection * Creates a collection of Model Objects,
Collect(VARIANT Root, VARIANT which represents a subcollection of
ClassId [optional], VARIANT Depth itself. All filtering criteria specified in
[optional], VARIANT MustBeOn the Collect call is applied toward
[optional], VARIANT MustBeOff membership in the collection.
[optional])
The method creates a valid collection
even though the collection may be
empty.
All enumerations are depth-first.
long Count() Number of objects in the collection. The
number does not include the root
object.
long Depth() Depth limit on iteration in the
collection. -1 represents unlimited
depth.

A–28 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Method Description
ISCModelObject * Item(VARIANT Returns an IUnknown pointer for a
nIndex, VARIANT Class [optional]) Model Object component identified by
the Index parameter.
SC_ModelObjectFlags MustBeOff() Filter on model object flags in the
collection.
SC_ModelObjectFlags MustBeOn() Filter on model object flags in the
collection.
VARIANT_BOOL Remove(VARIANT Removes the specified model object
Object) from a model.
ISCModelObject * Root() Returns a pointer to the root object in a
collection.

ISCModelObjectCollection::Add Arguments

Here is the signature for the Add function:


ISCModelObject * Add(VARIANT Class, VARIANT ObjectId)

The following table contains the valid arguments for the Add function:

Parameter Valid Type/Value Description


Class VT_BSTR—Name of a Identifies an object class
class by the given class name.
For information on valid
object class names, see the
appendix “AllFusion
ERwin DM Metamodel.”
Class VT_BSTR—Class ID of Identifies an object class
an object type by the given identifier.
For information on valid
object class identifiers, see
the appendix “AllFusion
ERwin DM Metamodel.”
ObjectId [optional] Empty The API assigns an object
identifier for a new object.
ObjectId [optional] VT_BSTR—Object ID for The API assigns the given
a new object object identifier to the
new object.

API Interfaces Reference A–29


API Interfaces

ISCModelObjectCollection::Collect Arguments

Here is the signature for the Collect function:


ISCModelObjectCollection * Collect(VARIANT Root, VARIANT ClassId, VARIANT Depth,
VARIANT MustBeOn, VARIANT MustBeOff)

The following table contains the valid arguments for the Collect function:

Parameter Valid Type/Value Description


Root VT_UNKNOWN— Provides a context
ISCModelObject pointer (parent) object for the
of the root object collection.
Root VT_BSTR—ID of the root Provides a context
object (parent) object for the
collection.
ClassId [optional] VT_ARRAY|VT_BSTR— Contains a list of
SAFEARRAY of class IDs acceptable class
identifiers.
For information on valid
object IDs, see the
appendix “AllFusion
ERwin DM Metamodel.”
ClassId [optional] VT_ARRAY|VT_BSTR— Contains a list of
SAFEARRAY of class acceptable class names.
names
For information on valid
object class names, see the
appendix “AllFusion
ERwin DM Metamodel.”
ClassId [optional] VT_BSTR—Class ID Provides a class identifier
for a monotype collection.
For information on valid
object identifiers, see the
appendix “AllFusion
ERwin DM Metamodel.”
ClassId [optional] VT_BSTR—Semicolon Contains a list of
delimited list of class IDs acceptable class
identifiers.
For information on valid
object identifiers, see the
appendix “AllFusion
ERwin DM Metamodel.”

A–30 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Parameter Valid Type/Value Description


ClassId [optional] VT_BSTR—Class name Provides a type name for
a monotype collection.
For information on valid
object class names, see the
appendix “AllFusion
ERwin DM Metamodel.”
ClassId [optional] VT_BSTR—Semicolon Contains a list of
delimited list of class acceptable class names.
names
For information on valid
object class names, see the
appendix “AllFusion
ERwin DM Metamodel.”
ClassId [optional] Empty Returns all descendents
regardless of class type.
Depth [optional] VT_I4—Maximum depth Returns the descendents
for descendents. Depth of the root at a depth no
of 1 returns the more than the given
immediate children of depth.
the root. A depth of -1
(which is the default
value) represents
unlimited depth.
Depth [optional] Empty Returns all descendents
of the root (unlimited
depth).
MustBeOn [optional] VT_I4— Provides a set of required
SC_ModelObjectFlags flags.
that must be set
For information on
SC_ModelObjectFlags,
see the Enumerations
section in this appendix.
MustBeOn [optional] Empty Defaults to
SCD_MOF_DONT_CARE.

API Interfaces Reference A–31


API Interfaces

Parameter Valid Type/Value Description


MustBeOff [optional] VT_I4— Provides a set of flags that
SC_ModelObjectFlags must not be set.
that must not be set
For information on
SC_ModelObjectFlags,
see the Enumerations
section in this appendix.
MustBeOff [optional] Empty Defaults to
SCD_MOF_DONT_CARE.

ISCModelObjectCollection::Item Arguments

Here is the signature for the Item function:


ISCModelObject * Item(VARIANT nIndex, VARIANT Class)

The following table contains the valid arguments for the Item function:

Parameter Valid Type/Value Description


nIndex VT_UNKNOWN— Identifies an object with
Pointer to the Model Object pointer.
ISCModelObject
interface
nIndex VT_BSTR—ID of an Identifies an object with
object the given object identifier.
nIndex VT_BSTR—Name of an If the name of an object is
object used, the Class parameter
must also be used.
Identifies an object with
the given name and given
object class.
Class [optional] Empty Only if nIndex is not an
object name.

A–32 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Parameter Valid Type/Value Description


Class [optional] VT_BSTR—Name of a Must be used if the
class nIndex parameter is the
name of an object.
Identifies an object class
name.
For information on valid
object class names, see the
appendix “AllFusion
ERwin DM Metamodel.”
Class [optional] VT_BSTR—Class ID of Must be used if the
object type nIndex parameter is the
name of an object.
Identifies an object class
identifier.
For information on valid
object class names, see the
appendix “AllFusion
ERwin DM Metamodel.”

ISCModelObjectCollection::Remove Arguments

Here is the signature for the Remove function:


VARIANT_BOOL Remove(VARIANT Object)

The following table contains the valid arguments for the Remove function:

Parameter Valid Type/Value Description


Object VT_UNKNOWN - Identifies the removed
ISCModelObject - pointer object by the Model
to an object Object pointer.
Object VT_BSTR—ID of the Identifies the removed
object object by the object’s
identifier.

API Interfaces Reference A–33


API Interfaces

ISCModelProperty

The ISCModelProperty interface represents a property of a given object.

The following table contains the methods for the ISCModelProperty interface:

Method Description
SC_CLSID ClassId() Returns the class identifier of the
property.
For information on property class
identifiers, see the appendix “AllFusion
ERwin DM Metamodel.”
BSTR ClassName() Returns the class name of the property.
For information on property class
names, see the appendix “AllFusion
ERwin DM Metamodel.”
long Count() Contains the number of values in the
property.
SC_ValueTypes DataType(VARIANT Passes back the identifier of the native
ValueId [optional]) value type for the indicated property
value.
For information on SC_ValueTypes, see
the Enumerations section in this
appendix.
VARIANT_BOOL IsValid() Returns TRUE if self is valid.
SC_ModelPropertyFlags Flags() Returns the flags of the property.
For information on
SC_ModelPropertyFlags, see the
Enumerations section in this appendix.
BSTR FormatAsString() Formats the property value as a string.
ISCPropertyValueCollection * Returns the collection of values for the
PropertyValues() model property.
VARIANT_BOOL RemoveAllValues() Removes all values from the property.
VARIANT_BOOL Removes the specified value from the
RemoveValue(VARIANT ValueId property. If no values remain after the
[optional]) removal, the property has a NULL
value.
Returns TRUE if the value was
removed.

A–34 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Method Description
VARIANT Value(VARIANT ValueId Retrieves the indicated property value
[optional], VARIANT ValueType in the requested format.
[optional])
For information on property data types,
see SC_ValueTypes in the
Enumerations section in this appendix.
void Value(VARIANT ValueId Sets the indicated property value with
[optional], VARIANT ValueType the given value.
[optional], VARIANT Val )

ISCModelProperty::DataType Arguments

Here is the signature for the DataType function:


SC_ValueTypes DataType(VARIANT ValueId)

The following table contains the valid arguments for the DataType function:

Parameter Valid Type/Value Description


ValueId Empty Valid if a property is
scalar or if all elements of
a multi-valued property
have the same datatype.
ValueId VT_I4—Index Ignored if the property is
scalar. Identifies an
element in a multi-valued
property with a zero-
based index.
ValueId VT_BSTR—Name of a Ignored if the property is
non-scalar element scalar. If the property is
multi-valued, indicates an
element by name.

API Interfaces Reference A–35


API Interfaces

ISCModelProperty::RemoveValue Arguments

Here is the signature for the RemoveValue function:


VARIANT_BOOL RemoveValue(VARIANT ValueId)

The following table contains the valid arguments for the RemoveValue function:

Parameter Valid Type/Value Description


ValueId Empty Valid for a scalar
property only.
ValueId VT_I4—Index Ignored if the property is
scalar. Identifies an
element in a multi-valued
property with a zero-
based index.
ValueId VT_BSTR—Name of a Ignored if the property is
non-scalar element scalar. If the property is
multi-valued, indicates an
element by name.

ISCModelProperty::Value Arguments (Get Function)

Here is the signature for the Value (Get) function:


VARIANT Value(VARIANT ValueId, VARIANT ValueType)

The following table contains the valid arguments for the Value (Get) function:

Parameter Valid Type/Value Description


ValueId [optional] Empty Valid for a scalar
property only.
ValueId [optional] VT_BSTR—Name of a Ignored if the property is
non-scalar element scalar. If the property is
multi-valued, indicates an
element by name.
ValueId [optional] VT_I4—Index of a non- Ignored if the property is
scalar element scalar. If the property is
multi-valued, indicates an
element by a zero-based
index.

A–36 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Parameter Valid Type/Value Description


ValueType [optional] Empty Indicates a native
datatype for return
values.
ValueType [optional] VT_I4— Indicates a native
SCVT_DEFAULT datatype for return
values.
ValueType [optional] VT_I4—SCVT_BSTR Indicates a conversion to
a string for return values.

ISCModelProperty::Value Arguments (Set Function)

Here is the signature for the Value (Set) function:


void Value(VARIANT ValueId, VARIANT ValueType, VARIANT Val)

The following table contains the valid arguments for the Value (Set) function:

Parameter Valid Type/Value Description


ValueId [optional] Empty Valid for a scalar
property only.
ValueId [optional] VT_I4—Index of a non- Indicates a value position
scalar property with a zero-based index
in a non-scalar property.
A value of –1 causes a
new value to be added at
the end of the vector.
ValueId [optional] VT_BSTR—Name of the Indicates a value position
element in a multi- with the given name.
valued property
ValueType [optional] Empty Not used
Val Dependent upon the
property type

API Interfaces Reference A–37


API Interfaces

ISCModelPropertyCollection

The ISCModelPropertyCollection interface is a collection of properties for a given


model object. Membership in this collection can be limited by establishing filter
criteria.

The following table contains the methods for the ISCModelPropertyCollection


interface:

Method Description
IUnknown _NewEnum() Constructs an instance of the collection
enumerator object.
ISCModelProperty * Add(VARIANT Construct a new property for a bound
ClassId) model object if it does not exist.
SC_CLSID * ClassIds() Returns a SAFEARRAY of property
class identifiers in the property
collection.
Represents a value of the
ModelProperties collection attribute
that limited the membership at the time
when this collection was created and
can be used for reference purposes.
ClassIds contain an array of acceptable
class identifiers (such as property
classes). If this list is non-empty, the
property collection includes only those
properties whose class identifier
appears on the list. If the list is empty
or the caller supplies a NULL pointer,
the collection includes all the properties
owned by the object.
For information on property class
identifiers, see the appendix “AllFusion
ERwin DM Metamodel.”
BSTR * ClassNames() Same as the ClassIds property, but
returns a SAFEARRAY of property
type names in the property collection.
For information on property class
names, see the appendix “AllFusion
ERwin DM Metamodel.”
long Count() Number of properties in the collection.

A–38 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Method Description
VARIANT_BOOL Returns TRUE if the object owns a
HasProperty(VARIANT ClassId, property of the passed class.
VARIANT MustBeOn [optional],
Treats properties as absent if they fail
VARIANT MustBeOff [optional])
to satisfy ClassIds, MustBeOn, and
MustBeOff attributes of the collection.
Alternative MustBeOn, MustBeOff can
be offered using optional parameters.
ISCModelProperty * Item(VARIANT Returns a model object property.
Class)
The method checks if the property
exists. If it does not, the method creates
a property description, returns an
ISCModelProperty instance, and sets
the NULL flag for the property. A new
property value can be set by using the
Value property of the instance.
However, it will fail to retrieve a value
before it is set.
The method allows you to create an
instance of ISCModelProperty for
properties like ReadOnly, Maintained
By the Tool, and so on. The value for
these properties cannot be changed or
assigned. Yet property flags, datatype,
and so on are available even when the
collection does not have the property
instance. Use HasProperty to check on
the existence of the property for a
model object instance.
SC_ModelPropertyFlags MustBeOff() Filter on property flags in the
collection. The filter is set when the
property collection is created through
the ISCModelObject::CollectProperties
method.
For information on
SC_ModelPropertyFlags, see the
Enumerations section in this appendix.

API Interfaces Reference A–39


API Interfaces

Method Description
SC_ModelPropertyFlags MustBeOn() Filter on property flags in the
collection. The filter is set when the
property collection is created through
the ISCModelObject::CollectProperties
method.
For information on
SC_ModelPropertyFlags, see the
Enumerations section in this appendix.
VARIANT_BOOL Remove(VARIANT Removes the indicated property from
ClassId) the bound object.
Successful execution of the call renders
all binds with the removed property
invalid. The client should release all
ISCModelProperty pointers, and all
related Value Collection and Value
pointers known to represent such an
association. Calls to interfaces fail and
the IsValid method returns FALSE.

ISCModelPropertyCollection::Add Arguments

Here is the signature for the Add function:


ISCModelProperty * Add(VARIANT ClassId)

The following table contains the valid arguments for the Add function:

Parameter Valid Type/Value Description


ClassId VT_BSTR—Name of a Provides a new property
property class type name.
For information on valid
property class names, see
the appendix “AllFusion
ERwin DM Metamodel.”
ClassId VT_BSTR—ID of a Provides a new property
property class identifier.
For information on valid
property class identifiers,
see the appendix
“AllFusion ERwin DM
Metamodel.”

A–40 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCModelPropertyCollection::HasProperty Arguments

Here is the signature for the HasProperty function:


VARIANT_BOOL HasProperty(VARIANT ClassId, VARIANT MustBeOn, VARIANT MustBeOff)

The following table contains the valid arguments for the HasProperty function:

Parameter Valid Type/Value Description


ClassId VT_BSTR—Name of a Identifies a class name for
property a property.
For information on valid
property class names, see
the appendix “AllFusion
ERwin DM Metamodel.”
ClassId VT_BSTR—ID of a Identifies a class identifier
property for a property.
For information on valid
property class identifiers,
see the appendix
“AllFusion ERwin DM
Metamodel.”
MustBeOn [optional] VT_I4— Provides a set of required
SC_ModelPropertyFlags flags.
that must be set
For information on
SC_ModelPropertyFlags,
see the Enumerations
section in this appendix.
MustBeOn [optional] Empty Default is set to the
MustBeOn filter that was
used to create the
property collection.
For information on
SC_ModelPropertyFlags,
see the Enumerations
section in this appendix.

API Interfaces Reference A–41


API Interfaces

Parameter Valid Type/Value Description


MustBeOff [optional] VT_I4— Provides a set of flags that
SC_ModelPropertyFlags must not be set.
that must not be set
For information on
SC_ModelPropertyFlags,
see the Enumerations
section in this appendix.
MustBeOff [optional] Empty Default is set to the
MustBeOff filter that was
used to create the
property collection.

ISCModelPropertyCollection::Item Arguments

Here is the signature for the Item function:


ISCModelProperty * Item(VARIANT Class)

The following table contains the valid arguments for the Item function:

Parameter Valid Type/Value Description


Class VT_BSTR—ID of a Provides the property
property class identifier.
For information on valid
property class identifiers,
see the appendix
“AllFusion ERwin DM
Metamodel.”
Class VT_BSTR—Name of a Provides the property
property class name.
For information on valid
property class names, see
the appendix “AllFusion
ERwin DM Metamodel.”

A–42 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCModelPropertyCollection::Remove Arguments

Here is the signature for the Remove function:


VARIANT_BOOL Remove(VARIANT ClassId)

The following table contains the valid arguments for the Remove function:

Parameter Valid Type/Value Description


ClassId ISCModelProperty * Identifies a property with
a Model Property object.
ClassId VT_BSTR—Name of the Identifies the property
property with a class name.
For information on valid
property class names, see
the appendix “AllFusion
ERwin DM Metamodel.”
ClassId VT_BSTR—ID of the Identifies the property
property with a class identifier.
For information on valid
property class identifiers,
see the appendix
“AllFusion ERwin DM
Metamodel.”

API Interfaces Reference A–43


API Interfaces

ISCModelSet

A Model Set component provides access to a member of a hierarchically


organized collection of model sets.

The following table contains the methods for the ISCModelSet interface:

Method Description
SC_MODELTYPEID ClassId() Class identifier for metadata associated
with the model set.
For information on metadata class
identifiers, see the appendix “AllFusion
ERwin DM Metamodel.”
BSTR ClassName() Class name for metadata associated
with the model set.
For information on metadata class
names, see the appendix “AllFusion
ERwin DM Metamodel.”
VARIANT_BOOL DirtyBit() Returns a flag that indicates that the
data has changed in the model set.
void DirtyBit(VARIANT_BOOL ) Sets the flag that indicates that the data
in the model set has changed.
SC_MODELTYPEID ModelSetId() Passes back an identifier for the model
set.
BSTR Name() Passes back a persistence unit name.
ISCModelSet * Owner() A pointer to the owner model set.
Returns NULL for the top model set in
the persistence unit.
ISCModelSetCollection * Provides a collection with directly
OwnedModelSets() owned model sets.
SC_MODELTYPEID The identifier for the persistence unit
PersistenceUnitId() that contains the model set.

A–44 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Method Description
ISCPropertyBag * Returns a property bag with the model
PropertyBag(VARIANT List [optional], set’s properties.
VARIANT AsString [optional])
A model set property is present in the
resulting bag only if it has a value. If
the property does not have any value
set, the property bag will not have the
property listed.
void PropertyBag(VARIANT List Sets a model set with the properties in
[optional], VARIANT AsString the given property bag.
[optional], ISCPropertyBag * propBag)

ISCModelSet::PropertyBag Arguments (Get Function)

Here is the signature for the PropertyBag (Get) function:


ISCPropertyBag * PropertyBag(VARIANT List, VARIANT AsString)

The following table contains the valid arguments for the PropertyBag (Get)
function:

Parameter Valid Type/Value Description


List [optional] VT_BSTR—Semicolon Provides a list of the
separated list of model set properties. If
properties the list is provided, only
listed properties are
placed in the returned
property bag.
For information on
property names, see the
Property Bag for
Persistence Unit and
Persistence Unit
Collection in this
appendix.
List [optional] Empty Requests a complete set of
properties.

API Interfaces Reference A–45


API Interfaces

Parameter Valid Type/Value Description


AsString [optional] VT_BOOL—TRUE or If set to TRUE, requests
FALSE that all values in the bag
to be presented as strings.
The default is FALSE
with all values in their
native format.
AsString [optional] Empty All values in the property
bag are presented in
native type.

ISCModelSet::PropertyBag Arguments (Set Function)

Here is the signature for the PropertyBag (Set) function:


void PropertyBag(VARIANT List, VARIANT AsString, ISCPropertyBag * propBag)

The following table contains the valid arguments for the PropertyBag (Set)
function:

Parameter Valid Type/Value Description


List [optional] Not used
AsString [optional] Not used
propBag ISCPropertyBag * A pointer on a property
bag with the model set
properties to process.

A–46 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCModelSetCollection

A Model Set Collection contains all model sets directly owned by an owner
model set.

The following table contains the methods for the ISCModelSetCollection


interface:

Method Description
IUnknown _NewEnum() Constructs an instance of a model set
enumerator object.
long Count() Number of model sets in the collection.
ISCPersistenceUnit * Item(VARIANT Passes back a pointer for a ModelSet
nIndex) component.
ISCModelSet * Owner() Returns a pointer to the owner model
set.

ISCModelSetCollection::Item Arguments

Here is the signature for the Item function:


ISCModelSet * Item(VARIANT nIndex)

The following table contains the valid arguments for the Item function:

Parameter Valid Type/Value Description


nIndex VT_UNKNOWN— Creates a clone for the
Pointer to Model Set object.
ISCPersistenceUnit
nIndex VT_I4—Index of a model Ordered position in the
set in the model set collection. The index is
collection zero-based.
nIndex VT_BSTR—Model Set ID Model set identifier.

API Interfaces Reference A–47


API Interfaces

Parameter Valid Type/Value Description


nIndex VT_BSTR—Metadata Class identifier for
Class ID metadata associated with
a model set.
For information on
metadata class identifiers,
see the appendix
“AllFusion ERwin DM
Metamodel.”
nIndex VT_BSTR—Metadata Class name for metadata
Class name associated with a model
set.
For information on
metadata class names, see
the appendix “AllFusion
ERwin DM Metamodel.”

ISCPersistenceUnit

A Persistence Unit encapsulates the information required to connect to an


existing, outer level persistence unit within an application.

The following table contains the methods for the ISCPersistenceUnit interface:

Method Description
VARIANT_BOOL DirtyBit() Returns a flag that indicates that the
data has changed in the persistence
unit.
void DirtyBit(VARIANT_BOOL ) Sets the flag that indicates that the data
in the persistence unit has changed.
VARIANT_BOOL HasSession() Returns TRUE if a unit has one or more
sessions connected.
VARIANT_BOOL IsValid() Returns TRUE if self is valid.
ISCModelSet * ModelSet() Passes back a pointer on the top model
set in the Persistence Unit.
BSTR Name() Passes back a persistence unit name.
SC_MODELTYPEID ObjectId() Passes back an identifier for the
persistence unit.

A–48 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Method Description
ISCPropertyBag * Returns a property bag with the
PropertyBag(VARIANT List [optional], persistence unit’s properties.
VARIANT AsString [optional])
A unit property is present in the
resulting bag only if it has a value. If
the property does not have any value
set, the property bag will not have the
property listed.
For a detailed description of properties,
see the Property Bag for Persistence
Units and the Persistence Unit
Collections section in this Appendix.
void PropertyBag(VARIANT List Sets a persistence unit with the
[optional], VARIANT AsString properties in the given property bag.
[optional], ISCPropertyBag * propBag)
VARIANT_BOOL Save(VARIANT Persists model data to external storage.
Locator [optional], VARIANT Uncommitted transactions are ignored.
Disposition [optional])

API Interfaces Reference A–49


API Interfaces

ISCPersistenceUnit::PropertyBag Arguments (Get Function)

Here is the signature for the PropertyBag (Get) function:


ISCPropertyBag * PropertyBag(VARIANT List, VARIANT AsString)

The following table contains the valid arguments for the PropertyBag (Get)
function:

Parameter Valid Type/Value Description


List [optional] VT_BSTR—Semicolon Provides a list of the unit
separated list of properties. If the list is
properties provided, only listed
properties are placed in
the returned property
bag.
For information on valid
property names, see the
Property Bag for
Persistence Units and the
Persistence Unit
Collections in this
appendix.
List [optional] Empty Requests a complete set of
properties.
AsString [optional] VT_BOOL—TRUE or If set to TRUE, it requests
FALSE that all values in the bag
be presented as strings.
The default is FALSE and
all values are in their
native format.
AsString [optional] Empty All values in the property
bag are presented in
native type.

A–50 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCPersistenceUnit::PropertyBag Arguments (Set Function)

Here is the signature for the PropertyBag (Set) function:


void PropertyBag(VARIANT List, VARIANT AsString, ISCPropertyBag * propBag)

The following table contains the valid arguments for the PropertyBag (Set)
function:

Parameter Valid Type/Value Description


List [optional] Not used
AsString [optional] Not used
propBag ISCPropertyBag * A pointer on a property
bag with the unit
properties to process.

API Interfaces Reference A–51


API Interfaces

ISCPersistenceUnit::Save Arguments

Here is the signature for the Save function:


VARIANT_BOOL Save(VARIANT Locator, VARIANT Disposition)

The following table contains the valid arguments for the Save function:

Parameter Valid Type/Value Description


Locator [optional] VT_BSTR—Full path to a Provides a new location
storage location for the persistence unit
data source as a string
with a file or AllFusion
Model Manager item
location, along with the
attributes required for
successful access to
storage.
For information on the
format of the Location
parameter, see the
Location and Disposition
Properties in this
appendix.
Locator [optional] Empty Indicates the use of the
original persistence unit
location.
Disposition [optional] VT_BSTR—List of Specifies changes in
keywords parameters access attributes, such as
read only.

A–52 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCPersistenceUnitCollection

The ISCPersistenceUnitCollection contains all outer level persistence units


loaded in the application. It contains one entry for each active data model.

The following table contains the methods for the ISCPersistenceUnitCollection


interface:

Method Description
IUnknown _NewEnum() Constructs an instance of unit
enumerator object.
ISCPersistenceUnit * Add(VARIANT Adds a new persistence unit to the unit
Locator, VARIANT Disposition collection.
[optional])
VARIANT_BOOL Clear() Purges all units from the collection.
long Count() Number of persistence units in the
collection.
ISCPersistenceUnit * Creates a new unit, and registers the
Create(ISCPropertyBag * PropertyBag, unit with the collection.
VARIANT ObjectId [optional])
For a detailed description of properties
in the Property Bag, see the Property
Bag for Persistence Units section and
the Persistence Unit Collections section
in this appendix.
ISCPersistenceUnit * Item(VARIANT Passes back an IUnknown pointer for a
nIndex) PersistenceUnit component.
VARIANT_BOOL Remove(VARIANT Removes a persistence unit from the
Selector, VARIANT Save [optional]) collection.

API Interfaces Reference A–53


API Interfaces

ISCPersistenceUnitCollection::Add Arguments

Here is the signature for the Add function:


ISCPersistenceUnit * Add(VARIANT Locator, VARIANT Disposition)

The following table contains the valid arguments for the Add function:

Parameter Valid Type/Value Description


Locator VT_BSTR—Persistence Identifies a location for
unit location the persistence unit data
source as a string with a
file or AllFusion Model
Manager item location,
along with the attributes
required for successful
access to storage.
For a detailed description
of the Location format see
the Locations and
Dispositions section in
this appendix.
Disposition [optional] VT_BSTR—List of Arranges access
keywords parameters attributes, such as read
only.
For a detailed description
of the Disposition format
see the Locations and
Dispositions section in
this appendix.

A–54 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCPersistenceUnitCollection::Create Arguments

Here is the signature for the Create function:


ISCPersistenceUnit * Create(ISCPropertyBag * Property Bag, VARIANT ObjectId)

The following table contains the valid arguments for the Create function:

Parameter Valid Type/Value Description


Property Bag ISCPropertyBag * — Supplies required and
Pointer to a Property Bag optional properties to the
object creation process, such as
type of the model.
For information on valid
property names and
format, see the Property
Bag for Persistence Units
section and the
Persistence Unit
Collections section in this
appendix.
ObjectId [optional] Empty Generate an ID for the
new persistence unit.
ObjectId [optional] VT_BSTR—Object ID for Provides an identifier for
the new persistence unit the new persistence unit.

API Interfaces Reference A–55


API Interfaces

ISCPersistenceUnitCollection::Item Arguments

Here is the signature for the Item function:


ISCPersistenceUnit * Item(VARIANT nIndex)

The following table contains the valid arguments for the Item function:

Parameter Valid Type/Value Description


nIndex VT_UNKNOWN— Creates a clone for
Pointer to Persistence Unit object.
ISCPersistenceUnit
nIndex VT_I4—Index of a Ordered position in the
persistence unit in the collection. The index is
persistence unit zero-based.
collection
nIndex VT_BSTR—ID of a Application-wide unique
persistence unit persistence unit identifier.

ISCPersistenceUnitCollection::Remove Arguments

Here is the signature for the Remove function:


VARIANT_BOOL Remove(VARIANT Selector, VARIANT Save)

The following table contains the valid arguments for the Remove function:

Parameter Valid Type/Value Description


Selector VT_UNKNOWN— Identifies the persistence
Pointer to unit.
ISCPersistenceUnit
interface
Selector VT_BSTR—ID of a Application-wide unique
persistence unit persistence unit identifier.

A–56 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Parameter Valid Type/Value Description


Selector VT_I4—Index of a Ordered position in the
persistence unit in the collection. The index is
persistence unit zero-based.
collection
Save [optional] VT_BOOL If set to TRUE, it saves the
persistence unit prior to
removing it from the
collection. By default, all
unsaved data is saved
unless the Save parameter
has a FALSE value, or the
unit has a temporary
status with an unspecified
location property.

ISCPropertyBag

The ISCPropertyBag interface is used to set and access the properties of


ISCApplicationEnvironment, ISCPersistenceUnit, and ISCModelSet. The
ISCPropertyBag is also used to set the properties of a new persistence unit.

The following table contains the methods for the ISCPropertyBag interface:

Method Description
VARIANT_BOOL Add(BSTR Name, Adds a new property to the bag. Does
VARIANT Value) not check for duplicate names. Returns
TRUE if the property was added to the
bag, otherwise, it is FALSE.
void ClearAll() Removes all properties from the bag.
long Count() Returns the number of properties.
BSTR Name(long PropertyIdx) Retrieves the indicated property name
in the bag.
VARIANT Value(VARIANT Property) Retrieves the indicated property in the
bag.
void Value(VARIANT Property, Sets the indicated property in the bag.
VARIANT Val)

API Interfaces Reference A–57


API Interfaces

ISCPropertyBag::Add Arguments

Here is the signature for the Add function:


VARIANT_BOOL Add(BSTR Name, VARIANT Value)

The following table contains the valid arguments for the Add function:

Parameter Valid Type/Value Description


Name BSTR Name of a new property.
Value Dependent on the Value for a new property.
property

ISCPropertyBag::Name Arguments

Here is the signature for the Name function:


BSTR Name(long PropertyIdx)

The following table contains the valid arguments for the Name function:

Parameter Valid Type/Value Description


PropertyIdx Long A zero-based index for
the requested name.

ISCPropertyBag::Value Arguments (Get Function)

Here is the signature for the Value (Get) function:


VARIANT Value(VARIANT Property)

The following table contains the valid arguments for the Value (Get) function:

Parameter Valid Type/Value Description


Property VT_BSTR—Name of the Identifies retrieved
property property.
Property VT_I4—Index of the Zero-based property
property index in the Property Bag.

A–58 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCPropertyBag::Value Arguments (Set Function)

Here is the signature for the Value (Set) function:


void Value(VARIANT Property, VARIANT Val)

The following table contains the valid arguments for the Value (Set) function:

Parameter Valid Type/Value Description


Property VT_BSTR—Name of the Identifies the property to
property update.
Val Dependent on the Value for the given
property property.

ISCPropertyValue

The ISCPropertyValue interface is a single value of a given property.

The following table contains the methods for the ISCPropertyValue interface:

Method Description
SC_ValueTypes * Groups a list of supported value types
GetSupportedValueIdTypes() for the current value identifier and
returns it as a SAFEARRAY.
The GetValue method must be able to
convert the current value into any
value type whose code appears in the
returned list. If the list is empty, the
value is available only in its native
(such as default) format. Reference
properties must return an empty list.
SC_ValueTypes * Groups a list of supported value types
GetSupportedValueTypes() and returns it as a SAFEARRAY.
The GetValueId method must be able
to convert the current value into any
value type whose code appears in the
returned list. If the list is empty, then
the current identifier is available only
in its native (such as default) format.
SC_CLSID PropertyClassId() Returns the class identifier of the
current property.

API Interfaces Reference A–59


API Interfaces

Method Description
BSTR PropertyClassName() Returns the class name of the current
property.
VARIANT Value(VARIANT Converts the current value to the
ValueType [optional]) passed value type.
For information on the value data
types, see SC_ValueTypes in the
Enumerations section in this appendix.
VARIANT ValueId(VARIANT Uniquely identifies the value in a non-
ValueType [optional]) scalar property.
SC_ValueTypes ValueIdType() Passes back the default type of the
ValueId that identifies the value within
the non-scalar property.
SC_ValueTypes ValueType() Passes back the default type of the
property value.

ISCPropertyValue::ValueId Arguments

Here is the signature for the ValueId function:


VARIANT ValueId(VARIANT ValueType)

The following table contains the valid arguments for the ValueId function:

Parameter Valid Type/Value Description


ValueType [optional] VT_I4—SCVT_I2 or Returns VT_EMPTY if
SCVT_I4 property is scalar. If it is
non-scalar, the value of
the zero-based index of
the property is returned.
ValueType [optional] VT_I4—SCVT_BSTR Returns VT_EMPTY if the
property is scalar, the
name of the non-scalar
property member if it is
available, or else it is the
index of the member.

A–60 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Parameter Valid Type/Value Description


ValueType [optional] VT_I4— Returns VT_EMPTY if the
SCVT_DEFAULT property is scalar. If it is
non-scalar, the value of
the zero-based index of
the property is returned.
ValueType [optional] Empty Defaults to
SCVT_Default.

ISCPropertyValue::Value Arguments

Here is the signature for the Value function:


VARIANT Value(VARIANT ValueType)

The following table contains the valid arguments for the Value function:

Parameter Valid Type/Value Description


ValueType [optional] VT_I4— Identifies a request for the
SCVT_DEFAULT property value in native
format.
ValueType [optional] VT_I4—SCVT_BSTR Identifies a request for the
string conversion for the
property value.
ValueType [optional] VT_I4—Type of property Identifies a target for type
conversion.
ValueType [optional] Empty Defaults to
SCVT_DEFAULT.

API Interfaces Reference A–61


API Interfaces

ISCPropertyValueCollection

The ISCPropertyValueCollection interface is a collection of values for a non-


scalar property.

The following table contains the methods for the ISCPropertyValueCollection


interface:

Method Description
IUnknown _NewEnum() Constructs an instance of the collection
enumerator object.
long Count() Number of values in the collection.
ISCPropertyValue * Item(VARIANT Returns a single value from the
ValueId) property value collection.

ISCPropertyValueCollection::Item Arguments

Here is the signature for the Item function:


ISCPropertyValue * Item(VARIANT ValueId)

The following table contains the valid arguments for the Item function:

Parameter Valid Type/Value Description


ValueId VT_I4—Index of the Identifies an element with
element in multi-valued a zero-based index.
property
ValueId VT_BSTR—Name of an Identifies an element by
element in a multi- name.
valued property

A–62 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCSession

The ISCSession interface is an active connection between the API client and a
model.

The following table contains the methods for the ISCSession interface:

Method Description
VARIANT BeginTransaction() Opens a transaction on the session. The
method passes back a transaction
identifier. Implementations use the
identifier to scope Commit and
Rollback operations. If the application
does not support nested transactions, it
passes back VT_EMPTY.
Transaction nesting is implicit. If an
AllFusion ERwin DM API client
invokes BeginTransaction and a
transaction is already open, the new
transaction is nested inside the existing
one.
VARIANT Opens a transaction on the session.
BeginNamedTransaction(BSTR Name, Similar to BeginTransaction with an
VARIANT PropertyBag [optional]) option to provide a transaction name
and additional properties.
For information on the transaction’s
properties, see the section Property Bag
for Session in this appendix.
VARIANT_BOOL Changes the model access to the
ChangeAccess(SC_SessionFlags Flags) specified level.
For information on valid
SC_SessionFlags, see the Enumerations
section in this appendix.
VARIANT_BOOL Close() Disconnects self from its associated
persistence unit or model set.
VARIANT_BOOL Commits the specified transaction and
CommitTransaction(VARIANT all nested transactions contained within
TransactionId) it.

API Interfaces Reference A–63


API Interfaces

Method Description
SC_SessionFlags Flags() Returns a set of flags associated with
the session.
For information on SC_SessionFlags,
see the Enumerations section in this
appendix.
VARIANT_BOOL IsValid() Returns TRUE if self is valid.
VARIANT_BOOL IsTransactionEmpty( TRUE if there was no data modification
VARIANT All [optional] ) applied from the beginning of the outer
transaction or for the duration of the
current transaction.
Returns TRUE with no open
transaction present.
SC_SessionLevel Level() Returns the level at which the
persistence unit or model is bound.
This value is valid only if the session is
open.
For information on SC_SessionLevel,
see the Enumerations section in this
appendix.
VARIANT_BOOL IsOpen() TRUE if and only if the session is open.
ISCModelObjectCollection * Creates a ModelObject collection for
ModelObjects() the session.
The returned collection contains every
object associated with the persistence
unit or model set.
SC_MODELTYPEID ModelSetId() Passes back an identifier for the model
set associated with the session.
BSTR Name() Name of the associated persistence unit
or model set.
Contains a valid name only when self is
in the Opened state.

A–64 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

Method Description
VARIANT_BOOL Open(IUnknown * Binds to the persistence unit, model set,
Target, VARIANT Level [optional], or intrinsic metamodel identified by the
VARIANT Flags [optional]) Target parameter.
ISCPersistenceUnit * PersistenceUnit() Persistence unit associated with the
session. Contains a valid pointer only
when it is in the Opened state.
long TransactionDepth() Returns the current depth level of the
nested transaction. Returns zero if there
are no active transactions present.

ISCSession::BeginNamedTransaction Arguments

Here is the signature for the BeginNamedTransaction function:


VARIANT_BOOL BeginNamedTransaction(BSTR Name, VARIANT PropertyBag )

The following table contains the valid arguments for the


BeginNamedTransaction function:

Parameter Valid Type/Value Description


Name BSTR Provides a name for a
new transaction.
PropertyBag Empty No optional parameters.
PropertyBag VT_UNKNOWN— Collection of the
Pointer to a Property Bag transaction properties.
object
For information on the
transaction’s properties,
see the section Property
Bag for Session in this
appendix.

API Interfaces Reference A–65


API Interfaces

ISCSession::CommitTransaction Arguments

Here is the signature for the CommitTransaction function:


VARIANT_BOOL CommitTransaction(VARIANT TransactionId)

The following table contains the valid arguments for the CommitTransaction
function:

Parameter Valid Type/Value Description


TransactionId The ID of the session Provides a transaction
identifier.

ISCSession::IsTransactionEmpty Arguments

Here is the signature for the IsTransactionEmpty function:


VARIANT_BOOL IsTransactionEmpty(VARIANT All)

The following table contains the valid arguments for the IsTransactionEmpty
function:

Parameter Valid Type/Value Description


All Empty Identifies a request on the
status of the current
transaction.
All VT_BOOL, FALSE Identifies a request on the
status of the current
transaction.
All VT_BOOL, TRUE Identifies a request on the
status of all transactions
starting with the
beginning of the outer
transaction.

A–66 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCSession::Open Arguments

Here is the signature for the Open function:


VARIANT_BOOL Open(ISCPersistenceUnit * Unit, VARIANT Level, VARIANT Flags)

The following table contains the valid arguments for the Open function:

Parameter Valid Type/Value Description


Target ISCPersistenceUnit *— Provides a persistence
pointer to a persistence unit to attach.
unit
Target ISCModelSet *—pointer Provides a model set to
to a model set attach.
Target ISCPropertyBag * — Provides a property bag
pointer to a property bag with the description of an
intrinsic metamodel to
attach.
Level [optional] Empty Defaults to SCD_SL_M0.
Level [optional] SCD_SL_M0 Data-level access.
Level [optional] SCD_SL_M1 Metamodel access.
Flags [optional] Empty Defaults to
SCD_SF_NONE.
Flags [optional] SCD_SF_NONE Other sessions can have
access to the attached
persistence unit.
Flags [optional] SCD_SF_EXCLUSIVE Other sessions cannot
have access to the
attached persistence unit.

API Interfaces Reference A–67


API Interfaces

ISCSession::RollbackTransaction Arguments

Here is the signature for the RollbackTransaction function:


VARIANT_BOOL RollbackTransaction(VARIANT TransactionId)

The following table contains the valid arguments for the RollbackTransaction
function:

Parameter Valid Type/Value Description


TransactionId The ID of the session Provides a transaction
identifier.

ISCSessionCollection

The Session Collection contains the active connections between the AllFusion
ERwin DM API client and the application.

The following table contains the methods for the ISCSessionCollection interface:

Method Description
IUnknown _NewEnum() Constructs an instance of a session
enumerator object.
ISCSession * Add() Construct a new, closed Session object,
and adds it to the collection.
VARIANT_BOOL Clear() Removes all Session objects from the
collection
long Count() The number of sessions in the
collection.
ISCSession * Item(long nIndex) Passes back a session identified by its
ordered position.
VARIANT_BOOL Remove(VARIANT Removes a Session object from the
SessionId) collection. If the session is opened, it is
closed before it is removed. All
committed changes are saved in the
persistence unit.

A–68 AllFusion ERwin Data Modeler API Reference Guide


API Interfaces

ISCSessionCollection::Item Arguments

Here is the signature for the Item function:


ISCSession * Item(long Index)

The following table contains the valid arguments for the Item function:

Parameter Valid Type/Value Description


Index long—Index Provides a zero-based
index of a session.

ISCSessionCollection::Remove Arguments

Here is the signature for the Remove function:


VARIANT_BOOL Remove(VARIANT SessionId)

The following table contains the valid arguments for the Remove function:

Parameter Valid Type/Value Description


SessionId VT_UNKNOWN— Identifies a session with
Pointer to the ISCSession the Session object.
interface
SessionId VT_I4—Index in the Provides a zero-based
session collection index of a session.

API Interfaces Reference A–69


Enumerations

Enumerations
This section contains information regarding the various enumerations for the
AllFusion ERwin DM API. The enumerations define valid values for various
properties.

SC_ModelDirectoryFlags

The following table contains the properties and enumerations for


SC_ModelDirectoryFlags:

Property Enumeration Description


SCD_MDF_DIRECTORY 0 Directory
SCD_MDF_ROOT 1 Root directory

SC_ModelDirectoryType

The following table contains the properties and enumerations for


SC_ModelDirectoryType:

Property Enumeration Description


SCD_MDT_NONE 0 Type is not available
SCD_MDT_FILE 1 File system
SCD_MDT_MART 2 AllFusion Model Manager

SC_ModelObjectFlags

The following table contains the properties and enumerations for


SC_ModelObjectFlags:

Property Flag Bit Enumeration Description


SCD_MOF_DONT_CARE 0 No flags are set
SCD_MOF_PERSISTENCE_UNIT 0 1 Object is a persistence unit (such as
model)
SCD_MOF_USER_DEFINED 1 2 Object is user-defined (such as user-
defined properties)

A–70 AllFusion ERwin Data Modeler API Reference Guide


Enumerations

Property Flag Bit Enumeration Description


SCD_MOF_ROOT 2 4 Object is the root object (such as
model)
SCD_MOF_TOOL 3 8 Object is maintained by the tool
SCD_MOF_DEFAULT 4 16 Object is created by the tool and not
removable
SCD_MOF_TRANSACTION 5 32 Object is new or updated in a
transaction and the transaction was
not committed

SC_ModelPropertyFlags

The following table contains the properties and enumerations for


SC_ModelPropertyFlags:

Property Flag Bit Enumeration Description


SCD_MPF_DONT_CARE 0 No flags are set
SCD_MPF_NULL 0 1 Property has NULL value or no value
SCD_MPF_USER_DEFINED 1 2 Property is user-defined
SCD_MPF_SCALAR 2 4 Property is scalar
SCD_MPF_TOOL 3 8 Property is maintained by the tool
SCD_MPF_READ_ONLY 4 16 Property is read-only (however, not
used in AllFusion ERwin DM)
SCD_MPF_DERIVED 5 32 Property is inherited, calculated, or
derived
SCD_MPF_OPTIONAL 6 64 Property is optional and can be
removed

API Interfaces Reference A–71


Enumerations

SC_SessionFlags

The following table contains the properties and enumerations for


SC_SessionFlags:

Property Enumeration Description


SCD_SF_NONE 0 Session has non-exclusive access to
its connected persistence unit. Other
sessions can connect to the same
persistence unit.
SCD_SF_EXCLUSIVE 1 Session has exclusive access to its
connected persistence unit. No other
sessions are allowed to access the
persistence unit.

SC_SessionLevel

The following table contains the properties and enumerations for


SC_SessionLevel:

Property Enumeration Description


SCD_SL_NONE -1 Not used
SCD_SL_M0 0 Data level access
SCD_SL_M1 1 Metamodel access

SC_ValueTypes

The following table contains the properties and enumerations for


SC_ValueTypes:

Property Enumeration Description


SCVT_NULL 0 Missing value
SCVT_I2 1 Signed 16-bit integer
SCVT_I4 2 Signed 32-bit integer
SCVT_UI1 3 Unsigned 8-bit integer. Do not
use this type to hold character
data.

A–72 AllFusion ERwin Data Modeler API Reference Guide


Enumerations

Property Enumeration Description


SCVT_R4 4 4 byte floating point real
SCVT_R8 5 8 byte floating point real
SCVT_BOOLEAN 6 Boolean
SCVT_CURRENCY 7 64-bit currency value
SCVT_IUNKNOWN 8 IUnknown interface pointer
SCVT_IDISPATCH 9 IDispatch interface pointer
SCVT_DATE 10 Date value in
VARIANT_DATE format
SCVT_BSTR 11 String
SCVT_UI2 12 Unsigned 16-bit integer
SCVT_UI4 13 Unsigned 32-bit integer
SCVT_GUID 14 GUID
SCVT_OBJID 15 A string (VT_BSTR) contains
an object identifier with offset
SCVT_BLOB 16 SAFEARRAY of unsigned
BYTEs
SCVT_DEFAULT 17 Default value type
SCVT_I1 18 Signed 1 byte integer. Do not
use this type to hold character
data.
SCVT_INT 19 Machine-dependent signed
integer
SCVT_UINT 20 Machine-dependent unsigned
integer
SCVT_RECT 21 Rectangle–array of four
integers (VT_ARRAY & VT_I2)
SCVT_POINT 22 Point–array of two integers
(VT_ARRAY & VT_I2)
SCVT_I8 23 Signed 64-bit integer
SCVT_UI8 24 Unsigned 64-bit integer

API Interfaces Reference A–73


Property Bag Reference

Property Bag Reference


This section contains information about the content of the Property Bag
container. A property bag is a placeholder for an array of properties. The content
of the bag is dictated by a source interface.

Property Bag for Application Environment

This property bag provides access for Application Features sets. The parameters
of the PropertyBag call determine the context of the bag. The contents of the bag
can have one of two available forms: native format, or a string based on the
optional parameter of the PropertyBag property of the
ISCApplicationEnvironment interface.

Feature categories in the Category parameter of the PropertyBag property are


hierarchical and use a dot (.) to define feature subsets. For instance, the
Application category populates a property bag with a complete set of AllFusion
ERwin DM features, while [Link] provides a subset related to the
AllFusion ERwin DM API.

If the Category parameter is not set, then the Property Bag property returns the
complete set of all the features from all the available categories.

The following tables summarize the available feature categories and lists the
Property Bag properties for each category.

ISCApplicationEnvironment::PropertyBag

The PropertyBag function from the ISCApplicationEnvironment interface


populates a property bag with one or more property values as indicated by
Category and Name.

Here is the signature for the ISCApplicationEnvironment PropertyBag function:


ISCPropertyBag * PropertyBag(VARIANT Category, VARIANT Name, VARIANT AsString)

The following table contains the valid arguments for the


ISCApplicationEnvironment PropertyBag function:

Parameter Valid Type/Value Description


Category [optional] Empty Complete set of features
from all categories are
returned.
Category [optional] VT_BSTR—Name of Features from the given
category category are returned.

A–74 AllFusion ERwin Data Modeler API Reference Guide


Property Bag Reference

Parameter Valid Type/Value Description


Name [optional] Empty All properties from the
selected category are
returned.
Name [optional] VT_BSTR—Name of The property with the
property given name and category
is returned.
AsString [optional] Empty All values in the property
bag are presented in
native type.
AsString [optional] VT_BOOL—TRUE or If set to TRUE, all values
FALSE in the property bag are
presented as strings.

Category Parameter Contains an Empty String

The following table describes the Category parameter that contains an empty
string:

Property Name Type Description


Categories SAFEARRAY(BSTR) Returns an array of all the available categories.

Application Category

The following table describes the Application category, which describes the
features associated with the AllFusion ERwin DM tool:

Property Name Type Description


Title BSTR Provides the AllFusion ERwin DM title.
Version BSTR Provides the AllFusion ERwin DM version.
Hosting Application Long ■ 0—Returns 0 if the AllFusion ERwin DM API
is controlled by third-party application, in
standalone mode.
■ 1—Returns 1 if the AllFusion ERwin DM user
interface is active and the AllFusion ERwin
DM API is in add-in mode.
Metadata Version Long Metadata value for the current version of
AllFusion ERwin DM.

API Interfaces Reference A–75


Property Bag Reference

Property Name Type Description


EMX Metadata Class SC_MODELTYPEID Metadata class identifier for EMX model sets.
EM2 Metadata Class SC_MODELTYPEID Metadata class identifier for EM2 model sets.

[Link] Category

The following table describes the [Link] category, which describes the
features associated with the AllFusion ERwin DM API:

Property Name Type Description


API Version BSTR Provides the version of the AllFusion ERwin DM
API interfaces.
API Major Version Number Long The AllFusion ERwin DM API major version
number.
API Minor Version Number Long The AllFusion ERwin DM API minor version
number.

[Link] Category

The following table describes the [Link] category, which


summarizes the level of support the AllFusion ERwin DM API provides in its
main set of operations:

Property Name Type Description


Undo Long Describes the ability to undo operations.
■ 0—Undo not supported.
■ Non-zero—Undo is supported.
Redo Long Describes the ability to redo undone operations.
■ 0—Redo not supported.
■ Non-zero—Redo is supported.
Change Logging Long Describes the ability to report all changes since
the last synchronization with the client.
■ 0—Change logging not supported.
■ Non-zero—Change logging is supported.

A–76 AllFusion ERwin Data Modeler API Reference Guide


Property Bag Reference

Property Name Type Description


Ownership Support Long Queries the support level of the application for
object ownership. The following describes the
support levels:
■ 0—The application does not support object
ownership.
■ 1—The application supports ownership and
the ownership meta-relation contains no
cycles.
■ 2—The application supports ownership and
the ownership meta-relation contains cycles.
Transactions Long Describes the level of support for transaction
control. The following describes the support
levels:
■ 0—No support for transactions.
■ 1—Begin/End only. No nesting.
■ 2—Begin, End, and Rollback, no nesting.
■ 3—Begin, End, and Rollback, with arbitrary
transaction nesting.

[Link] Category

The following table describes the [Link] category, which


provides access to additional messages registered during AllFusion ERwin DM
API operations:

Property Name Type Description


Is Empty Boolean Returns TRUE if the message log is not empty.
The log is reset before the beginning of every
API operation.
Log SAFEARRAY Returns the content of the log.
(VARIANT)

API Interfaces Reference A–77


Property Bag Reference

The Property Log from the MessageLog category is organized as a one-


dimensional SAFEARRAY with VARIANT type as elements. The array has the
following structure:

Total Message 1 … Message N


Number

Error Severity Message Model Object Object Property Reserved


Code Code Set Id Type Id Type

The following table describes the elements of the array:

Message Log Element Type Description


Total Number Long Total number of messages in the array. The
value can be zero if there were no messages
when the Log property was requested.
Error Code BSTR A message string identifier.
Severity Code Long The following are the
SC_MessageLogSeverityLevels severity
codes:
■ SCD_ESL_NONE—No severity code
was assigned.
■ SCD_ESL_INFORMATION—
Information message.
■ SCD_ESL_WARNING—Warning
message.
■ ESD_ESL_ERROR—Error message.
Message BSTR Message text.
Model Set Id SC_MODELSETID An identifier of a model set associated with
a message. An element has the VARIANT
type VT_EMPTY if no data was provided.
For details on how to use the Model Set
Identifier in locating a model set, see the
sections Accessing a Model and Accessing a
Model Set in the chapter “API Tasks.”

A–78 AllFusion ERwin Data Modeler API Reference Guide


Property Bag Reference

Message Log Element Type Description


Object Type SC_CLSID Class identifier for a model object associated
with a message. An element has the
VARIANT type VT_EMPTY if no data was
provided.
For details on how to use the Class Identifier
to learn more about object types, see the
section Accessing Metamodel Information in
the chapter “API Tasks,” and the appendix
“AllFusion ERwin DM Metamodel.”
Object Id SC_OBJID Identifier for a model object associated with
a message. The identifier is unique in the
scope of the model set. An element has the
VARIANT type VT_EMPTY if no data was
provided.
For details on how to use the Object
Identifier to access the associated model
object, see the section Accessing Objects in a
Model in the chapter “API Tasks.”
Property Type SC_CLSID Class identifier for a property associated
with a message. An element has the
VARIANT type VT_EMPTY if no data was
provided.
For details on how to use the Class Identifier
to learn more about property types, see the
section Accessing Metamodel Information in
the chapter “API Tasks,” and the appendix
“AllFusion ERwin DM Metamodel.”
Reserved Always marked as VT_EMPTY.

API Interfaces Reference A–79


Property Bag Reference

[Link] Category

The [Link] category describes the features associated with the


AllFusion ERwin DM modeling engine. There are no properties in this category.

[Link] Category

The following table describes the [Link] category, which


describes the features associated with physical modeling in AllFusion ERwin
DM:

Property Name Type Description


DBMS Brand And SAFEARRAY(Long) The data is organized as a
Version List one-dimensional
SAFEARRAY with the
Long type as elements.
The elements are grouped
into subsets of three. The
first member of the subset
contains a DBMS brand
identifier, the second
member is the major
version value, and the last
member is the minor
version value.

[Link] Category

The [Link] category describes the features associated with


persistence support in AllFusion ERwin DM. There are no properties in this
category.

[Link] Category

The following table describes the [Link] category,


which describes the features associated with the file system:

Property Name Type Description


Current Directory BSTR Absolute path for the
current local directory.

A–80 AllFusion ERwin Data Modeler API Reference Guide


Property Bag Reference

[Link]

The following table describes the [Link] category,


which describes the features associated with persistence support in AllFusion
ERwin DM working with AllFusion Model Manager:

Property Name Type Description


Model Mart Connection SAFEARRAY(BSTR) Enumerate AllFusion
Types Model Manager
supported database
connection types.

Property Bag for Model Directory and Model Directory Unit

This Property Bag provides access to the properties of the Model Directory and
the Model Directory Unit objects. The PropertyBag property for both the
ISCModelDirectory interface and the ISCModelDirectoryUnit interface populates
the bag with the set of current properties. The same property of these interfaces
allows modification of directory (if it is not read-only) or directory unit
attributes. The contents of the bag can have one of two available forms: native
format or as a string based on the optional parameter of the PropertyBag
property of ISCModelDirectory and ISCModelDirectoryUnit. The client can
populate the bag in either of these two forms. Different forms can be mixed in the
same instance of the bag.

Not all properties that exist in the directory or directory unit have to be present
in the bag when it is submitted. All property data as well as property names are
validated by the AllFusion ERwin DM API, and all are either accepted or
rejected. The rejection forces a method call to fail. If the bag includes properties
that are read-only at the moment, for example, the Locator property, then such
properties are ignored and do not affect validation of the bag data.

API Interfaces Reference A–81


Property Bag Reference

The following table lists the Property Bag properties and datatypes for the Model
Directory:

Property Name Type Read- Description


only
Directory Name BSTR No Returns a directory name without the path
information.
Applying a new value renames a directory.
For the AllFusion Model Manager root
directory, this is a repository name. The
property does not allow the modification of the
repository name.
Locator BSTR Yes Location of a directory including absolute path
and parameters. For AllFusion Model Manager,
parameters do not include password
information.
Directory Path BSTR Yes Directory absolute path.
Created By BSTR Yes Identification for a user that has created a
directory. For AllFusion Model Manager only,
an AllFusion Model Manager user ID is used.
Updated By BSTR Yes Identification for a user that has updated a
directory. For AllFusion Model Manager only,
an AllFusion Model Manager user ID is used.
Created SAFEARRAY(Long) Yes Creation date of a directory. The time is an
array of numbers in the following order:
■ Seconds after minute (0 – 59)
■ Minutes after hour (0 – 59)
■ Hours since midnight (0 – 23)
■ Day of month (1 – 31)
■ Month (0 – 11; January = 0)
■ Year (current year)
■ Day of week (0 – 6; Sunday = 0)
■ Day of year (0 – 365; January 1 = 0)

A–82 AllFusion ERwin Data Modeler API Reference Guide


Property Bag Reference

Property Name Type Read- Description


only
Updated SAFEARRAY(Long) Yes Update date of a directory. The time is an array
of numbers in the following order:
■ Seconds after minute (0 – 59)
■ Minutes after hour (0 – 59)
■ Hours since midnight (0 – 23)
■ Day of month (1 – 31)
■ Month (0 – 11; January = 0)
■ Year (current year)
■ Day of week (0 – 6; Sunday = 0)
■ Day of year (0 – 365; January 1 = 0)
Description BSTR No A directory description. Only for AllFusion
Model Manager.

The following table lists the Property Bag properties and datatypes for the Model
Directory Unit:

Property Name Type Read- Description


only
Directory Unit Name BSTR No Returns a directory unit name without path
information.
Applying a new value renames a directory
unit.
Locator BSTR Yes Location of a directory unit including absolute
path and parameters. For AllFusion Model
Manager, parameters do not include
password information.
Directory Unit Path BSTR Yes Directory unit absolute path.
Created By BSTR Yes Identification for a user that has created a
unit. For AllFusion Model Manager only, an
AllFusion Model Manager user ID is used.
Updated By BSTR Yes Identification for a user that has updated a
unit. For AllFusion Model Manager only, an
AllFusion Model Manager user ID is used.

API Interfaces Reference A–83


Property Bag Reference

Property Name Type Read- Description


only
Created SAFEARRAY(Long) Yes Creation date of a directory. The time is an
array of numbers in the following order:
■ Seconds after minute (0 – 59)
■ Minutes after hour (0 – 59)
■ Hours since midnight (0 – 23)
■ Day of month (1 – 31)
■ Month (0 – 11; January = 0)
■ Year (current year)
■ Day of week (0 – 6; Sunday = 0)
■ Day of year (0 – 365; January 1 = 0)
Updated SAFEARRAY(Long) Yes Update date of a directory. The time is an
array of numbers in the following order:
■ Seconds after minute (0 – 59)
■ Minutes after hour (0 – 59)
■ Hours since midnight (0 – 23)
■ Day of month (1 – 31)
■ Month (0 – 11; January = 0)
■ Year (current year)
■ Day of week (0 – 6; Sunday = 0)
■ Day of year (0 – 365; January 1 = 0)
Description BSTR Yes A directory description. Only for AllFusion
Model Manager.
Model Type Long Yes Retrieves the type of a unit model. A model
type can be logical, logical/physical, or
physical.
Object Count Long Yes Reports total number of objects in the unit.
Only for AllFusion Model Manager.
Entity Count Long Yes Reports total number of entity objects in the
unit. Only for AllFusion Model Manager.
Is Template Boolean Yes Returns True if a unit model is a template.

A–84 AllFusion ERwin Data Modeler API Reference Guide


Property Bag Reference

Property Bag for Persistence Units and Persistence Unit Collections

This Property Bag provides access to the properties of a persistence unit. An


empty Property Bag can be obtained through a call to the CoCreateInstance of
the COM API. The client populates a bag and then submits it as a parameter for
the Create method of the ISCPersistenceUnitCollection interface. Alternatively,
the present state of persistence unit properties can be retrieved through the
PropertyBag property of ISCPersistenceUnit. The retrieved value can be
reviewed, modified, and submitted back through the PropertyBag property of
the same interface. The contents of the bag can have one of two available forms:
native format or as a string based on the optional parameter of the PropertyBag
property of the ISCPersistenceUnit. The client can populate the bag in either of
these two forms. Different forms can be mixed in the same instance of the bag.

Not all properties that exist in the unit have to be present in the bag when it is
submitted. All property data as well as property names are validated by the
AllFusion ERwin DM API and either all are accepted or all are rejected. The
rejection forces a method call to fail. If the bag includes properties that are
read-only at the moment, for instance, the model type for an AllFusion ERwin
DM model when the model was created previously, then such properties are
ignored and will not affect validation of the bag data.

API Interfaces Reference A–85


Property Bag Reference

ISCPersistenceUnit::PropertyBag Arguments (Get Function)

Here is the signature for the PropertyBag (Get) function:


ISCPropertyBag * PropertyBag(VARIANT List, VARIANT AsString)

The following table contains the valid arguments for the PropertyBag (Get)
function:

Parameter Valid Type/Value Description


List [optional] VT_BSTR—Semicolon Provides a list of the unit
separated list of properties. If the list is
properties provided, only listed
properties are placed in
the returned property
bag.
List [optional] Empty Requests a complete set of
properties.
AsString [optional] VT_BOOL—TRUE or If set to TRUE, it requests
FALSE that all values in the bag
be presented as strings.
The default is FALSE and
all values are in their
native format.
AsString [optional] Empty All values in the property
bag are presented in
native format.

ISCPersistenceUnit::PropertyBag Arguments (Set Function)

Here is the signature for the PropertyBag (Set) function:


void PropertyBag(VARIANT List, VARIANT AsString, ISCPropertyBag * propBag)

The following table contains the valid arguments for the PropertyBag (Set)
function:

Parameter Valid Type/Value Description


List [optional] Not used
AsString [optional] Not used
propBag ISCPropertyBag * A pointer on a property
bag with the unit
properties to process

A–86 AllFusion ERwin Data Modeler API Reference Guide


Property Bag Reference

Property Bag Contents for Persistence Unit and Persistence Unit Collection

The following table lists the Property Bag properties and datatypes recognized
by AllFusion ERwin DM:

Property Name Type Read- Description


only
Locator BSTR Yes Returns the location of the persistence unit,
such as file name. Not available for models
without a persistence location, such as new
models that were never saved.
Disposition BSTR Yes Returns the disposition of the persistence
unit, such as read-only.
Persistence Unit Id SC_MODELTYPEID No Retrieves and sets an identifier for the
persistence unit.
A new identifier can be assigned to the
existing persistence unit. In this case, the
old identifier will be placed in the
persistence unit’s branch log. For more
information, see the description of the
Branch Log property.
Branch Log SAFEARRAY After Retrieves and sets the branch log of the
(SC_MODELTYPEID) create persistence unit identifiers. A persistence
unit retains its log of identifiers.
AllFusion ERwin DM uses the branch logs
of the persistence units for extended
identification match.
The API uses only the most current
identifier for searching in the Persistence
Unit Collection.
Model Type Long After Retrieves and sets the type of the
create persistence unit, such as logical,
logical/physical, and physical models. Can
be set when a persistence unit is created;
after that the property becomes read-only.
Available values are:
■ 1—Logical, for logical models. This is
the default if no value is provided.
■ 2—Physical, for physical models.
■ 3—Combined, for a logical/physical
model.

API Interfaces Reference A–87


Property Bag Reference

Property Name Type Read- Description


only
Target Server Long After Retrieves and sets the target database
Target Server Version create properties for physical and logical-physical
Target Server Minor models. Can be set when a persistence unit
Version is created; after that the property becomes
read-only.
See the next table for available values for
the Target Server property.
Storage Format Long After Retrieves and sets the storage format,
create which has a value of Normal for a model
and a value of Template for a model
template. Can be set when a persistence
unit is created; after that the property
becomes read-only.
Available values are:
■ 4012—Normal, for a regular model. This
is the default if no value is provided.
■ 4016—Template, for a template model.
Active Model Boolean No TRUE if the persistence unit represents the
current model and is active in the AllFusion
ERwin DM user interface. Not available for
the AllFusion ERwin DM API standalone
mode.
Hidden Model Boolean No TRUE if a model window with the
persistence unit data is not visible in the
AllFusion ERwin DM user interface. Not
available for the AllFusion ERwin DM API
standalone mode.

A–88 AllFusion ERwin Data Modeler API Reference Guide


Property Bag Reference

Property Name Type Read- Description


only
Active Subject Area SAFEARRAY(BSTR) No Reports names of active Subject Area and
and Stored Display Stored Display model objects. This
indicates the Subject Area and Stored
Display that AllFusion ERwin DM shows
on the screen. The returned value is a safe
array with two elements. The first element
is a name for the active Subject Area and
the second element is for the Stored
Display.
Providing a new set of Subject Area and
Stored Display names can change this
selection. The change has an effect
immediately if the model is active in the
AllFusion ERwin DM user interface or in
the next model opened by the AllFusion
ERwin DM user interface.
Optionally, to change a selection, you need
only a BSTR with a name for a new Subject
Area. From the Subject Area you provide,
the AllFusion ERwin DM API chooses the
first Stored Display as active.

The Target Server property is a vector that consists of three members. The first
member of the vector contains a DBMS brand identifier, the second member is
the major version value, and the last member is the minor version value.

The following table lists DBMS brand identifiers for the Target Server property.
The table also lists the brand names that are used when the identifier is presented
as a string:

DBMS Brand DBMS Brand Name DBMS Brand ID


Access Access 1075859004
Advantage Ingres Ingres 1075859007
DB2 DB2 1075858978
DB2 UDB DB2 UDB 1075858977
FoxPro FoxPro 1075859029
Informix Informix 1075859006
iSeries (AS400) iSeries 1075859019

API Interfaces Reference A–89


Property Bag Reference

DBMS Brand DBMS Brand Name DBMS Brand ID


ODBC ODBC 1075859009
Oracle Oracle 1075858979
Progress Progress 1075859010
Red Brick Red Brick 1075859012
SAS SAS 1075859013
SQL Server SQL Server 1075859016
Sybase Sybase 1075859017
Teradata Teradata 1075859018

Property Bag for Session

This Property Bag provides additional information to the


BeginNamedTransaction function of the ISCSession interface and can be
submitted as the second optional argument of the function. The contents of the
bag can have one of two available forms: native format or as a string. The client
can populate the bag in either of these two forms. Different forms can be mixed
in the same instance of the bag.

Not all properties have to be present in the bag when it is submitted. All
property data as well as property names are validated by the AllFusion ERwin
DM API, and all are either accepted or rejected. The rejection forces a method call
to fail.

The transaction properties are in effect at the initiation of an outer transaction


and are confined to the scope of the transaction.

A–90 AllFusion ERwin Data Modeler API Reference Guide


Property Bag Reference

The following table lists the Property Bag properties and datatypes for the
BeginNamedTransaction:

Property Name Type Read- Description


only
History Tracking Boolean No TRUE—Indicates that all historical information
generated during the transaction will be
marked as the API event. A TRUE value is
assumed if the property is not provided.
FALSE—Uses the standard AllFusion ERwin
DM mechanism of history tracking.
History Description BSTR No When the History Tracking property is TRUE,
it provides the content of the history event
Description field.

API Interfaces Reference A–91


Location and Disposition in Model Directories and Persistence Units

Location and Disposition in Model Directories and


Persistence Units
The AllFusion ERwin DM API describes the location of Persistence Units and
their disposition in persistence storage facilities with the Locator and Disposition
properties. This information is required by some of the AllFusion ERwin DM API
methods and is also accessible using Property Bags. Examples of persistence
storage for AllFusion ERwin DM models are file system and AllFusion Model
Manager.

Locator Property

The following table describes the syntax supported by the Locator property:

Syntax Arguments
[provider://]pathinfo[?param=value[;param=value]…n] provider: This is a type of persistence storage. Use
erwin to specify file system, and use mmart for an
AllFusion Model Manager repository. If this is
skipped, erwin is the default.
pathinfo: This is the path to the storage location,
which is either a file path or the AllFusion Model
Manager path.
param: This is either a parameter name or a
keyword.
value: This is a text string.

There are no param keywords defined for the file system persistence storage.

For a list of Locator param keywords for use with the mmart type of provider for
models stored in AllFusion Model Manager, see the following table.

Note: There is a special arrangement for the AllFusion Model Manager Locator.
Part of the Locator string with params can be omitted if an application has
connections open with one or more AllFusion Model Manager repositories. In
this case, the params part of the Locator string can have only partial information
or not be present at all, as long as it is clear to which connection from the
available list it refers.

Currently, the AllFusion ERwin DM client for AllFusion Model Manager allows
only one open connection to an AllFusion Model Manager repository at any
given time. Therefore, it is possible, after establishing a connection, to omit the
params part of the Locator string completely and to provide the model path
information only.

A–92 AllFusion ERwin Data Modeler API Reference Guide


Location and Disposition in Model Directories and Persistence Units

The following table provides a list of Locator param keywords for use with the
mmart type of provider for models stored in AllFusion Model Manager:

Complete Name Abbreviation Description


Server SRV The AllFusion Model Manager server.
Server Type SRT Type of server connection. For more information, see the
section [Link] Category.
Trusted Connection TRC For SQL Server Version 7 or later, and Oracle Version 8 or
later. When set to YES, it instructs the database driver to
use Windows Authentication Mode for login validation, in
which case the UID and PSW keywords are optional.
When set to NO, it instructs the database driver to use a
database username and password for login validation, in
which case the UID and PSW keywords must be specified.
User UID Login user name. UID need not be specified when using
Windows Authentication.
Password PSW User login password. You do not need to specify PSW if
the login has a NULL password or if you use Windows
Authentication (Trusted Connection set to YES).
Submodel Name SBN Name of a submodel to access.
Library ID LID Optional library, model, and submodel IDs. When
provided, you reduce the access time required to open a
Model ID MID
model.
Submodel ID SID

API Interfaces Reference A–93


Location and Disposition in Model Directories and Persistence Units

The following table describes various scenarios in which you can use the Locator
param keyword along with the mmart type of provider for models stored in
AllFusion Model Manager:

Scenario Description
AllFusion Model Manager using SQL If you have a model called MyModel located in MyLib, which
Server is in MyMart in AllFusion Model Manager, you can use the
following:
mmart://MyMart/MyLib/MyModel?SRV=MyServer;SRT=SQL Server
2000/2005 (using db-lib);UID=<mm user id>;PSW=<password>

AllFusion Model Manager using Oracle If you have a model called MyModel located in MyLib, which
is on OracleHome in AllFusion Model Manager (the database
name is not indicated, and the additional slash ( / ) is
required), you can use the following:
mmart:///MyLib/MyModel?SRV=OracleHome;SRT=Oracle Vers.
[Link]/9i/10g;UID=<mm user id>;PSW=<password>

Local drive If you have a model called [Link] located in the models
directory on the C drive, you can use the following:
C:\models\[Link]

Disposition Property

The Disposition parameter provides optional information for the AllFusion


ERwin DM API to access model data specified by the Locator parameter.

The following table describes the syntax supported by the Disposition property:

Syntax Arguments
param=value[;param=value]…n param: This is either a parameter name
or a keyword.
value: Yes/No.

A–94 AllFusion ERwin Data Modeler API Reference Guide


Location and Disposition in Model Directories and Persistence Units

The following table lists Disposition param keywords for use with the erwin
type of provider, such as for models stored in the file system:

Complete Name Abbreviation Description


Read Only RDO Requests read-only access to a file. Available for the
Persistence Unit Collection Add method.
Full access to a persistence unit is possible if the parameter
was not specified.
Override File OVF Overrides an existing file upon Save. Available for the
Persistence Unit Save method. There is no override if the
parameter was not specified.

The following table lists Disposition param keywords for use with the
modelmart type of provider for models stored in AllFusion Model Manager:

Complete Name Abbreviation Description


Read Only RDO Does not impose any locks on a model in AllFusion Model
Manager storage. Otherwise a model acquires an exclusive
lock.
Override Locks OVL If AllFusion Model Manager has open sessions associated
with a user, disregard them and continue.
Resume Session RSS If specified, AllFusion Model Manager tries to resume a
session if a model was opened by a user and never closed.
Override Model OVM Override an existing model in a mart. Available for the
Persistence Unit Save method. There is no override if the
parameter was not specified.
Clear All Connections CLC Clear any open connections to other marts and continue
with a new server.

API Interfaces Reference A–95


Appendix

AllFusion ERwin DM Metamodel


B
This appendix lists information regarding the AllFusion ERwin DM metamodel.

Metadata Organization
The following is a diagram that shows the organization of the metadata:

+Owning Object Aggregation Type +Owned Object


+Tags
1 1
+Valid Ownees *

*
Object Type Property Type
* +Name
+Name
+Parent +Is Abstract +Data type
+Tags +Is Reference
+Valid Owners +Tags
0..1

* +Valid Properties
*
+Participating Object +Participating Property
Association Type

1 +Tags 1

Metamodel Elements

AllFusion ERwin DM organizes data as a group of linked model sets. The model
sets are arranged in a tree-like hierarchy with a single model set at the top.

The top model set contains the bulk of the modeling data. The AllFusion ERwin
DM API uses the abbreviation EMX to identify the top model set.

AllFusion ERwin DM Metamodel B–1


Metadata Organization

The EMX model set owns a secondary model set, abbreviated as EM2, which
contains user interface settings and user options for AllFusion ERwin DM
services such as Forward Engineering, Complete Compare, and so on.

EMX
Model Set
Owns

EMX2
Model Set

The API clients access the model data by constructing a session and connecting it
to a model set using the Session component.

A model set contains several levels of data. It contains the data the application
manipulates, such as entity instances, attribute instances, relationship instances,
and so on.

The model set also contains metadata: a description of the objects and properties
that may occur within the application’s data.

In AllFusion ERwin DM, the metadata includes object and property classes,
object aggregations, and property associations:
■ Object classes—Define the type of objects that may occur within a model
such as an entity class, an attribute class, or a relationship class.
■ Property classes—Define the type of properties an object may have such as
the Name property, Comment property, or Parent Domain Ref property.
■ Object aggregations—Identify an ownership relationship between classes of
objects, such as a model that owns entities, or entities that own attributes,
and so on.
■ Property associations—Define property usage by object classes. For instance,
the metadata includes property associations for every object class that has
the Name property.

B–2 AllFusion ERwin Data Modeler API Reference Guide


Metadata Organization

Metadata Tags

Each metadata object may include one or more tags. A tag is a metadata object
property that conveys certain descriptive meta information, such as if an object
class is logical, physical, valid for a specific target DBMS, and so on.

A tag on an object aggregation overrides the identical tag set on the associated
owned object class.

A tag on a property association overrides the identical tag set on the associated
property class.

The following table lists some of the EMX metadata tags:

Tag Name Datatype Description


BitFieldValues String Describes valid values for a bit field property. A
combination of values from the description list

can be used as a value for the property.
BitFieldValues10
The descriptions are grouped as follows:
{<value>|<string equivalent>|<internal>}
DBMS_Brands_And_Versions Integer, vector Defines conditions when an object or property
class is available for physical modeling with the
specific DBMS. Assumes that the IsPhysical tag
has a TRUE value.
Absence of the tag indicates that the class is
available for all DBMS targets, but only if the
IsPhysical tag has a TRUE value.
A NULL value for the tag indicates that the class
is not available for any DBMS.
DBMS brand IDs are described in the next table.
DBMS_Is_Represented Integer, vector Defines conditions when an object or property
class represents a concept in the specific DBMS.
Assumes that the DBMS_Brands_And_Versions
tag is valid for the class.
Absence of the tag indicates that the class is
available for all DBMS targets, but only if the
DBMS_Brands_And_Versions tag is valid for the
class.
A NULL value for the tag indicates that the class
is not available for any DBMS.
DBMS brand IDs are described in the next table.

AllFusion ERwin DM Metamodel B–3


Metadata Organization

Tag Name Datatype Description


DBMS_Is_Top_Level_Object Integer, vector Defines conditions when an object class is
considered top level, such as when it has a
CREATE or DROP statement associated with it for
the specific DBMS. Assumes that the
DBMS_Is_Represented tag is valid for the class.
Absence of the tag indicates that the class is
available for all DBMS targets, if the
DBMS_Is_Represented tag is valid for the class.
A NULL value for the tag indicates that the class
is not a top level object for any DBMS.
DBMS brand IDs are described in the next table.
EnumValues String Describes valid values for an enumerated
property. Only one value from the description list

can be used as a value for the property.
EnumValues10
The descriptions are grouped as follows:
{<value>|<string equivalent>|<internal>}
IsFontOrColor Boolean TRUE for classes responsible for model data
visualization.
IsForDataMovement Boolean TRUE for an object or property class that is
available for dimensional and data warehouse
modeling.
IsGraphicData Boolean TRUE for classes responsible for model data
visualization.
IsLogical Boolean TRUE for an object or property class that is
available for logical modeling.
IsPhysical Boolean TRUE for an object or property class that is
available for physical modeling.
IsUserSettings Boolean TRUE for classes responsible for storing options
for AllFusion ERwin DM features.

DBMS specific tags, such as DBMS_Brands_And_Versions,


DBMS_Is_Represented, and DBMS_Is_Top_Level_Object, are vectors and
organize data in groups of triplets as described below:
■ First element—DBMS brand ID.
■ Second element—The minimum version level for the DBMS, multiplied by
1000.
■ Third element—The maximum version level for the DBMS, multiplied by
1000; 999000 indicates the absence of a maximum level.

B–4 AllFusion ERwin Data Modeler API Reference Guide


Metadata Organization

The following graphic provides an example of these elements, specifically for the
DBMS_Brands_And_Versions tag:

The first element, the DBMS brand ID, is for Oracle, which is 1075858979.

The second element, the minimum version level for this DBMS, multiplied by
1000, is 8000. This means the minimum DBMS version level for this DBMS,
which is Oracle, is 8.0.

The third element, the maximum version level for this DBMS, is 999000 in this
example, which means there is no maximum version level for this DBMS.

This example is from a metamodel document generated with AllFusion ERwin


DM. For more information on generating a metamodel document, see the section
Metamodel Document.

The following table lists DBMS brand IDs:

DBMS Brand DBMS Brand ID


Access 1075859004
Advantage Ingres 1075859007
DB2 1075858978
DB2 UDB 1075858977
FoxPro 1075859029
Informix 1075859006
iSeries (AS400) 1075859019
ODBC 1075859009

AllFusion ERwin DM Metamodel B–5


Metadata Organization

DBMS Brand DBMS Brand ID


Oracle 1075858979
Progress 1075859010
Red Brick 1075859012
SAS 1075859013
SQL Server 1075859016
Sybase 1075859017
Teradata 1075859018

Abstract Metadata Objects

The metadata organization makes use of generalizations with the ability to


derive a specialized object class from an abstract object class using generalization
association. Specialized classes can then be marked as abstract, and then they can
be used as a source for further specializations.

Only instances of the concrete, non-abstract object classes may occur within the
application’s data. AllFusion ERwin DM uses the generalization mechanism to
flatten metadata by replicating aggregations, associations, and tags from the
abstract object classes in the concrete object classes.

Metamodel Classes

A unique metadata class identifies what type of metadata a model set contains.
The following describes these classes:
■ EMX Class Model Set—Contains the bulk of model data such as entities and
attributes.
– Class name—EMX
– Class identifier—The value defined in the Application Environment
component, category Application, property EMX Metadata Class.
■ EM2 Class Model Set—Stores additional data such as user interface settings
and user options for AllFusion ERwin DM services such as Forward
Engineering and Complete Compare.
– Class name—EM2
– Class identifier—The value defined in the Application Environment
component, category Application, property EM2 Metadata Class.

B–6 AllFusion ERwin Data Modeler API Reference Guide


Metadata Reports

Metadata Reports
AllFusion ERwin DM makes metadata descriptions available in various formats.

Metamodel Document

You can generate metamodel documents from the AllFusion ERwin DM Help
menu.

The application can generate a document for the complete EMX model or for just
the current model. If you generate a metamodel document for the current model,
you have an additional option to filter your output based on the target DBMS of
the current model, and this option also allows you to see user defined properties.

However you choose to generate the document, it will contain the following
definitions:
■ Object definitions
■ Property definitions
■ Association definitions (for property ownership)
■ Aggregation definitions (for object ownership)

The default output of this document is in HTML format, and AllFusion ERwin
DM provides a template for this format. However, you can create your own
template for the output that you require.

Object and property class names appear as titles for definition descriptions:

For object types that are specific to an AllFusion ERwin DM 4.1.4 model that is
being upgraded, the object definition is TRUE for the Is Deprecated field. These
object types are not available otherwise. Likewise for property types that are
specific to an AllFusion ERwin DM 4.1.4 model that is being upgraded, the
property definition Is Deprecated field is TRUE. These property types are not
available otherwise.

AllFusion ERwin DM Metamodel B–7


Metadata Reports

The following is an example of an object type that has TRUE defined for the Is
Deprecated field:

The object definition is TRUE for the Is Abstract field for abstract object types.
These types are used for defining metadata only. No model data objects have
them as their object type.

The following is an example of an object type that has TRUE defined for the Is
Abstract field:

B–8 AllFusion ERwin Data Modeler API Reference Guide


Metadata Reports

The report marks every definition with a unique identifier:

The value in the Long Id field is the API’s metadata object identifier. Information
on object identifiers and type codes is in the section Object Identifiers in the
chapter “API Components.”

More information on generating a metamodel document is in the AllFusion


ERwin DM online help.

XML Schema

An XML schema is a document or a set of documents that defines the XML file’s
structure and legal elements. XML schemas can be used to ensure that an XML
file is syntactically correct and conforms to the defined schema. AllFusion ERwin
DM provides such a schema and uses the schema to validate XML files when
they are opened in the tool.

The AllFusion ERwin DM installation places the complete set of XML schema
files necessary for an XML file validation into the Doc directory. The schema files
have .xsd extensions. The following is the list of XML schema files provided by
AllFusion ERwin DM:
■ [Link]—Top level schema
■ [Link]—Schema for UDP definitions
■ [Link]—Schema for object hierarchy
■ [Link]—Schema for non-transactional data
■ [Link]—Schema for object properties and UDP instances

XML schemas contain descriptions of model object and property classes and
define property containment by object classes. Schema definitions for EMX and
EM2 classes are provided. XML schemas do not include deprecated classes.

AllFusion ERwin DM Metamodel B–9


Metadata Reports

The following is a diagram of the five AllFusion ERwin DM XML schema files:

[Link]
Top level schema

Namespace: [Link]

Imports Imports

[Link] [Link] [Link]


Schema for UDP Schema for object Schema for non-
definitions hierarchy (EMX) transactional data (EM2)
Namespace: [Link] Namespace: [Link]
ERwin/UDP Namespace: [Link]
ERwin/data ERwin/EM2

Includes

[Link]
Schema for object properties
and UDP instances

Namespace: [Link]
ERwin/data

The schema files under the Doc directory are not database specific and represent
the entire AllFusion ERwin DM metamodel. The schema contains all possible
objects and properties for all valid database targets. If you need database specific
schema, those files are located in the Doc\DBMS_schemas directory. Within the
Doc\DBMS_schemas directory, there is a folder for each target database that
AllFusion ERwin DM supports. The database specific schema files are stored in
that folder and only consist of objects and properties that are valid for the given
database target.

Note: The XML schema that is in the Doc directory is always used by AllFusion
ERwin DM to validate an XML file; the database specific schema is not used. The
database specific schemas are provided for documentation purposes and to assist
third party tool integrators to determine the valid objects and properties for a
given database target. An external XML validation tool can be used to validate
an XML file against a database specific schema.

B–10 AllFusion ERwin Data Modeler API Reference Guide


Conversion from AllFusion ERwin DM Version 4.1.4

ERwin Spy

The ERwin Spy application visualizes metadata information and provides


intrinsic and model-specific metadata. It is an invaluable tool for anyone who
wants to write applications using the AllFusion ERwin DM API, as it provides a
view of the internals of an AllFusion ERwin DM model. For detailed information
on the ERwin Spy application and how it works, see the ERwin Spy section in the
chapter, “API Components.”

Conversion from AllFusion ERwin DM Version 4.1.4


The following sections describe the changes in the metadata from Version 4.1.4 to
r7. The files that are described in these sections are found in the Doc directory
after you install AllFusion ERwin DM.

User-Defined Property (UDP)

r7 does not use the UDP Definition object type to define UDP properties. In r7,
UDP definitions are part of the metadata. In order to define a new UDP, a new
Property Type object must be added to the metadata of the EMX model set.

For more information, see the section Creating User-Defined Properties in the
chapter, “API Tasks.”

AllFusion ERwin DM Metamodel B–11


Conversion from AllFusion ERwin DM Version 4.1.4

Changes in Type Names

The files listed in the following table contain only object and property types with
changed names, but their role in model data remains the same. There are a
number of objects and properties that were deprecated and replaced by new
object and property types. These new and replaced types are described in the
files shown in the table in the next section, Additions and Deprecations in
Metadata.

File Name Description


Api Appendix [Link] Describes changes in object and
property type names. The column with
the Legacy_ApiName= items lists the
legacy Version 4.1.4 type names along
with their r7 equivalent.
Api Appendix [Link] Renamed Lists only the renamed object types.
[Link]
Api Appendix [Link] Renamed Lists only the renamed property types.
[Link]

Note: The Api Appendix B. EMX Renamed [Link] file and the Api
Appendix [Link] Renamed [Link] file are similar, they just break down
the object and property types separately.

Additions and Deprecations in Metadata

The following table lists the files that reflect the changes in the metadata:

File Name Description


Api Appendix [Link] Object Provides a list of new and deprecated
[Link] object types for the EMX metamodel
Api Appendix [Link] Property Provides a list of new and deprecated
[Link] property types for the EMX metamodel
Api Appendix [Link] Property usage Tracks changes in property
[Link] assignments for the EMX metamodel
Api Appendix B.EM2 Object Provides a list of new and deprecated
[Link] object types for the EM2 metamodel
Api Appendix B.EM2 Property Provides a list of new and deprecated
[Link] property types for the EM2 metamodel

B–12 AllFusion ERwin Data Modeler API Reference Guide


Conversion from AllFusion ERwin DM Version 4.1.4

Datatype Changes

The file Api Appendix [Link] Property datatype [Link] provides a list of
properties with changed datatypes. AllFusion ERwin DM uses the properties in a
way similar to Release 4.1.4, however, the datatype of those properties was
changed to accommodate the new, expanded use in r7.

AllFusion ERwin DM Metamodel B–13


Index

deleting
non-scalar property values, 3-57
objects, 3-54
A
properties and property values, 3-55
scalar properties, 3-56
active scripting, 1-2, 1-4 depth filter, 3-30
disposition property, A-94
API environment, 3-1
abstract metadata objects, B-6 error handling, 3-65
accessing ERwin Spy application, 2-14, B-11
metamodel information, 3-58 filtering
model data, 3-7 object collections, 3-28
model objects, 3-23, 3-25 object collections, filters used, 3-30
non-scalar property values, 3-36, 3-40 properties, 3-42
object properties, 3-31 iterating through open models, 3-7
scalar property values, 3-34 iteration of properties, 3-32
specific objects, 3-27 locator property, A-92
specific properties, 3-41 major features, 1-1
advanced tasks, 3-69 metadata tags, B-3
creating UDPs, 3-69, 3-73 metamodel
application environment property bag, A-74 classes, B-6
automation documents, B-7
default properties, 2-12 elements, B-1
optional parameter, 2-12 model directory property bag, A-81, A-90
Begin Transaction, 3-46 model directory unit property bag, A-81, A-90
clearing a persistence unit, 3-64 ModelObjects property, 3-23
closing a session, 3-63 MustBeOn/MustBeOff filter, 3-31
Commit Transaction, 3-47 object identifiers, 2-8
converting Version 4.1.4 to r7, B-11 object type filter, 3-30
metadata additions and deprecations, B-12 opening
type names, B-12 a session, 3-17
UDPs, B-11 an existing model, 3-16
creating persistence unit collections property bag, A-85
a new model, 3-14 persistence units property bag, A-85
a new persistence unit, 3-15 property bag reference, A-74
an entry point, 3-2 sample client, 2-12
ISCApplication object, 3-2 session transactions, 3-45
objects, 3-49 setting
UDPs, 3-69, 3-73 non-scalar property values, 3-52
DBMS brand IDs, B-5 property values, 3-51
for target server property, A-89 scalar property values, 3-51
typical use cases, 1-2

Index–1
using ISCPersistenceUnitCollection
as a standalone executable, 1-3, 3-13 clearing persistence units, 3-64
as an add-in or script, 1-4 creating a new model, 3-14
as an add-in tool, 3-7 description of, A-53
XML schema, B-9 opening an existing model, 3-16
using with API as add-in, 3-8
API interfaces
ISCPropertyBag
IEnumVARIANT, 2-10
creating a new model, 3-15
ISCApplication
description of, A-57
application properties, 3-3
using with API as add-in, 3-11
description of, A-1
ISCPropertyValue, 2-5
using with API as add-in, 3-8
accessing non-scalar property values, 3-38
ISCApplicationEnvironment
description of, A-59
application properties, 3-4, 3-59, 3-66
ISCPropertyValueCollection
description of, A-2
accessing non-scalar property values, 3-37
ISCModelDirectory, 2-3, 2-7
accessing specific properties, 3-41
description of, A-4
description of, A-62
ISCModelDirectoryCollection
ISCSession, 2-4, 2-7, 3-21
description of, A-18
accessing metamodel information, 3-60
ISCModelDirectoryUnit, 2-3
accessing model objects, 3-23
ISCModelObject, 2-5
Begin Transaction, 3-46
accessing model objects, 3-24
closing the session, 3-62
description of, A-23
Commit transaction, 3-47, 3-73
filtering properties, 3-43
description of, A-63
iteration of properties, 3-32
opening a session, 3-18
ISCModelObjectCollection, 2-5
ISCSessionCollection, 2-4
accessing
closing the session, 3-62
model objects, 3-23
description of, A-68
specific objects, 3-27
opening a session, 3-17
creating objects, 3-49
ISCValueCollection, 2-5
deleting objects, 3-54
description of, A-27 Application Tier
filtering object collections, 3-28 overview, 2-1
ISCModelProperty, 2-5
automation
accessing non-scalar property values, 3-36
default properties, 2-12
accessing scalar property values, 3-34
optional parameter, 2-12
deleting properties and property values, 3-56
description of, A-34
iteration of properties, 3-32
setting non-scalar property values, 3-53 C
setting scalar property values, 3-51
ISCModelPropertyCollection
deleting properties and property values, 3-55 Class parameter, 3-27
description of, A-38 Collect method, 3-28
iteration of properties, 3-32
ISCModelSet, 3-20 CollectProperties method, 3-42
description of, A-44 components
ISCModelSetCollection, 3-20 values, 2-5, 2-8
description of, A-47
ISCPersistenceUnit creating a new model, 3-14
description of, A-48
saving the model, 3-57
using with API as add-in, 3-9

Index–2 AllFusion ERwin Data Modeler API Reference Guide


E ISCPersistenceUnit interface
methods of, A-48
ISCPersistenceUnitCollection interface
enumerations, 3-34, 3-42
methods of, A-53
ERwin Spy application, 2-14, B-11
ISCPropertyBag interface
methods of, A-57
ISCPropertyValue interface
F
methods of, A-59
ISCPropertyValueCollection interface
filters methods of, A-62
Depth, 3-30
filtering object collections, 3-28 ISCSession instance, establishing for
filtering properties, 3-42 ISCPersistenceUnit, 3-17
MustBeOn/MustBeOff, 3-31 ISCSession interface
Object Type, 3-30 methods of, A-63
ISCSessionCollection interface
methods of, A-68
I
Item method, 3-27, 3-41

interfaces. See API interfaces


ISCApplication interface, 3-2 L
methods of, A-1
ISCApplication object, creating, 3-2 Level parameter, 3-58
ISCApplicationEnvironment interface
methods of, A-2
ISCModelDirectory interface M
methods of, A-4
ISCModelDirectoryCollection interface member
methods of, A-18 PropertyValues, 3-36
Value, 3-51
ISCModelObject interface
ValueId, 3-36
methods of, A-23
members, property bag, for a persistence unit, 3-9
ISCModelObjectCollection interface
methods of, A-27 metamodel
accessing information, 3-58
ISCModelProperty interface
methods of, A-34 methods
Collect, 3-28
ISCModelPropertyCollection interface
CollectProperties, 3-42
methods of, A-38
Item, 3-27, 3-41
ISCModelSet interface Open, 3-58
methods of, A-44 Remove, 3-56
RemoveValue, 3-55, 3-56
ISCModelSetCollection interface
methods of, A-47
ISCPersistenceUnit
establishing ISCSession instance for, 3-17

Index–3
model N
accessing
metamodel information, 3-58
model objects, 3-23, 3-25 nIndex parameter, 3-27
non-scalar property values, 3-36, 3-40
object properties, 3-31 non-scalar properties, accessing specific, 3-41
scalar property values, 3-34
specific objects, 3-27
specific properties, 3-41 O
Begin Transaction, 3-46
clearing a persistence unit, 3-64
closing a session, 3-63 Open method, 3-58
Commit Transaction, 3-47
creating
new, 3-14 P
new persistence unit, 3-15
objects, 3-49
deleting parameters
non-scalar property values, 3-57 Class, 3-27
objects, 3-54 Level, 3-58
properties and property values, 3-55 nIndex, 3-27
scalar properties, 3-56 Unit, 3-18, 3-60
depth filter, 3-30 ValueId, 3-52, 3-56
error handling, 3-65
filtering persistence unit
object collections, 3-28 new, 3-14
object collections, filters used, 3-30 property bag members for, 3-9
properties, 3-42 properties
iteration accessing
of properties, 3-32 non-scalar values of, 3-36
through, 3-7 scalar values of, 3-34
MustBeOn/MustBeOff filter, 3-31 specific, 3-41
object type filter, 3-30 deleting, 3-55
opening non-scalar values of, 3-56
a session, 3-17 scalar, 3-56
an existing, 3-16 iteration of, 3-32
setting ModelObjects, 3-23
non-scalar property values, 3-52 PersistenceUnits, 3-7, 3-13
property values, 3-51 setting values of, 3-51
scalar property values, 3-51 Value, 3-34
Model Data Tier property bag members, for a persistence unit, 3-9
overview, 2-5
property bag reference, A-74
Model Directory Tier
overview, 2-3 property of model object
flags, A-4
ModelObjects property, 3-23 multi-valued, 2-5
property, accessing specific, 3-41
PropertyValues member, 3-36

Index–4 AllFusion ERwin Data Modeler API Reference Guide


R V

Remove method, 3-56 Value member, 3-51


RemoveValue method, 3-55, 3-56 ValueId member, 3-36
ValueId parameter, 3-52, 3-56

SC_ModelDirectoryFlags, enumerations and


properties, A-70
SC_ModelDirectoryType, enumerations and
properties, A-70
SC_ModelObjectFlags, enumerations and properties,
A-70
SC_ModelPropertyFlags, enumerations and
properties, A-71
SC_SessionFlags, enumerations and properties, A-72
SC_SessionLevel, enumerations and properties, A-72
SC_ValueTypes, enumerations and properties, A-72
script, 1-4
session
opening, 3-17
session transactions
Begin, 3-46
Commit, 3-47
Sessions Tier
overview, 2-4

transactions
Begin, 3-46
Commit, 3-47

Unit parameter, 3-18, 3-60

Index–5

You might also like