Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) SiteWhere, LLC. All rights reserved. http://www.sitewhere.com
   *
   * The software in this package is published under the terms of the CPAL v1.0
   * license, a copy of which has been included with this distribution in the
   * LICENSE.txt file.
   */
  package com.sitewhere.device.event.processor;
  
 
Implementation of com.sitewhere.spi.device.event.processor.IInboundEventProcessor that attempts to store the inbound event request using device management APIs.

Author(s):
Derek
 
Static logger instance
 
 	private static Logger LOGGER = Logger.getLogger(DefaultEventStorageProcessor.class);
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see com.sitewhere.rest.model.device.event.processor.InboundEventProcessor#
 	 * onDeviceCommandResponseRequest(java.lang.String, java.lang.String,
 	 * com.sitewhere.spi.device.event.request.IDeviceCommandResponseCreateRequest)
 	 */
 	public void onDeviceCommandResponseRequest(String hardwareIdString originator,
 		IDeviceAssignment assignment = getCurrentAssignment(hardwareId);
 		SiteWhere.getServer().getDeviceManagement().addDeviceCommandResponse(assignment.getToken(), request);
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see com.sitewhere.rest.model.device.event.processor.InboundEventProcessor#
 	 * onDeviceMeasurementsCreateRequest(java.lang.String, java.lang.String,
 	 * com.sitewhere.spi.device.event.request.IDeviceMeasurementsCreateRequest)
 	 */
 	public void onDeviceMeasurementsCreateRequest(String hardwareIdString originator,
 		IDeviceAssignment assignment = getCurrentAssignment(hardwareId);
 		IDeviceMeasurements measurements =
 						request);
 		handleLinkResponseToInvocation(originatormeasurements.getId(), assignment);
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see com.sitewhere.rest.model.device.event.processor.InboundEventProcessor#
 	 * onDeviceLocationCreateRequest(java.lang.String, java.lang.String,
 	 * com.sitewhere.spi.device.event.request.IDeviceLocationCreateRequest)
 	 */
 	public void onDeviceLocationCreateRequest(String hardwareIdString originator,
 		IDeviceAssignment assignment = getCurrentAssignment(hardwareId);
 		IDeviceLocation location =
 				SiteWhere.getServer().getDeviceManagement().addDeviceLocation(assignment.getToken(), request);
 		handleLinkResponseToInvocation(originatorlocation.getId(), assignment);
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see com.sitewhere.rest.model.device.event.processor.InboundEventProcessor#
 	 * onDeviceAlertCreateRequest(java.lang.String, java.lang.String,
 	 * com.sitewhere.spi.device.event.request.IDeviceAlertCreateRequest)
 	 */
 	public void onDeviceAlertCreateRequest(String hardwareIdString originator,
 		IDeviceAssignment assignment = getCurrentAssignment(hardwareId);
 		IDeviceAlert alert =
				SiteWhere.getServer().getDeviceManagement().addDeviceAlert(assignment.getToken(), request);
		handleLinkResponseToInvocation(originatoralert.getId(), assignment);
	}

Get the current assignment or throw errors if it can not be resolved.

Parameters:
hardwareId
Returns:
Throws:
com.sitewhere.spi.SiteWhereException
		IDevice device = SiteWhere.getServer().getDeviceManagement().getDeviceByHardwareId(hardwareId);
		if (device == null) {
		}
		if (device.getAssignmentToken() == null) {
		}
	}

If an originator was assocaited with the event, create a com.sitewhere.spi.device.event.IDeviceCommandResponse that links back to the original invocation.

Parameters:
originator
eventId
assignment
Throws:
com.sitewhere.spi.SiteWhereException
	protected void handleLinkResponseToInvocation(String originatorString eventId,
			IDeviceAssignment assignmentthrows SiteWhereException {
		if ((originator != null) && (!originator.isEmpty())) {
			response.setOriginatingEventId(originator);
			response.setResponseEventId(eventId);
					response);
		}
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sitewhere.spi.server.lifecycle.ILifecycleComponent#getLogger()
	 */
	public Logger getLogger() {
		return ;
	}
New to GrepCode? Check out our FAQ X