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.marshaling;
 
Configurable helper class that allows com.sitewhere.rest.model.device.event.DeviceCommandInvocation model objects to be created from com.sitewhere.spi.device.event.IDeviceCommandInvocation SPI objects.

Author(s):
dadams
Static logger instance
	private static Logger LOGGER = Logger.getLogger(DeviceCommandInvocationMarshalHelper.class);

Indicates whether to include command information
	private boolean includeCommand = false;

Cache to prevent repeated command lookups
		this(false);
	}
	public DeviceCommandInvocationMarshalHelper(boolean includeCommand) {
		this. = includeCommand;
	}

Convert an com.sitewhere.spi.device.event.IDeviceCommandInvocation to a com.sitewhere.rest.model.device.event.DeviceCommandInvocation, populating command information if requested so the marshaled data includes it.

Parameters:
source
Returns:
Throws:
com.sitewhere.spi.SiteWhereException
		DeviceEvent.copy(sourceresult);
		result.setInitiator(source.getInitiator());
		result.setInitiatorId(source.getInitiatorId());
		result.setTarget(source.getTarget());
		result.setTargetId(source.getTargetId());
		result.setStatus(source.getStatus());
		if (isIncludeCommand()) {
			if ((source.getCommandToken() == null) || (source.getCommandToken().isEmpty())) {
				.warn("Device invocation is missing command token.");
				return result;
			}
			if (command == null) {
				IDeviceCommand found =
								source.getCommandToken());
				if (found == null) {
					.warn("Device invocation references a non-existent command token.");
					return result;
				}
				command = DeviceCommand.copy(found);
				.put(command.getToken(), command);
			}
			if (command != null) {
				result.setCommand(command);
				result.setAsHtml(CommandHtmlHelper.getHtml(result));
			}
		}
		return result;
	}
	public boolean isIncludeCommand() {
	}
	public void setIncludeCommand(boolean includeCommand) {
		this. = includeCommand;
	}
New to GrepCode? Check out our FAQ X