Lifecycle Applications

Document Management

Manipulating Document Objects

Programming basic methods in ENOVDDManager
Use Case

Abstract

This article shows how to use functionalities provided by interfaces in ENOVDDManager framework.


What You Will Learn With This Use Case

This use case is intended to show you how to use interfaces in ENOVDDManager framework. Involved interfaces are ENOVIDocumentRevision, ENOVIDocumentIteration, and ENOVIIterationFormat. This use case will help you to understand how to create an iteration under a revision, create format from an iteration, and other useful methods from revision, iteration, and format, etc.

As explained in the Data Model section, the structure of a Document could be viewed as follows:

Document Master
  |
  ---- Document Revision
         |
         ---- Document Iteration
                |
                ---- Document Format
                       |
                       ---- Document File

When a Document without an attached file is created, the object type that gets created is a Document Revision. When a Document with an attached file is created, the object type that gets created is a Document File.

[Top]

The CAADdmDocumentFunctions Use Case

CAADdmDocumentFunctions is a use case of the CAAENOVDDManager.edu framework that illustrates ENOVDDManager framework capabilities.

[Top]

What Does CAADdmDocumentFunctions Do

CAADdmDocumentFunctions begins by creating a document master and document revision, then uses functionalities provided by ENOVIDocumentRevision to create document iteration, and also creates document format, document file through ENOVIDocumentIteration and ENOVIIterationFormat interfaces. Methods defined in these interfaces are called one by one to demonstrate their usages.

Here is the list of methods called in this use case:

[Top]

How to Launch CAADdmDocumentFunctions

To launch CAADdmDocumentFunctions, you will need to set up the build time environment, then compile CAADdmDocumentFunctions along with its prerequisites, set up the run time environment, and then execute the use case [1].

Launch the use case by executing the following command:

mkrun -c "CAADdmDocumentFunctions"

[Top]

Where to Find the CAADdmDocumentFunctions Code

The CAADdmDocumentFunctions use case is made of one class in a single file located in the CAADdmDocumentFunctions.m module of the CAAENOVDDManager.edu framework:

Windows InstallRootDirectory\CAAENOVDDManager.edu\CAADdmDocumentFunctions.m\
Unix InstallRootDirectory/CAAENOVDDManager.edu/CAADdmDocumentFunctions.m/

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

[Top]

Step-by-Step

There are totally 19 steps in the CAADDManagerFunctions use case:
  1. Creating a Login Session
  2. Retrieving a CATIEnovDDManager Interface Handler
  3. Creating a Document
  4. Retrieving the Last Document Revision under the Master
  5. Obtaining the ENOVIDocumentRevision
  6. Aggregating an Iteration through ENOVIDocumentRevision
  7. Obtaining ENOVIDocumentIteration Interface
  8. Aggregating a Format from Iteration
  9. Creating a File for More Testing
  10. Creating an Iteration by Copying an Old One in ENOVIDocumentRevision
  11. Retrieving Primary Format Using ENOVIDocumentRevision
  12. Retrieving MimeType from ENOVIDocumentRevision
  13. Setting MimeType from ENOVIDocumentRevision
  14. Retrieving Revision from ENOVIDocumentIteration
  15. Retrieving All the Formats from ENOVIDocumentIteration
  16. Retrieving Format Count from ENOVIDocumentIteration
  17. Obtaining the ENOVIIterationFormat interface
  18. Retrieving Iteration from Format
  19. Closing the Session

Creating a Login Session

...
//--- Get Session
    CATIVpmLoginSession_var spSession = NULL_var;
    VPMSession* piSess_handle = VPMSession::OpenSession();
    if (piSess_handle!=NULL)
        rc = piSess_handle->CreateLoginSession("", "", "", 0, spSession);
    if(rc != S_OK || spSession==NULL_var) return 1;
...

The first step is to create a login session as in the above code.

[Top]

Retrieving a CATIEnovDDManager Interface Handler

...
//--- Get a DDManager
    CATIEnovDDManager_var spDDMgr = ::GetRootDesktop();
    if ( spDDMgr == NULL_var ) return 2;

    cout << "Got DDManager successfully." << endl;
...

The above code retrieves a pointer to the CATIEnovDDManager interface.

Creating a Document

1. First initialize some attributes before calling the createDocument.

...
//--- Initialize class field and keywords
    CATListOfCATUnicodeString Doc_classfield;
    Doc_classfield.Append(CATUnicodeString("Name"));
    CATListOfCATUnicodeString Doc_keywords;
    Doc_keywords.Append(CATUnicodeString("ENOVIA"));
...

2. Secondly call CreateDocument.

...
//--- Create a DocumentMaster (It also creates a default Revision)
    CATIAVPMDocumentMaster  * piDocMaster = NULL;
    rc = spDDMgr->CreateDocument( "CAADocument_ID",
                                  "Doc_title",
                                  "Doc_desc",
                                  "Doc_type",
                                  Doc_classfield,
                                  Doc_keywords,
                                  piDocMaster );
    if ( !SUCCEEDED(rc) || piDocMaster==NULL )
        return 3;
    cout << "Created Document successfully." << endl;
...

Call CreateDocument from the CATIEnovDDManager interface to create a document. In this method the input arguments are:

"CAADocument_ID" Document ID
"Doc_title" Document name (title)
"Doc_desc" Document description
"Doc_type" Document type
Doc_classfield Document classification field
Doc_keywords Document keywords
piDocMaster Resulted document master

[Top]

Retrieving the Last Document Revision under the Master

...
//--- Get the Revision as a ObjectVersion
    CATIAVPMObjectMaster_var spObjectMaster(piDocMaster);
    CATIAVPMObjectVersion *piObjectVersion=NULL;
    rc = spObjectMaster->get_LastVersion(piObjectVersion);
    if ( !SUCCEEDED(rc) || piObjectVersion==NULL )
        return 4;
    cout << "Got Revision successfully." << endl;
...

This call uses the master object to retrieve its latest revision.

[Top]

Obtaining the ENOVIDocumentRevision

...
//--- Convert ObjectVersion to DocumentRevision
    ENOVIDocumentRevision_var spDocRevision = piObjectVersion;
...

Convert a CATIAVPMObjectVersion to ENOVIDocumentRevision.

[Top]

Aggregating an Iteration through ENOVIDocumentRevision

...
//--- Create an Iteration by AggregateIteration()
    CATIVpmFactoryObject_var spIterationObj=NULL_var;
    rc = spDocRevision->AggregateIteration(spIterationObj); 
    if ( !SUCCEEDED(rc) || spIterationObj==NULL_var )    
        return 5;
    cout << "Created Iteration successfully." << endl;
...

This call creates an new iteration under the calling revision.

[Top]

Obtaining ENOVIDocumentIteration interface

...
//--- Convert oIterationObj to DocumentIteration
    ENOVIDocumentIteration_var spDocIteration = spIterationObj;
...

Convert an CATIVpmFactoryObject to ENOVIDocumentIteration.

[Top]

Aggregating a Format from Iteration

...
//--- Create a Format by AggregateFormat()
    CATIVpmFactoryObject_var spFormatObj=NULL_var;
    rc = spDocIteration->AggregateFormat( 2,                 // ControlCode
                                          "DocMimeType",     // input MIMEType
                                          "SubMimeType",     // Sub MIMETYPE
                                          FALSE,             // IsURL
                                          spFormatObj);
    if (  !SUCCEEDED(rc) || spFormatObj==NULL_var )
        return 6;
    cout << "Create a Format successfully." << endl;
...

This call creates a format under the calling iteration. Its argument list:

2 Control code (1 for system controlled document, 2 for user controlled)
"DocMimeType" Format Mime type
"SubMimeType" Sub-Mime type
FALSE Whether it is URL link or not
spFormatObj The resulted format

[Top]

Creating a File for More Testing

1. First we must get the UUID of the format that the file will be attached to.

...
//--- Get UUID of DocFormat in order to call CreateFile() from DDManager
      CORBAAny oFormatUuid;
      CATILinkableObject_var splinkObjectFmt(spFormatObj);
      SEQUENCE(octet) FormatUuid = splinkObjectFmt->GetName_B(CATSafestName);
      oFormatUuid << FormatUuid;
...

2. Create the file

...
//--- Create a File using DDManager interface
      CATIVpmFactoryObject_var spFileObj=NULL_var;
      CORBAAny oVaultUuid;
      rc = spDDMgr->CreateFile(oFormatUuid,    // Format UUID
                               2,              // Control Code
                               oVaultUuid,     // VaultDocument UUID
                               "TestVault",    // Vault Name
                               "TestHost",     // File Host Name
                               "TestPath",     // File Path Name
                               "TestFileName", // File Name
                               1,              // File Number (never used.)
                               spFileObj);
      if ( !SUCCEEDED(rc) || spFileObj==NULL_var )
          return 7;
      cout << "Create a File successfully." << endl;
...

The call to create a file has following argument list:
oFormatUuid Format UUID
2 Control code (as in the format)
oVaultUuid Vault document UUID
"TestVault" Vault Name
"TestHost" Vault Host name
"TestPath" Vault path name
"TestFileName" File name
1 File number (never used)
spFileObj Resulted file object.

[Top]

Create an Iteration by Copying an Old One in ENOVIDocumentRevision

...
//--- CopyIteration
      CATIVpmFactoryObject_var spIterObj2=NULL_var;
      rc = spDocRevision->CopyIteration(spIterationObj, spIterObj2);
      if ( !SUCCEEDED(rc) || spIterObj2==NULL_var )
          return 8;
      cout << "Copied Iteration successfully." << endl;
...

This call uses CopyIteration() method in interface ENOVIDocumentRevision to create a new iteration from an old one.

[Top]

Retrieving Primary Format Using ENOVIDocumentRevision

...
//--- Get Primary Format
      CATIVpmFactoryObject_var spPrimFormat=NULL_var;
      rc = spDocRevision->get_PrimaryFormat( spPrimFormat );
      if ( !SUCCEEDED(rc) || spPrimFormat==NULL_var )
         return 9;
      cout << "Got primary Format successfully." << endl;
...

This call retrieves the primary format from revision.

[Top]

Retrieving MimeType from ENOVIDocumentRevision

...
//--- Get MIMEType
      CATListOfCATUnicodeString aTypes=NULL;
      rc = spDocRevision->get_MIMEType(aTypes);
      if ( !SUCCEEDED(rc) )
         return 10;
      cout << "Got MIMEType successfully." << endl;
...

This call retrieves the MimeType attribute in document format object under the revision.

[Top]

Setting MimeType from ENOVIDocumentRevision

...
//--- Set MIMEType
      CATUnicodeString iMimeType("New MimeType");
      rc = spDocRevision->set_MIMEType(iMimeType);
      if ( !SUCCEEDED(rc) )
          return 11;
      cout << "Set MIMEType successfully." << endl;
...

This call sets the MimeType attribute in document format object under the revision.

[Top]

Retrieving Revision from ENOVIDocumentIteration

...
//--- Get Revision from Iteration
      CATIAVPMObjectVersion * piObjVer2 =NULL;
      rc = spDocIteration->get_RevisionFromIteration(piObjVer2);
      if ( !SUCCEEDED(rc) || piObjVer2==NULL )
          return 12;
      cout << "Got Revision from Iteration successfully." << endl;
...

This call retrieves the revision that the calling iteration belongs to.

[Top]

Retrieving All the Formats from ENOVIDocumentIteration

...
//--- Get all Formats
      CATLISTV(CATIVpmFactoryObject_var) aFormatList=NULL;
      rc = spDocIteration->get_DocFormats(aFormatList);
      if ( !SUCCEEDED(rc) )
          return 13;
      cout << "Got all the Formats successfully." << endl;
...

This call retrieves all the format under the calling iteration.

[Top]

Retrieving Format Count from ENOVIDocumentIteration

...
//--- Get Format count
      long nbFormats=0;
      rc = spDocIteration->get_DocFormatCount(nbFormats);
      if ( !SUCCEEDED(rc) )
          return 14;
      cout << "Got Format count successfully." << endl;
...

This call retrieves the format count of the calling iteration.

[Top]

Obtaining the ENOVIIterationFormat interface

...
//--- Convert Format from Factory object to DocumentFormat
      ENOVIIterationFormat_var spDocFormat=spFormatObj;
...

Convert an CATIVpmFactoryObject to ENOVIIterationFormat.

[Top]

Retrieving Iteration from Format

...
//--- Get Iteration from Format
      ENOVIDocumentIteration_var spDocIter2=NULL_var;
      rc=spDocFormat->get_IterationFromFormat(spDocIter2);
      if ( !SUCCEEDED(rc) || spDocIter2==NULL_var )
          return 15;
      cout << "Got Iteration from Format successfully." << endl;
...

This call retrieves the iteration that the calling format belongs to.

[Top]

Closing the Session

...
//-----------------------------------------------------------------------------
// Close the VPM Session
//-----------------------------------------------------------------------------
    VPMSession::CloseSession();
    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 demos the usages of document related interfaces in Content Manager

[Top]


References

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

History

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

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