Lifecycle Applications |
Document Management |
Manipulating Document ObjectsProgramming basic methods in ENOVDDManager |
Use Case |
AbstractThis article shows how to use functionalities provided by interfaces in ENOVDDManager framework. |
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]
CAADdmDocumentFunctions is a use case of the CAAENOVDDManager.edu framework that illustrates ENOVDDManager framework capabilities.
[Top]
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:
HRESULT CopyIteration(CATIVpmFactoryObject_var & iDocIteration, CATIVpmFactoryObject_var & oNewIter); HRESULT AggregateIteration(CATIVpmFactoryObject_var & oDocIteration); HRESULT get_MIMEType(CATListOfCATUnicodeString &oTypes); HRESULT set_MIMEType(const CATUnicodeString & iMIMEType); HRESULT IsTOC(boolean & isTOC); HRESULT IsSheet(boolean & isSheet); HRESULT get_PrimaryFormat(CATIVpmFactoryObject_var & oFormat);
HRESULT get_RevisionFromIteration(CATIAVPMObjectVersion* & oDocRevision); HRESULT AggregateFormat(const int iControlCode, const CATUnicodeString & iMimeType, const CATUnicodeString & iSubMimeType, const boolean & iIsURL, CATIVpmFactoryObject_var & oDocFormat); HRESULT get_DocFormats(CATLISTV(CATIVpmFactoryObject_var) & oDocFormats); HRESULT get_DocFormatCount(long & oNbFormats);
HRESULT get_IterationFromFormat(ENOVIDocumentIteration_var & oDocIteration);
[Top]
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]
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]
... //--- 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]
... //--- 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.
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]
... //--- 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]
... //--- Convert ObjectVersion to DocumentRevision ENOVIDocumentRevision_var spDocRevision = piObjectVersion; ... |
Convert a CATIAVPMObjectVersion to ENOVIDocumentRevision.
[Top]
... //--- 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]
... //--- Convert oIterationObj to DocumentIteration ENOVIDocumentIteration_var spDocIteration = spIterationObj; ... |
Convert an CATIVpmFactoryObject to ENOVIDocumentIteration.
[Top]
... //--- 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]
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]
... //--- 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]
... //--- 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]
... //--- 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]
... //--- 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]
... //--- 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]
... //--- 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]
... //--- 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]
... //--- Convert Format from Factory object to DocumentFormat ENOVIIterationFormat_var spDocFormat=spFormatObj; ... |
Convert an CATIVpmFactoryObject to ENOVIIterationFormat.
[Top]
... //--- 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]
... //----------------------------------------------------------------------------- // 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]
This use case demos the usages of document related interfaces in Content Manager
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [May 2001] | Document created |
[Top] |
Copyright © 2001, Dassault Systèmes. All rights reserved.