Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/28751 remove metadata #680

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions ext/hivemq-edge-openapi-2024.8-SNAPSHOT.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5090,11 +5090,8 @@ components:
description: List of instructions to be applied to incoming data
items:
$ref: '#/components/schemas/Instruction'
metadata:
$ref: '#/components/schemas/Metadata'
required:
- instructions
- metadata
FirstUseInformation:
type: object
description: Information relating to the firstuse experience
Expand Down Expand Up @@ -5383,17 +5380,6 @@ components:
- destination
- filters
- maxQoS
Metadata:
type: object
description: Metadata for the whole mapping
properties:
destination:
$ref: '#/components/schemas/JsonNode'
source:
$ref: '#/components/schemas/JsonNode'
required:
- destination
- source
Metric:
type: object
description: List of result items that are returned by this endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,19 @@ public class FieldMappingModel {
@Schema(description = "List of instructions to be applied to incoming data")
private final @NotNull List<InstructionModel> instructions;

@JsonProperty(value = "metadata", required = true)
@Schema(description = "Metadata for the whole mapping")
private final @NotNull MetadataModel metadata;

public FieldMappingModel(
@JsonProperty(value = "instructions", required = true) final @NotNull List<InstructionModel> instructions,
@JsonProperty(value = "metadata", required = true) final @NotNull MetadataModel metadata) {
@JsonProperty(value = "instructions", required = true) final @NotNull List<InstructionModel> instructions) {
this.instructions = instructions;
this.metadata = metadata;
}

public @NotNull List<InstructionModel> getInstructions() {
return instructions;
}

public @NotNull MetadataModel getMetadata() {
return metadata;
}

public static FieldMappingModel from(final FieldMapping fieldMapping) {
if(fieldMapping == null) {
return null;
}
return new FieldMappingModel(
fieldMapping.getInstructions().stream().map(InstructionModel::from)
.collect(Collectors.toList()),
MetadataModel.from(fieldMapping.getMetaData()));
public static @NotNull FieldMappingModel from(final @NotNull FieldMapping fieldMapping) {
return new FieldMappingModel(fieldMapping.getInstructions()
.stream()
.map(InstructionModel::from)
.collect(Collectors.toList()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.hivemq.bootstrap.factories;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.hivemq.persistence.topicfilter.TopicFilterPersistence;
import org.jetbrains.annotations.NotNull;
import com.hivemq.mqtt.topic.tree.LocalTopicTree;
import com.hivemq.persistence.SingleWriterService;
Expand All @@ -24,9 +25,9 @@

public interface WritingServiceFactory {

@NotNull
InternalProtocolAdapterWritingService build(
@NotNull InternalProtocolAdapterWritingService build(
@NotNull ObjectMapper objectMapper,
@NotNull LocalTopicTree localTopicTree,
@NotNull SingleWriterService singleWriterService);
@NotNull SingleWriterService singleWriterService,
@NotNull TopicFilterPersistence topicFilterPersistence);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.hivemq.adapter.sdk.api.services.ProtocolAdapterMetricsService;
import com.hivemq.adapter.sdk.api.writing.WritingProtocolAdapter;
import com.hivemq.bootstrap.services.EdgeCoreFactoryService;
import com.hivemq.persistence.topicfilter.TopicFilterPersistence;
import org.jetbrains.annotations.NotNull;
import com.hivemq.mqtt.topic.tree.LocalTopicTree;
import com.hivemq.persistence.SingleWriterService;
Expand All @@ -39,17 +40,20 @@ public class WritingServiceProvider {
private final @NotNull ObjectMapper objectMapper;
private final @NotNull LocalTopicTree localTopicTree;
private final @NotNull SingleWriterService singleWriterService;
private final @NotNull TopicFilterPersistence topicFilterPersistence;

@Inject
public WritingServiceProvider(
final @NotNull EdgeCoreFactoryService edgeCoreFactoryService,
final @NotNull ObjectMapper objectMapper,
final @NotNull LocalTopicTree localTopicTree,
final @NotNull SingleWriterService singleWriterService) {
final @NotNull SingleWriterService singleWriterService,
final @NotNull TopicFilterPersistence topicFilterPersistence) {
this.edgeCoreFactoryService = edgeCoreFactoryService;
this.objectMapper = objectMapper;
this.localTopicTree = localTopicTree;
this.singleWriterService = singleWriterService;
this.topicFilterPersistence = topicFilterPersistence;
}

public @NotNull InternalProtocolAdapterWritingService get() {
Expand All @@ -59,7 +63,9 @@ public WritingServiceProvider(
}
return writingServiceFactory.build(objectMapper,
localTopicTree,
singleWriterService);
singleWriterService,
topicFilterPersistence
);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
package com.hivemq.configuration.entity.adapter.fieldmapping;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.jetbrains.annotations.NotNull;
import com.hivemq.persistence.mappings.fieldmapping.FieldMapping;
import com.hivemq.persistence.mappings.fieldmapping.Instruction;
import org.jetbrains.annotations.NotNull;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
Expand All @@ -33,45 +33,32 @@ public class FieldMappingEntity {
@XmlElement(name = "instruction")
private final @NotNull List<InstructionEntity> instructions;

@XmlElement(name = "metadata")
private final @NotNull MetadataEntity metaData;

//no arg constructor for JaxB
public FieldMappingEntity() {;
public FieldMappingEntity() {
instructions = new ArrayList<>();
metaData = new MetadataEntity();
}

public FieldMappingEntity(
final @NotNull List<InstructionEntity> instructions,
final @NotNull MetadataEntity metaData) {
final @NotNull List<InstructionEntity> instructions) {
this.instructions = instructions;
this.metaData = metaData;
}

public @NotNull List<InstructionEntity> getInstructions() {
return instructions;
}

public @NotNull MetadataEntity getMetaData() {
return metaData;
}

public static @NotNull FieldMappingEntity from(final @NotNull FieldMapping model) {
if (model == null) {
return null;
}
final List<InstructionEntity> fieldMappingEntityList =
model.getInstructions().stream().map(InstructionEntity::from).collect(Collectors.toList());
return new FieldMappingEntity(fieldMappingEntityList,
MetadataEntity.from(model.getMetaData()));
return new FieldMappingEntity(fieldMappingEntityList);
}

public @NotNull FieldMapping to(final @NotNull ObjectMapper mapper) {
final List<Instruction> instructions =
getInstructions().stream().map(InstructionEntity::to).collect(Collectors.toList());
return new FieldMapping(
instructions,
getMetaData().to(mapper));
return new FieldMapping(instructions);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,15 @@ public class FieldMapping {

private final @NotNull List<Instruction> instructions;

private final @NotNull Metadata metadata;


public FieldMapping(final List<Instruction> instructions, final Metadata metadata) {
public FieldMapping(final @NotNull List<Instruction> instructions) {
this.instructions = instructions;
this.metadata = metadata;
}

public @NotNull List<Instruction> getInstructions() {
return instructions;
}

public Metadata getMetaData() {
return metadata;
}

public static @NotNull FieldMapping fromModel(final @NotNull FieldMappingModel model) {
return new FieldMapping(
model.getInstructions().stream().map(Instruction::from).collect(Collectors.toList()),
Metadata.from(model.getMetadata()));
return new FieldMapping(model.getInstructions().stream().map(Instruction::from).collect(Collectors.toList()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.hivemq.persistence.topicfilter;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

Expand All @@ -38,5 +39,6 @@ public interface TopicFilterPersistence {
@NotNull
List<TopicFilter> getTopicFilters();

@NotNull TopicFilter getTag(@NotNull String filter);
@Nullable
TopicFilter getTopicFilter(@NotNull String filter);
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ private void loadPersistence() {
}

@Override
public @NotNull TopicFilter getTag(final @NotNull String filter) {
final TopicFilter topicFilter = filterToTopicFilter.get(filter);
if (topicFilter == null) {
throw new TagNotFoundException("TopicFilter for filter '" + filter + "' was not found in the persistence.");
}
return topicFilter;
public @NotNull TopicFilter getTopicFilter(final @NotNull String filter) {
return filterToTopicFilter.get(filter);
}
}
Loading