Skip to content
This repository was archived by the owner on Mar 16, 2021. It is now read-only.

Commit

Permalink
Add deprecation metadata to registration when it is present in catalog (
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Bommarito authored May 21, 2019
1 parent d7826c0 commit 9b4edff
Show file tree
Hide file tree
Showing 11 changed files with 374 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/Catalog/context/Registration.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"parent" : { "@id" : "catalog:parent", "@type" : "@id" },

"tags": { "@container" : "@set", "@id": "tag" },
"reasons" : { "@container" : "@set" },

"packageTargetFrameworks": { "@container": "@set", "@id": "packageTargetFramework" },

Expand Down
25 changes: 24 additions & 1 deletion src/Catalog/sparql/ConstructCatalogEntryGraph.rq
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ CONSTRUCT
nuget:language ?language ;
nuget:authors ?authors ;
nuget:tag ?tag ;
nuget:minClientVersion ?minClientVersion .
nuget:minClientVersion ?minClientVersion ;
nuget:deprecation ?deprecation .

?dependency_group a nuget:PackageDependencyGroup ;
nuget:dependency ?dependency ;
Expand All @@ -31,6 +32,15 @@ CONSTRUCT
nuget:id ?dependency_id ;
nuget:range ?dependency_range ;
nuget:version ?dependency_version .

?deprecation a nuget:deprecation ;
nuget:reasons ?deprecation_reasons ;
nuget:message ?deprecation_message ;
nuget:alternatePackage ?deprecation_alternatePackage .

?deprecation_alternatePackage a nuget:alternatePackage ;
nuget:id ?deprecation_alternatePackage_id ;
nuget:range ?deprecation_alternatePackage_range .
}
WHERE
{
Expand Down Expand Up @@ -67,4 +77,17 @@ WHERE
OPTIONAL { ?dependency nuget:version ?dependency_version . }
}
}

OPTIONAL
{
?catalogEntry nuget:deprecation ?deprecation .
?deprecation nuget:reasons ?deprecation_reasons .
OPTIONAL { ?deprecation nuget:message ?deprecation_message . }
OPTIONAL
{
?deprecation nuget:alternatePackage ?deprecation_alternatePackage .
?deprecation_alternatePackage nuget:id ?deprecation_alternatePackage_id .
?deprecation_alternatePackage nuget:range ?deprecation_alternatePackage_range .
}
}
}
27 changes: 25 additions & 2 deletions src/Catalog/sparql/ConstructRegistrationPageContentGraph.rq
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,27 @@ CONSTRUCT
nuget:language ?language ;
nuget:authors ?authors ;
nuget:tag ?tag ;
nuget:minClientVersion ?minClientVersion .
nuget:minClientVersion ?minClientVersion ;
nuget:deprecation ?deprecation .

?dependency_group a nuget:PackageDependencyGroup ;
nuget:dependency ?dependency ;
nuget:dependency ?dependency ;
nuget:targetFramework ?dependency_group_targetFramework .

?dependency a nuget:PackageDependency ;
nuget:id ?dependency_id ;
nuget:registration ?dependency_registration ;
nuget:range ?dependency_range ;
nuget:version ?dependency_version .

?deprecation a nuget:deprecation ;
nuget:reasons ?deprecation_reasons ;
nuget:message ?deprecation_message ;
nuget:alternatePackage ?deprecation_alternatePackage .

?deprecation_alternatePackage a nuget:alternatePackage ;
nuget:id ?deprecation_alternatePackage_id ;
nuget:range ?deprecation_alternatePackage_range .
}
WHERE
{
Expand Down Expand Up @@ -98,4 +108,17 @@ WHERE
OPTIONAL { ?dependency nuget:version ?dependency_version . }
}
}

OPTIONAL
{
?catalogEntry nuget:deprecation ?deprecation .
?deprecation nuget:reasons ?deprecation_reasons .
OPTIONAL { ?deprecation nuget:message ?deprecation_message . }
OPTIONAL
{
?deprecation nuget:alternatePackage ?deprecation_alternatePackage .
?deprecation_alternatePackage nuget:id ?deprecation_alternatePackage_id .
?deprecation_alternatePackage nuget:range ?deprecation_alternatePackage_range .
}
}
}
2 changes: 2 additions & 0 deletions tests/CatalogTests/CatalogTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
<Compile Include="Dnx\DnxCatalogCollectorTests.cs" />
<Compile Include="Dnx\DnxMakerTests.cs" />
<Compile Include="Helpers\AsyncExtensionsTests.cs" />
<Compile Include="Helpers\RegistrationPackageDeprecationAlternatePackage.cs" />
<Compile Include="Helpers\RegistrationPackageDeprecationDetails.cs" />
<Compile Include="Helpers\CatalogIndependentPage.cs" />
<Compile Include="Helpers\CatalogIndex.cs" />
<Compile Include="Helpers\CatalogPackageDetails.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ internal sealed class CatalogIndependentPackageDetails
internal string CommitTimeStamp { get; }
[JsonProperty(CatalogConstants.Created)]
internal string Created { get; }
[JsonProperty(CatalogConstants.Deprecation)]
internal RegistrationPackageDeprecation Deprecation { get; }
[JsonProperty(CatalogConstants.Description)]
internal string Description { get; }
[JsonProperty(CatalogConstants.Id)]
Expand Down Expand Up @@ -97,7 +99,8 @@ internal CatalogIndependentPackageDetails(
string version = null,
string baseUri = null,
string commitId = null,
DateTimeOffset? commitTimeStamp = null)
DateTimeOffset? commitTimeStamp = null,
RegistrationPackageDeprecation deprecation = null)
{
var utc = commitTimeStamp ?? DateTimeOffset.UtcNow;

Expand All @@ -116,6 +119,7 @@ internal CatalogIndependentPackageDetails(
CommitId = commitId ?? Guid.NewGuid().ToString("D");
CommitTimeStamp = utc.ToString(CatalogConstants.CommitTimeStampFormat);
Created = utc.AddHours(-2).ToString(CatalogConstants.DateTimeFormat);
Deprecation = deprecation;
Description = TestUtility.CreateRandomAlphanumericString();
LastEdited = utc.AddHours(-1).ToString(CatalogConstants.DateTimeFormat);
Listed = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Newtonsoft.Json;
using NgTests;

namespace CatalogTests.Helpers
{
public class RegistrationPackageDeprecationAlternatePackage
{
[JsonConstructor]
public RegistrationPackageDeprecationAlternatePackage(
string id,
string range)
{
Id = id;
Range = range;
}

[JsonProperty(CatalogConstants.Id)]
public string Id { get; }

[JsonProperty(CatalogConstants.Range)]
public string Range { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Newtonsoft.Json;
using NgTests;

namespace CatalogTests.Helpers
{
public class RegistrationPackageDeprecation
{
[JsonConstructor]
public RegistrationPackageDeprecation(
string[] reasons,
string message = null,
RegistrationPackageDeprecationAlternatePackage alternatePackage = null)
{
Reasons = reasons;
Message = message;
AlternatePackage = alternatePackage;
}

[JsonProperty(CatalogConstants.Reasons)]
public string[] Reasons { get; }

[JsonProperty(CatalogConstants.Message)]
public string Message { get; }

[JsonProperty(CatalogConstants.AlternatePackage)]
public RegistrationPackageDeprecationAlternatePackage AlternatePackage { get; }
}
}
4 changes: 4 additions & 0 deletions tests/CatalogTests/Helpers/RegistrationPackageDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ internal sealed class RegistrationPackageDetails
internal string TypeKeyword { get; }
[JsonProperty(CatalogConstants.Authors)]
internal string Authors { get; }
[JsonProperty(CatalogConstants.Deprecation)]
internal RegistrationPackageDeprecation Deprecation { get; }
[JsonProperty(CatalogConstants.Description)]
internal string Description { get; }
[JsonProperty(CatalogConstants.IconUrl)]
Expand Down Expand Up @@ -50,6 +52,7 @@ internal RegistrationPackageDetails(
string idKeyword,
string typeKeyword,
string authors,
RegistrationPackageDeprecation deprecation,
string description,
string iconUrl,
string id,
Expand All @@ -69,6 +72,7 @@ internal RegistrationPackageDetails(
IdKeyword = idKeyword;
TypeKeyword = typeKeyword;
Authors = authors;
Deprecation = deprecation;
Description = description;
IconUrl = iconUrl;
Id = id;
Expand Down
Loading

0 comments on commit 9b4edff

Please sign in to comment.