Search in sources :

Example 1 with EndpointOptionModel

use of org.apache.camel.maven.packaging.model.EndpointOptionModel in project camel by apache.

the class SpringBootAutoConfigurationMojo method generateComponentModel.

private static ComponentModel generateComponentModel(String componentName, String json) {
    List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("component", json, false);
    ComponentModel component = new ComponentModel(true);
    component.setScheme(getSafeValue("scheme", rows));
    component.setSyntax(getSafeValue("syntax", rows));
    component.setAlternativeSyntax(getSafeValue("alternativeSyntax", rows));
    component.setTitle(getSafeValue("title", rows));
    component.setDescription(getSafeValue("description", rows));
    component.setFirstVersion(JSonSchemaHelper.getSafeValue("firstVersion", rows));
    component.setLabel(getSafeValue("label", rows));
    component.setDeprecated(getSafeValue("deprecated", rows));
    component.setConsumerOnly(getSafeValue("consumerOnly", rows));
    component.setProducerOnly(getSafeValue("producerOnly", rows));
    component.setJavaType(getSafeValue("javaType", rows));
    component.setGroupId(getSafeValue("groupId", rows));
    component.setArtifactId(getSafeValue("artifactId", rows));
    component.setVersion(getSafeValue("version", rows));
    rows = JSonSchemaHelper.parseJsonSchema("componentProperties", json, true);
    for (Map<String, String> row : rows) {
        ComponentOptionModel option = new ComponentOptionModel();
        option.setName(getSafeValue("name", row));
        option.setDisplayName(getSafeValue("displayName", row));
        option.setKind(getSafeValue("kind", row));
        option.setType(getSafeValue("type", row));
        option.setJavaType(getSafeValue("javaType", row));
        option.setDeprecated(getSafeValue("deprecated", row));
        option.setDescription(getSafeValue("description", row));
        option.setDefaultValue(getSafeValue("defaultValue", row));
        option.setEnums(getSafeValue("enum", row));
        component.addComponentOption(option);
    }
    rows = JSonSchemaHelper.parseJsonSchema("properties", json, true);
    for (Map<String, String> row : rows) {
        EndpointOptionModel option = new EndpointOptionModel();
        option.setName(getSafeValue("name", row));
        option.setDisplayName(getSafeValue("displayName", row));
        option.setKind(getSafeValue("kind", row));
        option.setGroup(getSafeValue("group", row));
        option.setRequired(getSafeValue("required", row));
        option.setType(getSafeValue("type", row));
        option.setJavaType(getSafeValue("javaType", row));
        option.setEnums(getSafeValue("enum", row));
        option.setPrefix(getSafeValue("prefix", row));
        option.setMultiValue(getSafeValue("multiValue", row));
        option.setDeprecated(getSafeValue("deprecated", row));
        option.setDefaultValue(getSafeValue("defaultValue", row));
        option.setDescription(getSafeValue("description", row));
        option.setEnumValues(getSafeValue("enum", row));
        component.addEndpointOption(option);
    }
    return component;
}
Also used : EndpointOptionModel(org.apache.camel.maven.packaging.model.EndpointOptionModel) ComponentModel(org.apache.camel.maven.packaging.model.ComponentModel) Map(java.util.Map) HashMap(java.util.HashMap) ComponentOptionModel(org.apache.camel.maven.packaging.model.ComponentOptionModel)

Example 2 with EndpointOptionModel

use of org.apache.camel.maven.packaging.model.EndpointOptionModel in project camel by apache.

the class UpdateReadmeMojo method generateComponentModel.

private ComponentModel generateComponentModel(String componentName, String json) {
    List<Map<String, String>> rows = parseJsonSchema("component", json, false);
    ComponentModel component = new ComponentModel(true);
    component.setScheme(getSafeValue("scheme", rows));
    component.setSyntax(getSafeValue("syntax", rows));
    component.setAlternativeSyntax(getSafeValue("alternativeSyntax", rows));
    component.setAlternativeSchemes(getSafeValue("alternativeSchemes", rows));
    component.setTitle(getSafeValue("title", rows));
    component.setDescription(getSafeValue("description", rows));
    component.setFirstVersion(getSafeValue("firstVersion", rows));
    component.setLabel(getSafeValue("label", rows));
    component.setDeprecated(getSafeValue("deprecated", rows));
    component.setConsumerOnly(getSafeValue("consumerOnly", rows));
    component.setProducerOnly(getSafeValue("producerOnly", rows));
    component.setJavaType(getSafeValue("javaType", rows));
    component.setGroupId(getSafeValue("groupId", rows));
    component.setArtifactId(getSafeValue("artifactId", rows));
    component.setVersion(getSafeValue("version", rows));
    String oldGroup = null;
    rows = parseJsonSchema("componentProperties", json, true);
    for (Map<String, String> row : rows) {
        ComponentOptionModel option = new ComponentOptionModel();
        option.setName(getSafeValue("name", row));
        option.setDisplayName(getSafeValue("displayName", row));
        option.setKind(getSafeValue("kind", row));
        option.setGroup(getSafeValue("group", row));
        option.setRequired(getSafeValue("required", row));
        option.setType(getSafeValue("type", row));
        option.setJavaType(getSafeValue("javaType", row));
        option.setEnums(getSafeValue("enum", row));
        option.setDeprecated(getSafeValue("deprecated", row));
        option.setSecret(getSafeValue("secret", row));
        option.setDefaultValue(getSafeValue("defaultValue", row));
        option.setDescription(getSafeValue("description", row));
        // lets put required in the description
        if ("true".equals(option.getRequired())) {
            String desc = "*Required* " + option.getDescription();
            option.setDescription(desc);
        }
        component.addComponentOption(option);
        // group separate between different options
        if (oldGroup == null || !oldGroup.equals(option.getGroup())) {
            option.setNewGroup(true);
        }
        oldGroup = option.getGroup();
    }
    oldGroup = null;
    rows = parseJsonSchema("properties", json, true);
    for (Map<String, String> row : rows) {
        EndpointOptionModel option = new EndpointOptionModel();
        option.setName(getSafeValue("name", row));
        option.setDisplayName(getSafeValue("displayName", row));
        option.setKind(getSafeValue("kind", row));
        option.setGroup(getSafeValue("group", row));
        option.setRequired(getSafeValue("required", row));
        option.setType(getSafeValue("type", row));
        option.setJavaType(getSafeValue("javaType", row));
        option.setEnums(getSafeValue("enum", row));
        option.setPrefix(getSafeValue("prefix", row));
        option.setMultiValue(getSafeValue("multiValue", row));
        option.setDeprecated(getSafeValue("deprecated", row));
        option.setSecret(getSafeValue("secret", row));
        option.setDefaultValue(getSafeValue("defaultValue", row));
        option.setDescription(getSafeValue("description", row));
        // lets put required in the description
        if ("true".equals(option.getRequired())) {
            String desc = "*Required* " + option.getDescription();
            option.setDescription(desc);
        }
        // separate the options in path vs parameter so we can generate two different tables
        if ("path".equals(option.getKind())) {
            component.addEndpointPathOption(option);
        } else {
            component.addEndpointOption(option);
        }
        // group separate between different options
        if (oldGroup == null || !oldGroup.equals(option.getGroup())) {
            option.setNewGroup(true);
        }
        oldGroup = option.getGroup();
    }
    return component;
}
Also used : EndpointOptionModel(org.apache.camel.maven.packaging.model.EndpointOptionModel) ComponentModel(org.apache.camel.maven.packaging.model.ComponentModel) Map(java.util.Map) ComponentOptionModel(org.apache.camel.maven.packaging.model.ComponentOptionModel)

Aggregations

Map (java.util.Map)2 ComponentModel (org.apache.camel.maven.packaging.model.ComponentModel)2 ComponentOptionModel (org.apache.camel.maven.packaging.model.ComponentOptionModel)2 EndpointOptionModel (org.apache.camel.maven.packaging.model.EndpointOptionModel)2 HashMap (java.util.HashMap)1