3D PLM Enterprise Architecture

Data Access - Database

Creating a New VPM Object

Performing basic VPM Persistency operations
Use Case

Abstract

This article illustrates how to create a new VPM session and how to create a new VPM object.


What You Will Learn With This Use Case

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]

The CAAVpyGeneralPersistency Use Case

CAAVpyGeneralPersistency is a use case of the CAAVPMPersistency.edu framework that illustrates VPMPersistency framework capabilities.

[Top]

What Does CAAVpyGeneralPersistency Do?

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]

How to Launch CAAVpyGeneralPersistency

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 "CAAVpyGeneralPersistency"

[Top]

Where to Find the CAAVpyGeneralPersistency Code

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\CAAVpyGeneralPersistency.m\
Unix InstallRootDirectory/CAAVPMPersistency.edu/CAAVpyGeneralPersistency.m/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

[Top]

Step-by-Step

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:

  1. Opening a VPM Session
  2. Creating the Login Session
  3. Creating a VPM Object
  4. Closing the VPM Session

[Top]

Opening a VPM Session

    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]

Creating the Login Session

...
    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:

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]

Creating a VPM Object

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:

The CreateVPMObject method returns a CATIVpmFactoryObject smart pointer to the new "ENOVIA_Part".

[Top]

Closing the VPM Session

...  
    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]


In Short

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]


References

[1] Building and Launching a CAA V5 Use Case
[Top]

History

Version: 1 [December 2001] Document created
[Top]

Copyright © 2001, Dassault Systèmes. All rights reserved.