diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 70f41bc841fef797f60350032c50e96f2d99fe9b..b339a45c43a1dcb4b80ab99e6224bc7232abd723 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,5 @@ stages: - test - - docs - release - releasetrigger @@ -19,15 +18,6 @@ cake:Test: - master - tags -docs: - stage: docs - script: - - .\publishDocs.ps1 $GITLAB_TOKEN - variables: - GIT_STRATEGY: clone - only: - - tags - cake:Release: stage: release script: diff --git a/README.md b/README.md index 549e949ef8799c10c136f6b8b4f26bb4c991a977..0c678a426a86ba7619d76db72c2d3d8b39063f8b 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,12 @@ -## C# Template +# GraphDeployer -This template includes: +This repository transforms RDF data graphs into the turtle format. -* Automatic building using cake -* Automatic testing with NUnit -* Automatic linting with Resharper -* Automatic documentation publishing using Gitlab CI / CD and a self written script which puts the docs in the docs folder to the wiki -* Automatic releases using semantic-release ([ESLint Code Convention](docs/ESLintConvention)), cake and Gitlab CI / CD +## Usage -## What you need to do +Source and target file path can be taken given as runtime options. Alternatively, the following consul keys may be registered: +`coscine/global/metadata_vocabularies/dfg_structure/` +`coscine/global/metadata_vocabularies/output` -Place you C# project solution file in .src/. -Make sure Create directory for solution is unticked. - - - -Delete unused docs and update this README. - -Add [NUnit](docs/nunit.md) tests to your solution. - -## Building - -Build this project by running either the build.ps1 or the build<span></span>.sh script. -The project will be build and tested. - -### Links - -* [Commit convention](docs/ESLintConvention.md) -* [Everything possible with markup](docs/testdoc.md) -* [Adding NUnit tests](docs/nunit.md) \ No newline at end of file +If the source file is to be loaded from Gitlab, register also the following konsul key: +`coscine/global/gitlabtoken/` diff --git a/publishDocs.ps1 b/publishDocs.ps1 deleted file mode 100644 index f49b3b93e477ca9d57f7b1163b2bcf246f86d35d..0000000000000000000000000000000000000000 --- a/publishDocs.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -param( - $token -) - -$remoteUrl = git config --get remote.origin.url -$remoteUrl = $remoteUrl.replace("git@", "") -$remoteUrl = $remoteUrl -replace "https(.*?)@","" -$remoteUrl = $remoteUrl.replace(":", "/") -$remoteUrl = $remoteUrl.replace(".git", ".wiki.git") - -$temporaryFolderName = "publishDocsTempFolder" - -git clone "https://gitlab-ci-token:$($token)@$($remoteUrl)" $temporaryFolderName -cd $temporaryFolderName -Remove-Item * -cp -r ../docs/* ./ -git add . -git commit -m "Docs: Documentation Update" -git push \ No newline at end of file diff --git a/src/DfgStructureParser/DfgStructureParser/Program.cs b/src/DfgStructureParser/DfgStructureParser/Program.cs index 905ba6cbcefcb424827afee7459d2aede8fd2432..b7ab9b3bbec3116277d9469853b9fd21d75f81a5 100644 --- a/src/DfgStructureParser/DfgStructureParser/Program.cs +++ b/src/DfgStructureParser/DfgStructureParser/Program.cs @@ -9,6 +9,7 @@ using NDesk.Options; using Coscine.Configuration; using System.Net; using System.IO; +using VDS.RDF.Parsing.Contexts; namespace DfgStructureParser { @@ -97,15 +98,19 @@ namespace DfgStructureParser var subClassNode = g.CreateUriNode(new Uri("http://www.w3.org/2000/01/rdf-schema#subClassOf")); ReplacePredicate(g, broaderTriples, subClassNode); - //remove notation count + var inpcompleteSuperClassTriples = g.GetTriplesWithPredicateObject(subClassNode, g.CreateUriNode(new Uri("http://www.dfg.de/dfg_profil/gremien/fachkollegien/faecher"))).ToList(); + var dfgParentNode = g.CreateUriNode(new Uri("http://www.dfg.de/dfg_profil/gremien/fachkollegien/faecher/")); + ReplaceObject(g, inpcompleteSuperClassTriples, dfgParentNode); + + // remove notation count var notationTriples = g.GetTriples(new Uri("http://www.w3.org/2004/02/skos/core#notation")).ToList(); RemoveTriples(g, notationTriples); - //remove concept scheme + // remove concept scheme var conceptSchemeTriples = g.GetTriples(new Uri("http://www.w3.org/2004/02/skos/core#ConceptScheme")).ToList(); RemoveTriples(g, conceptSchemeTriples); - //remove top concept + // remove top concept var topConceptTriples = g.GetTriples(new Uri("http://www.w3.org/2004/02/skos/core#hasTopConcept")).ToList(); RemoveTriples(g, topConceptTriples); @@ -151,6 +156,16 @@ namespace DfgStructureParser } } + public static void ReplaceObject(IGraph graph, List<Triple> triples, INode replacement) + { + foreach (var triple in triples) + { + var newTriple = new Triple(triple.Subject, triple.Predicate, replacement); + graph.Retract(triple); + graph.Assert(newTriple); + } + } + public static void RemoveTriples(IGraph graph, List<Triple> triples) { foreach (var triple in triples) @@ -173,11 +188,25 @@ namespace DfgStructureParser { var parentNodeTriples = graph.GetTriplesWithSubject(new Uri("http://www.dfg.de/dfg_profil/gremien/fachkollegien/faecher")).ToList(); var properParentNode = graph.GetUriNode(new Uri("http://www.dfg.de/dfg_profil/gremien/fachkollegien/faecher/")); + + // rebind triples to correct parent node ReplaceSubject(graph, parentNodeTriples, properParentNode); - graph.Assert(properParentNode, graph.CreateUriNode(new Uri("http://purl.org/dc/elements/1.1/publisher")), graph.CreateUriNode(new Uri("http://www.dfg.de/"))); + // remove unnecessary ascribing to schema + List<Triple> parentTypeTriples = graph.GetTriplesWithSubjectPredicate(graph.CreateUriNode(new Uri("http://www.dfg.de/dfg_profil/gremien/fachkollegien/faecher/")), graph.CreateUriNode(new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"))).ToList(); + RemoveTriples(graph, parentTypeTriples); + + // add parent node specific label and copyright notice + graph.Assert(properParentNode, graph.CreateUriNode(new Uri("http://purl.org/dc/terms/publisher")), graph.CreateUriNode(new Uri("http://www.dfg.de/"))); graph.Assert(properParentNode, graph.CreateUriNode(new Uri("http://purl.org/dc/terms/rights")), graph.CreateLiteralNode("Copyright © 2020 Deutsche Forschungsgemeinschaft")); + // add "@en" suffix to the title of the parent node + var titleTripleList = graph.GetTriplesWithSubjectPredicate(graph.CreateUriNode(new Uri("http://www.dfg.de/dfg_profil/gremien/fachkollegien/faecher/")), graph.CreateUriNode(new Uri("http://purl.org/dc/terms/title"))).ToList(); + var titleTriple = titleTripleList[0]; + LiteralNode titleNode = (LiteralNode)titleTriple.Object; + ILiteralNode newTitleNode = graph.CreateLiteralNode(titleNode.Value, "en"); + ReplaceObject(graph, titleTripleList, newTitleNode); + var schemeNodeTriples = graph.GetTriples(new Uri("http://www.w3.org/2004/02/skos/core#inScheme")).ToList(); RemoveTriples(graph, schemeNodeTriples); }