Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Migrations
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
libraries
Migrations
Merge requests
!9
Topic/712 organizations
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Topic/712 organizations
Topic/712-organizations
into
Product/483-organizations
Overview
0
Commits
3
Pipelines
1
Changes
6
Merged
Benedikt Heinrichs
requested to merge
Topic/712-organizations
into
Product/483-organizations
5 years ago
Overview
0
Commits
3
Pipelines
1
Changes
6
coscine/issues#712
0
0
Merge request reports
Compare
Product/483-organizations
Product/483-organizations (base)
and
latest version
latest version
74053448
3 commits,
5 years ago
6 files
+
116
−
42
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
src/Migrator/Migrations/Migration201910161154InstitutesDisciplines.cs
+
5
−
35
View file @ 74053448
Edit in single-file editor
Open in Web IDE
Show full file
@@ -13,17 +13,17 @@ namespace Coscine.Database.Migration.Migrations
{
public
override
void
Down
()
{
HandleInstitute
((
obj
)
=>
Delete
.
FromTable
(
"Institutes"
).
Row
(
obj
));
HandleDiscipline
((
obj
)
=>
Delete
.
FromTable
(
"Disciplines"
).
Row
(
obj
));
MigrationsHelpers
.
HandleInstitute
((
obj
)
=>
Delete
.
FromTable
(
"Institutes"
).
Row
(
obj
));
MigrationsHelpers
.
HandleDiscipline
((
obj
)
=>
Delete
.
FromTable
(
"Disciplines"
).
Row
(
obj
));
}
public
override
void
Up
()
{
HandleInstitute
((
obj
)
=>
Insert
.
IntoTable
(
"Institutes"
).
Row
(
obj
));
HandleDiscipline
((
obj
)
=>
Insert
.
IntoTable
(
"Disciplines"
).
Row
(
obj
));
MigrationsHelpers
.
HandleInstitute
((
obj
)
=>
Insert
.
IntoTable
(
"Institutes"
).
Row
(
obj
));
MigrationsHelpers
.
HandleDiscipline
((
obj
)
=>
Insert
.
IntoTable
(
"Disciplines"
).
Row
(
obj
));
}
private
void
HandleInstitute
(
Action
<
object
>
action
)
internal
void
HandleInstitute
(
Action
<
object
>
action
)
{
var
assembly
=
Assembly
.
GetExecutingAssembly
();
var
resourceName
=
"Coscine.Database.Migration.Assets.Institutes.csv"
;
@@ -44,35 +44,5 @@ namespace Coscine.Database.Migration.Migrations
}
}
}
private
void
HandleDiscipline
(
Action
<
object
>
action
)
{
var
assembly
=
Assembly
.
GetExecutingAssembly
();
var
resourceName
=
"Coscine.Database.Migration.Assets.dfg_structure.rdf"
;
using
(
var
stream
=
assembly
.
GetManifestResourceStream
(
resourceName
))
using
(
XmlReader
reader
=
XmlReader
.
Create
(
stream
))
{
reader
.
MoveToContent
();
XNamespace
skosNameSpace
=
"http://www.w3.org/2004/02/skos/core#"
;
XNamespace
rdfNameSpace
=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
;
while
(
reader
.
Read
())
{
if
(
reader
.
NodeType
==
XmlNodeType
.
Element
)
{
if
(
reader
.
Name
==
"skos:Concept"
)
{
XElement
el
=
(
XElement
)
XNode
.
ReadFrom
(
reader
);
var
notation
=
el
.
Element
(
skosNameSpace
+
"notation"
);
if
(
int
.
TryParse
(
notation
.
Value
,
out
int
val
)
&&
notation
.
Value
.
Length
==
3
)
{
var
url
=
el
.
Attribute
(
rdfNameSpace
+
"about"
).
Value
;
action
.
Invoke
(
new
{
DisplayName
=
el
.
Element
(
skosNameSpace
+
"prefLabel"
).
Value
,
Url
=
url
});
}
}
}
}
}
}
}
}
Loading