use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity in project azure-tools-for-java by Microsoft.
the class AzureSdkTreePanel method loadData.
private void loadData(final Map<String, List<AzureSdkCategoryEntity>> categoryToServiceMap, final List<? extends AzureSdkServiceEntity> services, String... filters) {
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) this.model.getRoot();
root.removeAllChildren();
final Map<String, AzureSdkServiceEntity> serviceMap = services.stream().collect(Collectors.toMap(e -> getServiceKeyByName(e.getName()), e -> e));
final List<String> categories = categoryToServiceMap.keySet().stream().filter(StringUtils::isNotBlank).sorted((s1, s2) -> StringUtils.contains(s1, "Others") ? 1 : StringUtils.contains(s2, "Others") ? -1 : s1.compareTo(s2)).collect(Collectors.toList());
for (final String category : categories) {
// no feature found for current category
if (CollectionUtils.isEmpty(categoryToServiceMap.get(category)) || categoryToServiceMap.get(category).stream().allMatch(e -> Objects.isNull(serviceMap.get(getServiceKeyByName(e.getServiceName()))) || CollectionUtils.isEmpty(serviceMap.get(getServiceKeyByName(e.getServiceName())).getContent()))) {
continue;
}
// add features for current category
final MutableTreeNode categoryNode = new DefaultMutableTreeNode(category);
final boolean categoryMatched = this.isMatchedFilters(category, filters);
categoryToServiceMap.get(category).stream().sorted(Comparator.comparing(AzureSdkCategoryEntity::getServiceName)).forEach(categoryService -> {
final AzureSdkServiceEntity service = serviceMap.get(getServiceKeyByName(categoryService.getServiceName()));
this.loadServiceData(service, categoryService, categoryNode, filters);
});
if (ArrayUtils.isEmpty(filters) || categoryMatched || categoryNode.getChildCount() > 0) {
this.model.insertNodeInto(categoryNode, root, root.getChildCount());
}
}
this.model.reload();
if (ArrayUtils.isNotEmpty(filters)) {
TreeUtil.expandAll(this.tree);
}
TreeUtil.promiseSelectFirstLeaf(this.tree);
}
use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity 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);
});
}
use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity 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));
}
});
}
use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity in project azure-tools-for-java by Microsoft.
the class AzureSdkTreePanel method fillDescriptionFromCategoryIfMissing.
private void fillDescriptionFromCategoryIfMissing(final Map<String, List<AzureSdkCategoryEntity>> categoryToServiceMap, final List<? extends AzureSdkServiceEntity> services) {
final Map<String, AzureSdkServiceEntity> serviceMap = services.stream().collect(Collectors.toMap(e -> getServiceKeyByName(e.getName()), e -> e));
categoryToServiceMap.forEach((category, categoryServices) -> categoryServices.forEach(categoryService -> Optional.ofNullable(serviceMap.get(getServiceKeyByName(categoryService.getServiceName()))).ifPresent(service -> {
for (final AzureSdkFeatureEntity feature : service.getContent()) {
if (StringUtils.isBlank(feature.getDescription()) && StringUtils.isNotBlank(categoryService.getDescription())) {
feature.setDescription(categoryService.getDescription());
}
}
})));
}
use of com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkServiceEntity in project azure-tools-for-java by Microsoft.
the class AzureSdkLibraryService method loadSpringSDKEntities.
public static List<AzureSdkServiceEntity> loadSpringSDKEntities(final URL destination) {
try {
final ObjectReader reader = YML_MAPPER.readerFor(AzureSdkServiceEntity.class);
final MappingIterator<AzureSdkServiceEntity> data = reader.readValues(destination);
return data.readAll();
} catch (final IOException e) {
log.warn(String.format("failed to load Azure SDK list from \"%s\"", destination.toString()), e);
}
return Collections.emptyList();
}
Aggregations