OGEMA Utilily Classes and Concepts Reference

Last modified by David Nestle on 2017/11/23 16:34

Utility classes: Categories and current structure

Resource naming and Internationalization

  • Get name for resource for GUI / logging based on name resource or resource name: ResourceUtils.getHumanReadableName(Resource r)
  • An alternative, customizable way to retrieve a human-readable name for a resource representing for instance a device or a room: use the NameService, available from OgemaGuiService. The SDK comes with a default implementation (bundle name-service-impl), but this can replaced, for instance in order to provide names in additional languages, use different naming conventions, etc. Example: room-link-app (source code not public yet, accescible for OGEMA Alliance participants).
  • Get an icon for a resource, for display in a GUI: similarly to NameService, use IconService, also available from the OgemaGuiService. You can replace the implementation bundle icon-service-impl to change the icons used. Example: room-link-app (source code not public yet, accescible for OGEMA Alliance participants).

Configure your application and OGEMA system to send messages via Email, SMS and XMPP

To configure messaging open the app "Message forwarding". It contains links to a further app required for configuration: "Message Settings" with two sub-pages: "Edit senders" and "Edit receivers". the documentaiton in the app can be switched to English.

MessageForwarding.png

And here is a simple example how to configure your application to send a message to the configured receiver:

@Component(specVersion = "1.2", immediate = true)
@Service(Application.class)
public class SimpleMessagingApp implements Application {
 ApplicationManager appMan;

@Reference
private OgemaGuiService guiService;

@Override
public void start(ApplicationManager appManager) {
 this.appMan = appManager;
}

public void sendMessage(String subject, String body) {
  MessagePriority pr = MessagePriority.LOW;
  Message msg = new MessageImpl(subj, bod, pr);
 try {
   guiService.getMessagingService().sendMessage(appMan, msg);
 } catch (RejectedExecutionException e) {
   appMan.getLogger().warn("Message could not be sent: "+ e);
 }  
}
...
}

Note that it is beyond the scope of the app to determine the transport mechanism for the message, so it's up to the user to configure the system such that messages from this app will really be forwarded by Email. It could as well be SMS, or no forwarding at all. 

Tags:
Created by Jan Lapp on 2016/11/24 13:49