AquaLogic User Interaction Development Guide

     Previous Next  Open TOC in new window   View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Creating Publisher Content Items Using IDK Remote APIs

To create new content items based on existing Data Entry Templates and Presentation Templates, use the IContentItemManager and IContentItem interfaces in the IDK.

The IContentItemManager interface allows you to create new content items from a Data Entry Template with defined properties and its associated Presentation Template. You can create multiple content items from a single Data Entry Template; all the content items will be formatted according to the attached Presentation Template.

Several processes are required before you can create a content item. The steps below provide a summary.

  1. Create a PRC session. For details, see Initiating a PRC Session to Use IDK Remote APIs.
  2. Create a Data Entry Template. For details, see Creating Publisher Data Entry Templates Using IDK Remote APIs.
  3. Create a Presentation Template. For details, see Creating Publisher Presentation Templates Using IDK Remote APIs. If associated content items should not be included in the search index, set the searchable flag on the Presentation Template object to false.
  4. Attach the Presentation Template to the Data Entry Template using the IDataEntryTemplate.attachPresentationTemplate method. You must call store to persist the attachment before creating a content item.
  5. Once these processes are complete, you can create a content item and set values for the associated properties as shown in the sample code below. These examples retrieve the properties from the Data Entry Template as an array and set the associated values.
    Note: To persist a new content item, you must check it in to Publisher using IContentItemManager.checkInItem.

Java

...
// Get a content item manager object.
IContentItemManager ciManager = factory.getContentItemManager();

// Create a new content item.
IContentItem contentitem = ciManager.createContentItem(det.getContainingFolder(), "Incident 123", det);

// Retrieve the properties from the Data Entry Template.
IBaseProperty[] props = det.getAllProperties();

// Set the incident ID as an integer property.
contentitem.setIntegerPropertyValue(props[0], 123);

// Set the resolution status as a Boolean property.
contentitem.setBooleanPropertyValue(props[1], false);

// Set the severity level as a real property.
contentitem.setDoublePropertyValue(props[2], 0.70 );

// Set the date the incident was opened as a date property.
contentitem.setDatePropertyValue(props[3], new Date());

// Set the name of the customer as a text property.
contentitem.setTextLinePropertyValue(props[4], "Joe Customer");

// Set the incident description as a long text property
contentitem.setTextBlockPropertyValue(props[5], "Can't open the application.");

// Link to another content item that contains customer information.
IContentItem customerData= ciManager.getContentItem(det.getContainingFolder(), "Customer Information");
contentitem.setItemReferencePropertyValue(props[6], customerData);

// Select the product from a selection list.
// When setting a selection list value, the passed-in string should 
// exactly match one of the values in the selection list.
contentitem.setSelectionListPropertyValue(props[7], "ALI");

// Set the value of the log file property.
// The name of the file can be set to a different file name
FileInputStream log = new FileInputStream("C:\uploads\logFile.txt");
contentItem.setFilePropertyValue(props[8], "logFile.txt", log);

// Set the image property value.
// The name of the image can be set to a different name
FileInputStream screenShot = new FileInputStream("C:\uploads\screenshot.jpg");
contentItem.setImagePropertyValue(props[9], "screenshot.jpg", screenShot);

// Store the content item by checking it in.
ciManager.checkInItem(contentitem, "New incident.");

...

.NET (C#)

...

// Get a content item manager object.
IContentItemManager ciManager = factory.GetContentItemManager();

// Create a new content item.
IContentItem contentitem = ciManager.CreateContentItem(det.GetContainingFolder(), "Incident 123", det);

// Retrieve the properties from the Data Entry Template.
IBaseProperty[] props = det.GetAllProperties();

// Set the incident ID as an integer property.
contentitem.SetIntegerPropertyValue(props[0], 123);

// Set the resolution status as a Boolean property.
contentitem.SetBooleanPropertyValue(props[1], false);

// Set the severity level as a real property.
contentitem.SetDoublePropertyValue(props[2], 0.70 );

// Set the date the incident was opened as a date property.
contentitem.SetDatePropertyValue(props[3], DateTime.Now);

// Set the name of the customer as a text property.
contentitem.SetTextLinePropertyValue(props[4], "Joe Customer");

// Set the incident summary as a long text property.
contentitem.SetTextBlockPropertyValue(props[5], "Can't open the application.");

// Link to another content item that contains customer information. 
IContentItem customerData = ciManager.GetContentItem(det.GetContainingFolder(), "Customer Information");
contentitem.SetItemReferencePropertyValue(props[6], customerData);

// Select the product from a selection list.
// When setting a selection list value, the passed-in string should exactly
// match one of the values in the selection list.
contentitem.SetSelectionListPropertyValue(props[7], "ALI");

// Set the value of the log file property.
// The name of the file can be set to a different file name
FileStream log = new FileStream("C:\uploads\logFile.txt", FileMode.Open);
contentItem.setFilePropertyValue(props[8], "logFile.txt", log);

// Set the image property value.
// The name of the image can be set to a different name
FileStream screenShot = new FileStream("C:\uploads\screenshot.jpg", FileMode.Open);
contentItem.setImagePropertyValue(props[9], "screenshot.jpg", screenShot);

// Store the content item by checking it in.
ciManager.CheckInItem(contentitem, "Automatically created an article.");
...

.NET (VB)

...

'Get the Content Item Manager.
Dim contentFactory As IContentFactory = remoteSession.GetContentFactory()
Dim contentItemManager As IContentItemManager = contentFactory.GetContentItemManager()

' Create a new Content Item.
Dim contentItemName As String = CType(pnlMain.FindControl("Incident 123"), TextBox).Text
Dim contentItem As IContentItem = contentItemManager.CreateContentItem(dataEntryTemplate.GetContainingFolder, contentItemName, dataEntryTemplate)

' Retrieve the properties from the Data Entry Template.
Dim props() As IBaseProperty = det.GetAllProperties() 

' Set the incident ID as an integer property. 
contentitem.SetIntegerPropertyValue(props(0), 123) 

' Set the resolution status as a Boolean property.
contentitem.SetBooleanPropertyValue(props(1), False) 

' Set the severity level as a real property. 
contentitem.SetDoublePropertyValue(props(2), 0.7) 

' Set the date  the incident was opened as a date property.
contentitem.SetDatePropertyValue(props(3), DateTime.Now)

' Set the name of the customer as a text property.
contentitem.SetTextLinePropertyValue(props(4), "Joe Customer")

' Set the incident summary as a long text property.
contentitem.SetTextBlockPropertyValue(props(5), "Can't open the application.")

' Link to another content item that contains customer information.
Dim customerData As IContentItem = ciManager.GetContentItem(det.GetContainingFolder(), "Customer Information")
contentitem.SetItemReferencePropertyValue(props(6), customerData)

' Select the product from a selection list. 
' When setting a selection list value, the passed-in string should exactly 
' match one of the values in the selection list. 
contentitem.SetSelectionListPropertyValue(props(7), "ALI")

' Set the value of the file property.
' The name of the file can be set to a different file name
Dim log As FileStream = New FileStream("C:\uploads\logFile.txt", FileMode.Open)
contentItem.SetFilePropertyValue(props(8), "logFile.txt", log)

' Set the value of the image property
' The name of the image can be set to a different name
Dim screenShot As FileStream = New FileStream("C:\uploads\screenshot.jpg", FileMode.Open)
contentItem.SetImagePropertyValue(props(9), "screenshot.jpg", screenShot)

' Store the content item by checking it in. 
ciManager.CheckInItem(contentitem, "Automatically created an article.")
...

  Back to Top      Previous Next