Search in sources :

Example 1 with CamelKafkaConnectorModel

use of org.apache.camel.kafkaconnector.model.CamelKafkaConnectorModel in project camel-kafka-connector by apache.

the class CamelKafkaConnectorKameletUpdateMojo method writeJson.

private void writeJson(List<CamelKafkaConnectorOptionModel> options, String componentDescription, File connectorDir, ConnectorType ct, String connectorClass, List<String> convertersList, List<String> transformsList, List<String> aggregationStrategiesList) throws MojoExecutionException {
    CamelKafkaConnectorModel model = new CamelKafkaConnectorModel();
    model.setOptions(options);
    model.setArtifactId(getMainDepArtifactId());
    model.setGroupId(getMainDepGroupId());
    model.setVersion(getMainDepVersion());
    model.setDescription(componentDescription);
    model.setConnectorClass(connectorClass);
    model.setType(ct.name().toLowerCase());
    model.setConverters(convertersList);
    model.setTransforms(transformsList);
    model.setAggregationStrategies(aggregationStrategiesList);
    if (getMainDepArtifactId().equalsIgnoreCase("camel-coap+tcp")) {
        model.setTitle("camel-coap-tcp");
    } else if (getMainDepArtifactId().equalsIgnoreCase("camel-coaps+tcp")) {
        model.setTitle("camel-coaps-tcp");
    } else {
        model.setTitle(getMainDepArtifactId());
    }
    File docFolder = new File(connectorDir, "src/generated/resources/");
    File docFile = new File(docFolder, getMainDepArtifactId() + "-" + ct.name().toLowerCase() + ".json");
    JsonObject j = JsonMapperKafkaConnector.asJsonObject(model);
    updateFile(docFile, Jsoner.prettyPrint(j.toJson()));
}
Also used : CamelKafkaConnectorModel(org.apache.camel.kafkaconnector.model.CamelKafkaConnectorModel) JsonObject(org.apache.camel.util.json.JsonObject) File(java.io.File)

Example 2 with CamelKafkaConnectorModel

use of org.apache.camel.kafkaconnector.model.CamelKafkaConnectorModel in project camel-kafka-connector by apache.

the class CamelKafkaConnectorUpdateMojo method writeJson.

private void writeJson(List<CamelKafkaConnectorOptionModel> options, String componentDescription, File connectorDir, ConnectorType ct, String connectorClass, List<String> convertersList, List<String> transformsList, List<String> aggregationStrategiesList) throws MojoExecutionException {
    CamelKafkaConnectorModel model = new CamelKafkaConnectorModel();
    model.setOptions(options);
    model.setArtifactId(getMainDepArtifactId());
    model.setGroupId(getMainDepGroupId());
    model.setVersion(getMainDepVersion());
    model.setDescription(componentDescription);
    model.setConnectorClass(connectorClass);
    model.setType(ct.name().toLowerCase());
    model.setConverters(convertersList);
    model.setTransforms(transformsList);
    model.setAggregationStrategies(aggregationStrategiesList);
    if (getMainDepArtifactId().equalsIgnoreCase("camel-coap+tcp")) {
        model.setTitle("camel-coap-tcp");
    } else if (getMainDepArtifactId().equalsIgnoreCase("camel-coaps+tcp")) {
        model.setTitle("camel-coaps-tcp");
    } else {
        model.setTitle(getMainDepArtifactId());
    }
    File docFolder = new File(connectorDir, "src/generated/resources/");
    File docFile = new File(docFolder, getMainDepArtifactId() + "-" + ct.name().toLowerCase() + ".json");
    JsonObject j = JsonMapperKafkaConnector.asJsonObject(model);
    updateFile(docFile, Jsoner.prettyPrint(j.toJson()));
}
Also used : CamelKafkaConnectorModel(org.apache.camel.kafkaconnector.model.CamelKafkaConnectorModel) JsonObject(org.apache.camel.util.json.JsonObject) File(java.io.File)

Example 3 with CamelKafkaConnectorModel

use of org.apache.camel.kafkaconnector.model.CamelKafkaConnectorModel in project camel-kafka-connector by apache.

the class CamelKafkaConnectorCatalog method createModel.

private CamelKafkaConnectorModel createModel(String json) {
    CamelKafkaConnectorModel model = new CamelKafkaConnectorModel();
    JsonObject obj = JsonMapper.deserialize(json);
    JsonObject wrapper = (JsonObject) obj.get("connector");
    model.setConnectorClass((String) wrapper.get("class"));
    model.setArtifactId((String) wrapper.get("artifactId"));
    model.setGroupId((String) wrapper.get("groupId"));
    model.setType((String) wrapper.get("type"));
    model.setVersion((String) wrapper.get("version"));
    model.setDescription((String) wrapper.get("description"));
    model.setOptions(getConnectorOptionModel(obj));
    if (obj.get("aggregationStrategies") != null) {
        model.setAggregationStrategies((List<String>) obj.get("aggregationStrategies"));
    }
    if (obj.get("converters") != null) {
        model.setConverters((List<String>) obj.get("converters"));
    }
    if (obj.get("transforms") != null) {
        model.setTransforms((List<String>) obj.get("transforms"));
    }
    return model;
}
Also used : CamelKafkaConnectorModel(org.apache.camel.kafkaconnector.model.CamelKafkaConnectorModel) JsonObject(org.apache.camel.util.json.JsonObject)

Example 4 with CamelKafkaConnectorModel

use of org.apache.camel.kafkaconnector.model.CamelKafkaConnectorModel in project camel-kafka-connector by apache.

the class CamelKafkaConnectorCatalogTest method testCouchbaseOptions.

@Test
void testCouchbaseOptions() throws Exception {
    Map<String, CamelKafkaConnectorModel> p = catalog.getConnectorsModel();
    CamelKafkaConnectorModel model = p.get("camel-aws2-iam-sink");
    assertEquals("org.apache.camel.kafkaconnector", model.getGroupId());
    assertEquals("sink", model.getType());
    assertEquals("org.apache.camel.kafkaconnector.aws2iam.CamelAws2iamSinkConnector", model.getConnectorClass());
    assertEquals("camel.sink.path.label", model.getOptions().get(0).getName());
    assertNull(model.getOptions().get(0).getDefaultValue());
    assertNull(model.getConverters());
    assertNull(model.getTransforms());
    assertNull(model.getAggregationStrategies());
}
Also used : CamelKafkaConnectorModel(org.apache.camel.kafkaconnector.model.CamelKafkaConnectorModel) Test(org.junit.jupiter.api.Test)

Aggregations

CamelKafkaConnectorModel (org.apache.camel.kafkaconnector.model.CamelKafkaConnectorModel)4 JsonObject (org.apache.camel.util.json.JsonObject)3 File (java.io.File)2 Test (org.junit.jupiter.api.Test)1