Search in sources :

Example 1 with AzureJavaSdkEntity

use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity in project azure-tools-for-java by Microsoft.

the class AzureSdkLibraryService method addClientLibs.

private static void addClientLibs(Map<String, AzureSdkServiceEntity> services) {
    getClientLibs().stream().sorted(Comparator.comparing(AzureJavaSdkEntity::getServiceName)).forEachOrdered(raw -> {
        final AzureSdkServiceEntity service = getOrCreateService(services, raw);
        for (final AzureSdkFeatureEntity feature : service.getContent()) {
            final boolean specified = Optional.ofNullable(feature.getClientSource()).filter(s -> s.getGroupId().equals(raw.getGroupId()) && s.getArtifactId().equals(raw.getArtifactId())).isPresent();
            final boolean sameFeatureName = trim(feature.getName()).equals(trim(raw.getDisplayName()));
            if (specified || sameFeatureName) {
                feature.getArtifacts().add(toSdkArtifactEntity(raw));
                return;
            }
        }
        // if no mapping feature found.
        final AzureSdkFeatureEntity feature = AzureSdkFeatureEntity.builder().name(raw.getDisplayName()).msdocs(raw.getMsdocsUrl()).artifacts(new ArrayList<>(Collections.singletonList(toSdkArtifactEntity(raw)))).build();
        service.getContent().add(feature);
    });
}
Also used : java.util(java.util) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) SneakyThrows(lombok.SneakyThrows) URL(java.net.URL) MappingIterator(com.fasterxml.jackson.databind.MappingIterator) StringUtils(org.apache.commons.lang3.StringUtils) Function(java.util.function.Function) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) AzureSdkAllowListEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkAllowListEntity) CacheEvict(com.microsoft.azure.toolkit.lib.common.cache.CacheEvict) YAMLMapper(com.fasterxml.jackson.dataformat.yaml.YAMLMapper) CacheManager(com.microsoft.azure.toolkit.lib.common.cache.CacheManager) Cacheable(com.microsoft.azure.toolkit.lib.common.cache.Cacheable) Preload(com.microsoft.azure.toolkit.lib.common.cache.Preload) Nonnull(javax.annotation.Nonnull) AzureSdkArtifactEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkArtifactEntity) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) ImmutableMap(com.google.common.collect.ImmutableMap) MalformedURLException(java.net.MalformedURLException) CsvMapper(com.fasterxml.jackson.dataformat.csv.CsvMapper) AzureJavaSdkEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CsvSchema(com.fasterxml.jackson.dataformat.csv.CsvSchema) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ExecutionException(java.util.concurrent.ExecutionException) Slf4j(lombok.extern.slf4j.Slf4j) AzureSdkFeatureEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity) AzureSdkServiceEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity) AzureJavaSdkEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity) AzureSdkServiceEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity) AzureSdkFeatureEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity)

Example 2 with AzureJavaSdkEntity

use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity in project azure-tools-for-java by Microsoft.

the class AzureSdkLibraryService method addManagementLibs.

private static void addManagementLibs(Map<String, AzureSdkServiceEntity> services) {
    getManagementLibs().stream().sorted(Comparator.comparing(AzureJavaSdkEntity::getServiceName)).forEachOrdered(raw -> {
        final AzureSdkServiceEntity service = getOrCreateService(services, raw);
        for (final AzureSdkFeatureEntity feature : service.getContent()) {
            feature.setName(feature.getName().replace("Resource Management - ", "").trim());
            feature.getArtifacts().add(toSdkArtifactEntity(raw));
        }
    });
}
Also used : AzureJavaSdkEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity) AzureSdkServiceEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity) AzureSdkFeatureEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity)

Example 3 with AzureJavaSdkEntity

use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity in project azure-tools-for-java by Microsoft.

the class AzureSdkLibraryService method loadAzureSDKEntities.

public static List<AzureJavaSdkEntity> loadAzureSDKEntities(final URL destination) {
    try {
        final ObjectReader reader = CSV_MAPPER.readerFor(AzureJavaSdkEntity.class).with(CsvSchema.emptySchema().withHeader());
        final MappingIterator<AzureJavaSdkEntity> data = reader.readValues(destination);
        return data.readAll().stream().filter(e -> StringUtils.isNoneBlank(e.getArtifactId(), e.getGroupId())).collect(Collectors.toList());
    } catch (final IOException e) {
        log.warn(String.format("failed to load Azure SDK list from \"%s\"", destination.toString()), e);
    }
    return Collections.emptyList();
}
Also used : java.util(java.util) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) SneakyThrows(lombok.SneakyThrows) URL(java.net.URL) MappingIterator(com.fasterxml.jackson.databind.MappingIterator) StringUtils(org.apache.commons.lang3.StringUtils) Function(java.util.function.Function) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) AzureSdkAllowListEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkAllowListEntity) CacheEvict(com.microsoft.azure.toolkit.lib.common.cache.CacheEvict) YAMLMapper(com.fasterxml.jackson.dataformat.yaml.YAMLMapper) CacheManager(com.microsoft.azure.toolkit.lib.common.cache.CacheManager) Cacheable(com.microsoft.azure.toolkit.lib.common.cache.Cacheable) Preload(com.microsoft.azure.toolkit.lib.common.cache.Preload) Nonnull(javax.annotation.Nonnull) AzureSdkArtifactEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkArtifactEntity) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) ImmutableMap(com.google.common.collect.ImmutableMap) MalformedURLException(java.net.MalformedURLException) CsvMapper(com.fasterxml.jackson.dataformat.csv.CsvMapper) AzureJavaSdkEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CsvSchema(com.fasterxml.jackson.dataformat.csv.CsvSchema) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ExecutionException(java.util.concurrent.ExecutionException) Slf4j(lombok.extern.slf4j.Slf4j) AzureSdkFeatureEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity) AzureSdkServiceEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity) AzureJavaSdkEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) IOException(java.io.IOException)

Aggregations

AzureJavaSdkEntity (com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureJavaSdkEntity)3 AzureSdkFeatureEntity (com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkFeatureEntity)3 AzureSdkServiceEntity (com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity)3 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)2 MappingIterator (com.fasterxml.jackson.databind.MappingIterator)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)2 CsvMapper (com.fasterxml.jackson.dataformat.csv.CsvMapper)2 CsvSchema (com.fasterxml.jackson.dataformat.csv.CsvSchema)2 YAMLMapper (com.fasterxml.jackson.dataformat.yaml.YAMLMapper)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 AzureSdkAllowListEntity (com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkAllowListEntity)2 AzureSdkArtifactEntity (com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkArtifactEntity)2 CacheEvict (com.microsoft.azure.toolkit.lib.common.cache.CacheEvict)2 CacheManager (com.microsoft.azure.toolkit.lib.common.cache.CacheManager)2 Cacheable (com.microsoft.azure.toolkit.lib.common.cache.Cacheable)2 Preload (com.microsoft.azure.toolkit.lib.common.cache.Preload)2 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)2 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)2 IOException (java.io.IOException)2