/* default */ static void addGlobalParameters(final Connector.Builder builder, final Swagger swagger) { final Map<String, Parameter> globalParameters = swagger.getParameters(); if (globalParameters != null) { globalParameters.forEach((name, parameter) -> { createPropertyFromParameter(parameter).ifPresent(property -> { builder.putProperty(name, property); }); }); } }
static void addGlobalParameters(final Connector.Builder builder, final Swagger swagger) { final Map<String, Parameter> globalParameters = swagger.getParameters(); if (globalParameters != null) { globalParameters.forEach((name, parameter) -> { createPropertyFromParameter(parameter).ifPresent(property -> { builder.putProperty(name, property); }); }); } }
protected final Connector basicConnector(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) { final Swagger swagger = parseSpecification(connectorSettings, false).getModel(); // could be either JSON of the Swagger specification or a URL to one final String specification = requiredSpecification(connectorSettings); if (specification.startsWith("http")) { swagger.vendorExtension(URL_EXTENSION, URI.create(specification)); } final Connector baseConnector = baseConnectorFrom(connectorTemplate, connectorSettings); final Connector.Builder builder = new Connector.Builder().createFrom(baseConnector); final Map<String, String> alreadyConfiguredProperties = builder.build().getConfiguredProperties(); connectorTemplate.getConnectorProperties().forEach((propertyName, template) -> { final Optional<ConfigurationProperty> maybeProperty = PropertyGenerators.createProperty(propertyName, swagger, template); maybeProperty.ifPresent(property -> { builder.putProperty(propertyName, property); if (!alreadyConfiguredProperties.containsKey(propertyName)) { final String defaultValue = property.getDefaultValue(); if (defaultValue != null) { builder.putConfiguredProperty(propertyName, defaultValue); } } }); }); return builder.build(); }
protected final Connector basicConnector(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) { final Swagger swagger = parseSpecification(connectorSettings, false).getModel(); // could be either JSON of the Swagger specification or a URL to one final String specification = requiredSpecification(connectorSettings); if (specification.startsWith("http")) { swagger.vendorExtension(URL_EXTENSION, URI.create(specification)); } final Connector baseConnector = baseConnectorFrom(connectorTemplate, connectorSettings); final Connector.Builder builder = new Connector.Builder().createFrom(baseConnector); final Map<String, String> alreadyConfiguredProperties = builder.build().getConfiguredProperties(); connectorTemplate.getConnectorProperties().forEach((propertyName, template) -> { final Optional<ConfigurationProperty> maybeProperty = PropertyGenerators.createProperty(propertyName, swagger, template); maybeProperty.ifPresent(property -> { builder.putProperty(propertyName, property); if (!alreadyConfiguredProperties.containsKey(propertyName)) { final String defaultValue = property.getDefaultValue(); if (defaultValue != null) { builder.putConfiguredProperty(propertyName, defaultValue); } } }); }); return builder.build(); }