Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • coscine/backend/libraries/database
1 result
Select Git revision
Loading items
Show changes
Commits on Source (3)
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("Database.Tests is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("Database.Tests")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
[assembly: AssemblyInformationalVersion("1.7.0.0")]
[assembly: AssemblyVersion("1.8.0.0")]
[assembly: AssemblyFileVersion("1.8.0.0")]
[assembly: AssemblyInformationalVersion("1.8.0.0")]
[assembly: AssemblyCopyright("2019 IT Center, RWTH Aachen University")]
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("Database is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("Database")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
[assembly: AssemblyInformationalVersion("1.7.0.0")]
[assembly: AssemblyVersion("1.8.0.0")]
[assembly: AssemblyFileVersion("1.8.0.0")]
[assembly: AssemblyInformationalVersion("1.8.0.0")]
[assembly: AssemblyCopyright("2019 IT Center, RWTH Aachen University")]
This diff is collapsed.
This diff is collapsed.
using FluentMigrator;
using System;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.Linq;
namespace Coscine.Database.Migration.Migrations
{
//yyyymmddhhmm
[Migration(201910161154)]
public class Migration201910161154InstitutesDisciplines : FluentMigrator.Migration
{
public override void Down()
{
HandleInstitute((obj) => Delete.FromTable("Institutes").Row(obj));
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));
}
private void HandleInstitute(Action<object> action)
{
var assembly = Assembly.GetExecutingAssembly();
var resourceName = "Coscine.Database.Migration.Assets.Institutes.csv";
using (var stream = assembly.GetManifestResourceStream(resourceName))
using (var reader = new StreamReader(stream))
{
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
if (line.Contains(","))
{
var values = line.Split(',');
if (values[0].Trim() != "" && values[1].Trim() != "")
{
action.Invoke(new { IKZ = values[0].Trim(), DisplayName = values[1].Trim() });
}
}
}
}
}
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 });
}
}
}
}
}
}
}
}
......@@ -24,8 +24,6 @@ namespace Coscine.Database.Migration
private void SetServiceProvider(System.Reflection.Assembly targetAssembly, string dbConnectionString)
{
var serviceProvider = new ServiceCollection()
// Logging is the replacement for the old IAnnouncer
.AddLogging(lb => lb.AddFluentMigratorConsole())
// Registration of all FluentMigrator-specific services
.AddFluentMigratorCore()
// Configure the runner
......
......@@ -154,12 +154,15 @@
<Compile Include="Migrations\Migration201908071616RdsResource.cs" />
<Compile Include="Migrations\Migration201907100900UserProfilesApi.cs" />
<Compile Include="Migrations\Migration201908231520ResourceDisplayName.cs" />
<Compile Include="Migrations\Migration201910161154InstitutesDisciplines.cs" />
<Compile Include="Migrator.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<EmbeddedResource Include="Assets\dfg_structure.rdf" />
<EmbeddedResource Include="Assets\Institutes.csv" />
<None Include="LinqToDB.Templates\DataAnnotations.ttinclude" />
<None Include="LinqToDB.Templates\DataModel.ttinclude" />
<None Include="LinqToDB.Templates\EditableObject.ttinclude" />
......
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("Migrator is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("Migrator")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
[assembly: AssemblyInformationalVersion("1.7.0.0")]
[assembly: AssemblyVersion("1.8.0.0")]
[assembly: AssemblyFileVersion("1.8.0.0")]
[assembly: AssemblyInformationalVersion("1.8.0.0")]
[assembly: AssemblyCopyright("2019 IT Center, RWTH Aachen University")]