Developing a composite application in IBM Lotus Notes to integrate Lotus Notes and Google calendars

This article shows you how to develop a composite application in IBM® Lotus® Notes® 8.0 that integrates the calendars in Google and Lotus Notes, based on the Atom API and XSLT technology. It demonstrates the ease with which you can create a composite application and consume the Atom API.

Ming Chen (minghchen@cn.ibm.com), Staff Software Engineer, IBM

Ming Chen is a Staff Software Engineer working in the Beijing, China Software Development Lab. Ming has been the team lead of Lotus Connections System Testing Team in Beijing since December 2006. He joined IBM in 2005, and he as worked on system testing of IBM Lotus Workplace Business Controls & Reporting and IBM Lotus Active Insight. You can reach Ming at mingchen@cn.ibm.com.



Xin Rang Wang (wangxr@cn.ibm.com), Staff Software Engineere, IBM

Xin Rang Wang is a Staff Software Engineer working in the Beijing, China Software Development Lab of IBM. Xin Rang has been the technical lead for the IBM Lotus Notes and Domino Maintenance Release Testing Team since April 2005. You can reach her at wangxr@cn.ibm.com.



10 June 2008

Also available in Russian

Today, you can select from many calendar products or calendar services, including Lotus Notes Calendar, Microsoft® Outlook Calendar, Google Calendar, and Yahoo! Calendar. You might own two or three calendar products and services at the same time. For example, you might use Lotus Notes Calendar to collaborate with your customers and colleagues, but you might use Google Calendar to track personal events such as an anniversary or a party.

In this case you have to switch, often inconveniently, among different calendar products and calendar services to track all calendar events. To solve this problem, in this article we demonstrate how to create a composite application in Lotus Notes 8 that integrates multiple calendars from distributed sources. This composite application provides an integrated view in which you can track all events easily among all distributed calendars.

In this article, we use Lotus Notes Calendar and Google Calendar as examples.

Lotus Notes Calendar is used to schedule and keep track of meetings, appointments, all-day events, anniversaries, reminders, and event announcements (which are collectively referred to as calendar entries), all in one place. It is part of the Lotus Notes mail application.

Google Calendar is an online shareable calendar service. Using Google Calendar, you can add events and invitations, share them with friends and family (or keep things to yourself), and search the Web for events that you might enjoy.

Overview

When you install Lotus Notes 8, be sure to install the Composite Application Editor as well. Create the Lotus Notes mail database from the Lotus Notes 8 mail template. We assume that you are already familiar with IBM Lotus Domino® databases, Atom/APP, and XSLT.

We use a composite application to integrate the Lotus Notes Calendar Navigator, Lotus Notes Calendar View, Google Calendar Navigator, and Managed Browser. As shown in figure 1, the four components communicate with each other using the property broker in the composite application. Google Calendar Navigator retrieves the Google Calendar Atom feed, adds the Extensible Stylesheet Language Transformation (XSLT) schema to the feed file, and notifies Managed Browser to render.

Figure 1. Overview of the calendar composite application
Overview of the calendar composite application

Create the composite application database

First, start the Lotus Notes 8 client and open a New Application window as shown in figure 2. In the New Application window, enter the following:

  • In the Title field, enter composite.
  • In the Template field, select Blank Composite Application. Click OK.
Figure 2. Create the composite application database
Create the composite application database

To start the Composite Application Editor, select Actions - Edit Application. Rename the new application by selecting Edit - Page - Rename and then entering composite as the title.


Integrate Lotus Notes Calendar Navigator and Lotus Notes Calendar View

There are some built-in components with properties and actions in the Lotus Notes 8 Composite Application Editor. If you are using mail8.ntf as your mail template, the personal information manager (PIM) component is available by default. In the Composite Application Editor, expand the Component Palette to display the PIM components that can be added to the application. In the Component Palette, select Lotus Notes Calendar Navigator. Drag the Lotus Notes Calendar Navigator to the leftmost point of the blank application page. In the Component Palette, select Lotus Notes Calendar View. Drag the Lotus Notes Calendar View to the rightmost point of the application page. The layout looks like the one shown in figure 3.

Figure 3. Integrate Lotus Notes Calendar Navigator and Lotus Notes Calendar View
Integrate Lotus Notes Calendar Navigator and Lotus Notes Calendar View

Components within a composite application can be wired together so that a user-initiated action in one component triggers a programmed action in another component. In this application, when the selected date in the Lotus Notes Calendar Navigator or Lotus Notes Calendar View is changed, the other component reflects the date change.

To create the wire between the Lotus Notes Calendar Navigator and the Lotus Notes Calendar View, right-click Lotus Notes Calendar Navigator in the navigation pane and select Wiring. Select the Selected data changed property of the Lotus Notes Calendar Navigator, and drag it to the Set selected date action of the Lotus Notes Calendar View. Select Lotus Notes Calendar View as the wire source. Select the Selected data change property of the Lotus Notes Calendar View, and drag it to the Set selected date action of the Lotus Notes Calendar Navigator. See figure 4.

Figure 4. Create the wire
Create the wire

Now you can test the wire that you just created. Exit the wiring page. When you change the date in Lotus Notes Calendar Navigator, the selected date is changed to the same date in Lotus Notes Calendar View. Similarly, when you change the date in Lotus Notes Calendar View, the selected date is also changed in Lotus Notes Calendar Navigator.


Integrate Managed Browser and view the Google Calendar

In this article, we use Managed Browser to view Google calendar. Managed Browser is a built-in component in the Lotus Notes 8 Composite Application Editor. To add Managed Browser, right-click the Component Palette and select Add Components - Add Locally Installed Components. Select Managed Browser and click OK. See figure 5. Managed Browser is then added to the Component Palette.

Figure 5. Add Managed Browser
Add Managed Browser

Drag Managed Browser to the lower part of the application page. Select Managed Browser from the navigation pane and right-click. As shown in figure 6, select Edit Component Properties - Advanced and add the following property:

initialURL=http://www.google.com/calendar

Figure 6. Configure the managed browser
Configure the managed browser

Now test the composite application as shown in figure 7. When the composite application is open, Managed Browser can open the login page of Google Calendar by default.

Figure 7. Test Managed Browser
Test Managed Browser

At this point, the Lotus Notes Calendar and Google Calendar cannot communicate with each other. In the following sections, the composite application uses RSS and the Atom application programming interface (API) to read Google Calendar data and uses XSLT to render the Google Calendar data. After that, when the selected date is changed in the Lotus Notes Calendar, the date also changes in Google Calendar.


Get calendar data from Google Calendar to your personal Web navigator

In this section, you work with the Google Calendar Atom feed, XSLT, WSDL, and more to create and test your composite application.

Google calendar Atom feed

As an online free shareable calendar service, Google Calendar provides abundant APIs and widgets to access its service. Your client application can use the Google Calendar data API to create new events, edit or delete existing events, and query for events in the form of Google data API (GData) feeds. GData uses either of two standard XML-based syndication formats: Atom or RSS. It also has a feed-publishing system that consists of the Atom publishing protocol plus some extensions (using Atom’s standard extension model) for handling queries.

The Atom publishing protocol uses HTTP to edit and author Web resources. The Atom publishing protocol uses the following HTTP methods:

  • GET is used to retrieve a representation of a resource or to perform a query.
  • POST is used to create a new, dynamically named resource.
  • PUT is used to update a known resource.
  • DELETE is used to remove a resource.

In this article, we retrieve events in a specified duration through the Google Calendar Atom API.

You can send an HTTP request such as the following one to a calendar service:

  • URL:http://www.google.com/calendar/feeds/UserGoogleAccount/public/full?start-min=2007-09-11T00:00:00&start-max=2007-09-11T23:59:59
  • HTTP Method: Get

Use XSLT to render Google Calendar data

We use the XSLT schema to render the Google Calendar Atom feed data. Add the following line to the feed file. The XSLT file is attached in the sample ZIP file.

<?xml-stylesheet type="text/xsl" href="gcal.xsl"?>

We saw the rendering shown in figure 8 when we opened the feed in the browser.

Figure 8. Render Google Calendar data by using XSLT
Render Google Calendar data by using XSLT

Get the Google Calendar feed in the navigator database

We use a Lotus Notes database to retrieve and cache the Google Calendar Atom feed data. Open Lotus Domino Designer 8, and select Create a new application. Enter Google Calendar Navigator as the title and gcalnav.nsf as the file name. Select Show advanced templates, and use perweb50.ntf as the template. See figure 9.

Figure 9. Create the navigator database
Create the navigator database

Create an action to get the Google Calendar Atom feed. Open the all page view, and select Create - Action - Action. Enter Reload Gcal as the Action name. Clear the Include action in Action bar and Include action in Action menu options. The code for the action is shown in listing 1. After the code is run, the action retrieves the feed file, full.xml, from the Google Calendar Atom feed. It’s the whole day’s calendar data of September 1, 2007. The XSLT schema line is also added to the feed file.

Listing 1. Action code
Sub Click(Source As Button)
	Dim s As New NotesSession, ws As New NotesUIWorkspace
	Dim uidb As NotesUIDatabase, db As NotesDatabase, doc As NotesDocument
	Set uidb = ws.CurrentDatabase 
	Set db = s.CurrentDatabase
	
	gcalurl$ = 
"http://www.google.com/calendar/feeds/UserGoogleAccount/public/full?start-min=
2007-09-01T00:00:00&start-max=2007-09-01T23:59:59"
	Dim xmlDoc As NotesDocument
	Set xmlDoc = db.GetDocumentByURL(gcalurl$,1)
	
	Dim xmlAttach As NotesEmbeddedObject
	Set xmlAttach = xmlDoc.GetAttachment("full")
	xmlAttach.ExtractFile("data/full.xml")
	Dim fileNum As Integer
	fileNum% = Freefile()
	Open "data/full.xml" For Input As fileNum%
	Input #fileNum%,xmlStr$
	Close #fileNum%
	
	Open "data/full.xml" For Output As fileNum%
	xmlStr$ = Left$(xmlStr$, 38) + "<?xml-stylesheet type=""text/xsl"" 
	href=""gcal.xsl""?>" + Right$(xmlStr$, Len(xmlStr$) - 38)
	Print #fileNum%, xmlStr$
	Close #fileNum%
End Sub

Create WSDL and expose the property and the action

From the navigation pane of Lotus Domino Designer 8, select Composite Applications - Wiring Properties - New Wiring Properties and enter gcalnav as the name. Select Open File to open the Property Broker Editor.

  1. In the Types tab, add a new namespace as shown in figure 10.
    • In the Prefix field, enter pfx.
    • In the Namespace field, enter http://www.ibm.com/wps/eb.
  2. In the Types area, select NewType and enter the following:
    • In the Name field, enter InURLType.
    • In the Type field, enter String.
    • In the Namespace field, enter http://www.ibm.com/wps/eb.
    Figure 10. Edit the WSDL file in the navigator database
    Edit the WSDL file in the navigator database
  3. Select the Properties tab, and add the following two properties as shown in figure 11:
    • LoadURLChanged property
      • In the Name field, enter LoadURLChanged.
      • In the Type field, enter InURLType.
      • In the Title field, enter LoadURLChanged.
      • In the Description field, enter Load URL when Changed.
    • SelectedDateChanged property
      • In the Name field, enter SelectedDateChanged.
      • In the Type field, enter Date/Time.
      • In the Title field, enter SelectedDateChanged.
      • In the Description field, enter Selected Date Changed.
    Figure 11. Add properties
    Add properties
  4. Next, select the Actions tab and enter the following information:
    • In the Name field, enter Reloadonedaycal.
    • In the Title field, enter Reloadonedaycal.
    • In the Description field, enter Reload one day calendar.
    • In the Action Input Parameter-Property field, enter SelectedDateChanged.
    • In the Action Output Parameter field, enter LoadURLChanged.
    See figure 12.
    Figure 12. Add actions
    Add actions

Save the WSDL file, and close the Property Broker Editor. Select Refresh, and select the WSDL file that you just edited. Open the property of the action Reload Gcal. Select the Advanced tab, and select Reloadonedaycal as the Action Name in the Composite Settings field. See figure 13.

Figure 13. Associate action
Associate action

Add the Property Broker code to the action code.

The content of Reload Gcal is similar to the code shown in listing 2.

Listing 2. Reload Gcal code
Sub Click(Source As Button)
	Dim s As New NotesSession, ws As New NotesUIWorkspace
	Dim uidb As NotesUIDatabase, db As NotesDatabase, doc As NotesDocument
	Set uidb = ws.CurrentDatabase 
	Set db = s.CurrentDatabase
	
	Dim pb As NotesPropertyBroker  ‘create new NotesPropertyBroker object
	Set pb = s.GetPropertyBroker
	
	Dim pbInputProperty As NotesProperty, pbContext As Variant
	pbContext = pb.InputPropertyContext   ‘array of NotesProperty objects
	Set pbInputProperty = pbContext(0)    ‘handle to first NotesProperty object
	
	Dim InputPropertyName As String, NameSpace As String  
	InputPropertyName = pbInputProperty.Name   ‘name of NotesProperty object
	NameSpace = pbInputProperty.NameSpace   ‘namespace of NotesProperty object
	
	Dim pbValue As Variant
	pbValue = pb.getPropertyValue(InputPropertyName) ‘array of values of NotesProperty
	
	Dim cDT As NotesDateTime
	Set cDT = pbValue(0)  ‘first value from array NotesProperty object
	
	gcalurl$ = “http://www.google.com/calendar/feeds/xinrangw%40hotmail.com/
	public/full?start-min=” + cDT.DateOnly + “T00:00:00&start-max=” 
	+ cDT.DateOnly + “T23:59:59”

	……Get Google Calendar feed and add XSLT schema line……

	Call pb.setPropertyValue(“LoadURLChanged”,”c:\notes\data\full.xml”)
	Call pb.Publish()
End Sub

Add the Google Calendar Navigator to the composite application and wire with others

Now, return to the Composite Application Editor. Add the Google Calendar Navigator to the composite application. In the component panel, select Add Components - Add NSF Component. Enter the following:

  • In the Component Name field, enter Google Calendar Navigator.
  • In the Component Description field, enter Google Calendar Navigator.

Select Browse following the Lotus Notes URL. Enter the following:

  • In the Kind of object field, enter Database.
  • In the Application field, enter Google Calendar Navigator.

See figures 14 and 15.

Figure 14. Add component (1)
Add component (1)
Figure 15. Add component (2)
Add component (2)

Click OK twice. The Google Calendar Navigator then is added to the Component Palette. Drag the Google Calendar Navigator component to the lower portion of the application page.

Now you can create the wires to the Google Calendar Navigator component. In the navigation pane, right-click Notes Calendar Navigator, and then select Wiring. Select the Selected date changed option in the Notes Calendar Navigator, and then drop it on the Reloadonedaycal action in the Google Calendar Navigator. See figure 16.

Figure 16. Create wire from the Lotus Notes Calendar Navigator to the Google Calendar Navigator
Create wire from the Lotus Notes Calendar Navigator to the Google Calendar Navigator

Right-click Google Calendar Navigator, and select the Select as wire source option. Drag a wire from LoadURLChanged in Google Calendar Navigator to the Set URL to browser option and load in Managed Browser. See figure 17.

Figure 17. Create the wire from the Google Calendar Navigator to the Lotus Notes Calendar Navigator
Create the wire from the Google Calendar Navigator to the Lotus Notes Calendar Navigator

You can test the composite application now. Change the date in Lotus Notes Calendar Navigator, and you see the same date in Google Calendar.


Conclusion

In this article, you learned how to develop a composite application in Lotus Notes 8.0 that lets you integrate Google Calendar and Lotus Notes Calendar based on the Atom API and XSLT technology.


Download

DescriptionNameSize
Sample codesamplecode.zip1470KB

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into IBM collaboration and social software on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Lotus
ArticleID=312846
ArticleTitle=Developing a composite application in IBM Lotus Notes to integrate Lotus Notes and Google calendars
publish-date=06102008