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
Loading items

Target

Select target project
  • coscine/backend/libraries/resource-types
1 result
Select Git revision
Loading items
Show changes
Commits on Source (9)
Showing
with 114 additions and 40 deletions
...@@ -5,7 +5,7 @@ include: ...@@ -5,7 +5,7 @@ include:
stages: stages:
- build - build
# - test - test
- publish - publish
variables: variables:
...@@ -17,8 +17,8 @@ build-branch: ...@@ -17,8 +17,8 @@ build-branch:
build-nuget-release: build-nuget-release:
extends: .build-nuget-release extends: .build-nuget-release
# test: test:
# extends: .test extends: .test
publish-branch-prerelease: publish-branch-prerelease:
extends: .publish-branch-prerelease extends: .publish-branch-prerelease
......
# Coscine Resource Types
This library contains all resource type implementations for Coscine (RDS, RDS-S3, RDS-S3-WORM, Linked, Gitlab).
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName> <AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName>
<RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace> <RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
<Version>1.8.7</Version> <Version>1.9.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName> <AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName>
<RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace> <RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
<Version>1.8.7</Version> <Version>1.9.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Coscine.Metadata" Version="2.*-*" /> <PackageReference Include="Coscine.Metadata" Version="*-*" />
<PackageReference Include="GitLabApiClient" Version="1.8.1-beta.5" /> <PackageReference Include="GitLabApiClient" Version="1.8.1-beta.5" />
</ItemGroup> </ItemGroup>
......
...@@ -15,6 +15,7 @@ public class LinkedResourceType : BaseResourceType ...@@ -15,6 +15,7 @@ public class LinkedResourceType : BaseResourceType
private readonly string _epicPrefix; private readonly string _epicPrefix;
private readonly string _predicate = "https://purl.org/coscine/terms/linked#body"; private readonly string _predicate = "https://purl.org/coscine/terms/linked#body";
private readonly RdfStoreConnector _rdfStoreConnector; private readonly RdfStoreConnector _rdfStoreConnector;
private readonly CoscineLDPHelper _coscineLDPHelper;
public LinkedResourceType(LinkedResourceTypeConfiguration linkedResourceTypeConfiguration) : base(linkedResourceTypeConfiguration) public LinkedResourceType(LinkedResourceTypeConfiguration linkedResourceTypeConfiguration) : base(linkedResourceTypeConfiguration)
{ {
...@@ -27,11 +28,7 @@ public class LinkedResourceType : BaseResourceType ...@@ -27,11 +28,7 @@ public class LinkedResourceType : BaseResourceType
{ {
_rdfStoreConnector = new(); _rdfStoreConnector = new();
} }
} _coscineLDPHelper = new CoscineLDPHelper(_rdfStoreConnector, _epicPrefix);
private string GetGraphName(string id, string key)
{
return $"{GetSubjectName(id, key)}&data";
} }
private string GetGraphNameForFilter(string id, string key) private string GetGraphNameForFilter(string id, string key)
...@@ -58,11 +55,12 @@ public class LinkedResourceType : BaseResourceType ...@@ -58,11 +55,12 @@ public class LinkedResourceType : BaseResourceType
key = "/" + key; key = "/" + key;
} }
var graph = _rdfStoreConnector.GetGraph(GetGraphName(id, key)); var urlId = _coscineLDPHelper.GetId(id, key, true, false, "data");
var graph = _rdfStoreConnector.GetGraph(urlId);
if (!graph.IsEmpty) if (!graph.IsEmpty)
{ {
_rdfStoreConnector.DeleteGraph(GetGraphName(id, key)); _rdfStoreConnector.DeleteGraph(urlId);
} }
return Task.CompletedTask; return Task.CompletedTask;
...@@ -75,14 +73,15 @@ public class LinkedResourceType : BaseResourceType ...@@ -75,14 +73,15 @@ public class LinkedResourceType : BaseResourceType
key = "/" + key; key = "/" + key;
} }
var graph = _rdfStoreConnector.GetGraph(GetGraphName(id, key)); var urlId = _coscineLDPHelper.GetId(id, key, true, false, "data");
var graph = _rdfStoreConnector.GetGraph(urlId);
if (graph.IsEmpty) if (graph.IsEmpty)
{ {
return Task.FromResult<ResourceEntry?>(null); return Task.FromResult<ResourceEntry?>(null);
} }
var triples = graph.GetTriplesWithSubjectPredicate(graph.CreateUriNode(new Uri(GetSubjectName(id, key))), graph.CreateUriNode(new Uri(_predicate))); var triples = graph.GetTriplesWithPredicate(graph.CreateUriNode(new Uri(_predicate)));
if (!triples.Any()) if (!triples.Any())
{ {
...@@ -125,6 +124,24 @@ public class LinkedResourceType : BaseResourceType ...@@ -125,6 +124,24 @@ public class LinkedResourceType : BaseResourceType
return GetEntry(id, key).Result; return GetEntry(id, key).Result;
}).Where(x => x != null).Cast<ResourceEntry>().ToList(); }).Where(x => x != null).Cast<ResourceEntry>().ToList();
// Add the new results as well
var currentDataList = _rdfStoreConnector.ListData(id);
if (currentDataList != null)
{
var resourceGraphUri = $"https://purl.org/coscine/resources/{id}";
var currentDataPaths = currentDataList.Select((entry) => entry?[..entry.LastIndexOf("/")].Replace(resourceGraphUri, ""));
var bothDataPaths = currentDataPaths.Where((currentDataPath) => resultList.Any((resultEntry) => resultEntry.Key == currentDataPath));
var newDataPaths = currentDataPaths.Where((currentDataPath) => !resultList.Any((resultEntry) => resultEntry.Key == currentDataPath));
// Remove the ones which are in both since the ones from the new structure would have the newest information
resultList.RemoveAll((entry) => bothDataPaths.Any((dataPath) => dataPath == entry.Key));
resultList.AddRange(currentDataPaths
.Where(x => x is not null)
.Select((x) => GetEntry(id, x!).Result)
.Where(x => x != null).Cast<ResourceEntry>());
}
return Task.FromResult(resultList); return Task.FromResult(resultList);
} }
...@@ -135,14 +152,16 @@ public class LinkedResourceType : BaseResourceType ...@@ -135,14 +152,16 @@ public class LinkedResourceType : BaseResourceType
key = "/" + key; key = "/" + key;
} }
var graph = _rdfStoreConnector.GetGraph(GetGraphName(id, key)); var urlId = _coscineLDPHelper.GetId(id, key, true, false, "data");
var graph = _rdfStoreConnector.GetGraph(urlId);
if (graph.IsEmpty) if (graph.IsEmpty)
{ {
return Task.FromResult<Stream?>(null); return Task.FromResult<Stream?>(null);
} }
var triples = graph.GetTriplesWithSubjectPredicate(graph.CreateUriNode(new Uri(GetSubjectName(id, key))), graph.CreateUriNode(new Uri(_predicate))); var triples = graph.GetTriplesWithPredicate(graph.CreateUriNode(new Uri(_predicate)));
if (!triples.Any()) if (!triples.Any())
{ {
...@@ -173,19 +192,21 @@ public class LinkedResourceType : BaseResourceType ...@@ -173,19 +192,21 @@ public class LinkedResourceType : BaseResourceType
Array.Resize(ref buffer, size); Array.Resize(ref buffer, size);
var graph = _rdfStoreConnector.GetGraph(GetGraphName(id, key)); var urlId = _coscineLDPHelper.GetId(id, key, true, false, "data");
var graph = _rdfStoreConnector.GetGraph(urlId);
if (!graph.IsEmpty) if (!graph.IsEmpty)
{ {
var triples = graph.GetTriplesWithSubjectPredicate(graph.CreateUriNode(new Uri(GetSubjectName(id, key))), graph.CreateUriNode(new Uri(_predicate))); var triples = graph.GetTriplesWithPredicate(graph.CreateUriNode(new Uri(_predicate)));
graph.Retract(triples.ToArray()); graph.Retract(triples.ToArray());
} }
else else
{ {
_rdfStoreConnector.CreateNamedGraph(GetGraphName(id, key)); _rdfStoreConnector.CreateNamedGraph(urlId);
} }
graph.Assert(new Triple(graph.CreateUriNode(new Uri(GetSubjectName(id, key))), graph.CreateUriNode(new Uri(_predicate)), graph.CreateLiteralNode(Encoding.UTF8.GetString(buffer)))); graph.Assert(new Triple(graph.CreateUriNode(urlId), graph.CreateUriNode(new Uri(_predicate)), graph.CreateLiteralNode(Encoding.UTF8.GetString(buffer))));
_rdfStoreConnector.AddGraph(graph); _rdfStoreConnector.AddGraph(graph);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName> <AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName>
<RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace> <RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
<Version>1.8.7</Version> <Version>1.9.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Coscine.Metadata" Version="2.*-*" /> <PackageReference Include="Coscine.Metadata" Version="*-*" />
<PackageReference Include="dotNetRDF" Version="2.7.4" /> <PackageReference Include="dotNetRDF" Version="2.7.4" />
</ItemGroup> </ItemGroup>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName> <AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName>
<RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace> <RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
<Version>1.8.7</Version> <Version>1.9.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName> <AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName>
<RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace> <RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
<Version>1.8.7</Version> <Version>1.9.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName> <AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName>
<RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace> <RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
<Version>1.8.7</Version> <Version>1.9.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName> <AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName>
<RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace> <RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
<Version>1.8.7</Version> <Version>1.9.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
......
...@@ -29,9 +29,17 @@ public static class Helpers ...@@ -29,9 +29,17 @@ public static class Helpers
// Linked has no quota. // Linked has no quota.
var baseResourceType = ResourceTypeFactory.Instance.GetResourceType(resource); var baseResourceType = ResourceTypeFactory.Instance.GetResourceType(resource);
if (baseResourceType.GetResourceTypeInformation().Result.IsQuotaAvailable) if (baseResourceType.GetResourceTypeInformation().Result.IsQuotaAvailable)
{
try
{ {
return baseResourceType.GetResourceQuotaAvailable(resource.Id.ToString(), _resourceModel.GetResourceTypeOptions(resource.Id)).Result; return baseResourceType.GetResourceQuotaAvailable(resource.Id.ToString(), _resourceModel.GetResourceTypeOptions(resource.Id)).Result;
} }
catch (Exception)
{
// Error in communicating with the resource
return 0;
}
}
else else
{ {
return 0; return 0;
...@@ -134,8 +142,16 @@ public static class Helpers ...@@ -134,8 +142,16 @@ public static class Helpers
if (returnObject.ResourceTypeOption.ContainsKey("Size")) if (returnObject.ResourceTypeOption.ContainsKey("Size"))
{ {
var resourceTypeDefinition = ResourceTypeFactory.Instance.GetResourceType(resource); var resourceTypeDefinition = ResourceTypeFactory.Instance.GetResourceType(resource);
try
{
returnObject.ResourceTypeOption["Size"] = resourceTypeDefinition.GetResourceQuotaAvailable(resource.Id.ToString()).Result; returnObject.ResourceTypeOption["Size"] = resourceTypeDefinition.GetResourceQuotaAvailable(resource.Id.ToString()).Result;
} }
catch (Exception)
{
// Error in communicating with the resource
returnObject.ResourceTypeOption["Size"] = 0;
}
}
return returnObject; return returnObject;
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace> <RootNamespace>Coscine.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
<AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName> <AssemblyName>Coscine.$(MSBuildProjectName)</AssemblyName>
<Version>1.8.7</Version> <Version>1.9.0</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
......
...@@ -29,7 +29,10 @@ ...@@ -29,7 +29,10 @@
"en": "RDS" "en": "RDS"
}, },
"status": "active", "status": "active",
"supportedOrganizations": [ "*" ] "supportedOrganizations": [
"https://ror.org/04xfq0f34",
"https://ror.org/04tqgg260"
]
}, },
"rdsude": { "rdsude": {
"type": "rds", "type": "rds",
...@@ -41,7 +44,7 @@ ...@@ -41,7 +44,7 @@
"en": "RDS UDE" "en": "RDS UDE"
}, },
"status": "active", "status": "active",
"supportedOrganizations": [ "*" ] "supportedOrganizations": [ "https://ror.org/04mz5ra38" ]
}, },
"rdsnrw": { "rdsnrw": {
"type": "rds", "type": "rds",
...@@ -53,7 +56,20 @@ ...@@ -53,7 +56,20 @@
"en": "RDS NRW" "en": "RDS NRW"
}, },
"status": "hidden", "status": "hidden",
"supportedOrganizations": [ "*" ] "supportedOrganizations": [
"https://ror.org/00edvg943",
"https://ror.org/04x02q560",
"https://ror.org/03hj8rz96",
"https://ror.org/03dv91853",
"https://ror.org/00ftx0026",
"https://ror.org/04p7ekn23",
"https://ror.org/04wdt0z89",
"https://ror.org/014nnvj65",
"https://ror.org/04eka8j06",
"https://ror.org/02nkxrq89",
"https://ror.org/00pv45a02",
"https://ror.org/04m2anh63"
]
}, },
"rdstudo": { "rdstudo": {
"type": "rds", "type": "rds",
...@@ -65,7 +81,7 @@ ...@@ -65,7 +81,7 @@
"en": "RDS TUDo" "en": "RDS TUDo"
}, },
"status": "hidden", "status": "hidden",
"supportedOrganizations": [ "*" ] "supportedOrganizations": [ "https://ror.org/01k97gp34" ]
}, },
"rdss3rwth": { "rdss3rwth": {
"type": "rdss3", "type": "rdss3",
...@@ -78,7 +94,10 @@ ...@@ -78,7 +94,10 @@
"en": "RDS S3" "en": "RDS S3"
}, },
"status": "active", "status": "active",
"supportedOrganizations": [ "*" ] "supportedOrganizations": [
"https://ror.org/04xfq0f34",
"https://ror.org/04tqgg260"
]
}, },
"rdss3ude": { "rdss3ude": {
"type": "rdss3", "type": "rdss3",
...@@ -91,7 +110,7 @@ ...@@ -91,7 +110,7 @@
"en": "RDS S3 UDE" "en": "RDS S3 UDE"
}, },
"status": "active", "status": "active",
"supportedOrganizations": [ "*" ] "supportedOrganizations": [ "https://ror.org/04mz5ra38" ]
}, },
"rdss3nrw": { "rdss3nrw": {
"type": "rdss3", "type": "rdss3",
...@@ -104,7 +123,20 @@ ...@@ -104,7 +123,20 @@
"en": "RDS S3 NRW" "en": "RDS S3 NRW"
}, },
"status": "active", "status": "active",
"supportedOrganizations": [ "*" ] "supportedOrganizations": [
"https://ror.org/00edvg943",
"https://ror.org/04x02q560",
"https://ror.org/03hj8rz96",
"https://ror.org/03dv91853",
"https://ror.org/00ftx0026",
"https://ror.org/04p7ekn23",
"https://ror.org/04wdt0z89",
"https://ror.org/014nnvj65",
"https://ror.org/04eka8j06",
"https://ror.org/02nkxrq89",
"https://ror.org/00pv45a02",
"https://ror.org/04m2anh63"
]
}, },
"rdss3tudo": { "rdss3tudo": {
"type": "rdss3", "type": "rdss3",
...@@ -118,7 +150,7 @@ ...@@ -118,7 +150,7 @@
"en": "RDS S3 TUDo" "en": "RDS S3 TUDo"
}, },
"status": "hidden", "status": "hidden",
"supportedOrganizations": [ "*" ] "supportedOrganizations": [ "https://ror.org/01k97gp34" ]
}, },
"rdss3wormrwth": { "rdss3wormrwth": {
"type": "rdss3", "type": "rdss3",
...@@ -132,6 +164,9 @@ ...@@ -132,6 +164,9 @@
"en": "RDS S3 Worm RWTH" "en": "RDS S3 Worm RWTH"
}, },
"status": "active", "status": "active",
"supportedOrganizations": [ "*" ] "supportedOrganizations": [
"https://ror.org/04xfq0f34",
"https://ror.org/04tqgg260"
]
} }
} }