/** * Get available configuration properties. * * @param instance connector instance. * @return configuration properties. */ @Override protected final List<ConnConfProperty> getConnProperties(final ConnInstanceTO instance) { return ConnectorWizardBuilder.getBundle(instance, bundles).getProperties().stream(). map(key -> { ConnConfProperty property = new ConnConfProperty(); property.setSchema(key); instance.getConf(key.getName()).ifPresent(conf -> { if (conf.getValues() != null) { property.getValues().addAll(conf.getValues()); property.setOverridable(conf.isOverridable()); } }); if (property.getValues().isEmpty() && !key.getDefaultValues().isEmpty()) { property.getValues().addAll(key.getDefaultValues()); } return property; }).collect(Collectors.toList()); } }
@Override public ConnConfPropSchema build(final ConfigurationProperty property) { ConnConfPropSchema connConfPropSchema = new ConnConfPropSchema(); connConfPropSchema.setName(property.getName()); connConfPropSchema.setDisplayName(property.getDisplayName(property.getName())); connConfPropSchema.setHelpMessage(property.getHelpMessage(property.getName())); connConfPropSchema.setRequired(property.isRequired()); connConfPropSchema.setType(property.getType().getName()); connConfPropSchema.setOrder(((ConfigurationPropertyImpl) property).getOrder()); connConfPropSchema.setConfidential(property.isConfidential()); if (property.getValue() != null) { if (property.getValue().getClass().isArray()) { connConfPropSchema.getDefaultValues().addAll(Arrays.asList((Object[]) property.getValue())); } else if (property.getValue() instanceof Collection<?>) { connConfPropSchema.getDefaultValues().addAll((Collection<?>) property.getValue()); } else { connConfPropSchema.getDefaultValues().add(property.getValue()); } } return connConfPropSchema; }