diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..49108b73e020ada3fea02d30c4c24bb0444fe050 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,34 @@ +include: + - project: coscine/tools/gitlab-ci-templates + file: + - /dotnet.yml + +stages: + - build + - publish + - commands + + +variables: + DOTNET_MAIN_PROJECT_FOLDER: "SQL2Linked" + +build-branch: + extends: .build-branch + +build-nuget-release: + extends: .build-nuget-release + +publish-gitlab-release: + extends: .publish-gitlab-release + +publish: + extends: .publish-artifact-release + +migration: + rules: + - if: $CI_PIPELINE_SOURCE != "schedule" + when: manual + stage: commands + script: + - dotnet run --project .\src\$DOTNET_MAIN_PROJECT_FOLDER -- --noDryRun + when: manual \ No newline at end of file diff --git a/src/SQL2Linked/Program.cs b/src/SQL2Linked/Program.cs index f64ddbc7245857470616ae895444e51c5ee9952f..82a230ff426598c2638f16ccb013cf4f0f6c3706 100644 --- a/src/SQL2Linked/Program.cs +++ b/src/SQL2Linked/Program.cs @@ -1,17 +1,24 @@ using SQL2Linked.Implementations; -Console.WriteLine("Begin SQL 2 Linked Data migration"); +var dummyMode = !(args.Length > 0 && args[0] == "--noDryRun"); +if (dummyMode) +{ + Console.WriteLine("\n DUMMY MODE \n"); + Console.WriteLine(" To exit dummy mode, execute with the \"--noDryRun\" argument"); +} + +Console.WriteLine("\nBegin SQL 2 Linked Data migration"); var roleStructuralData = new RoleStructuralData(); -roleStructuralData.Migrate(); +roleStructuralData.Migrate(dummyMode); var userStructuralData = new UserStructuralData(); -userStructuralData.Migrate(); +userStructuralData.Migrate(dummyMode); var projectStructuralData = new ProjectStructuralData(); -projectStructuralData.Migrate(); +projectStructuralData.Migrate(dummyMode); var resourceStructuralData = new ResourceStructuralData(); -resourceStructuralData.Migrate(); +resourceStructuralData.Migrate(dummyMode); Console.WriteLine("\n Finished."); diff --git a/src/SQL2Linked/StructuralData.cs b/src/SQL2Linked/StructuralData.cs index 1be0bb1f0fa1f3ecf90fe3c0cf4fa8cdd0509e9a..883fe3fb3d8c6309632431a518d7cee605754ae8 100644 --- a/src/SQL2Linked/StructuralData.cs +++ b/src/SQL2Linked/StructuralData.cs @@ -20,19 +20,22 @@ namespace SQL2Linked public abstract IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<S> entries); - public void Migrate() + public void Migrate(bool dummyMode) { var spacer = new string('-', 35); Console.WriteLine($"\n{spacer}\n{typeof(T).Name}\n{spacer}"); var graphs = ConvertToLinkedData(Model.GetAll()); - StoreGraphs(graphs); + if (!dummyMode) + { + StoreGraphs(graphs); + } } private void StoreGraphs(IEnumerable<IGraph> graphs) { foreach (var graph in graphs) { - Console.WriteLine($"({graph.BaseUri})"); + Console.WriteLine($" ({graph.BaseUri})"); var exists = RdfStoreConnector.HasGraph(graph.BaseUri); if (exists) {