Package gov.bnl.channelfinder.api

See: Description

Package gov.bnl.channelfinder.api Description

Contents

Creating a ChannelFinderClient

  1. Creating a simple client

Query Examples

  1. Query for channels based on name
  2. Query for channels based on tags
  3. Query for channels based on property
  4. Query channels based on multiple criteria
3

Set/Update/Delete Examples

Creating a simple client

The ChannelFinderClient contains a builder to guide users through the process of creating the client.
 // Import from here
 import gov.bnl.channelfinder.api.ChannelFinderClient.CFCBuilder;
 
 // Create a client of the default service URL
 
 client = CFCBuilder.serviceURL().create();
 
 // Create a client to the specified service with HTTP authentication enabled 
 and with username myUsername and password myPasword
 
 authenticatedClient = CFCBuilder.serviceURL("http://my.server.location/ChannelFinder")
 .withHTTPAuthentication(true).username("myUsername").password("myPassword").create();
 

Query for channels based on name

 
 // search for all channels in the channelfinder with name starting with "SR:C01".
  
 Collection foundChannels = client.findByName("SR:C01*");
 

Query for channels based on tags

 
 // search for all channels with the tag "shroffk-favorite-channel".
 
 Collection foundChannels = client.findByTag("shroffk-favorite-channel");
 

Query for channels based on property

 
 // search for all channel which have the property "device" with value = "bpm".
 
 Collection foundChannels = client.findByProperty("device", "bpm");
 
 // search for all channels which have the property "device with value "bpm" or "magnet"
 
 Collection foundChannels = client.findByProperty("device", "bpm", "magnet");
 

Query channels based on multiple criteria

 
 // search for channels with name starting with "SR:C01" AND with tag "shroffk-favorite-channel"
 // AND had property "device" with value "bpm" OR "magnet"
  
 Map map = new Hashtable();
 map.put("~name", "SR:C01*");
 map.put("~tag", "shroffk-favorite-channel");
 map.put("device", "bpm, magnet");
 Collection foundChannels = client.find(map);
 
 // search for channels with name starting with "SR:C01" AND with tag "shroffk-favorite-channel"
 // AND had property "device" with value "bpm" OR "magnet"
 
 MultivaluedMapImpl multiValuedMap = new MultivaluedMapImpl();
 multiValuedMap.put("~name", "SR:C01*");
 multiValuedMap.put("~tag", "shroffk-favorite-channel");
 multiValuedMap.add("device", "bpm");
 multiValuedMap.add("device", "magnet");
 Collection foundChannels = client.find(multiValuedMap);
 

Copyright © 2012. All Rights Reserved.