The Document object can be created by using the constructor
of the PortfolioDocument, as specified below:
public PortfolioDocument(String id, String name, String desc, String comment, int state, DocumentSource docSource, byte[] docContent, String docReference, Category ucat, Category lcat, int version, Date activeStartDate, Date activeEndDate, String lastChangeBy, String mimeType)
An alternative is to use the setter methods of the PortfolioDocument
to set the different properties of the object. A portfolio document
can either be a document from a File or from the Correspondence
Letter that was created in the Correspondence Management system.
A few parameters in the PortfolioDocument class enable us to create
either of the two. The following are the parameters which specify
what type of Document object is being created:
DocumentSource: Specifies whether the document
object is created from a File or from a Letter. Thus, it can either
take the value DocumentSource.FILE or DocumentSource.LETTER
DocumentReference: Set to NULL if the DocumentSource
is a File. Otherwise it references the new document object’s letter
ID.
DocumentContent: Set to NULL if the DocumentSource
is a Letter. If the DocumentSource is a File, then it references
the byte array of the PDF file.
The following code snippet illustrates how the portfolioDocument
can be created:
PortfolioDocument doc = new PortfolioDocument();
doc.setActiveEndDate(getDate());
doc.setActiveStartDate(getDate());
doc.setComment("Sample document");
doc.setDesc("Sample document");
doc.setDocContent(getdocumentContent());
doc.setDocReference(null);
doc.setDocSource(DocumentSource.FILE);
doc.setLcat(subCategoryObject);
doc.setUcat(categoryObject);
doc.setName(documentName);
doc.setState(iState);
doc.setVersion(0);
While creating the Portfolio, you can organize the Documents
in a folder structure by creating the PortfolioFolder object. Similar
to the portfolioDocument you can either use the constructor or a
different setter method.
public PortfolioFolder(String id, String name, String desc, List<PortfolioFolder> subFolders, List<PortfolioDocument> documents)
Finally, the portfolio object is created using the Folder objects
and the Document objects and also references the other managed assets
of CM.
public Portfolio(String id, String name, String desc, String comment, int state, Category ucat, Category lcat, int version, Date activeStartDate, Date activeEndDate, String lastChangeBy, PortfolioDocument navigator, PortfolioDocument cover, PortfolioFolder rootFolder)
There are a couple of special documents that are mentioned above
in the Portfolio constructor.
Note: It is mandatory to have the Navigator, Cover page, and a source
Document while creating the Portfolio.