com.apama.cumulocity
Event Util
Contains various static actions that are useful for interacting with Cumulocity such as generateReqId().
ensureSMSLength
string static ensureSMSLength(string text)
Truncate a string to max length of 160 characters.- Parameters:
- text
formatTime
string static formatTime(float t)
Format time into human readable form, as used by Cumulocity.- Parameters:
- t - Float that indicates the time you want to format. This value is the number of seconds since the UNIX epoch in UTC. This is the same format used by the currentTime variable. For information about the currentTime variable, see "Getting the current time" in "Developing Apama Applications".
generateReqId
integer static generateReqId()
Use this action for generating all reqIds for use with the Cumulocity API.
inMaintenanceMode
boolean static inMaintenanceMode(com.apama.cumulocity.ManagedObject device)
Determine if ManagedObject is in maintenance mode.- Parameters:
- device
- Returns:
- True if c8y_Availability.status is MAINTENANCE.
replacePlaceholders
string static replacePlaceholders(string value, any e)
Replace placeholders in string from an Event.
Replace #{field} with field values or entries in params from the event. Sub-objects are printed in JSON form. For fields named 'time' or 'timestamp', field values are converted to a human-readable form before replacement.
If the replacement string is of a form such as #{source.name} where source.name is the name of the underlying managed object/device or #{source.c8y_Hardware.notes} where c8y_Hardware is a fragment on the managed object, then special handling is required to achieve the replacement. After the initial replacement, you must update the placeholder field name and run Util::replacePlaceholders again with the source managedObject. myMailText := Util.replacePlaceholders("The device #{source} with the serial number #{source.c8y_Hardware.serialNumber} created an event with the text #{text} at #{time}. The device is located at #{source.c8y_Address.street} in #{source.c8y_Address.city}.", alarm);
myMailText := myMailText.replaceAll("#{source.", "#{");
myMailText := Util.replacePlaceholders(myMailText, managedObject);
- Parameters:
- value - String containing placeholder values
- e - Event containing values to be substituted.