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

fix(catalog-generator): Add "parameters" property #1371

Merged
merged 1 commit into from
Sep 3, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,44 @@
*/
package io.kaoto.camelcatalog.generator;

import java.io.InputStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.kaoto.camelcatalog.model.CatalogRuntime;
import org.apache.camel.catalog.CamelCatalog;
import org.apache.camel.tooling.model.ComponentModel;
import org.apache.camel.tooling.model.EipModel;
import org.apache.camel.tooling.model.JsonMapper;
import org.apache.camel.tooling.model.Kind;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import io.kaoto.camelcatalog.model.CatalogRuntime;
import java.io.InputStream;
import java.io.StringWriter;
import java.util.*;
import java.util.logging.Logger;

/**
* Customize Camel Catalog for Kaoto.
*/
public class CamelCatalogProcessor {
private static final Logger LOGGER = Logger.getLogger(CamelCatalogProcessor.class.getName());

private static final String TO_DYNAMIC_DEFINITION = "org.apache.camel.model.ToDynamicDefinition";
private static final List<String> PARAMETRIZED_PROCESSORS = List.of(

Check warning on line 39 in packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java

View check run for this annotation

Codecov / codecov/patch

packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java#L39

Added line #L39 was not covered by tests
"org.apache.camel.model.KameletDefinition",
"org.apache.camel.model.PollDefinition",
"org.apache.camel.model.ToDynamicDefinition",
"org.apache.camel.model.ToDefinition",
"org.apache.camel.model.WireTapDefinition"
);
private static final String SET_HEADERS_DEFINITION = "org.apache.camel.model.SetHeadersDefinition";
private static final String SET_VARIABLES_DEFINITION = "org.apache.camel.model.SetVariablesDefinition";
private final ObjectMapper jsonMapper;
private final CamelCatalog camelCatalog;
private final CamelYamlDslSchemaProcessor schemaProcessor;
private final CatalogRuntime runtime;
private boolean verbose;
private final boolean verbose;

public CamelCatalogProcessor(CamelCatalog camelCatalog, ObjectMapper jsonMapper,
CamelYamlDslSchemaProcessor schemaProcessor, CatalogRuntime runtime, boolean verbose) {
CamelYamlDslSchemaProcessor schemaProcessor, CatalogRuntime runtime, boolean verbose) {

Check warning on line 55 in packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java

View check run for this annotation

Codecov / codecov/patch

packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java#L55

Added line #L55 was not covered by tests
this.jsonMapper = jsonMapper;
this.camelCatalog = camelCatalog;
this.schemaProcessor = schemaProcessor;
Expand Down Expand Up @@ -115,7 +115,7 @@

componentDefinition.put("version", componentVersion);
if (componentVersion.contains("redhat")) {
componentDefinition.put("provider", "Red Hat");
componentDefinition.put("provider", "Red Hat");

Check warning on line 118 in packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java

View check run for this annotation

Codecov / codecov/patch

packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java#L118

Added line #L118 was not covered by tests
}

answer.set(name, catalogNode);
Expand Down Expand Up @@ -312,21 +312,19 @@

for (var propertyName : camelYamlDslProperties) {
var propertySchema = processorSchema.withObject("/properties").withObject("/" + propertyName);
if (TO_DYNAMIC_DEFINITION.equals(processorFQCN) && "parameters".equals(propertyName)) {
if ("parameters".equals(propertyName) && PARAMETRIZED_PROCESSORS.contains(processorFQCN)) {
// "parameters" as a common property is omitted in the catalog, but we need this
// for "toD"
// f.i. "toD" and "poll"
propertySchema.put("title", "Parameters");
propertySchema.put("description", "URI parameters");
sortedSchemaProperties.set(propertyName, propertySchema);
continue;
}
if (SET_HEADERS_DEFINITION.equals((processorFQCN)) && "headers".equals(propertyName)) {
} else if (SET_HEADERS_DEFINITION.equals((processorFQCN)) && "headers".equals(propertyName)) {
propertySchema.put("title", "Headers");
propertySchema.put("description", "Headers to set");
sortedSchemaProperties.set(propertyName, propertySchema);
continue;
}
if (SET_VARIABLES_DEFINITION.equals((processorFQCN)) && "variables".equals(propertyName)) {
} else if (SET_VARIABLES_DEFINITION.equals((processorFQCN)) && "variables".equals(propertyName)) {
propertySchema.put("title", "Variables");
propertySchema.put("description", "Variables to set");
sortedSchemaProperties.set(propertyName, propertySchema);
Expand Down
Loading