3D PLM Enterprise Architecture |
Data Access - Database |
Creating a New VPM ObjectPerforming basic VPM Persistency operations |
Use Case |
AbstractThis article illustrates how to create a new VPM session and how to create a new VPM object. |
This use case is intended to show you how to use some of the basic operations available with VPMPersistency interfaces. These include: creating a new login session, retrieving the VPM factory manager and creating a new VPM object.
[Top]
CAAVpyGeneralPersistency is a use case of the CAAVPMPersistency.edu framework that illustrates VPMPersistency framework capabilities.
[Top]
CAAVpyGeneralPersistency first of all opens a VPM session and creates a new login session. Then it retrieves a CATIVPMFactoryManager handler in order to create a new VPM object.
[Top]
To launch CAAVpyGeneralPersistency, you will need to set up the build time environment, then compile CAAVpyGeneralPersistency along with its prerequisites, set up the run time environment, and then execute the use case. [1] The required interfaces can be found in the VPMPersistency framework. Launch the use case by executing the following command:
mkrun -c "CAA
VpyGeneralPersistency
"
[Top]
The CAAVpyGeneralPersistency use case is made of a single file located in the CAAVpyGeneralPersistency.m module of the CAAVPMPersistency.edu framework:
Windows | InstallRootDirectory\CAAVPMPersistency.edu\CAA VpyGeneralPersistency .m\ |
Unix | InstallRootDirectory/CAAVPMPersistency.edu/CAA VpyGeneralPersistency .m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
Before launching this use case, check for its prerequisites.
For demonstration purposes, the code from the CAAVpyGeneralPersistency use case is shown here. There are four logical steps in the CAAVpyGeneralPersistency use case:
[Top]
VPMSession *pSession = VPMSession::OpenSession(); if (NULL == pSession) { cout << "Failed to Open Session." << endl; return 1; } cout << "Open Session successful." << endl; ... |
Use the OpenSession
static method of VPMSession in order
to open a new VPM session.
[Top]
... const int netWorkCommunication = 1; CATIVpmLoginSession_var spLogSession = NULL_var; HRESULT rc = pSession -> CreateLoginSession("MySelf", "MyEncodedPsswd", "MyRole", netWorkCommunication, spLogSession); if (FAILED(rc)) { cout << "Failed to create login session." << endl; VPMSession::CloseSession(); return 2; } cout << "Login session created successfully." << endl; ... |
In order to create a new login session, use the CreateLoginSession
method of VPMSession. This method is used to get the login session
corresponding to a specific user or to create one if none exists. The input
arguments are:
MySelf
" - User IdMyEncodedPsswd
" - User PasswordMyRole
" - User RolenetWorkCommunication
-Type of network communication. 0: a
local session; no communication bus will be created. 1: a distributed
session; a communication bus will be created.The method returns a CATIVpmLoginSession smart pointer to the login session. This is the entry point for all user dependant actions: once a pointer to this interface has been obtained, it is assumed that the user has been authenticated and that the implementation of the interface keeps track of the user's permissions.
[Top]
1. Retrieve the factory manager.
... CATIVpmFactoryManager_var spFactoManager = NULL_var; rc = pSession -> GetVPMObjectFactory(spFactoManager); if (FAILED(rc)) { cout << "Failed to get Factory Manager."<< endl; VPMSession::CloseSession(); return 3; } cout << "Factory Manager: OK" << endl; ... |
Retrieve a CATIVpmFactoryManager smart pointer using the GetVPMObjectFactory
method of VPMSession.
[Top]
2. Retrieve the domain container.
... CATUnicodeString domain ("INDEX"); CATIContainer_var spC1; rc = pSession -> SeekContainer(domain, spC1); if (FAILED(rc)) { cout << "Failed to get domain container" << endl; VPMSession::CloseSession(); return 4; } cout << "Domain container: OK" << endl; ... |
Use the SeekContainer
method of VPMSession to retrieve a CATIContainer
smart pointer to the container corresponding to the specified domain, in this
case "INDEX". The new VPM object will be created in this container.
[Top]
3. Create a VPM Part object.
... CATUnicodeString type ("ENOVIA_Part"); CATIVpmFactoryObject_var spMyPart = spFactoManager -> CreateVPMObject(domain, spC1, type); if (NULL_var == spMyPart) { cout << "Create VPMObject: KO" << endl; VPMSession::CloseSession(); return 5; } cout << "Create VPMObject: OK" << endl; ... |
Use the CreateVPMObject
method of CATIVpmFactoryManager
in order to create a new VPM object. This method needs the following input
arguments:
domain
- this is the current domain, in this case,
"INDEX".spC1
- this is the container retrieved in the previous
section. The new VPM object will be created in this container.type
- this is the type of object to be created, in this
case, an "ENOVIA_Part".The CreateVPMObject
method returns a CATIVpmFactoryObject
smart pointer to the new "ENOVIA_Part".
[Top]
... rc = pSession -> CloseSession(); if (FAILED(rc)) { cout << "Close Session failed. " << endl; return 6; } cout << "Close Session successful. " << endl; return 0; |
Close the session using the CloseSession
method of VPMSession.
Then return a 0 value for a successful completion.
[Top]
This use case has illustrated how to open a new VPM session using the OpenSession
static method of VPMSession, how to create a new login session using the CreateLoginSession
method of VPMSession, how to retrieve a CATIVpmFactoryManager
pointer using the GetVPMObjectFactory
method of VPMSession,
how to create a new VPM object in a selected domain container using the CreateVPMObject
method of CATIVpmFactoryManager and finally, how to close the VPM session
using the CloseSession
method of VPMSession.
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [December 2001] | Document created |
[Top] |
Copyright © 2001, Dassault Systèmes. All rights reserved.