public List<SessionPropertyValue> getAllSessionProperties( Session session, Map<String, ConnectorId> catalogs) { requireNonNull(session, "session is null"); ImmutableList.Builder<SessionPropertyValue> sessionPropertyValues = ImmutableList.builder(); Map<String, String> systemProperties = session.getSystemProperties(); for (PropertyMetadata<?> property : systemSessionProperties.values()) { String defaultValue = firstNonNull(property.getDefaultValue(), "").toString(); String value = systemProperties.getOrDefault(property.getName(), defaultValue); sessionPropertyValues.add( new SessionPropertyValue( value, defaultValue, property.getName(), Optional.empty(), property.getName(), property.getDescription(), property.getSqlType().getDisplayName(), property.isHidden())); } for (Entry<String, ConnectorId> entry : new TreeMap<>(catalogs).entrySet()) { String catalog = entry.getKey(); ConnectorId connectorId = entry.getValue(); Map<String, String> connectorProperties = session.getConnectorProperties(connectorId); for (PropertyMetadata<?> property : new TreeMap<>(connectorSessionProperties.get(connectorId)).values()) { String defaultValue = firstNonNull(property.getDefaultValue(), "").toString(); String value = connectorProperties.getOrDefault(property.getName(), defaultValue); sessionPropertyValues.add( new SessionPropertyValue( value, defaultValue, catalog + "." + property.getName(), Optional.of(catalog), property.getName(), property.getDescription(), property.getSqlType().getDisplayName(), property.isHidden())); } } return sessionPropertyValues.build(); }
private SessionProperty(Optional<String> catalogName, PropertyMetadata<T> propertyMetadata) { this.catalogName = catalogName; this.propertyName = propertyMetadata.getName(); String fullName = propertyMetadata.getName(); if (catalogName.isPresent()) { fullName = catalogName.get() + "." + fullName; } this.propertyMetadata = new PropertyMetadata<>( fullName, propertyMetadata.getDescription(), propertyMetadata.getSqlType(), propertyMetadata.getJavaType(), propertyMetadata.getDefaultValue(), propertyMetadata.isHidden(), propertyMetadata::decode); }