本文整理汇总了Java中org.edgexfoundry.domain.core.Reading.getId方法的典型用法代码示例。如果您正苦于以下问题:Java Reading.getId方法的具体用法?Java Reading.getId怎么用?Java Reading.getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.edgexfoundry.domain.core.Reading
的用法示例。
在下文中一共展示了Reading.getId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
/**
* Add a new reading. ServiceException (HTTP 503) for unknown or unanticipated issues.
* DataValidationException if the associated value descriptor is non-existent.
*
* @param reading - Reading object
* @return String id (database id) of the new Reading
* @throws ServiceException (HTTP 503) for unknown or unanticipated issues
* @throws DataValidationException (HTTP 409) if one of the readings associated to the new event
* contains a non-existent value descriptor.
*/
@RequestMapping(method = RequestMethod.POST)
@Override
public String add(@RequestBody Reading reading) {
if (valDescRepos.findByName(reading.getName()) == null)
throw new DataValidationException("Non-existent value descriptor specified in reading");
try {
if (persistData) {
readingRepos.save(reading);
} else
reading.setId("unsaved");
return reading.getId();
} catch (Exception e) {
logger.error("Error adding reading: " + e.getMessage());
throw new ServiceException(e);
}
}
示例2: setup
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
@Before
public void setup() {
ValueDescriptor valDesc = ValueDescriptorData.newTestInstance();
valDescRepos.save(valDesc);
Reading reading = ReadingData.newTestInstance();
readingRepos.save(reading);
testReadingId = reading.getId();
assertNotNull("Saved Reading does not have an id", testReadingId);
List<Reading> readings = new ArrayList<Reading>();
readings.add(reading);
Event event = EventData.newTestInstance();
event.setReadings(readings);
event.setOrigin(TEST_ORIGIN);
assertTrue("Reading device not the same as Event device or not set at all",
reading.getDevice().equals(event.getDevice()));
repos.save(event);
testEventId = event.getId();
assertNotNull("Saved Event does not have an id", testEventId);
}
示例3: setup
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
injectDAOwithTemplate();
Event event = new Event(TEST_DEVICE_ID, null);
event.setOrigin(TEST_ORIGIN);
Reading reading1 = new Reading(TEST_NAME1, TEST_VALUE1);
reading1.setOrigin(TEST_ORIGIN);
event.addReading(reading1);
Reading reading2 = new Reading(TEST_NAME2, TEST_VALUE2);
reading2.setOrigin(TEST_ORIGIN);
event.addReading(reading2);
event.markPushed(TEST_PUSHED);
readingRepos.save(reading1);
testReadingId1 = reading1.getId();
readingRepos.save(reading2);
testReadingId2 = reading2.getId();
eventRepos.save(event);
testEventId = event.getId();
assertNotNull("new test event has no identifier", testEventId);
}
示例4: update
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
/**
* Update the reading. NotFoundException (HTTP 404) if the reading cannot be found by id.
* ServiceException (HTTP 503) for unknown or unanticipated issues. DataValidationException if the
* associated value descriptor is non-existent.
*
* @param reading2 - Reading object containing update data and the id of the reading to be updated
* @return boolean indicating success of the update operation
* @throws ServiceException (HTTP 503) for unknown or unanticipated issues
* @throws DataValidationException (HTTP 409) if one of the readings associated to the new event
* contains a non-existent value descriptor.
* @throws NotFoundException (HTTP 404) if the reading cannot be located by the provided id in the
* reading.
*/
@RequestMapping(method = RequestMethod.PUT)
@Override
public boolean update(@RequestBody Reading reading2) {
try {
Reading reading = readingRepos.findOne(reading2.getId());
if (reading != null) {
if (reading2.getValue() != null) {
reading.setValue(reading2.getValue());
}
if (reading2.getName() != null) {
if (valDescRepos.findByName(reading2.getName()) == null)
throw new DataValidationException("Non-existent value descriptor specified in reading");
reading.setName(reading2.getName());
}
if (reading2.getOrigin() != 0) {
reading.setOrigin(reading2.getOrigin());
}
readingRepos.save(reading);
return true;
} else {
logger.error("Request to update with non-existent reading: " + reading2.getId());
throw new NotFoundException(Reading.class.toString(), reading2.getId());
}
} catch (DataValidationException dE) {
throw dE;
} catch (NotFoundException nE) {
throw nE;
} catch (Exception e) {
logger.error("Error updating reading: " + e.getMessage());
throw new ServiceException(e);
}
}
示例5: setup
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
@Before
public void setup() {
ValueDescriptor valDesc = ValueDescriptorData.newTestInstance();
valDesc.setOrigin(TEST_ORIGIN);
valDescRepos.save(valDesc);
Reading reading = newTestInstance();
reading.setOrigin(TEST_ORIGIN);
repos.save(reading);
testReadingId = reading.getId();
assertNotNull("Saved Reading does not have an id", testReadingId);
}
示例6: setup
import org.edgexfoundry.domain.core.Reading; //导入方法依赖的package包/类
/**
* Create and save an instance of the Reading before each test Note: the before method tests the
* save operation of the Repository
*/
@Before
public void setup() {
Reading reading = new Reading(TEST_NAME, TEST_VALUE);
reading.setOrigin(TEST_ORIGIN);
reading.setPushed(TEST_PUSHED);
reading.setDevice(EventData.TEST_DEVICE_ID);
readingRepos.save(reading);
testReadingId = reading.getId();
assertNotNull("Saved Reading does not have an id", testReadingId);
}