Observers

From AMTech WikiDocs
Revision as of 22:26, 11 March 2016 by Hector (Talk | contribs) (Allowed criteria)

Jump to: navigation, search

Things' observers

As seen before, it is possible to navigate among the things with the platform (see Tree navigator). The things will be organized by type and they can be filtered according to some regular expression on their name and/or description (see Quick filter).

We introduced the notion of Observer to allow to associate things of different types: for instance, to be able to retrieve the trucks and the clients of a company at the same time which allows to show them together in the map. As shown below, observers make also possible to filter with criteria on other fields than can be numerical, string, boolean and datetime.

More advanced constraints are available on the location and proximity area fields of the things. It is also possible to define criteria on aggregations of the things' snapshots.

Observers creation and loading

First thing to do is to open the observer's editor:

  • Navigate to things and then click on the observer button ObserverEditorButton.png at the bottom of the window.
The observer editor will appear over the navigator with its own menu bar on top of the page and another menu in the right side.
When there is no observer loaded, the editor menu will look like
EmptyObserverEditor.png
  • Click on NewObserverBtn.png to create a new observer and select its name in the opened dialog:
CreateObserverDlg.png
or just open an existing one by clicking on OpenObserverBtn.png and selecting it in the opened window
SelectObserver.png
  • Finally, the observer editor top menu will appear
ObserverEditorMenu.png

Deletion and unloading

Click on ObserverDeleteBtn.png to delete the currently loaded observer or just unload it by using the ObserverUnloadBtn.png. The editor will return to its initial state: EmptyObserverEditor.png

Also, if the observer was executed, and thus the things filtered, the editor will return to the list of collections of entities.

Adding/Removing entity types

In order to show things of different types at the same time you must load or create an observer. The thing types can be chosen with the button ObserverEntityTypeBtn.png and once a type is selected the menu in the right will be updated

   For instance, let us suppose we want to see all the Trucks and the endCustomers of a company. We click on the button once to select type Truck and once to select endCustomers.Then you can save the observer by clicking on button ObserverSaveBtn.png and the observer editor will look like this
   Observer with trucks and endCustomers
   Execute the observer with button ObserverExecuteBtn.png and the list of things will contain all the trucks and endCustomers the user has access to.
   List of trucks and endCustomers after executing an observer

If a chosen thing type is no longer needed and it is wanted to be removed from the list, go to the right side menu, click on the thing type submenu and then click on the last option at the bottom ObserverRemoveThingType.png

  Note: Do not forget to save the observer if you want to keep your changes. If you execute it, a dialog window will allow you to save it or cancel the operation.

Allowed criteria

It is possible to filter the things to observe, by activating some constraints on thing fields. The constraints will depend on the type of the field as it will be shown below. There are several basic constraints that correspond to base field types (numerical, text, datetime and boolean). There are also some advanced constraints and constraints on aggregation functions.

Basic constraints

The basic constraints correspond to the primitive field types and are given below

  • numerical (long, integer and double)
    • lte - lower than or equal
    • gte - greater than or equal
  • text
    • regex - satifies a regular expression
    • eq - equals
  • datetime
    • lte - lower than or equal
    • gte - greater than or equal
  • boolean
    • eq - equals


Advanced constraints

Aggregation functions

Activity observers

Follower's observers

Observers API

https://<dapurl>/amtech/observersexec/<observeruri>[?params]

Available params:

  • observation: JSON string representation of the observation. May be mandatory depending on the requirements of the observer.
  • resourceStatusFilter: You can specify this parameter with the value valid to only return things that passed validation.
  • limit: Limit for the number of results.
  • noOlderThan: Does not return results older than this date expressed as the number of milliseconds since the epoch (January 1st, 1970, 00:00:00 GMT)
  • offsetDate: This works in conjunction with offsetId. This is expected to be the creation date of the thing indicated with the param offsetId.
  • offsetId: The results will start with the first thing that is older than the record with this ID. This works in conjunction with the offsetDate and you should indicate either both or none of them.
  • tenant: Only return those things available to this tenant.
  • includeCount: Set to true to indicate that we are interested in the total number of results for the execution of this observer. false otherwise.

Target things

targetthings "[{\"thingType\":\"/amtech/linkeddata/types/composite/entity/truck\",\"thingsId\":[\"truck888\"], proximityarea}]" It allows to establish relations between an observation and things instances grouped by type including a proximity area. It offers a tool to resolve thing type instances. From client to server: It can be configured to used by observer to returns just target things instances. The proximityarea is used at the observation enrichment to assigned target things instances with a location. From server to client: Allows to send observations to specific instances. Example m2mBridge leverages this functionality to implement centralized management and send observations.