Skip to content

Commit 277c88f

Browse files
Merge pull request #1168 from dlcs/feature/supportProvides
Add provides to adjunct
2 parents 5010d08 + cf9804f commit 277c88f

9 files changed

Lines changed: 1307 additions & 6 deletions

File tree

src/protagonist/API.Tests/Integration/AdjunctTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public async Task PostAdjunct_CreatesExternalAdjunct()
6767
"mediaType": "a-mediaType",
6868
"label": {"label": ["value"]},
6969
"motivation": "a motivation",
70+
"provides": "translation",
7071
"language": ["en"],
7172
}
7273
""";
@@ -90,6 +91,7 @@ public async Task PostAdjunct_CreatesExternalAdjunct()
9091
adjunct.ExternalId.Should().Be("https://some-location.com/an-adjunct");
9192
adjunct.PublicId.Should().Be("https://some-location.com/an-adjunct");
9293
adjunct.Motivation.Should().Be("a motivation");
94+
adjunct.Provides.Should().Be("translation");
9395

9496
response.Headers.Location.Should()
9597
.Be(
@@ -580,7 +582,7 @@ public async Task PutAdjunct_UpdatesAdjunct_WhenIdAlreadyExists()
580582
// Arrange
581583
var assetId = AssetIdGenerator.GetAssetId();
582584
await dbContext.Images.AddTestAsset(assetId)
583-
.WithTestAdjunct("someAdjunctId", created: DateTime.UtcNow.AddDays(-2), motivation: "something");
585+
.WithTestAdjunct("someAdjunctId", created: DateTime.UtcNow.AddDays(-2), motivation: "something", provides: "something");
584586
await dbContext.SaveChangesAsync();
585587

586588
const string updateAdjunctJson = """
@@ -592,7 +594,8 @@ await dbContext.Images.AddTestAsset(assetId)
592594
"mediaType": "a-mediaType",
593595
"label": {"label": ["value"]},
594596
"language": ["en"],
595-
"motivation": "changed"
597+
"motivation": "changed",
598+
"provides": "changed"
596599
}
597600
""";
598601

@@ -617,6 +620,7 @@ await dbContext.Images.AddTestAsset(assetId)
617620
adjunct.ExternalId.Should().Be("https://some-location.com/an-adjunct");
618621
adjunct.PublicId.Should().Be("https://some-location.com/an-adjunct");
619622
adjunct.Motivation.Should().Be("changed");
623+
adjunct.Provides.Should().Be("changed");
620624

621625
A.CallTo(() => DeliverableNotificationSender.SendDeliverableModifiedMessage(
622626
A<NotificationRecord<DLCS.Model.Assets.Adjunct>>.That.Matches(r => r.ChangeType == ChangeType.Update && r.After.AssetId == assetId),

src/protagonist/API/Converters/AdjunctConverter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public static Adjunct ToDlcsModel(this DLCS.HydraModel.Adjunct hydraAdjunct, int
4848
Language = hydraAdjunct.Language,
4949
Size = hydraAdjunct.Size,
5050
Motivation = hydraAdjunct.Motivation,
51+
Provides = hydraAdjunct.Provides,
5152
};
5253

5354
if (hydraAdjunct.Origin is not null)
@@ -87,6 +88,7 @@ public static DLCS.HydraModel.Adjunct ToHydra(this Adjunct adjunct, UrlRoots url
8788
Size = adjunct.Size,
8889
Error = adjunct.Error,
8990
Motivation = adjunct.Motivation,
91+
Provides = adjunct.Provides,
9092
Ingesting = adjunct.Ingesting
9193
};
9294
}

src/protagonist/API/Features/Adjuncts/Requests/CreateOrUpdateAdjunct.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public async Task<ModifyEntityResult<Adjunct>> Handle(CreateOrUpdateAdjunct requ
8383
dbAdjunct.Error = adjunct.Error;
8484
dbAdjunct.Type = adjunct.Type;
8585
dbAdjunct.Motivation = adjunct.Motivation;
86+
dbAdjunct.Provides = adjunct.Provides;
8687
dbAdjunct.Ingesting = adjunct.Ingesting;
8788
}
8889
else

src/protagonist/DLCS.HydraModel/Adjunct.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,18 @@ public Adjunct(string baseUrl, int customerId, int space, string assetId, string
9191
[JsonProperty(Order = 24, PropertyName = "motivation")]
9292
public string? Motivation { get; set; }
9393

94+
[RdfProperty(Description = "An additional set of features or functionality this adjunct provides.",
95+
Range = Names.XmlSchema.String, ReadOnly = false, WriteOnly = false)]
96+
[JsonProperty(Order = 25, PropertyName = "provides")]
97+
public string? Provides { get; set; }
98+
9499
[RdfProperty(Description = "Whether the adjunct is currently being ingested.",
95100
Range = Names.XmlSchema.Boolean, ReadOnly = true, WriteOnly = false)]
96-
[JsonProperty(Order = 25, PropertyName = "ingesting")]
101+
[JsonProperty(Order = 26, PropertyName = "ingesting")]
97102
public bool? Ingesting { get; set; }
98103

99104
[RdfProperty(Description = "Reported errors with this adjunct.",
100105
Range = Names.XmlSchema.String, ReadOnly = false, WriteOnly = false)]
101-
[JsonProperty(Order = 26, PropertyName = "error")]
106+
[JsonProperty(Order = 27, PropertyName = "error")]
102107
public string? Error { get; set; }
103108
}

src/protagonist/DLCS.Model/Assets/Adjunct.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public class Adjunct : IDeliverable
9090
/// The reason why this adjunct exists.
9191
/// </summary>
9292
public string? Motivation { get; set; }
93+
94+
/// <summary>
95+
/// An additional set of features or functionality this adjunct provides
96+
/// </summary>
97+
public string? Provides { get; set; }
9398

9499
public Asset Asset { get; set; } = null!;
95100

0 commit comments

Comments
 (0)