Unofficial Content
  • This documentation is valid for:

versión en español aqui

An "RSS Feed Pattern" has been implemented whose purpose is to generate an RSS feed from the information of a KB. You can obtain further information and the mentioned pattern here.

The purpose of this article is documenting how this pattern operates and what it generates. 

You can find an introduction to the RSS topic here.


How does RSS Feed pattern work?

I'ts quite simple: you select the transactions to which you want to apply the pattern (those over which you want to generate an RSS Feed) and then you apply it, which generates a group of objects according to the values set in the instance. The objects of this group are essentially procedures that generate and return the RSS (xml).

Watching RSS Feed pattern in operation 

To understand it easier, you can watch videos that show the use of pattern in an Invoicing application (minimal): 

Step 1: Applying pattern to the customers transaction and watching the results 

This video (Mplayer - wmv  / Flash - swf )  shows how to apply RSS Feed Pattern to the customers transaction. Then you can see the result of  "consuming" the feed with RSS Bandit (Mplayer - wmv video / Flash - swf video), a "standalone" reader, or using RSS Popper (Mplayer - wmv video / Flash - swf video), a reader integrated to outlook.


Step 2: Applying RSS feed pattern and Work With Pattern to the entire knowledge base 


This video (Mplayer - wmv / Flash - swf)shows how to apply RSS feed pattern to the entire KB and also how to integrate the "work with pattern" in the same kb. Then, you can see the result in runtime, either using RSS Popper or RSS Bandit (Mplayer - wmv video / Flash - swf video)


Step 3: Modifying the pattern instance 

The previous examples showed how to apply RSS Feed pattern with the default values. In this case we start from a more complex example: the Invoices transaction. 

In addition to have more than one level, this transaction is characterized by not having a first level "Description Attribute". This "Description Attribute" is the one used by default for the "title and "description" included in RSS. Therefore, what you can do is setting up other attributes operating as "Description Attribute? in the ?ItemTitle" and "ItemDescription" properties.

Specifically, what is included in the example is not an attribute, but more complex expressions of the following type: "Invoice"+str(InvoiceNbr). This is not only possible, but also useful in some cases. 

You can watch the video that shows more details of this example (instance modification, the result at generated objects level, runtime, etc.) (Mplayer - wmv video / Flash - swf video).


More about what pattern generates 


Pattern creates two object types: basic and specific. 

Basic objects are procedures that start an XML (PBeginRSS), finish it (PEndRSS) or write an Item/element to the RSS file (PRSSWriteItem).
Besides, there is an object (PRSSisAuthorized) called in each "feed" to verify that the user is authorized to use it. By default, this procedure only returns "true". The idea is that if there is a procedure in the kb that really controls security, this procedure must be modified to call the KB real security procedure.  

Specific objects are the ones generated for each feed. E.g.: if you start from the Customers feed that we have seen before, the following objects will be created:  PRSSCustomers, PRSSgetCustomersitems and Webpanel: RSSCustomersAddFavorite.

PRSSCustomers is a kind of "controller" of the rest of the objects; the source (summed up) is the following: 


 

// controls security
PRSSisAuthorized.Call(&Pgmname, &isAuthorized)
If &isAuthorized = RSSBoolean.True
 
// Starts the XML file
   PBeginRSS.Call(&Name, &ShortContent, &Link, &Xml, &BaseUrl)
 
// calls another procedure that returns an SDT (&items) to be returned in the RSS
   PrssgetCustomersitems.Call(&Items)
 
// reads the SDT and returns saving each item
   For &Item in &Items
     PRSSWriteItem.Call(&Xml, &Item.Title, &Item.Description, &Link)
   Endfor
 
// Finish the XML file 
   PEndRSS.Call(&Xml)
 
Endif


What PRSSgetCustomersitems does is read the corresponding table (in this case customer) according to the properties setup in the instance (quantity of items, order, etc.) and returns a SDT with the elements to be returned in RSS. 
 

// Quantity of items to be shown
&ItemsQuantity = 20
&Quantity = 0
 
&Items = new RSSEntityItems() 
 
For each (CustomerID)
    If &Quantity <= &ItemsQuantity
        &Item = new RSSEntityItems.Item()
        &Item.Title = CustomerName
        &Item.Description = CustomerName
        &Item.Link = link(HViewCustomers,ltrim(CustomerID.ToString()))
        &Items.Add(&Item)
    else
         exit
    Endif
 
    // Increase the quantity
    &Quantity += 1
Endfor

 

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant