Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • Fix/v0.1.7-dependencies
  • Hotfix/2212-fixFiles
  • Hotfix/2776-workingNewVersion
  • Hotfix/xxxx-changeUrls
  • Hotfix/xxxx-correctAssignments
  • Hotfix/xxxx-coscineGraph
  • Issue/1321-pidEnquiryOverhaul
  • Issue/1781-sqlToLinked
  • Issue/1782-structualDataIntegration
  • Issue/2081-migrateUserStructuralData
  • Issue/2082-migrateRoleStructuralData
  • Issue/2083-migrateResourceTypeStructuralData
  • Issue/2084-migrateResourceStructuralData
  • Issue/2085-migrateProjectStructuralData
  • Issue/2221-projectDateCreated
  • Issue/2222-resourceDateCreated
  • Issue/2304-virtuosoRoars
  • Issue/2518-docs
  • Issue/2666-adminCronjobs
  • Issue/2666-adminCronjobs-theSequal
  • Issue/2847-reporting
  • Issue/2914-trellisMigrator
  • dev
  • gitkeep
  • main
  • v0.1.0
  • v0.1.1
  • v0.1.10
  • v0.1.11
  • v0.1.12
  • v0.1.13
  • v0.1.14
  • v0.1.15
  • v0.1.16
  • v0.1.17
  • v0.1.18
  • v0.1.19
  • v0.1.2
  • v0.1.20
  • v0.1.21
  • v0.1.22
  • v0.1.23
  • v0.1.24
  • v0.1.3
  • v0.1.4
  • v0.1.5
  • v0.1.6
  • v0.1.7
  • v0.1.8
  • v0.1.9
50 results

Target

Select target project
  • coscine/backend/scripts/sql2linked
1 result
Select Git revision
  • Fix/v0.1.7-dependencies
  • Hotfix/2212-fixFiles
  • Hotfix/2776-workingNewVersion
  • Hotfix/xxxx-changeUrls
  • Hotfix/xxxx-correctAssignments
  • Hotfix/xxxx-coscineGraph
  • Issue/1321-pidEnquiryOverhaul
  • Issue/1781-sqlToLinked
  • Issue/1782-structualDataIntegration
  • Issue/2081-migrateUserStructuralData
  • Issue/2082-migrateRoleStructuralData
  • Issue/2083-migrateResourceTypeStructuralData
  • Issue/2084-migrateResourceStructuralData
  • Issue/2085-migrateProjectStructuralData
  • Issue/2221-projectDateCreated
  • Issue/2222-resourceDateCreated
  • Issue/2304-virtuosoRoars
  • Issue/2518-docs
  • Issue/2666-adminCronjobs
  • Issue/2666-adminCronjobs-theSequal
  • Issue/2847-reporting
  • Issue/2914-trellisMigrator
  • dev
  • gitkeep
  • main
  • v0.1.0
  • v0.1.1
  • v0.1.10
  • v0.1.11
  • v0.1.12
  • v0.1.13
  • v0.1.14
  • v0.1.15
  • v0.1.16
  • v0.1.17
  • v0.1.18
  • v0.1.19
  • v0.1.2
  • v0.1.20
  • v0.1.21
  • v0.1.22
  • v0.1.23
  • v0.1.24
  • v0.1.3
  • v0.1.4
  • v0.1.5
  • v0.1.6
  • v0.1.7
  • v0.1.8
  • v0.1.9
50 results
Show changes
Commits on Source (4)
......@@ -28,7 +28,9 @@ public class ProjectStructuralData : StructuralData<ProjectAdminDto>
AssertToGraphUriNode(coscineGraph, RdfUris.CoscinePrefix, RdfUris.DcatCatalog, RdfUris.CoscineProjects);
AssertToGraphUriNode(coscineGraph, RdfUris.CoscinePrefix, RdfUris.DcatCatalog, RdfUris.CoscineResources);
yield return coscineGraph; // yeld coscineGraph first
yield return coscineGraph; // yield coscineGraph first
var trellisGraph = PatchGraph.Empty(RdfUris.TrellisGraph);
await foreach (var entry in entries)
{
......@@ -138,14 +140,42 @@ public class ProjectStructuralData : StructuralData<ProjectAdminDto>
Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {RdfUris.DcTermsCreator} {UriHelper.TryCombineUri(RdfUris.CoscineUsers, entry.Creator.Id)}'. ");
}
if (entry.CreationDate is not null && entry.CreationDate.HasValue)
{
AssertToGraphLiteralNode(graph, projectGraphName, RdfUris.DcTermsCreated, entry.CreationDate.Value.ToString(), RdfUris.XsdDateTime);
Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{projectGraphName} {RdfUris.DcTermsCreated} {entry.CreationDate}'. ");
}
// Add data to the trellis graph
AssertToGraphUriNode(trellisGraph,
projectGraphName,
RdfUris.A,
RdfUris.LdpBasicContainerClass);
AddModifiedDate(trellisGraph, projectGraphName);
AssertToGraphUriNode(trellisGraph,
projectGraphName,
RdfUris.DcTermsIsPartOf,
RdfUris.CoscineProjectsEntity);
AssertToGraphUriNode(trellisGraph,
RdfUris.CoscineProjectsEntity,
RdfUris.A,
RdfUris.LdpBasicContainerClass);
AddModifiedDate(trellisGraph, RdfUris.CoscineProjectsEntity);
AssertToGraphUriNode(trellisGraph,
RdfUris.CoscineProjectsEntity,
RdfUris.DcTermsIsPartOf,
RdfUris.CoscinePrefix);
AssertToGraphUriNode(trellisGraph,
RdfUris.CoscinePrefix,
RdfUris.A,
RdfUris.LdpBasicContainerClass);
AddModifiedDate(trellisGraph, RdfUris.CoscinePrefix);
yield return graph;
}
yield return trellisGraph;
}
}
\ No newline at end of file
......@@ -23,6 +23,8 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto>
var coscineHandlePrefix = UriHelper.TryCombinePath(RdfUris.HandlePrefix, _pidConfiguration.Prefix)
?? throw new Exception("Could not combine handle prefix with PID prefix");
var trellisGraph = PatchGraph.Empty(RdfUris.TrellisGraph);
await foreach (var entry in entries)
{
var resourceGraphName = UriHelper.TryCombineUri(RdfUris.CoscineResources, entry.Id)
......@@ -165,7 +167,57 @@ public class ResourceStructuralData : StructuralData<ResourceAdminDto>
Console.WriteLine($"For resource '{entry.DisplayName}' will migrate triple '{resourceGraphName} {RdfUris.DcTermsCreated} {entry.DateCreated}'. ");
}
// Add data to the trellis graph
AssertToGraphUriNode(trellisGraph,
resourceGraphName,
RdfUris.A,
RdfUris.LdpBasicContainerClass);
AddModifiedDate(trellisGraph, resourceGraphName);
AssertToGraphUriNode(trellisGraph,
resourceGraphName,
RdfUris.DcTermsIsPartOf,
RdfUris.CoscineResourcesEntity);
AssertToGraphUriNode(trellisGraph,
RdfUris.CoscineResourcesEntity,
RdfUris.A,
RdfUris.LdpBasicContainerClass);
AddModifiedDate(trellisGraph, RdfUris.CoscineResourcesEntity);
AssertToGraphUriNode(trellisGraph,
RdfUris.CoscineResourcesEntity,
RdfUris.DcTermsIsPartOf,
RdfUris.CoscinePrefix);
AssertToGraphUriNode(trellisGraph,
RdfUris.CoscinePrefix,
RdfUris.A,
RdfUris.LdpBasicContainerClass);
AddModifiedDate(trellisGraph, RdfUris.CoscinePrefix);
var resourceACLGraphName = UriHelper.TryCombineUri(resourceGraphName, "?ext=acl");
var aclGraph = new Graph()
{
BaseUri = resourceACLGraphName
};
var aclSubjects = graph.GetTriplesWithObject(RdfUris.AclAuthorizationClass).Select((triple) => triple.Subject);
foreach (var subject in aclSubjects)
{
var subjectNode = aclGraph.CreateBlankNode();
foreach (var triple in graph.GetTriplesWithSubject(subject))
{
aclGraph.Assert(new Triple(
subjectNode,
triple.Predicate,
triple.Object
));
}
}
yield return graph;
yield return aclGraph;
}
yield return trellisGraph;
}
}
......@@ -5,7 +5,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.1.23</Version>
<Version>0.1.24</Version>
</PropertyGroup>
<PropertyGroup>
......
......@@ -4,7 +4,10 @@ using Coscine.ApiClient.Core.Client;
using Coscine.ApiClient.Core.Model;
using Microsoft.Extensions.Configuration;
using SQL2Linked.Models.ConfigurationModels;
using SQL2Linked.Utils;
using System.Globalization;
using VDS.RDF;
using VDS.RDF.Parsing;
namespace SQL2Linked;
......@@ -97,10 +100,25 @@ public abstract class StructuralData<S>
var rdfWriter = MimeTypesHelper.GetWriter(format);
var content = VDS.RDF.Writing.StringWriter.Write(graph, rdfWriter);
if (graph is PatchGraph patchGraph)
{
var patchOperations = new List<RdfPatchOperationDto>
{
new(RdfPatchOperationType.A, new RdfDefinitionForManipulationDto(content, formatEnum))
};
await _adminApi.PatchMetadataAsync(
graph.BaseUri.AbsoluteUri,
new RdfPatchDocumentDto(patchOperations)
);
}
else
{
await _adminApi.UpdateMetadataGraphAsync(
graph.BaseUri.AbsoluteUri,
new MetadataUpdateAdminParameters(new RdfDefinitionForManipulationDto(content, formatEnum))
);
}
Console.WriteLine($" - Graph {graph.BaseUri} added successfully");
Console.WriteLine();
......@@ -115,6 +133,17 @@ public abstract class StructuralData<S>
}
}
public void AddModifiedDate(IGraph graph, Uri rootUri)
{
AssertToGraphLiteralNode(
graph,
rootUri,
RdfUris.DcTermsModified,
DateTime.UtcNow.ToString("o", CultureInfo.InvariantCulture),
new Uri(XmlSpecsHelper.XmlSchemaDataTypeDateTime)
);
}
/// <summary>
/// Asserts a triple to the graph with a URI node object.
/// </summary>
......
using VDS.RDF;
namespace SQL2Linked.Utils;
/// <summary>
/// Represents a specialized RDF graph for small-scale updates.
/// This class extends the standard Graph class with additional
/// functionalities for tracking changes (assertions and retractions).
/// </summary>
/// <remarks><i>TODO: Consider extending <see cref="ITransactionalGraph"/> to allow for rollback and commit operations.</i></remarks>
public class PatchGraph : Graph
{
public List<Triple> AssertList { get; set; } = new();
public List<Triple> RetractList { get; set; } = new();
/// <summary>
/// Initializes a new instance of the <see cref="PatchGraph"/> class.
/// </summary>
public PatchGraph() : base()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="PatchGraph"/> class.
/// </summary>
public PatchGraph(Uri graphUri) : base(graphUri)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="IPatchGraph"/> class with the specified graph URI.
/// </summary>
/// <param name="graphUri">The base URI for the graph.</param>
/// <returns>A new empty instance of <see cref="IPatchGraph"/> with the provided base URI.</returns>
public static PatchGraph Empty(Uri graphUri)
{
return new PatchGraph(graphUri)
{
BaseUri = graphUri
};
}
/// <summary>
/// Initializes a new instance of the <see cref="IPatchGraph"/> class with the specified graph URI.
/// </summary>
/// <param name="graphUri">The base URI for the graph as a string.</param>
/// <returns>A new empty instance of <see cref="IPatchGraph"/> with the provided base URI.</returns>
public static PatchGraph Empty(string graphUri)
{
return Empty(new Uri(graphUri));
}
public override bool Assert(Triple t)
{
AssertList.Add(t);
return base.Assert(t);
}
public override bool Assert(IEnumerable<Triple> triples)
{
AssertList.AddRange(triples);
return base.Assert(triples);
}
public override bool Retract(Triple t)
{
RetractList.Add(t);
return base.Retract(t);
}
public override bool Retract(IEnumerable<Triple> triples)
{
RetractList.AddRange(triples);
return base.Retract(triples);
}
}
\ No newline at end of file
......@@ -29,8 +29,10 @@ public static class RdfUris
public static readonly Uri CoscineApplicationProfile = new("https://purl.org/coscine/ap/");
public static readonly Uri CoscineFixedValue = new("https://purl.org/coscine/fixedValue");
public static readonly Uri CoscineMetadataExtractionVersion = new("https://purl.org/coscine/terms/metatadataextraction#version");
public static readonly Uri CoscineProjectsEntity = new("https://purl.org/coscine/projects");
public static readonly Uri CoscineProjects = new("https://purl.org/coscine/projects/");
public static readonly Uri CoscineResourceTypes = new("https://purl.org/coscine/resourcetypes/");
public static readonly Uri CoscineResourcesEntity = new("https://purl.org/coscine/resources");
public static readonly Uri CoscineResources = new("https://purl.org/coscine/resources/");
public static readonly Uri CoscineRoles = new("https://purl.org/coscine/roles/");
public static readonly Uri CoscineUsers = new("https://purl.org/coscine/users/");
......