Skip to content
Snippets Groups Projects
Commit e1804f8c authored by Petar Hristov's avatar Petar Hristov :speech_balloon:
Browse files

Fix: Refactored

parent b7641139
Branches
No related tags found
2 merge requests!29Fix: Working new version,!27BREAKING: Migrated SQL2Linked to the APIv2 infrastructure
Pipeline #1188126 failed
using Coscine.ApiClient;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
using Coscine.ApiClient.Core.Model;
using VDS.RDF;
namespace SQL2Linked.Implementations
{
namespace SQL2Linked.Implementations;
public class ProjectStructuralData : StructuralData<ProjectAdminDto>
{
public readonly Uri org = new("http://www.w3.org/ns/org#");
......@@ -18,7 +17,7 @@ namespace SQL2Linked.Implementations
// Override to also receive deleted projects
public override async Task<IEnumerable<ProjectAdminDto>> GetAll()
{
return await RequestUtil.WrapPagedRequest<ProjectAdminDtoIEnumerablePagedResponse, ProjectAdminDto>(
return await RequestUtil.WrapPagedRequest<ProjectAdminDtoPagedResponse, ProjectAdminDto>(
(currentPage) => AdminApi.GetAllProjectsAsync(includeDeleted: true, pageNumber: currentPage, pageSize: 150));
}
......@@ -156,4 +155,3 @@ namespace SQL2Linked.Implementations
return graphs;
}
}
\ No newline at end of file
}
\ No newline at end of file
using Coscine.ApiClient;
using Coscine.ApiClient.Core.Model;
using Newtonsoft.Json;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
using VDS.RDF;
namespace SQL2Linked.Implementations
{
namespace SQL2Linked.Implementations;
public class ResourceStructuralData : StructuralData<ResourceAdminDto>
{
public readonly Uri org = new("http://www.w3.org/ns/org#");
......@@ -20,7 +19,7 @@ namespace SQL2Linked.Implementations
// Override to also receive deleted resources
public override async Task<IEnumerable<ResourceAdminDto>> GetAll()
{
return await RequestUtil.WrapPagedRequest<ResourceAdminDtoIEnumerablePagedResponse, ResourceAdminDto>(
return await RequestUtil.WrapPagedRequest<ResourceAdminDtoPagedResponse, ResourceAdminDto>(
(currentPage) => AdminApi.GetAllResourcesAsync(includeDeleted: true, pageNumber: currentPage, pageSize: 150));
}
......@@ -151,4 +150,3 @@ namespace SQL2Linked.Implementations
return graphs;
}
}
}
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
using Coscine.ApiClient.Core.Api;
using Coscine.ApiClient.Core.Model;
using VDS.RDF;
using VDS.RDF.Parsing;
namespace SQL2Linked.Implementations
{
namespace SQL2Linked.Implementations;
public class ResourceTypeStructuralData : StructuralData<ResourceTypeInformationDto>
{
public readonly string ResourceTypeUrlPrefix = "https://purl.org/coscine/resourcetypes";
......@@ -83,5 +83,3 @@ namespace SQL2Linked.Implementations
return graphs;
}
}
\ No newline at end of file
}
\ No newline at end of file
using Coscine.ApiClient;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
using Coscine.ApiClient.Core.Api;
using Coscine.ApiClient.Core.Model;
using VDS.RDF;
using VDS.RDF.Parsing;
namespace SQL2Linked.Implementations
{
namespace SQL2Linked.Implementations;
public class RoleStructuralData : StructuralData<RoleDto>
{
public readonly string RoleUrlPrefix = "https://purl.org/coscine/roles";
......@@ -18,7 +18,7 @@ namespace SQL2Linked.Implementations
public override async Task<IEnumerable<RoleDto>> GetAll()
{
var roleApi = new RoleApi();
return await RequestUtil.WrapPagedRequest<RoleDtoIEnumerablePagedResponse, RoleDto>(
return await RequestUtil.WrapPagedRequest<RoleDtoPagedResponse, RoleDto>(
(currentPage) => roleApi.GetRolesAsync(pageNumber: currentPage));
}
......@@ -69,4 +69,3 @@ namespace SQL2Linked.Implementations
return graphs;
}
}
\ No newline at end of file
}
\ No newline at end of file
using Coscine.ApiClient;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
using Coscine.ApiClient.Core.Model;
using VDS.RDF;
using VDS.RDF.Parsing;
namespace SQL2Linked.Implementations
{
namespace SQL2Linked.Implementations;
public class UserStructuralData : StructuralData<UserDto>
{
public readonly string UserUrlPrefix = "https://purl.org/coscine/users";
......@@ -15,7 +14,7 @@ namespace SQL2Linked.Implementations
// Override to only transform users which have accepted the TOS
public override async Task<IEnumerable<UserDto>> GetAll()
{
return await RequestUtil.WrapPagedRequest<UserDtoIEnumerablePagedResponse, UserDto>(
return await RequestUtil.WrapPagedRequest<UserDtoPagedResponse, UserDto>(
(currentPage) => AdminApi.GetAllUsersAsync(tosAccepted: true, pageNumber: currentPage, pageSize: 150));
}
......@@ -38,7 +37,7 @@ namespace SQL2Linked.Implementations
// check if the current display name is already applied in the user graph
var getTriplesName = graph.GetTriplesWithPredicate(new Uri(foaf + "name"));
if (!getTriples.Any() || !getTriplesName.Any((triple) => (triple.Object as ILiteralNode).Value == entry.DisplayName))
if (!getTriples.Any() || !getTriplesName.Any((triple) => (triple.Object as ILiteralNode)?.Value == entry.DisplayName))
{
AssertToGraphUriNode(graph, userGraphName, rdf + "type", foaf + "Person");
......@@ -57,4 +56,3 @@ namespace SQL2Linked.Implementations
return graphs;
}
}
}
......@@ -2,14 +2,21 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.1.19</Version></PropertyGroup>
<Version>0.1.19</Version>
</PropertyGroup>
<PropertyGroup>
<Authors>RWTH Aachen University</Authors>
<Company>IT Center, RWTH Aachen University</Company>
<Copyright>©2024 IT Center, RWTH Aachen University</Copyright>
<Description>SQL2Linked is a part of the Coscine group.</Description>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Coscine.ApiClient" Version="1.0.0-issue-2666-admin0014" />
<PackageReference Include="Coscine.Configuration" Version="2.1.1" />
<PackageReference Include="Coscine.ApiClient" Version="1.3.0-issue-2666-admin0007" />
<PackageReference Include="dotNetRdf" Version="3.1.1" />
</ItemGroup>
......
......
using Coscine.ApiClient;
using Coscine.Configuration;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Coscine.ApiClient.Core.Api;
using Coscine.ApiClient.Core.Client;
using Coscine.ApiClient.Core.Model;
using VDS.RDF;
namespace SQL2Linked
......@@ -15,10 +15,9 @@ namespace SQL2Linked
public StructuralData()
{
Configuration = new ConsulConfiguration();
Prefix = Configuration.GetStringAndWait("coscine/global/epic/prefix");
var jwtConfiguration = JwtUtil.RetrieveJwtConfiguration();
AdminToken = JwtUtil.GenerateAdminToken(jwtConfiguration);
var jwtConfiguration = ApiConfigurationUtil.RetrieveJwtConfiguration();
AdminToken = ApiConfigurationUtil.GenerateAdminToken(jwtConfiguration);
AdminApi = new AdminApi(new Configuration()
{
ApiKeyPrefix = { { "Authorization", "Bearer" } },
......@@ -43,7 +42,7 @@ namespace SQL2Linked
public async Task StoreGraphs(IEnumerable<IGraph> graphs)
{
var formatEnum = Org.OpenAPITools.Model.RdfFormat.TextTurtle;
var formatEnum = RdfFormat.TextTurtle;
var format = "text/turtle";
foreach (var graph in graphs)
......@@ -55,15 +54,15 @@ namespace SQL2Linked
if (graph is WrapperGraph)
{
var rdfWriter = MimeTypesHelper.GetWriter(format);
var assert = VDS.RDF.Writing.StringWriter.Write((graph as WrapperGraph).AssertGraph, rdfWriter);
var retract = VDS.RDF.Writing.StringWriter.Write((graph as WrapperGraph).RetractGraph, rdfWriter);
var assert = VDS.RDF.Writing.StringWriter.Write((graph as WrapperGraph)?.AssertGraph, rdfWriter);
var retract = VDS.RDF.Writing.StringWriter.Write((graph as WrapperGraph)?.RetractGraph, rdfWriter);
await AdminApi.PatchMetadataGraphAsync(
new Org.OpenAPITools.Model.MetadataPatchAdminParameters
new MetadataPatchAdminParameters
(
graph.BaseUri.AbsoluteUri,
new Org.OpenAPITools.Model.RdfDefinitionForManipulationDto(assert, formatEnum),
new Org.OpenAPITools.Model.RdfDefinitionForManipulationDto(retract, formatEnum)
new RdfDefinitionForManipulationDto(assert, formatEnum),
new RdfDefinitionForManipulationDto(retract, formatEnum)
)
);
}
......@@ -73,10 +72,10 @@ namespace SQL2Linked
var content = VDS.RDF.Writing.StringWriter.Write(graph, rdfWriter);
await AdminApi.UpdateMetadataGraphAsync(
new Org.OpenAPITools.Model.MetadataUpdateAdminParameters
new MetadataUpdateAdminParameters
(
graph.BaseUri.AbsoluteUri,
new Org.OpenAPITools.Model.RdfDefinitionForManipulationDto(content, formatEnum)
new RdfDefinitionForManipulationDto(content, formatEnum)
)
);
}
......
......
using VDS.RDF;
namespace SQL2Linked
{
namespace SQL2Linked;
public class WrapperGraph : Graph
{
public IGraph AssertGraph { get; set; }
......@@ -37,4 +37,3 @@ namespace SQL2Linked
return base.Retract(triples);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment