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
e2401853
Commit
e2401853
authored
Jun 15, 2022
by
Hanna Führ
Browse files
Options
Downloads
Patches
Plain Diff
Update: Migrate user structural data to linked data (coscine/issues#2081)
parent
04bf9e9d
No related branches found
No related tags found
1 merge request
!3
Fix: Migrate user structural data to linked data
Pipeline
#735280
skipped
Stage: commands
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/SQL2Linked/Implementations/UserStructuralData.cs
+46
-2
46 additions, 2 deletions
src/SQL2Linked/Implementations/UserStructuralData.cs
src/SQL2Linked/StructuralData.cs
+6
-2
6 additions, 2 deletions
src/SQL2Linked/StructuralData.cs
with
52 additions
and
4 deletions
src/SQL2Linked/Implementations/UserStructuralData.cs
+
46
−
2
View file @
e2401853
using
Coscine.Database.DataModel
;
using
Coscine.Database.DataModel
;
using
Coscine.Database.Models
;
using
Coscine.Database.Models
;
using
Coscine.Metadata
;
using
VDS.RDF
;
using
VDS.RDF
;
using
VDS.RDF.Query
;
namespace
SQL2Linked.Implementations
namespace
SQL2Linked.Implementations
{
{
public
class
UserStructuralData
:
StructuralData
<
User
,
UserModel
>
public
class
UserStructuralData
:
StructuralData
<
User
,
UserModel
>
{
{
public
readonly
string
UserUrlPrefix
=
"https://purl.org/coscine/users"
;
public
readonly
Uri
FoafPerson
=
new
Uri
(
"http://xmlns.com/foaf/0.1/Person"
);
public
override
IEnumerable
<
IGraph
>
ConvertToLinkedData
(
IEnumerable
<
User
>
entries
)
public
override
IEnumerable
<
IGraph
>
ConvertToLinkedData
(
IEnumerable
<
User
>
entries
)
{
{
// ToDo: Implement
var
graphs
=
new
List
<
IGraph
>();
throw
new
NotImplementedException
();
foreach
(
User
entry
in
entries
)
{
string
userGraphName
=
$"
{
UserUrlPrefix
}
/
{
entry
.
Id
}
"
;
IGraph
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
.
Count
()
==
0
)
{
// check if a user graph already exists
bool
exists
=
RdfStoreConnector
.
HasGraph
(
userGraphName
);
if
(!
exists
)
{
RdfStoreConnector
.
CreateNamedGraph
(
userGraphName
);
}
// extend graph by triple https://purl.org/coscine/users/{userId} a foaf:Person
var
commandString
=
new
SparqlParameterizedString
{
CommandText
=
@"INSERT
{
GRAPH @userGraphName
{
[
a foaf:Person ;
]
}
}"
};
commandString
.
Namespaces
.
AddNamespace
(
"foaf"
,
FoafPrefixUrl
);
commandString
.
SetUri
(
"userGraphName"
,
new
Uri
(
userGraphName
));
QueryEndpoint
.
QueryRaw
(
commandString
.
ToString
());
}
graphs
.
Add
(
graph
);
}
return
graphs
;
}
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/SQL2Linked/StructuralData.cs
+
6
−
2
View file @
e2401853
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
using
Coscine.Database.Models
;
using
Coscine.Database.Models
;
using
Coscine.Metadata
;
using
Coscine.Metadata
;
using
VDS.RDF
;
using
VDS.RDF
;
using
VDS.RDF.Query
;
namespace
SQL2Linked
namespace
SQL2Linked
{
{
...
@@ -10,12 +11,15 @@ namespace SQL2Linked
...
@@ -10,12 +11,15 @@ namespace SQL2Linked
public
T
Model
{
get
;
init
;
}
public
T
Model
{
get
;
init
;
}
public
ConsulConfiguration
Configuration
{
get
;
init
;
}
public
ConsulConfiguration
Configuration
{
get
;
init
;
}
public
RdfStoreConnector
RdfStoreConnector
{
get
;
init
;
}
public
RdfStoreConnector
RdfStoreConnector
{
get
;
init
;
}
public
readonly
SparqlRemoteEndpoint
QueryEndpoint
;
public
readonly
Uri
FoafPrefixUrl
=
new
Uri
(
"http://xmlns.com/foaf/0.1/"
);
public
StructuralData
()
public
StructuralData
()
{
{
Configuration
=
new
ConsulConfiguration
();
Configuration
=
new
ConsulConfiguration
();
RdfStoreConnector
=
new
RdfStoreConnector
(
Configuration
.
GetStringAndWait
(
"coscine/local/virtuoso/additional/url"
));
RdfStoreConnector
=
new
RdfStoreConnector
(
Configuration
.
GetStringAndWait
(
"coscine/local/virtuoso/additional/url"
));
Model
=
new
T
();
Model
=
new
T
();
QueryEndpoint
=
new
SparqlRemoteEndpoint
(
new
Uri
(
string
.
Format
(
"http://localhost:8890/sparql"
)));
}
}
public
abstract
IEnumerable
<
IGraph
>
ConvertToLinkedData
(
IEnumerable
<
S
>
entries
);
public
abstract
IEnumerable
<
IGraph
>
ConvertToLinkedData
(
IEnumerable
<
S
>
entries
);
...
...
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