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
!8
Release: Sprint/2022 12
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Release: Sprint/2022 12
dev
into
main
Overview
0
Commits
6
Pipelines
2
Changes
3
Merged
Petar Hristov
requested to merge
dev
into
main
2 years ago
Overview
0
Commits
6
Pipelines
2
Changes
3
Expand
This Merge Request is automatically created
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
868940b1
6 commits,
2 years ago
3 files
+
117
−
13
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/SQL2Linked/Implementations/ResourceTypeStructuralData.cs
+
59
−
2
Options
@@ -6,10 +6,67 @@ namespace SQL2Linked.Implementations
{
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
)
{
// 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
Loading