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 DeviceAssignment model objects to be created from IDeviceAssignment SPI objects.

Author(s):
dadams
 
 public class DeviceAssignmentMarshalHelper {

Static logger instance
 
 	private static Logger LOGGER = Logger.getLogger(DeviceAssignmentMarshalHelper.class);

Indicates whether device asset information is to be included
 
 	private boolean includeAsset = true;

Indicates whether to include device information
 
 	private boolean includeDevice = false;

Indicates whether to include site information
 
 	private boolean includeSite = false;

Used to control marshaling of devices
 
Convert the SPI object into a model object for marshaling.

Parameters:
source
manager
Returns:
Throws:
com.sitewhere.spi.SiteWhereException
 
 			throws SiteWhereException {
 		DeviceAssignment result = new DeviceAssignment();
 		result.setToken(source.getToken());
 		result.setActiveDate(source.getActiveDate());
 		result.setReleasedDate(source.getReleasedDate());
 		result.setStatus(source.getStatus());
 		result.setAssetId(source.getAssetId());
 		MetadataProviderEntity.copy(sourceresult);
 		if (source.getState() != null) {
 			result.setState(DeviceAssignmentState.copy(source.getState()));
 		}
 			IAsset asset = manager.getAssetById(source.getAssetModuleId(), source.getAssetId());
 			if (isIncludeAsset() || (asset == null)) {
 				if (asset instanceof HardwareAsset) {
 				} else if (asset instanceof PersonAsset) {
 					result.setAssociatedPerson((PersonAssetasset);
 				} else if (asset instanceof LocationAsset) {
 				}
 			} else {
 				result.setAssetName(asset.getName());
 				result.setAssetImageUrl(asset.getImageUrl());
 			}
 		}
 		result.setSiteToken(source.getSiteToken());
 		if (isIncludeSite()) {
 			ISite site = SiteWhere.getServer().getDeviceManagement().getSiteForAssignment(source);
 			result.setSite(Site.copy(site));
 		}
 		if (isIncludeDevice()) {
 			IDevice device = SiteWhere.getServer().getDeviceManagement().getDeviceForAssignment(source);
 			if (device != null) {
 				result.setDevice(getDeviceHelper().convert(devicemanager));
 			} else {
 				.error("Assignment references invalid hardware id.");
			}
		}
		return result;
	}

Get the helper for marshaling device information.

Returns:
		if ( == null) {
		}
		return ;
	}
	public boolean isIncludeAsset() {
		return ;
	}
	public DeviceAssignmentMarshalHelper setIncludeAsset(boolean includeAsset) {
		this. = includeAsset;
		return this;
	}
	public boolean isIncludeDevice() {
	}
	public DeviceAssignmentMarshalHelper setIncludeDevice(boolean includeDevice) {
		this. = includeDevice;
		return this;
	}
	public boolean isIncludeSite() {
		return ;
	}
	public DeviceAssignmentMarshalHelper setIncludeSite(boolean includeSite) {
		this. = includeSite;
		return this;
	}
New to GrepCode? Check out our FAQ X