Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SQL2Linked
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coscine
backend
scripts
SQL2Linked
Commits
abfaaef3
Commit
abfaaef3
authored
2 years ago
by
Benedikt Heinrichs
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Speedup listing of metadata
parent
f5f77526
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#837305
passed
2 years ago
Stage: build
Stage: publish
Stage: commands
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/SQL2Linked/Implementations/ResourceStructuralData.cs
+36
-1
36 additions, 1 deletion
src/SQL2Linked/Implementations/ResourceStructuralData.cs
with
36 additions
and
1 deletion
src/SQL2Linked/Implementations/ResourceStructuralData.cs
+
36
−
1
View file @
abfaaef3
...
...
@@ -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
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment