Skip to content

Commit

Permalink
Fix logging and comments
Browse files Browse the repository at this point in the history
Signed-off-by: Yannic Klem <Yannic.Klem@bosch.io>
  • Loading branch information
Yannic92 committed Mar 7, 2022
1 parent 9068d3f commit 20cf2b9
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,26 @@ private static List<String> resolveIdPlaceholder(final Signal<?> signal) {
private static List<String> resolveFeatureIds(final JsonPointer path, final JsonValue value) {
final List<String> featureIds;
if (path.isEmpty()) {
// MergeThing is related to the full thing. We can expect value to be a Thing JSON
// Signal is related to the full thing. We can expect value to be a Thing JSON
if (value.isObject()) {
final Thing thing = ThingsModelFactory.newThing(value.asObject());
featureIds = thing.getFeatures()
.map(features -> features.stream().map(Feature::getId).collect(Collectors.toList()))
.orElseGet(List::of);
} else {
LOGGER.info("MergeThing command had empty path but non-object value. " +
"Can't resolve placeholder <feature:id>.");
LOGGER.info("Signal had empty path but non-object value. Can't resolve placeholder <feature:id>.");
featureIds = List.of();
}
} else if (path.get(0).map(JsonKey::toString).filter("features"::equals).isEmpty()) {
// MergeThing is not related to features therefore stop resolving.
// Signal is not related to features therefore stop resolving.
featureIds = List.of();
} else if (path.getLevelCount() > 1) {
// MergeThing is not related to a specific feature therefore use this feature ID.
// Signal is not related to a specific feature therefore use this feature ID.
featureIds = path.get(1).map(JsonKey::toString)
.stream()
.toList();
} else {
// MergeThing is related to features. Therefore use all of the modified feature IDs.
// Signal is related to features. Therefore use all of the modified feature IDs.
if (value.isObject()) {
featureIds = ThingsModelFactory.newFeatures(value.asObject())
.stream()
Expand Down

0 comments on commit 20cf2b9

Please sign in to comment.