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
Commits
57191db8
Commit
57191db8
authored
5 years ago
by
Benedikt Heinrichs
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Include Bulk Import (coscine/issues#854)
parent
3a70d789
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/OrganizationDeployer/Program.cs
+53
-29
53 additions, 29 deletions
src/OrganizationDeployer/Program.cs
src/OrganizationDeployer/getOrganizations.ps1
+21
-1
21 additions, 1 deletion
src/OrganizationDeployer/getOrganizations.ps1
with
74 additions
and
30 deletions
src/OrganizationDeployer/Program.cs
+
53
−
29
View file @
57191db8
...
...
@@ -14,26 +14,10 @@ namespace Coscine.OrganizationDeployer
{
public
static
void
Main
(
string
[]
args
)
{
ProcessStartInfo
startInfo
=
new
ProcessStartInfo
{
FileName
=
@"powershell.exe"
,
Arguments
=
$@"& '
{
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"getOrganizations.ps1"
)
}
'"
,
RedirectStandardOutput
=
true
,
RedirectStandardError
=
true
,
UseShellExecute
=
false
,
CreateNoWindow
=
true
};
Process
process
=
new
Process
{
StartInfo
=
startInfo
};
process
.
Start
();
string
output
=
process
.
StandardOutput
.
ReadToEnd
();
Console
.
WriteLine
(
output
);
string
errors
=
process
.
StandardError
.
ReadToEnd
();
Console
.
WriteLine
(
errors
);
ExecuteCommand
(
"powershell.exe"
,
$@"& '
{
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"getOrganizations.ps1"
)
}
'"
);
var
configuration
=
new
ConsulConfiguration
();
...
...
@@ -45,28 +29,68 @@ namespace Coscine.OrganizationDeployer
VirtuosoManager
virtuosoManager
=
new
VirtuosoManager
(
$"Server=
{
virtuosoHost
}
;Uid=
{
virtuosoUser
}
;pwd=
{
virtuosoPassword
}
"
);
var
_util
=
new
Util
(
virtuosoServer
);
foreach
(
var
file
in
GetFiles
(
"organizations"
).
Where
((
file
)
=>
file
.
Contains
(
".ttl"
)))
{
var
folder
=
"/voc"
;
var
virtuosoISQLLocation
=
configuration
.
GetString
(
"coscine/local/virtuoso/isql"
,
"C:/Programs/Virtuoso/bin/isql.exe"
);
var
queries
=
new
List
<
string
>();
foreach
(
var
file
in
GetFiles
(
folder
).
Where
((
file
)
=>
file
.
Contains
(
".ttl"
)))
{
var
fileInfo
=
new
FileInfo
(
file
);
var
graph
=
new
Graph
();
graph
.
LoadFromFile
(
file
);
var
graphName
=
graph
.
BaseUri
.
ToString
();
if
(
_util
.
HasGraph
(
graphName
))
{
Console
.
WriteLine
(
$"Clearing
{
graphName
}
"
);
_util
.
ClearGraph
(
graphName
);
}
else
{
Console
.
WriteLine
(
$"Creating
{
graphName
}
"
);
_util
.
CreateNamedGraph
(
graphName
);
queries
.
Add
(
$"ld_dir('
{
fileInfo
.
DirectoryName
.
Substring
(
2
).
Replace
(
"\\"
,
"/"
)}
', '
{
fileInfo
.
Name
}
', '
{
graphName
}
');"
);
}
queries
.
Add
(
$"rdf_loader_run ();"
);
queries
.
Add
(
$"DELETE from DB.DBA.load_list where 1=1;"
);
Console
.
WriteLine
(
$"Adding to
{
graphName
}
"
);
virtuosoManager
.
SaveGraph
(
graph
);
foreach
(
var
query
in
queries
)
{
ExecuteCommand
(
"powershell.exe"
,
$"\"\\\"
{
query
}
\\\" |
{
virtuosoISQLLocation
}
\""
);
}
Console
.
WriteLine
(
"Done"
);
}
private
static
void
ExecuteCommand
(
string
fileName
,
string
arguments
)
{
ProcessStartInfo
startInfo
=
new
ProcessStartInfo
{
FileName
=
fileName
,
Arguments
=
arguments
,
RedirectStandardOutput
=
true
,
RedirectStandardError
=
true
,
UseShellExecute
=
false
,
CreateNoWindow
=
true
,
};
using
(
var
process
=
new
Process
{
StartInfo
=
startInfo
})
{
process
.
Start
();
string
output
=
process
.
StandardOutput
.
ReadToEnd
();
Console
.
WriteLine
(
output
);
string
errors
=
process
.
StandardError
.
ReadToEnd
();
Console
.
WriteLine
(
errors
);
}
}
private
static
IEnumerable
<
string
>
GetFiles
(
string
path
)
{
Queue
<
string
>
queue
=
new
Queue
<
string
>();
...
...
This diff is collapsed.
Click to expand it.
src/OrganizationDeployer/getOrganizations.ps1
+
21
−
1
View file @
57191db8
...
...
@@ -10,6 +10,26 @@ git clone https://gitlab-ci-token:$gitlab_token@git.rwth-aachen.de/coscine/organ
cd
organizations
git
checkout
Master
$pagebranch
=
&
$fullPath
kv
get
'coscine/local/organizationdeployer/branch'
if
(
!
$pagebranch
)
{
$pagebranch
=
'master'
;
}
git
checkout
$pagebranch
git
pull
cd
..
$path
=
'/voc'
# Twice remove, because of: https://stackoverflow.com/questions/7909167/how-to-quietly-remove-a-directory-with-content-in-powershell#comment10316056_7909195
If
(
Test-Path
$path
)
{
Remove-Item
-LiteralPath
$path
-Force
-Recurse
}
If
(
Test-Path
$path
)
{
Remove-Item
-LiteralPath
$path
-Force
-Recurse
}
New-Item
-ItemType
Directory
-Force
-Path
$path
Copy-Item
'./organizations/*'
$path
-Recurse
;
Pop-Location
\ No newline at end of file
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