Skip to content
Snippets Groups Projects
Commit 3cb0ff4a authored by Sirieam Marie Hunke's avatar Sirieam Marie Hunke
Browse files

Small fixes

parent ee808214
Branches
No related tags found
1 merge request!26New: MigrateSQL2Linked to GD
......@@ -23,6 +23,16 @@ public class Deployer
private readonly RoleStructuralData _roleStructuralData;
private readonly ResourceTypeStructuralData _resourceTypeStructuralData;
// Define ANSI escape codes for colors
private const string _esc = "\u001b"; // ANSI escape character
private const string _r = $"{_esc}[91m";
private const string _gb = $"{_esc}[1;92m";
private const string _y = $"{_esc}[93m";
private const string _bb = $"{_esc}[1;94m";
private const string _c = $"{_esc}[96m";
private const string _0 = $"{_esc}[0m";
public Deployer(ILogger<Deployer> logger, IOptionsMonitor<GraphDeployerConfiguration> graphDeployerConfiguration, RoleStructuralData roleStructuralData, ResourceTypeStructuralData resourceTypeStructuralData)
{
_logger = logger;
......@@ -59,14 +69,6 @@ public class Deployer
public static Uri CoscineEntitiesGraphDeployed { get; } = new("https://purl.org/coscine/entities/graph#deployed");
public static Uri CoscineTermsDeployedVersion { get; } = new("https://purl.org/coscine/terms/deployed#version");
public ResourceTypeApi GetResourceTypeApi()
{
return _resourceTypeApi;
}
public RoleApi GetRoleApi()
{
return _roleApi;
}
public async Task<bool> RunAsync(GraphDeployerOptions opts)
{
// Check if the graph deployer is enabled
......
......@@ -12,9 +12,12 @@ namespace Coscine.GraphDeployer;
public class ResourceTypeStructuralData
{
private readonly AdminApi _adminApi;
private readonly ILogger<ResourceTypeStructuralData> _logger;
public ResourceTypeStructuralData(AdminApi adminApi)
{
_adminApi = adminApi;
_logger = logger;
}
public async IAsyncEnumerable<IGraph> ConvertToLinkedDataAsync(IAsyncEnumerable<ResourceTypeInformationDto> entries)
{
......@@ -37,11 +40,11 @@ public class ResourceTypeStructuralData
if (!getTriplesDcatDataService.Any())
{
GraphExtensions.AssertToGraph(graph, resourceTypeGraphName, RdfUris.A, RdfUris.DcatDataServiceClass);
Console.WriteLine($"For resource type '{entry.SpecificType}' will migrate triple '{graph.BaseUri} {RdfUris.A} {RdfUris.DcatDataServiceClass}'. ");
_logger.LogInformation($"For resource type '{entry.SpecificType}' will migrate triple '{graph.BaseUri} {RdfUris.A} {RdfUris.DcatDataServiceClass}'. ");
}
else
{
Console.WriteLine($"For resource type '{entry.SpecificType}' will NOT migrate triple '{graph.BaseUri} {RdfUris.A} {RdfUris.DcatDataServiceClass}'. ");
_logger.LogInformation($"For resource type '{entry.SpecificType}' will NOT migrate triple '{graph.BaseUri} {RdfUris.A} {RdfUris.DcatDataServiceClass}'. ");
}
// check if a triple with dcterms:title '{entry.DisplayName}' already exists in the role graph
......@@ -50,11 +53,11 @@ public class ResourceTypeStructuralData
if (!getTriplesDctermsTitle.Any())
{
GraphExtensions.AssertToGraph(graph, resourceTypeGraphName, RdfUris.DcTermsTitle, entry.SpecificType);
Console.WriteLine($"For resource type '{entry.SpecificType}' will migrate triple '{graph.BaseUri} {RdfUris.DcTermsTitle} {entry.SpecificType}'. ");
_logger.LogInformation($"For resource type '{entry.SpecificType}' will migrate triple '{graph.BaseUri} {RdfUris.DcTermsTitle} {entry.SpecificType}'. ");
}
else
{
Console.WriteLine($"For resource type '{entry.SpecificType}' will NOT migrate triple '{graph.BaseUri} {RdfUris.DcTermsTitle} {entry.SpecificType}'. ");
_logger.LogInformation($"For resource type '{entry.SpecificType}' will NOT migrate triple '{graph.BaseUri} {RdfUris.DcTermsTitle} {entry.SpecificType}'. ");
}
......@@ -64,11 +67,11 @@ public class ResourceTypeStructuralData
if (!getTriplesDctermsAlternative.Any())
{
GraphExtensions.AssertToGraph(graph, resourceTypeGraphName, RdfUris.DcTermsAlternative, entry.GeneralType);
Console.WriteLine($"For resource type '{entry.SpecificType}' will migrate triple '{graph.BaseUri} {RdfUris.DcTermsAlternative} {entry.GeneralType}'. ");
_logger.LogInformation($"For resource type '{entry.SpecificType}' will migrate triple '{graph.BaseUri} {RdfUris.DcTermsAlternative} {entry.GeneralType}'. ");
}
else
{
Console.WriteLine($"For resource type '{entry.SpecificType}' will NOT migrate triple '{graph.BaseUri} {RdfUris.DcTermsAlternative} {entry.GeneralType}'. ");
_logger.LogInformation($"For resource type '{entry.SpecificType}' will NOT migrate triple '{graph.BaseUri} {RdfUris.DcTermsAlternative} {entry.GeneralType}'. ");
}
if (!getTriplesDcatDataService.Any() || !getTriplesDctermsTitle.Any())
......
......@@ -13,9 +13,11 @@ namespace Coscine.GraphDeployer;
public class RoleStructuralData
{
private readonly AdminApi _adminApi;
private readonly ILogger<ResourceTypeStructuralData> _logger;
public RoleStructuralData(AdminApi adminApi)
{
_adminApi = adminApi;
_logger = logger;
}
public async IAsyncEnumerable<IGraph> CreateGraphAsync(IAsyncEnumerable<RoleDto> entries)
......@@ -39,11 +41,11 @@ public class RoleStructuralData
if (!getTriplesOrgRole.Any())
{
GraphExtensions.AssertToGraph(graph, roleGraphName, RdfUris.A, RdfUris.OrgRoleClass);
Console.WriteLine($"For role '{entry.DisplayName}' will migrate triple '{graph.BaseUri} {RdfUris.A} {RdfUris.OrgRoleClass}'. ");
_logger.LogInformation($"For role '{entry.DisplayName}' will migrate triple '{graph.BaseUri} {RdfUris.A} {RdfUris.OrgRoleClass}'. ");
}
else
{
Console.WriteLine($"For role '{entry.DisplayName}' will NOT migrate triple '{graph.BaseUri} {RdfUris.A} {RdfUris.OrgRoleClass}'. ");
_logger.LogInformation($"For role '{entry.DisplayName}' will NOT migrate triple '{graph.BaseUri} {RdfUris.A} {RdfUris.OrgRoleClass}'. ");
}
// check if a triple with dcterms:title '{entry.DisplayName}' already exists in the role graph
......@@ -52,11 +54,11 @@ public class RoleStructuralData
if (!getTriplesDctermsTitle.Any())
{
GraphExtensions.AssertToGraph(graph, roleGraphName, RdfUris.DcTermsTitle, entry.DisplayName);
Console.WriteLine($"For role '{entry.DisplayName}' will migrate triple '{graph.BaseUri} {RdfUris.DcTermsTitle} {entry.DisplayName}'. ");
_logger.LogInformation($"For role '{entry.DisplayName}' will migrate triple '{graph.BaseUri} {RdfUris.DcTermsTitle} {entry.DisplayName}'. ");
}
else
{
Console.WriteLine($"For role '{entry.DisplayName}' will NOT migrate triple '{graph.BaseUri} {RdfUris.DcTermsTitle} {entry.DisplayName}'. ");
_logger.LogInformation($"For role '{entry.DisplayName}' will NOT migrate triple '{graph.BaseUri} {RdfUris.DcTermsTitle} {entry.DisplayName}'. ");
}
if (!getTriplesOrgRole.Any() || !getTriplesDctermsTitle.Any())
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment