FME Version
Files
Introduction
The workspace attached to this article, described in detail below, will guide you how to create the Visual Calendar Dashboard, as depicted above, for use in FME Server. This workflow heavily relies on a template created by FullCalendar and leveraging the Google Calendar and FME Server REST APIs. The workspace can be scheduled to run on FME Server providing you with an updated overview of when your FME Server Schedules will run!
Learn how to create your own “Visual Calendar” Dashboard of FME Server Schedules.
Requirements
FME Desktop and Server (2017.1.2 or Newer)
Google Account (Developer Key for Calendar API)
Step-by-step Instructions
1. Get a Google Account and Calendar API Key
Create a Google account (or use an existing one) and visit the Google Developer API Dashboard. Here you will have to enable the Google Calendar API and then create an API Key – there are plenty of great ‘How To’ resources available to help.
2. Make Google Calendar Public and Determine the Google Calendar ID
The logic for this workflow revolves around reading and writing to an existing Public Google Calendar. You can use any calendar that you have created on your Google account, or link to an external one. Remember that it has to be publicly accessible! It is important to search for current instructions if you need help determining the Calendar ID.
3. Get an FME Server Token
For this workflow to gather details from FME Server, you need to obtain a valid fme token to access the REST API. It is preferred to get the token from a user that is a member of the fmeadmin role.
4. The Workspace and Template HTML
Download the attached FME Workspace. You can set FME to “Run with Prompt” and replace all the default values with information obtained in the first three steps.
For a more detailed look into the workspace, read Workspace Overview below.
5. Publish to FME Server and Configure Published Parameters
Publish this workspace to FME Server. You can either manually run the workspace or configure it to run daily on a schedule. Just make sure to adjust all of the Published Parameters to match your unique values and – voila! A visual calendar for you to see all of your FME Server Schedules.
Workspace Overview
Bookmark 1. GET FME Server Schedule List
The Creator transformer starts the workflow with a null feature to invoke the HTTPCaller. This transformer then gathers a response from the FME Server REST API, /fmerest/v3/schedules, of all the FME Server Schedules. The return is in JSON format, and the FeatureWriter saves the output to file for use later in the workspace.
Bookmark 2. GET Google Calendar Event Ids and DELETE All
The next HTTPCaller in this workflow gathers a list, again in JSON, of all Events in the Google Calendar by accessing a Google Calendar REST API endpoint. The JSONFlattener and ListExploder will expose each Event as an individual feature for FME to process. The second HTTPCaller in this Bookmark then issues the DELETE command against each Calendar Event – this operation is necessary since this workflow does not have logic to determine which FME Server Schedules already exist as Events. The Sampler transformer is used here to reduce the number of features flowing into the next Bookmark.
Note: This effectively deletes every item in the specified Google Calendar. It is important to be aware of this!
Bookmark 3. Read Each Schedule as Feature and Filter Disabled
The FeatureReader will read back the JSON response saved earlier – if the Sampler was not previously used, this transformer would create redundant features by reading in the same dataset multiple times. The combination of AttributeExposer and ListExploder creates a separate feature for each FME Server Schedule. TestFilter simply removes any disabled Schedules that are not important to track in the Google Calendar.
Bookmark 4. Create and Format JSON for Google Calendar REST API
There are a lot of transformers here to do attribute manipulation. The AttributeExposer and AttributeValueMapper work together ensuring that the values returned by FME Server’s REST API are compatible with the Google Calendar REST API. DateTimeConverter, DateTimeCalculator, and, again, DateTimeConverter are used here to provide an arbitrary length (30 minutes) for each FME Server Schedule. The AttributeManager creates a JSON-formatted string for passing to the Google Calendar REST API. Use of the JSONValidator ensures that the string will not be rejected.
Bookmark 5. POST FME Server Schedules to Google Calendar
HTTPCaller is used here once again to interact with the Google Calendar REST API. This transformer is configured to POST – or add – all the FME Server Schedules to Google Calendar as unique Events. Another Sampler is used to reduce the feature count flowing to the next Bookmark.
Bookmark 6. HTML Template Magic
If the Sampler was not previously used, then for every FME Server Schedule posted to Google Calendar, there would be a new HTML file written – which wouldn’t be very efficient. The AttributeCreator placed here contains all of the raw HTML used, with many Published Parameter references allowing for dynamic output based on user input. The HTML Writer is configured to place the resulting output into the proper Dashboards Repository on FME Server where it is automatically made available on the Dashboards page in the Web Interface.
Please note that there are no plans to maintain this workspace, or the contents of this Knowledge Center Article. If you would like to ask more questions or share your enhancements to this workflow, please start a thread on the FME Community!
Comments
0 comments
Please sign in to leave a comment.