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
c3f42c1f
Commit
c3f42c1f
authored
Jul 6, 2022
by
Benedikt Heinrichs
Browse files
Options
Downloads
Plain Diff
Merge branch 'dev' into Issue/2082-migrateRoleStructuralData
parents
54d7a9f3
28df7884
No related branches found
No related tags found
1 merge request
!6
Fix: Migrate role structured data to linked data
Pipeline
#751390
skipped
Stage: commands
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/SQL2Linked/Implementations/ResourceTypeStructuralData.cs
+59
-2
59 additions, 2 deletions
src/SQL2Linked/Implementations/ResourceTypeStructuralData.cs
src/SQL2Linked/Implementations/UserStructuralData.cs
+1
-9
1 addition, 9 deletions
src/SQL2Linked/Implementations/UserStructuralData.cs
with
60 additions
and
11 deletions
src/SQL2Linked/Implementations/ResourceTypeStructuralData.cs
+
59
−
2
View file @
c3f42c1f
...
@@ -6,10 +6,67 @@ namespace SQL2Linked.Implementations
...
@@ -6,10 +6,67 @@ namespace SQL2Linked.Implementations
{
{
public
class
ResourceTypeStructuralData
:
StructuralData
<
ResourceType
,
ResourceTypeModel
>
public
class
ResourceTypeStructuralData
:
StructuralData
<
ResourceType
,
ResourceTypeModel
>
{
{
public
readonly
string
ResourceTypeUrlPrefix
=
"https://purl.org/coscine/resourcetype"
;
public
readonly
Uri
RdfType
=
new
(
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
);
public
readonly
Uri
DcatDataService
=
new
(
"http://www.w3.org/ns/dcat#DataService"
);
public
readonly
Uri
dctermsTitle
=
new
(
"http://purl.org/dc/terms/title"
);
public
override
IEnumerable
<
IGraph
>
ConvertToLinkedData
(
IEnumerable
<
ResourceType
>
entries
)
public
override
IEnumerable
<
IGraph
>
ConvertToLinkedData
(
IEnumerable
<
ResourceType
>
entries
)
{
{
// ToDo: Implement
throw
new
NotImplementedException
();
var
graphs
=
new
List
<
IGraph
>();
foreach
(
var
entry
in
entries
)
{
var
resourceTypeGraphName
=
$"
{
ResourceTypeUrlPrefix
}
/
{
entry
.
Id
}
"
;
var
graph
=
RdfStoreConnector
.
GetGraph
(
resourceTypeGraphName
);
// check if a triple with a dcat:DataService already exists in the resourcetype graph
var
getTriplesDcatDataService
=
graph
.
GetTriplesWithObject
(
DcatDataService
);
if
(!
getTriplesDcatDataService
.
Any
())
{
graph
.
Assert
(
new
Triple
(
graph
.
CreateUriNode
(
new
Uri
(
resourceTypeGraphName
)),
graph
.
CreateUriNode
(
RdfType
),
graph
.
CreateUriNode
(
DcatDataService
)
)
);
Console
.
WriteLine
(
$"For resource type '
{
entry
.
DisplayName
}
' will migrate triple '
{
graph
.
BaseUri
}
' a dcat:DataService. "
);
}
else
{
Console
.
WriteLine
(
$"For resource type '
{
entry
.
DisplayName
}
' will NOT migrate triple '
{
graph
.
BaseUri
}
' a dcat:DataService. "
);
}
// check if a triple with dcterms:title '{entry.DisplayName}' already exists in the role graph
var
getTriplesDctermsTitle
=
graph
.
GetTriplesWithPredicate
(
dctermsTitle
);
if
(!
getTriplesDctermsTitle
.
Any
())
{
graph
.
Assert
(
new
Triple
(
graph
.
CreateUriNode
(
new
Uri
(
resourceTypeGraphName
)),
graph
.
CreateUriNode
(
dctermsTitle
),
graph
.
CreateLiteralNode
(
entry
.
DisplayName
)
)
);
Console
.
WriteLine
(
$"For resource type '
{
entry
.
DisplayName
}
' will migrate triple '
{
graph
.
BaseUri
}
' dcterms:title '
{
entry
.
DisplayName
}
'. "
);
}
}
else
{
Console
.
WriteLine
(
$"For resource type '
{
entry
.
DisplayName
}
' will NOT migrate triple '
{
graph
.
BaseUri
}
' dcterms:title '
{
entry
.
DisplayName
}
'. "
);
}
}
if
(!
getTriplesDcatDataService
.
Any
()
||
!
getTriplesDctermsTitle
.
Any
())
{
graphs
.
Add
(
graph
);
}
}
return
graphs
;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/SQL2Linked/Implementations/UserStructuralData.cs
+
1
−
9
View file @
c3f42c1f
...
@@ -25,17 +25,9 @@ namespace SQL2Linked.Implementations
...
@@ -25,17 +25,9 @@ namespace SQL2Linked.Implementations
if
(!
getTriples
.
Any
())
if
(!
getTriples
.
Any
())
{
{
// check if a user graph already exists
var
exists
=
RdfStoreConnector
.
HasGraph
(
userGraphName
);
if
(!
exists
)
{
RdfStoreConnector
.
CreateNamedGraph
(
userGraphName
);
}
graph
.
Assert
(
graph
.
Assert
(
new
Triple
(
new
Triple
(
graph
.
Create
BlankNode
(
),
graph
.
Create
UriNode
(
new
Uri
(
userGraphName
)
),
graph
.
CreateUriNode
(
RdfType
),
graph
.
CreateUriNode
(
RdfType
),
graph
.
CreateUriNode
(
FoafPerson
)
graph
.
CreateUriNode
(
FoafPerson
)
)
)
...
...
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