Skip to content

Commit

Permalink
Extend signal enrichment facade for search update; fix interpretation…
Browse files Browse the repository at this point in the history
… of delete events.

Signed-off-by: Yufei Cai <yufei.cai@bosch.io>
  • Loading branch information
yufei-cai committed Aug 20, 2021
1 parent e3570ac commit 75ae753
Show file tree
Hide file tree
Showing 45 changed files with 565 additions and 126 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,27 @@

import javax.annotation.Nonnull;

import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonPointer;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.base.model.entity.metadata.Metadata;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.things.model.ThingId;
import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.base.model.signals.events.Event;
import org.eclipse.ditto.base.model.signals.events.EventsourcedEvent;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonPointer;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.protocol.Adaptable;
import org.eclipse.ditto.protocol.adapter.DittoProtocolAdapter;
import org.eclipse.ditto.protocol.EventsTopicPathBuilder;
import org.eclipse.ditto.protocol.LiveTwinTest;
import org.eclipse.ditto.protocol.Payload;
import org.eclipse.ditto.protocol.adapter.ProtocolAdapterTest;
import org.eclipse.ditto.protocol.TestConstants;
import org.eclipse.ditto.protocol.TopicPath;
import org.eclipse.ditto.protocol.TopicPathBuilder;
import org.eclipse.ditto.protocol.UnknownEventException;
import org.eclipse.ditto.base.model.signals.events.Event;
import org.eclipse.ditto.base.model.signals.events.EventsourcedEvent;
import org.eclipse.ditto.protocol.adapter.DittoProtocolAdapter;
import org.eclipse.ditto.protocol.adapter.ProtocolAdapterTest;
import org.eclipse.ditto.things.model.ThingId;
import org.eclipse.ditto.things.model.signals.events.AttributeCreated;
import org.eclipse.ditto.things.model.signals.events.AttributeDeleted;
import org.eclipse.ditto.things.model.signals.events.AttributeModified;
Expand Down Expand Up @@ -1640,6 +1641,11 @@ public UnknownThingEvent setDittoHeaders(final DittoHeaders dittoHeaders) {
return this;
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.MODIFY;
}

@Nonnull
@Override
public String getManifest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public Thing getThing() {
}

@Override
public JsonValue getEntity(final JsonSchemaVersion schemaVersion) {
public JsonObject getEntity(final JsonSchemaVersion schemaVersion) {
return thing;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonFieldDefinition;
Expand Down Expand Up @@ -183,6 +184,11 @@ public AttributeCreated setDittoHeaders(final DittoHeaders dittoHeaders) {
dittoHeaders, getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.MODIFY;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonFieldDefinition;
Expand Down Expand Up @@ -154,6 +155,11 @@ public AttributeDeleted setDittoHeaders(final DittoHeaders dittoHeaders) {
getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.DELETE;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonFieldDefinition;
Expand Down Expand Up @@ -183,6 +184,11 @@ public AttributeModified setDittoHeaders(final DittoHeaders dittoHeaders) {
dittoHeaders, getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.MODIFY;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.entity.metadata.Metadata;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonParsableEvent;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.base.model.signals.events.EventJsonDeserializer;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonFieldDefinition;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonObjectBuilder;
import org.eclipse.ditto.json.JsonPointer;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.base.model.entity.metadata.Metadata;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonParsableEvent;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.things.model.Attributes;
import org.eclipse.ditto.things.model.ThingId;
import org.eclipse.ditto.things.model.ThingsModelFactory;
import org.eclipse.ditto.base.model.signals.events.EventJsonDeserializer;

/**
* This event is emitted after all {@code Attribute}s were created at once.
Expand Down Expand Up @@ -162,6 +163,11 @@ public AttributesCreated setDittoHeaders(final DittoHeaders dittoHeaders) {
getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.MODIFY;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonObject;
Expand Down Expand Up @@ -129,6 +130,11 @@ public AttributesDeleted setDittoHeaders(final DittoHeaders dittoHeaders) {
getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.DELETE;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonFieldDefinition;
Expand Down Expand Up @@ -163,6 +164,11 @@ public AttributesModified setDittoHeaders(final DittoHeaders dittoHeaders) {
getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.MODIFY;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonFieldDefinition;
Expand Down Expand Up @@ -176,6 +177,11 @@ public FeatureCreated setDittoHeaders(final DittoHeaders dittoHeaders) {
getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.MODIFY;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonArray;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
Expand Down Expand Up @@ -183,6 +184,11 @@ public FeatureDefinitionCreated setDittoHeaders(final DittoHeaders dittoHeaders)
getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.MODIFY;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonObject;
Expand Down Expand Up @@ -147,6 +148,11 @@ public FeatureDefinitionDeleted setDittoHeaders(final DittoHeaders dittoHeaders)
getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.DELETE;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonArray;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
Expand Down Expand Up @@ -182,6 +183,11 @@ public FeatureDefinitionModified setDittoHeaders(final DittoHeaders dittoHeaders
getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.MODIFY;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonObject;
Expand Down Expand Up @@ -147,6 +148,11 @@ public FeatureDeleted setDittoHeaders(final DittoHeaders dittoHeaders) {
getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.DELETE;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonFieldDefinition;
Expand All @@ -48,8 +49,7 @@
@Immutable
@JsonParsableEvent(name = FeatureDesiredPropertiesCreated.NAME, typePrefix = ThingEvent.TYPE_PREFIX)
public final class FeatureDesiredPropertiesCreated extends AbstractThingEvent<FeatureDesiredPropertiesCreated>
implements
ThingModifiedEvent<FeatureDesiredPropertiesCreated>, WithFeatureId {
implements ThingModifiedEvent<FeatureDesiredPropertiesCreated>, WithFeatureId {

/**
* Name of the "Feature Desired Properties Created" event.
Expand Down Expand Up @@ -193,6 +193,11 @@ public FeatureDesiredPropertiesCreated setDittoHeaders(final DittoHeaders dittoH
getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.MODIFY;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonObject;
Expand All @@ -42,8 +43,7 @@
@Immutable
@JsonParsableEvent(name = FeatureDesiredPropertiesDeleted.NAME, typePrefix = ThingEvent.TYPE_PREFIX)
public final class FeatureDesiredPropertiesDeleted extends AbstractThingEvent<FeatureDesiredPropertiesDeleted>
implements
ThingModifiedEvent<FeatureDesiredPropertiesDeleted>, WithFeatureId {
implements ThingModifiedEvent<FeatureDesiredPropertiesDeleted>, WithFeatureId {

/**
* Name of the "Feature Desired Properties Deleted" event.
Expand Down Expand Up @@ -152,6 +152,11 @@ public FeatureDesiredPropertiesDeleted setDittoHeaders(final DittoHeaders dittoH
getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.DELETE;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonFieldDefinition;
Expand All @@ -48,8 +49,7 @@
@Immutable
@JsonParsableEvent(name = FeatureDesiredPropertiesModified.NAME, typePrefix = ThingEvent.TYPE_PREFIX)
public final class FeatureDesiredPropertiesModified extends AbstractThingEvent<FeatureDesiredPropertiesModified>
implements
ThingModifiedEvent<FeatureDesiredPropertiesModified>, WithFeatureId {
implements ThingModifiedEvent<FeatureDesiredPropertiesModified>, WithFeatureId {

/**
* Name of the "Feature Desired Properties Modified" event.
Expand Down Expand Up @@ -188,6 +188,11 @@ public FeatureDesiredPropertiesModified setDittoHeaders(final DittoHeaders ditto
getMetadata().orElse(null));
}

@Override
public Command.Category getCommandCategory() {
return Command.Category.MODIFY;
}

@Override
protected void appendPayloadAndBuild(final JsonObjectBuilder jsonObjectBuilder,
final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) {
Expand Down
Loading

0 comments on commit 75ae753

Please sign in to comment.