Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Database
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
Database
Merge requests
!27
Sprint/201920
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Sprint/201920
Sprint/201920
into
master
Overview
0
Commits
4
Pipelines
1
Changes
2
Merged
Marcel Nellesen
requested to merge
Sprint/201920
into
master
5 years ago
Overview
0
Commits
4
Pipelines
1
Changes
2
Sprint/201920
Edited
5 years ago
by
Marcel Nellesen
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
87b530c4
4 commits,
5 years ago
2 files
+
123
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
src/Migrator/Migrations/Migration201911040900EnglishDFG.cs
0 → 100644
+
122
−
0
View file @ 87b530c4
Edit in single-file editor
Open in Web IDE
using
FluentMigrator
;
using
System
;
using
System.IO
;
using
System.Linq
;
using
System.Reflection
;
using
System.Xml
;
using
System.Xml.Linq
;
#region DupFinder Exclusion
namespace
Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[
Migration
(
201911040900
)]
public
class
Migration201911040900EnglishDFG
:
FluentMigrator
.
Migration
{
public
override
void
Down
()
{
Delete
.
Column
(
"DisplayNameDe"
).
FromTable
(
"Disciplines"
);
Delete
.
Column
(
"DisplayNameEn"
).
FromTable
(
"Disciplines"
);
Alter
.
Table
(
"Disciplines"
).
AddColumn
(
"DisplayName"
).
AsString
(
200
).
Nullable
();
HandleDisciplineEnDown
();
}
public
override
void
Up
()
{
Delete
.
Column
(
"DisplayName"
).
FromTable
(
"Disciplines"
);
Alter
.
Table
(
"Disciplines"
).
AddColumn
(
"DisplayNameDe"
).
AsString
(
200
).
Nullable
();
Alter
.
Table
(
"Disciplines"
).
AddColumn
(
"DisplayNameEn"
).
AsString
(
200
).
Nullable
();
HandleDisciplineEnUp
();
}
private
void
HandleDisciplineEnUp
()
{
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
;
var
digits
=
el
.
Element
(
skosNameSpace
+
"notation"
).
Value
;
var
displayNames
=
el
.
Elements
(
skosNameSpace
+
"prefLabel"
);
var
displayNameDe
=
"Keine Angabe"
+
" "
+
digits
;
var
displayNameEn
=
"No Information"
+
" "
+
digits
;
foreach
(
var
displayName
in
displayNames
)
{
if
(
displayName
.
Attribute
(
XNamespace
.
Xml
+
"lang"
).
Value
.
Equals
(
"de"
))
{
displayNameDe
=
displayName
.
Value
+
" "
+
digits
;
}
else
if
(
displayName
.
Attribute
(
XNamespace
.
Xml
+
"lang"
).
Value
.
Equals
(
"en"
))
{
displayNameEn
=
displayName
.
Value
+
" "
+
digits
;
}
}
Update
.
Table
(
"Disciplines"
).
Set
(
new
{
DisplayNameDe
=
displayNameDe
,
DisplayNameEn
=
displayNameEn
}).
Where
(
new
{
Url
=
url
});
}
}
}
}
}
}
private
void
HandleDisciplineEnDown
()
{
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
;
var
digits
=
el
.
Element
(
skosNameSpace
+
"notation"
).
Value
;
var
displayNames
=
el
.
Elements
(
skosNameSpace
+
"prefLabel"
);
var
displayNameDe
=
"Keine Angabe"
;
foreach
(
var
displayName
in
displayNames
)
{
if
(
displayName
.
Attribute
(
XNamespace
.
Xml
+
"lang"
).
Value
.
Equals
(
"de"
))
{
displayNameDe
=
displayName
.
Value
;
}
}
Update
.
Table
(
"Disciplines"
).
Set
(
new
{
DisplayName
=
displayNameDe
}).
Where
(
new
{
Url
=
url
});
}
}
}
}
}
}
}
}
#
endregion
\ No newline at end of file
Loading