checkDuplicateCommand(target, existing);
/** * Common logic for creating new device command and populating it from * request. * * @param request * @param token * @return * @throws SiteWhereException */ public static DeviceCommand deviceCommandCreateLogic(IDeviceSpecification spec, IDeviceCommandCreateRequest request, String token, List<IDeviceCommand> existing) throws SiteWhereException { DeviceCommand command = new DeviceCommand(); // Token is required. require(token); command.setToken(token); // Name is required. require(request.getName()); command.setName(request.getName()); command.setSpecificationToken(spec.getToken()); command.setNamespace(request.getNamespace()); command.setDescription(request.getDescription()); command.getParameters().addAll(request.getParameters()); checkDuplicateCommand(command, existing); MetadataProvider.copy(request.getMetadata(), command); SiteWherePersistence.initializeEntityMetadata(command); return command; }