Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GraphDeployer
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor 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
GraphDeployer
Merge requests
!9
Fix: Deploy only changed graphs
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Fix: Deploy only changed graphs
Hotfix/2352-onlyChanged
into
master
Overview
0
Commits
2
Pipelines
2
Changes
1
Merged
Benedikt Heinrichs
requested to merge
Hotfix/2352-onlyChanged
into
master
2 years ago
Overview
0
Commits
2
Pipelines
2
Changes
1
coscine/issues#2352
0
0
Merge request reports
Compare
master
version 1
65de903b
2 years ago
master (base)
and
version 1
latest version
86a17cf7
2 commits,
2 years ago
version 1
65de903b
1 commit,
2 years ago
1 file
+
44
−
9
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/GraphDeployer/Program.cs
+
44
−
9
View file @ 65de903b
Edit in single-file editor
Open in Web IDE
Show full file
@@ -90,24 +90,59 @@ public class Program
// Graph Insertion
var
queries
=
new
List
<
string
>();
var
turtleFiles
=
Directory
.
GetFiles
(
WorkingFolder
,
"*.ttl"
,
SearchOption
.
AllDirectories
);
foreach
(
var
file
in
turtleFiles
)
var
graphAccumulation
=
new
Dictionary
<
Uri
,
(
Graph
,
List
<
string
>)>();
Array
.
ForEach
(
turtleFiles
,
(
file
)
=>
{
var
fileInfo
=
new
FileInfo
(
file
);
var
graph
=
new
Graph
();
graph
.
LoadFromFile
(
file
);
var
graphName
=
graph
.
BaseUri
.
ToString
();
if
(
graphAccumulation
.
ContainsKey
(
graph
.
BaseUri
))
{
graphAccumulation
[
graph
.
BaseUri
].
Item1
.
Merge
(
graph
);
graphAccumulation
[
graph
.
BaseUri
].
Item2
.
Add
(
file
);
}
else
{
graphAccumulation
.
Add
(
graph
.
BaseUri
,
(
graph
,
new
List
<
string
>()
{
file
}));
}
});
if
(
_rdfStoreConnector
.
HasGraph
(
graphName
))
foreach
(
var
kv
in
graphAccumulation
)
{
var
graph
=
kv
.
Value
.
Item1
;
var
graphName
=
kv
.
Key
.
ToString
();
var
currentGraph
=
_rdfStoreConnector
.
GetGraph
(
graphName
);
var
graphWasChanged
=
graph
.
Triples
.
Count
!=
currentGraph
.
Triples
.
Count
||
graph
.
Triples
.
Any
((
triple
)
=>
!
currentGraph
.
Triples
.
Any
((
currentTriple
)
=>
(
triple
.
Subject
.
Equals
(
currentTriple
.
Subject
)
||
(
triple
.
Subject
.
NodeType
==
NodeType
.
Blank
&&
currentTriple
.
Subject
.
NodeType
==
NodeType
.
Blank
)
&&
triple
.
Predicate
.
Equals
(
currentTriple
.
Predicate
)
&&
triple
.
Object
.
Equals
(
currentTriple
.
Object
)
||
(
triple
.
Object
.
NodeType
==
NodeType
.
Blank
&&
currentTriple
.
Object
.
NodeType
==
NodeType
.
Blank
))));
if
(
graphWasChanged
)
{
_rdfStoreConnector
.
ClearGraph
(
graphName
);
_logger
.
LogInformation
(
"Cleared Graph {graphName}"
,
graphName
);
if
(!
currentGraph
.
IsEmpty
)
{
_rdfStoreConnector
.
ClearGraph
(
graphName
);
_logger
.
LogInformation
(
"Cleared Graph {graphName}"
,
graphName
);
}
else
{
_logger
.
LogInformation
(
"No Graph {graphName}"
,
graphName
);
}
foreach
(
var
file
in
kv
.
Value
.
Item2
)
{
var
fileInfo
=
new
FileInfo
(
file
);
queries
.
Add
(
$"ld_dir('
{
fileInfo
.
DirectoryName
[
2
..].
Replace
(
"\\"
,
"/"
)}
', '
{
fileInfo
.
Name
}
', '
{
graphName
}
');"
);
}
}
else
{
_logger
.
LogInformation
(
"No Graph {graphName}"
,
graphName
);
}
_logger
.
LogInformation
(
"Skipping {graphName}"
,
graphName
);
queries
.
Add
(
$"ld_dir('
{
fileInfo
.
DirectoryName
[
2
..].
Replace
(
"\\"
,
"/"
)}
', '
{
fileInfo
.
Name
}
', '
{
graphName
}
');"
);
}
}
queries
.
Add
(
$"rdf_loader_run ();"
);
queries
.
Add
(
$"DELETE from DB.DBA.load_list where 1=1;"
);
Loading