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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coscine
backend
scripts
SQL2Linked
Merge requests
!3
Fix: Migrate user structural data to linked data
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Fix: Migrate user structural data to linked data
Issue/2081-migrateUserStructuralData
into
dev
Overview
0
Commits
3
Pipelines
7
Changes
2
Merged
Hanna Führ
requested to merge
Issue/2081-migrateUserStructuralData
into
dev
2 years ago
Overview
0
Commits
3
Pipelines
7
Changes
2
Expand
coscine/issues#2081
0
0
Merge request reports
Compare
dev
version 2
8af130f1
2 years ago
version 1
e2401853
2 years ago
dev (base)
and
latest version
latest version
a989ff56
3 commits,
2 years ago
version 2
8af130f1
2 commits,
2 years ago
version 1
e2401853
1 commit,
2 years ago
2 files
+
45
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
src/SQL2Linked/Implementations/UserStructuralData.cs
+
44
−
3
Options
using
Coscine.Database.DataModel
;
using
Coscine.Database.Models
;
using
Coscine.Metadata
;
using
VDS.RDF
;
namespace
SQL2Linked.Implementations
{
public
class
UserStructuralData
:
StructuralData
<
User
,
UserModel
>
{
public
readonly
string
UserUrlPrefix
=
"https://purl.org/coscine/users"
;
public
readonly
Uri
RdfType
=
new
(
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
);
public
readonly
Uri
FoafPerson
=
new
(
"http://xmlns.com/foaf/0.1/Person"
);
public
override
IEnumerable
<
IGraph
>
ConvertToLinkedData
(
IEnumerable
<
User
>
entries
)
{
// ToDo: Implement
throw
new
NotImplementedException
();
var
graphs
=
new
List
<
IGraph
>();
foreach
(
var
entry
in
entries
)
{
var
userGraphName
=
$"
{
UserUrlPrefix
}
/
{
entry
.
Id
}
"
;
var
graph
=
RdfStoreConnector
.
GetGraph
(
userGraphName
);
// check if a triple with a foaf:Person already exists in the user graph
var
getTriples
=
graph
.
GetTriplesWithObject
(
FoafPerson
);
if
(!
getTriples
.
Any
())
{
// check if a user graph already exists
var
exists
=
RdfStoreConnector
.
HasGraph
(
userGraphName
);
if
(!
exists
)
{
RdfStoreConnector
.
CreateNamedGraph
(
userGraphName
);
}
graph
.
Assert
(
new
Triple
(
graph
.
CreateBlankNode
(),
graph
.
CreateUriNode
(
RdfType
),
graph
.
CreateUriNode
(
FoafPerson
)
)
);
graphs
.
Add
(
graph
);
Console
.
WriteLine
(
$"Will migrate user '
{
entry
.
DisplayName
}
' with id '
{
entry
.
Id
}
'."
);
}
else
{
Console
.
WriteLine
(
$"Will NOT migrate user '
{
entry
.
DisplayName
}
' with id '
{
entry
.
Id
}
'."
);
}
}
return
graphs
;
}
}
}
\ No newline at end of file
}
Loading