Page tree
Skip to end of metadata
Go to start of metadata

Methods

  • CRUD
    • add(DeviceRegistration)
    • get(deviceId)
    • update(deviceId, Device)
    • delete(deviceId)
  • Querying Catalog
    • getResource(resourceId)
    • getDevices(page, perPage)
  • Search / Filtering
    • findDevice(path, operation, value)
    • findDevices(path, operation, value, page, perPage)
    • findResource(path, operation, value)
    • findResources(path, operation, value, page, perPage)


Implementation

A Java-based implementation is available and can be used by applications as follows:

add following maven artifact into your project:

<dependency>
    <groupId>eu.linksmart.lc</groupId>
    <artifactId>resource-catalog-client</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

In case, Maven is not a preferred build environment then resource-catalog-client jar can be downloaded from LinkSmart® repository, to configure into build path of the application.

Set URL of the catalog service by calling following static method of ResourceCatalog class:

ResourceCatalog.setURL("http://hostname:port/base_path");

use DeviceBuilder utility class to create Registration object to add into resource catalog:

  • create registration object from a json file
Registration registration = DeviceBuilder.createRegistration(String jsonFileName)
  • create a device registration for device connectorID & device name with one resource of protocol type REST
Registration registration = DeviceBuilder.createRegistration(String deviceConnectorID, String deviceName, String resourceName, String URL)

Alternatively, the Registration instance can be instantiated and populated directly for required configuration and data values.


to add a device registration:

ResourceCatalog.add(registration);

to get a given Device:

Device device = ResourceCatalog.get(deviceID);

to update a given device:

ResourceCatalog.update(deviceID, registration);

to delete a given device:

ResourceCatalog.delete(deviceID);

to get a given Resource:

Resource resource = ResourceCatalog.getResource(resourceID);

to get registered devices as Catalog:

Catalog catalog = ResourceCatalog.getDevices(page, perPage);

to find a device for a given criteria:

Device device = ResourceCatalog.findDevice(path, criteria, value);

to find devices for a given criteria:

Catalog catalog = ResourceCatalog.findDevices(path, criteria, value, page, perPage);

to find a resource for a given criteria:

Resource resource = ResourceCatalog.findResource(path, criteria, value);

to find resources for a given criteria:

Catalog catalog = ResourceCatalog.findResources(path, criteria, value, page, perPage);  
  • No labels