com.axeda.esrs.sdk
Class SDKFacade

java.lang.Object
  extended by com.axeda.esrs.sdk.SDKFacade

public class SDKFacade
extends java.lang.Object

Created by IntelliJ IDEA. User: kholbrook Date: Dec 15, 2008 Time: 10:21:47 AM To change this template use File | Settings | File Templates.


Constructor Summary
SDKFacade()
           
 
Method Summary
static Device createDevice(Context context, java.lang.String serialNumber, Model model)
          Creates a new SDK Device with the supplied serialnumber and model, then retrieves it from the DB and returns the persisted instance of the Device.
static Location createLocation(Context context, java.lang.String locationName, java.lang.String locationLine1, java.lang.String locationLine2, java.lang.String city, java.lang.String stateOrProvince, java.lang.String postalCode, java.lang.String country, boolean persist)
          Create an IN-MEMORY or PERSISTED location.
static Model createModel(Context context, java.lang.String modelName)
          Creates a new SDK Model with the supplied name, then retrieves it from the DB and returns the persisted instance of the Model.
static Organization createNewOrganization(Context context, java.lang.String name, Location location)
          Creates a new Organization in the DB, with the given name and a new Location (cannot have been persisted)
static DataValue findCurrentDataItemValue(Context context, Device device, java.lang.String dataItemName)
          Returns the currentDataValue for a given Device and DataItemName.
static DataValueList findHistoricalDataItemValue(Context context, Device device, java.lang.String dataItemName)
          Returns the currentDataValue for a given Device and DataItemName.
static DataItem loadDataItem(Context context, Model model, java.lang.String dataItemName)
          Lookup a DataItem from the database for a specific model and dataitem name
static Device loadDevice(Context context, Identifier id)
          Loads a Device from the DB based on the Serial Number and the Model
static Device loadDevice(Context context, java.lang.String serialNumber, Model model)
          Loads a Device from the DB based on the Serial Number and the Model
static Location loadLocation(Context context, java.lang.String locationName, java.lang.String locationLine1, java.lang.String city, java.lang.String postalCode, java.lang.String stateOrProvince, java.lang.String country)
          Load a location by a combination of parameters.
static Model loadModel(Context context, java.lang.String modelName)
          Loads a model from the DB based on the model name.
static Organization loadOrganization(Context context, java.lang.String name)
          Loads an organization from the DB based on the organization name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SDKFacade

public SDKFacade()
Method Detail

createModel

public static Model createModel(Context context,
                                java.lang.String modelName)
Creates a new SDK Model with the supplied name, then retrieves it from the DB and returns the persisted instance of the Model.

Parameters:
context - Valid SDK Context
modelName - The name of the Model
Returns:
The persisted copy of the Model from the DB

loadModel

public static Model loadModel(Context context,
                              java.lang.String modelName)
Loads a model from the DB based on the model name.

Parameters:
context - Valid SDK Context
modelName - The name of the Model to load
Returns:
The persisted copy of the Model from the DB

createDevice

public static Device createDevice(Context context,
                                  java.lang.String serialNumber,
                                  Model model)
Creates a new SDK Device with the supplied serialnumber and model, then retrieves it from the DB and returns the persisted instance of the Device.

Parameters:
context - Valid SDk Context
serialNumber - The Serial Number for the Device
model - A persisted SDK Model
Returns:
The persisted copy of the Device from the DB

loadDevice

public static Device loadDevice(Context context,
                                java.lang.String serialNumber,
                                Model model)
Loads a Device from the DB based on the Serial Number and the Model

Parameters:
context - Valid SDK Context
serialNumber - The Serial Number of the Device
model - The persisted copy of the Model for this Device
Returns:
The persisted copy of the Device from the DB

loadDevice

public static Device loadDevice(Context context,
                                Identifier id)
Loads a Device from the DB based on the Serial Number and the Model

Parameters:
context - Valid SDK Context
id - The ID of the Device
Returns:
The persisted copy of the Device from the DB

createLocation

public static Location createLocation(Context context,
                                      java.lang.String locationName,
                                      java.lang.String locationLine1,
                                      java.lang.String locationLine2,
                                      java.lang.String city,
                                      java.lang.String stateOrProvince,
                                      java.lang.String postalCode,
                                      java.lang.String country,
                                      boolean persist)
Create an IN-MEMORY or PERSISTED location. You cannot persist a location and pass it into a new Organization() call. To do so will yield an exception. To pass a Location into a new Organization, you must use an in-memory copy. If this location is to be used in another way then it should be persisted, and returned. If the @persist attribute is set to true, this Location will be persisted, and the DB version of this class will be returned. Otherwise, an in memory copy will be returned which is safe to use when creating a new Organization.

Parameters:
context - Valid SDK Context
locationName - Name of the location
locationLine1 - First address line
locationLine2 - Second address line
city - The city of the location
stateOrProvince - The state or province of the location
postalCode - The postalCode for the location
country - The country for the location
persist - True is this location should be persisted, false if this location should be returned as an in-memory only (used when creating a new Organization)
Returns:
Either an in-memory Location or a persisted DB Location

loadLocation

public static Location loadLocation(Context context,
                                    java.lang.String locationName,
                                    java.lang.String locationLine1,
                                    java.lang.String city,
                                    java.lang.String postalCode,
                                    java.lang.String stateOrProvince,
                                    java.lang.String country)
Load a location by a combination of parameters. The name parameter is required If any of the other parameters are left blank, the search will not use them. If this search returns more than one result, only the first result found will be returned.

Parameters:
context - Valid SDK Context
locationName - Name of the location
locationLine1 - First address line
city - The city of the location
postalCode - The postalCode for the location
stateOrProvince - The state or province of the location
country - The country for the location
Returns:
The persisted copy of the Location from the DB

createNewOrganization

public static Organization createNewOrganization(Context context,
                                                 java.lang.String name,
                                                 Location location)
Creates a new Organization in the DB, with the given name and a new Location (cannot have been persisted)

Parameters:
context - Valid SDK Context
name - The Organization name
location - A in-Memory non-persisted Location
Returns:
The persisted copy of the Organization from the DB

loadOrganization

public static Organization loadOrganization(Context context,
                                            java.lang.String name)
Loads an organization from the DB based on the organization name

Parameters:
context - Valid SDK Context
name - The organization name, cannot be null
Returns:
Persisted copy of the Organization from the DB

findCurrentDataItemValue

public static DataValue findCurrentDataItemValue(Context context,
                                                 Device device,
                                                 java.lang.String dataItemName)
Returns the currentDataValue for a given Device and DataItemName. This can then be used to get the format of Data that you want, either String, boolean, double, long and int

Parameters:
context - Valid SDK Context
device - Valid Device (must have been loaded from DB)
dataItemName - Name of a DataItem which exists for the given Device
Returns:
DataValue object representing the current value for this DataItem

findHistoricalDataItemValue

public static DataValueList findHistoricalDataItemValue(Context context,
                                                        Device device,
                                                        java.lang.String dataItemName)
Returns the currentDataValue for a given Device and DataItemName. This can then be used to get the format of Data that you want, either String, boolean, double, long and int

Parameters:
context - Valid SDK Context
device - Valid Device (must have been loaded from DB)
dataItemName - Name of a DataItem which exists for the given Device
Returns:
DataValueList which contains all of the historical DataValues for the given DataItem

loadDataItem

public static DataItem loadDataItem(Context context,
                                    Model model,
                                    java.lang.String dataItemName)
Lookup a DataItem from the database for a specific model and dataitem name

Parameters:
context - Valid SDK Context
model - A persisted Model from the DB
dataItemName - The name of the Data Item to load from the DB
Returns:
The DataItem object from the DB