use of org.eclipse.ditto.things.model.signals.events.ThingEvent in project ditto by eclipse.
the class RetrieveAttributeStrategy method getAttributeValueResult.
private Result<ThingEvent<?>> getAttributeValueResult(final JsonObject attributes, final ThingId thingId, final RetrieveAttribute command, @Nullable final Thing thing) {
final JsonPointer attributePointer = command.getAttributePointer();
final DittoHeaders dittoHeaders = command.getDittoHeaders();
return attributes.getValue(attributePointer).map(value -> RetrieveAttributeResponse.of(thingId, attributePointer, value, dittoHeaders)).<Result<ThingEvent<?>>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))).orElseGet(() -> ResultFactory.newErrorResult(ExceptionFactory.attributeNotFound(thingId, attributePointer, dittoHeaders), command));
}
use of org.eclipse.ditto.things.model.signals.events.ThingEvent in project ditto by eclipse.
the class RetrieveFeatureDefinitionStrategy method getFeatureDefinition.
private Result<ThingEvent<?>> getFeatureDefinition(final Feature feature, final ThingId thingId, final RetrieveFeatureDefinition command, @Nullable final Thing thing) {
final String featureId = feature.getId();
final DittoHeaders dittoHeaders = command.getDittoHeaders();
return feature.getDefinition().map(featureDefinition -> RetrieveFeatureDefinitionResponse.of(thingId, featureId, featureDefinition, dittoHeaders)).<Result<ThingEvent<?>>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))).orElseGet(() -> ResultFactory.newErrorResult(ExceptionFactory.featureDefinitionNotFound(thingId, featureId, dittoHeaders), command));
}
use of org.eclipse.ditto.things.model.signals.events.ThingEvent in project ditto by eclipse.
the class RetrieveFeatureDefinitionStrategy method doApply.
@Override
protected Result<ThingEvent<?>> doApply(final Context<ThingId> context, @Nullable final Thing thing, final long nextRevision, final RetrieveFeatureDefinition command, @Nullable final Metadata metadata) {
final ThingId thingId = context.getState();
final String featureId = command.getFeatureId();
return extractFeature(command, thing).map(feature -> getFeatureDefinition(feature, thingId, command, thing)).orElseGet(() -> ResultFactory.newErrorResult(ExceptionFactory.featureNotFound(thingId, featureId, command.getDittoHeaders()), command));
}
use of org.eclipse.ditto.things.model.signals.events.ThingEvent in project ditto by eclipse.
the class RetrieveFeatureDesiredPropertiesStrategy method getFeatureDesiredProperties.
private Result<ThingEvent<?>> getFeatureDesiredProperties(final Feature feature, final ThingId thingId, final RetrieveFeatureDesiredProperties command, @Nullable final Thing thing) {
final String featureId = feature.getId();
final DittoHeaders dittoHeaders = command.getDittoHeaders();
return feature.getDesiredProperties().map(desiredProperties -> getFeatureDesiredPropertiesJson(desiredProperties, command)).map(desiredPropertiesJson -> RetrieveFeatureDesiredPropertiesResponse.of(thingId, featureId, desiredPropertiesJson, dittoHeaders)).<Result<ThingEvent<?>>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))).orElseGet(() -> ResultFactory.newErrorResult(ExceptionFactory.featureDesiredPropertiesNotFound(thingId, featureId, dittoHeaders), command));
}
use of org.eclipse.ditto.things.model.signals.events.ThingEvent in project ditto by eclipse.
the class RetrieveFeaturePropertiesStrategy method getFeatureProperties.
private Result<ThingEvent<?>> getFeatureProperties(final Feature feature, final ThingId thingId, final RetrieveFeatureProperties command, @Nullable final Thing thing) {
final String featureId = feature.getId();
final DittoHeaders dittoHeaders = command.getDittoHeaders();
return feature.getProperties().map(featureProperties -> getFeaturePropertiesJson(featureProperties, command)).map(featurePropertiesJson -> RetrieveFeaturePropertiesResponse.of(thingId, featureId, featurePropertiesJson, dittoHeaders)).<Result<ThingEvent<?>>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))).orElseGet(() -> ResultFactory.newErrorResult(ExceptionFactory.featurePropertiesNotFound(thingId, featureId, dittoHeaders), command));
}
Aggregations