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 committed Sep 2, 2024
1 parent 7d9abe0 commit e24093d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
9 changes: 9 additions & 0 deletions packages/catalog-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
<name>catalog-generator</name>
<description>A Camel Catalog generator for Kaoto.</description>
<url>https://kaoto.io</url>
<repositories>
<repository>
<id>apache.snapshots</id>
<url>https://repository.apache.org/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<properties>
<compiler-plugin.version>3.13.0</compiler-plugin.version>
<maven.compiler.release>21</maven.compiler.release>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@
*/
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;
Expand All @@ -52,7 +52,7 @@ public class CamelCatalogProcessor {
private 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 e24093d

Please sign in to comment.