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

Optimizing the code

parent 7603e60b
No related tags found
1 merge request!26New: MigrateSQL2Linked to GD
......@@ -20,6 +20,8 @@ public class Deployer
private readonly ILogger<Deployer> _logger;
private readonly GraphDeployerConfiguration _graphDeployerConfiguration;
private readonly AdminApi _adminApi;
private readonly ResourceTypeApi _resourceTypeApi;
private readonly RoleApi _roleApi;
public Deployer(ILogger<Deployer> logger, IOptionsMonitor<GraphDeployerConfiguration> graphDeployerConfiguration)
{
......@@ -42,6 +44,8 @@ public class Deployer
apiClientConfig.RemoteCertificateValidationCallback = (_, _, _, _) => true;
}
_adminApi = new(apiClientConfig);
_resourceTypeApi = new ResourceTypeApi(apiClientConfig);
_roleApi = new RoleApi(apiClientConfig);
}
public static string WorkingFolder { get; set; } = "./output/";
......@@ -52,6 +56,14 @@ 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
......@@ -77,6 +89,16 @@ public class Deployer
(currentPage) => _adminApi.GetDeployedGraphsAsync(pageNumber: currentPage, pageSize: 50));
var deployedGraphsList = await graphs.ToListAsync();
var roleResponse = PaginationHelper.GetAllAsync<RoleDtoPagedResponse, RoleDto>(
(currentPage) => _roleApi.GetRolesAsync(pageNumber: currentPage));
var resourceTypeInformationsResponse = await _resourceTypeApi.GetAllResourceTypesInformationAsync();
var resourceTypeList = new List<ResourceTypeInformationDto>();
foreach (var item in resourceTypeInformationsResponse.Data)
{
resourceTypeList.Add(item);
}
// Iterate over the repositories and deploy the graphs
foreach (var graphRepo in _graphDeployerConfiguration.GitLab.Repositories)
{
......@@ -168,14 +190,12 @@ public class Deployer
continue;
}
}
// Convert to linked data
// Store the graph
}
// Clean up the working folder
EmptyWorkingFolder();
}
// Convert to linked data
// Store the graph
return true;
}
......
......@@ -19,17 +19,7 @@ public class ResourceTypeStructuralData
_deployer = deployer;
}
public async IAsyncEnumerable<ResourceTypeInformationDto> GetAll()
{
var resourceTypeApi = new ResourceTypeApi(apiClientConfig);
var resourceTypeInformationsResponse = await resourceTypeApi.GetAllResourceTypesInformationAsync();
foreach (var item in resourceTypeInformationsResponse.Data)
{
yield return item; // Yield each item in the list to keep the IAsyncEnumerable logic
}
}
public override async IAsyncEnumerable<IGraph> ConvertToLinkedDataAsync(IAsyncEnumerable<ResourceTypeInformationDto> entries)
public async IAsyncEnumerable<IGraph> ConvertToLinkedDataAsync(IAsyncEnumerable<ResourceTypeInformationDto> entries)
{
await foreach (var entry in entries)
{
......
......@@ -21,12 +21,6 @@ public class RoleStructuralData
_deployer = deployer;
}
public IAsyncEnumerable<RoleDto> GetAll()
{
var roleApi = new RoleApi(apiClientConfig);
return PaginationHelper.GetAllAsync<RoleDtoPagedResponse, RoleDto>(
(currentPage) => roleApi.GetRolesAsync(pageNumber: currentPage));
}
public async IAsyncEnumerable<IGraph> ConvertToLinkedDataAsync(IAsyncEnumerable<RoleDto> entries)
{
await foreach (var entry in entries)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment