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/scripts/sql2linked
1 result
Select Git revision
Loading items
Show changes
Commits on Source (2)
......@@ -20,6 +20,8 @@ namespace SQL2Linked.Implementations
private ProjectResourceModel ProjectResourceModel = new ProjectResourceModel();
private LicenseModel LicenseModel = new LicenseModel();
private readonly Dictionary<string, string> _targetClassMap = new Dictionary<string, string>();
// Override to also receive deleted resources
public override IEnumerable<Resource> GetAll()
{
......@@ -134,11 +136,13 @@ namespace SQL2Linked.Implementations
AssertToGraphLiteralNode(graph, resourceGraphName, cosc + "terms/resource#deleted", entry.Deleted.ToString().ToLower(), new Uri("http://www.w3.org/2001/XMLSchema#boolean"));
Console.WriteLine($"For project '{entry.DisplayName}' will migrate triple '{resourceGraphName} {cosc}terms/resource#deleted {entry.Deleted}'. ");
var targetClass = GetTargetClass(entry);
SparqlParameterizedString cmdString = new SparqlParameterizedString
{
CommandText = "SELECT DISTINCT ?g " +
"WHERE {" +
"GRAPH ?g { ?s ?p ?o } . " +
"GRAPH ?g { ?s a <" + targetClass + "> } . " +
"FILTER(contains(STR(?g), \"" + resourceHandleName + "@\"))" +
"}"
};
......@@ -188,5 +192,36 @@ namespace SQL2Linked.Implementations
return graphs;
}
/// <summary>
/// Since Application Profile URL does not have to be the targetClass, resolve it first
/// </summary>
/// <param name="entry"></param>
/// <returns></returns>
private string GetTargetClass(Resource entry)
{
if (_targetClassMap.ContainsKey(entry.ApplicationProfile))
{
return _targetClassMap[entry.ApplicationProfile];
}
var targetClassCmdString = new SparqlParameterizedString
{
CommandText = "SELECT DISTINCT ?targetClass " +
"WHERE { @applicationProfile <http://www.w3.org/ns/shacl#targetClass> ?targetClass }"
};
targetClassCmdString.SetUri("applicationProfile", new Uri(entry.ApplicationProfile));
var targetClassResultSet = QueryEndpoint.QueryWithResultSet(targetClassCmdString.ToString());
var targetClass = entry.ApplicationProfile;
foreach (var result in targetClassResultSet)
{
targetClass = result[0].ToString();
}
_targetClassMap.Add(entry.ApplicationProfile, targetClass);
return targetClass;
}
}
}
......@@ -5,7 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.1.10</Version></PropertyGroup>
<Version>0.1.11</Version></PropertyGroup>
<ItemGroup>
<PackageReference Include="Coscine.Database" Version="2.*-*" />
......