IBM i > DEVELOPER > GENERAL

Using Google App API to Send Calendar Events


This is the third and final article in the Google Apps for Business (GA4B) series where I provided you with steps for connecting with the GA4B cloud world to retrieve a list of documents and send documents from the IFS to your Google Drive folder using the GA4B APIs.

See Part 1 here and Part 2 here.

This article provides the coding to send calendar events you created in your proof of concept article from the Employee Master Birthdate column to a Google calendar. As you may recall, the previous CSV Proof of Concept provided for the current employee birthday, next year’s birthday and a 10-day vacation. While this is doable in the supplied sample wrapper CLLE program, I chose to just create a sample birthday event for each employee this time.

Creating the CMD/PNLGRP/CLLE/RPGLE/Java Source

As has been the case in all the examples, you need to first create an interface command to prompt the user for the Google email and password parameters along with other event-required parameters to be passed to GA4B for processing.

I created this simple command, GA4BEVNT (Code Sample 1), and a panel group for command parameter help, GA4BEVNTP (Code Sample 2).

To reiterate, the PASSWORD parameter on your command is not secure with just the DSPINPUT(*NO) variable setting.

The command executes the GA4BEVNTC (Code Sample 3) CLLE command processor program (CPP) to set your Java Class path as before. The GA4BEVNTR RPGLE program is then called with user-supplied parameter values.

The GA4BEVNTR RPGLE (Code Sample 4) is a simple program that accepts 11 parameters passed to it, parses them into Java string objects and calls the Java main method.

The Java program, GA4BEVNTJ (Code Sample 5), was again created in Eclipse. Add this program to your existing GoogleDocs project and configure the compiler to use these packages from Google:

  • import com.google.gdata.client.calendar.CalendarService;
  • import com.google.gdata.data.DateTime;
  • import com.google.gdata.data.PlainTextConstruct;
  • import com.google.gdata.data.calendar.CalendarEventEntry;
  • import com.google.gdata.data.extensions.Reminder;
  • import com.google.gdata.data.extensions.Reminder.Method;
  • import com.google.gdata.data.extensions.When;
  • import com.google.gdata.data.extensions.Where;

and these additional packages as well:

  • import java.net.URL;
  • import java.util.Calendar;
  • import java.util.TimeZone;

As was the case in the first two articles, configure your Java compiler to use the Java 1.5 Java Runtime Environment at a minimum and create a Java Runtime Configuration for testing and to export the Java Classes as a run-capable JAR.

After you import your required classes and parse the passed parameter data to variables, connect to the Google CalendarService to validate your credentials (email and password). Once validated and connected, use the applicable Google Calendar API to send the calendar event data piece to GA4B for the Google user’s default calendar.

I again used limited error checking in my code, which you should modify in your production code. This example is by no means inclusive of all data that can be sent as a calendar event but serves as a working example of what can be done programmatically to interface your two worlds.

Executing Your Utility

From a command line, you can prompt your GA4BEVNT command and enter the required parameters for your test to send a single event request.

Once your process is executed, check out your GA4B calendar and verify that the event has been created as shown in Figures 1 and 2.

To provide for the similar results from your Employee Master table data like you accomplished in the Google CSV Calendars and IBM i article, I decided to write a wrapper CLLE program to read your Employee Master table, format the event parameters and execute the GA4BEVNT command for each employee in the table. The GA4BEVNT_E CLLE (Code Sample 6) does just the trick and can be called from the command line.

Automating Your Business Needs

Automating the steps to push documents and calendar events to, or receive lists from, the GA4B Suite using the Google Apps for Business Developer APIs makes the integration of the IBM i DB2 database and the public cloud easier and more likely to be integrated into your day-to-day processing once you see how it all plays together programmatically.

While these examples are by no means the final solution you’d need in your mission-critical applications, they do provide the beginning steps and basic architecture of sharing data with your staff, vendors and customers regardless of their location. If they have Internet access, they have access to the cloud and the data shared!

 

David Andruchuk is the senior architect for Computer Systems Design Associates Inc.



Like what you just read? To receive technical tips and articles directly in your inbox twice per month, sign up for the EXTRA e-newsletter here.



Advertisement

Advertisement

2017 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

Are You Multilingual?

Rational enables development in multiplatform environments

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters