Skip to content

Commit

Permalink
fix(catalog-generator): Add "parameters" property
Browse files Browse the repository at this point in the history
Currently, the `parameters` property is only added for
`ToDynamicDefinition` EIP.

This represents a problem for Camel 4.8.0 since there's a new `poll` EIP
that requires it.
  • Loading branch information
lordrip authored and lhein committed Sep 3, 2024
1 parent 21b9b79 commit dc54036
Showing 1 changed file with 22 additions and 24 deletions.
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(
"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) {
this.jsonMapper = jsonMapper;
this.camelCatalog = camelCatalog;
this.schemaProcessor = schemaProcessor;
Expand Down Expand Up @@ -115,7 +115,7 @@ public String getComponentCatalog() throws Exception {

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

answer.set(name, catalogNode);
Expand Down Expand Up @@ -312,21 +312,19 @@ public String getPatternCatalog() throws Exception {

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

0 comments on commit dc54036

Please sign in to comment.