diff --git a/src/dotnet/APIView/APIView/Model/CodeFile.cs b/src/dotnet/APIView/APIView/Model/CodeFile.cs index 3b3f2430d05..131785c5431 100644 --- a/src/dotnet/APIView/APIView/Model/CodeFile.cs +++ b/src/dotnet/APIView/APIView/Model/CodeFile.cs @@ -34,6 +34,8 @@ public string VersionString public string Language { get; set; } + public string LanguageVariant { get; set; } + public string PackageName { get; set; } public string ServiceName { get; set; } diff --git a/src/dotnet/APIView/APIViewWeb/Models/ReviewCodeFileModel.cs b/src/dotnet/APIView/APIViewWeb/Models/ReviewCodeFileModel.cs index e32a30dcde5..b0b8090d530 100644 --- a/src/dotnet/APIView/APIViewWeb/Models/ReviewCodeFileModel.cs +++ b/src/dotnet/APIView/APIViewWeb/Models/ReviewCodeFileModel.cs @@ -14,7 +14,6 @@ public class ReviewCodeFileModel // This is field is more of a display name. It is set to name value returned by parser which has package name and version in following format // Package name ( Version ) public string Name { get; set; } - public string Language { get => _language ?? (Name.EndsWith(".json", StringComparison.OrdinalIgnoreCase) ? "Json" : "C#"); @@ -23,6 +22,8 @@ public string Language public string VersionString { get; set; } + public string LanguageVariant { get; set; } + public bool HasOriginal { get; set; } public DateTime CreationDate { get; set; } = DateTime.Now; @@ -36,4 +37,4 @@ public string Language // This field stores original file name uploaded to create review public string FileName { get; set; } } -} \ No newline at end of file +} diff --git a/src/dotnet/APIView/APIViewWeb/Models/ReviewModel.cs b/src/dotnet/APIView/APIViewWeb/Models/ReviewModel.cs index b25258b3ba5..e3b7149930a 100644 --- a/src/dotnet/APIView/APIViewWeb/Models/ReviewModel.cs +++ b/src/dotnet/APIView/APIViewWeb/Models/ReviewModel.cs @@ -78,6 +78,9 @@ public string DisplayName [JsonIgnore] public string Language => Revisions.LastOrDefault()?.Files.LastOrDefault()?.Language; + [JsonIgnore] + public string LanguageVariant => Revisions.LastOrDefault()?.Files.LastOrDefault()?.LanguageVariant; + [JsonIgnore] public string PackageName { get diff --git a/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml b/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml index 49de22aaf89..dd87ce95789 100644 --- a/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml +++ b/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml @@ -32,7 +32,25 @@ imageSource = "icons/go-original.svg"; break; case "java": - imageSource = "icons/java-original.svg"; + if(@Model.Review.LanguageVariant != null) + { + switch(@Model.Review.LanguageVariant.ToLower()) + { + case "spring": + imageSource = "icons/java-spring-original.svg"; + break; + case "android": + imageSource = "icons/java-android-original.svg"; + break; + default: + imageSource = "icons/java-original.svg"; + break; + } + } + else + { + imageSource = "icons/java-original.svg"; + } break; case "swift": imageSource = "icons/swift-original.svg"; @@ -49,11 +67,11 @@ } if (String.IsNullOrEmpty(imageSource)) { - @Model.Review.Language + @Model.Review.Language @Model.Review.LanguageVariant } else { - + } }
diff --git a/src/dotnet/APIView/APIViewWeb/Pages/Shared/_ReviewsPartial.cshtml b/src/dotnet/APIView/APIViewWeb/Pages/Shared/_ReviewsPartial.cshtml index a619480e467..71fc2aa5ed7 100644 --- a/src/dotnet/APIView/APIViewWeb/Pages/Shared/_ReviewsPartial.cshtml +++ b/src/dotnet/APIView/APIViewWeb/Pages/Shared/_ReviewsPartial.cshtml @@ -46,7 +46,25 @@ break; case "java": - + if(@review.LanguageVariant != null) + { + switch(@review.LanguageVariant.ToLower()) + { + case "spring": + + break; + case "android": + + break; + default: + + break; + } + } + else + { + + } break; case "swift": diff --git a/src/dotnet/APIView/APIViewWeb/Repositories/ReviewManager.cs b/src/dotnet/APIView/APIViewWeb/Repositories/ReviewManager.cs index 3c79cbe0ef7..8153dc26856 100644 --- a/src/dotnet/APIView/APIViewWeb/Repositories/ReviewManager.cs +++ b/src/dotnet/APIView/APIViewWeb/Repositories/ReviewManager.cs @@ -361,6 +361,7 @@ public async Task ToggleIsClosedAsync(ClaimsPrincipal user, string id) private void InitializeFromCodeFile(ReviewCodeFileModel file, CodeFile codeFile) { file.Language = codeFile.Language; + file.LanguageVariant = codeFile.LanguageVariant; file.VersionString = codeFile.VersionString; file.Name = codeFile.Name; file.PackageName = codeFile.PackageName; diff --git a/src/dotnet/APIView/APIViewWeb/wwwroot/icons/java-android-original.svg b/src/dotnet/APIView/APIViewWeb/wwwroot/icons/java-android-original.svg new file mode 100644 index 00000000000..8cb02410427 --- /dev/null +++ b/src/dotnet/APIView/APIViewWeb/wwwroot/icons/java-android-original.svg @@ -0,0 +1,54 @@ + + + diff --git a/src/dotnet/APIView/APIViewWeb/wwwroot/icons/java-spring-original.svg b/src/dotnet/APIView/APIViewWeb/wwwroot/icons/java-spring-original.svg new file mode 100644 index 00000000000..bcc0f7cb597 --- /dev/null +++ b/src/dotnet/APIView/APIViewWeb/wwwroot/icons/java-spring-original.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/java/apiview-java-processor/src/main/java/com/azure/tools/apiview/processor/Main.java b/src/java/apiview-java-processor/src/main/java/com/azure/tools/apiview/processor/Main.java index cd095f34a3c..9ae7b9dbdbe 100644 --- a/src/java/apiview-java-processor/src/main/java/com/azure/tools/apiview/processor/Main.java +++ b/src/java/apiview-java-processor/src/main/java/com/azure/tools/apiview/processor/Main.java @@ -6,6 +6,7 @@ import com.azure.tools.apiview.processor.model.APIListing; import com.azure.tools.apiview.processor.model.Diagnostic; import com.azure.tools.apiview.processor.model.DiagnosticKind; +import com.azure.tools.apiview.processor.model.LanguageVariant; import com.azure.tools.apiview.processor.model.Token; import com.azure.tools.apiview.processor.model.maven.Pom; import com.fasterxml.jackson.annotation.JsonInclude; @@ -157,6 +158,15 @@ private static void processJavaSourcesJar(File inputFile, APIListing apiListing) apiListing.setLanguage("Java"); apiListing.setMavenPom(reviewProperties.getMavenPom()); + if(groupId.contains("spring")) { + apiListing.setLanguageVariant(LanguageVariant.SPRING); + } else if(groupId.contains("android")) { + apiListing.setLanguageVariant(LanguageVariant.ANDROID); + } else { + apiListing.setLanguageVariant(LanguageVariant.DEFAULT); + } + System.out.println(" Using '" + apiListing.getLanguageVariant() + "' for the language variant"); + final Analyser analyser = new JavaASTAnalyser(inputFile, apiListing); // Read all files within the jar file so that we can create a list of files to analyse diff --git a/src/java/apiview-java-processor/src/main/java/com/azure/tools/apiview/processor/model/APIListing.java b/src/java/apiview-java-processor/src/main/java/com/azure/tools/apiview/processor/model/APIListing.java index 8af0678f7e5..022d15f0303 100644 --- a/src/java/apiview-java-processor/src/main/java/com/azure/tools/apiview/processor/model/APIListing.java +++ b/src/java/apiview-java-processor/src/main/java/com/azure/tools/apiview/processor/model/APIListing.java @@ -23,6 +23,9 @@ public class APIListing { @JsonProperty("Language") private String language; + @JsonProperty("LanguageVariant") + private LanguageVariant languageVariant; + @JsonProperty("PackageName") private String packageName; @@ -91,6 +94,14 @@ public void setLanguage(final String language) { this.language = language; } + public LanguageVariant getLanguageVariant() { + return languageVariant; + } + + public void setLanguageVariant(final LanguageVariant variant) { + this.languageVariant = variant; + } + public String getPackageName() { return packageName; } diff --git a/src/java/apiview-java-processor/src/main/java/com/azure/tools/apiview/processor/model/LanguageVariant.java b/src/java/apiview-java-processor/src/main/java/com/azure/tools/apiview/processor/model/LanguageVariant.java new file mode 100644 index 00000000000..329e2e82716 --- /dev/null +++ b/src/java/apiview-java-processor/src/main/java/com/azure/tools/apiview/processor/model/LanguageVariant.java @@ -0,0 +1,21 @@ +package com.azure.tools.apiview.processor.model; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum LanguageVariant { + DEFAULT("Default"), + SPRING("Spring"), + ANDROID("Android"); + + private final String variantName; + + LanguageVariant(String name) { + this.variantName = name; + } + + @Override + @JsonValue + public String toString() { + return this.variantName; + } +}