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/docs/ESLintConvention.md b/docs/ESLintConvention.md deleted file mode 100644 index 001dba56ac6f0f96234f03d0278f618826728495..0000000000000000000000000000000000000000 --- a/docs/ESLintConvention.md +++ /dev/null @@ -1,45 +0,0 @@ -## ESLint Convention - -Make the changes to the code and tests and then commit to your branch. Be sure to follow the commit message conventions. - -Commit message summaries must follow this basic format: - -``` -Tag: Message (fixes #1234) -``` - -`Tag` should not be confused with git tag. -`Message` should not be confused with git commit message. - -The `Tag` is one of the following: - -* `Fix` - for a bug fix. -* `Update` - for a backwards-compatible enhancement. -* `Breaking` - for a backwards-incompatible enhancement. -* `Docs` - changes to documentation only. -* `Build` - changes to build process only. -* `New` - implemented a new feature. -* `Upgrade` - for a dependency upgrade. - -The message summary should be a one-sentence description of the change. The issue number should be mentioned at the end. * The commit message should say "(fixes #1234)" at the end of the description if it closes out an existing issue (replace 1234 with the issue number). If the commit doesn't completely fix the issue, then use `(refs #1234)` instead of `(fixes #1234)`. - -Here are some good commit message summary examples: - -``` -Build: Update Travis to only test Node 0.10 (refs #734) -Fix: Semi rule incorrectly flagging extra semicolon (fixes #840) -Upgrade: Esprima to 1.2, switch to using Esprima comment attachment (fixes #730) -``` - -The commit message format is important because these messages are used to create a changelog for each release. The tag and issue number help to create more consistent and useful changelogs. - -Based on https://github.com/eslint/eslint.github.io/blob/master/docs/developer-guide/contributing.md#step-2-make-your-changes - -[npm-image]: https://badge.fury.io/js/conventional-changelog-eslint.svg -[npm-url]: https://npmjs.org/package/conventional-changelog-eslint -[travis-image]: https://travis-ci.org/stevemao/conventional-changelog-eslint.svg?branch=master -[travis-url]: https://travis-ci.org/stevemao/conventional-changelog-eslint -[daviddm-image]: https://david-dm.org/stevemao/conventional-changelog-eslint.svg?theme=shields.io -[daviddm-url]: https://david-dm.org/stevemao/conventional-changelog-eslint -[coveralls-image]: https://coveralls.io/repos/stevemao/conventional-changelog-eslint/badge.svg -[coveralls-url]: https://coveralls.io/r/stevemao/conventional-changelog-eslint \ No newline at end of file diff --git a/docs/home.md b/docs/home.md deleted file mode 100644 index e57a4ee9c07e6ca3f79756079043959585835658..0000000000000000000000000000000000000000 --- a/docs/home.md +++ /dev/null @@ -1,31 +0,0 @@ -## C# Template - -This template includes: - -* 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](ESLintConvention)), cake and Gitlab CI / CD - -## What you need to do - -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](nunit) 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](ESLintConvention) -* [Everything possible with markup](testdoc) -* [Adding NUnit tests](nunit) diff --git a/docs/images/add_a_package.png b/docs/images/add_a_package.png deleted file mode 100644 index e8e8ed2121edfc81d8fb2e4f3e03ed4807c66eea..0000000000000000000000000000000000000000 Binary files a/docs/images/add_a_package.png and /dev/null differ diff --git a/docs/images/add_a_reference.png b/docs/images/add_a_reference.png deleted file mode 100644 index 4ee38c9951bc5739297b78abb2c82113286f6e71..0000000000000000000000000000000000000000 Binary files a/docs/images/add_a_reference.png and /dev/null differ diff --git a/docs/images/create_class_library.png b/docs/images/create_class_library.png deleted file mode 100644 index 89a252c6e358c73fb9b7299464f851e69127285a..0000000000000000000000000000000000000000 Binary files a/docs/images/create_class_library.png and /dev/null differ diff --git a/docs/images/create_project.png b/docs/images/create_project.png deleted file mode 100644 index f7ae1a1701c9287d5f7a959bf856f55966293081..0000000000000000000000000000000000000000 Binary files a/docs/images/create_project.png and /dev/null differ diff --git a/docs/images/select_framework.png b/docs/images/select_framework.png deleted file mode 100644 index bba5b07168b73cb1005150aad92d6d925bada649..0000000000000000000000000000000000000000 Binary files a/docs/images/select_framework.png and /dev/null differ diff --git a/docs/images/select_project.png b/docs/images/select_project.png deleted file mode 100644 index 6f42cc3a18e89d6e2a26cd76de9730f39feb51bf..0000000000000000000000000000000000000000 Binary files a/docs/images/select_project.png and /dev/null differ diff --git a/docs/images/test_code.png b/docs/images/test_code.png deleted file mode 100644 index e9d9b5f88107c03fb19d4d2c6567981d25658154..0000000000000000000000000000000000000000 Binary files a/docs/images/test_code.png and /dev/null differ diff --git a/docs/nunit.md b/docs/nunit.md deleted file mode 100644 index 020e56f85510b1319edbe89e76cdd0891b5abe43..0000000000000000000000000000000000000000 --- a/docs/nunit.md +++ /dev/null @@ -1,33 +0,0 @@ -## Add NUnit Tests - -### Add Nunit test adapter -1. Choose **Tools > Extensions and Updates** -2. In the **Extensions and Updates** dialog box, expand the **Online** category and then **Visual Studio Marketplace**. Then, choose **Tools > Testing**. -2. Select the **NUnit test adapter** and then choose **Download.** -### Add Tests - -1. Create a class library project and add it to your solution. - - For convinience name it like your main project and add **.Tests** as a suffix. -  - -2. Install the plug-in. In **Solution Explorer**, select the class library project, and then choose **Manage NuGet Packages** from its right-click or context menu. - -  - -3. In the **NuGet Package Manager** window, search for and select the plug-in (NUnit), and then choose **Install**. -  - - The framework is now referenced in your project under **References**. - -4. From the class library project's **References** node, select **Add Reference**. - -  - -5. In the **Reference Manager** dialog box, select the project that contains the code you'll test. - -  - -6. Code your unit test. - -  diff --git a/docs/testdoc.md b/docs/testdoc.md deleted file mode 100644 index 938b6eb3d01ae251f10a000bda25fd4538d87d7a..0000000000000000000000000000000000000000 --- a/docs/testdoc.md +++ /dev/null @@ -1,78 +0,0 @@ -It's very easy to make some words **bold** and other words *italic* with Markdown. You can even [link to Google!](http://google.com) - -Sometimes you want numbered lists: - -1. One -2. Two -3. Three - -Sometimes you want bullet points: - -* Start a line with a star -* Profit! - -Alternatively, - -- Dashes work just as well -- And if you have sub points, put two spaces before the dash or star: - - Like this - - And this - -If you want to embed images, this is how you do it: - - - -# Structured documents - -Sometimes it's useful to have different levels of headings to structure your documents. Start lines with a `#` to create headings. Multiple `##` in a row denote smaller heading sizes. - -### This is a third-tier heading - -You can use one `#` all the way up to `######` six for different heading sizes. - -If you'd like to quote someone, use the > character before the line: - -> Coffee. The finest organic suspension ever devised... I beat the Borg with it. -> - Captain Janeway - -[200~There are many different ways to style code with GitHub's markdown. If you have inline code blocks, wrap them in backticks: `var example = true`. If you've got a longer block of code, you can indent with four spaces: - - if (isAwesome){ - return true - } - -GitHub also supports something called code fencing, which allows for multiple lines without indentation: - -``` -if (isAwesome){ - return true -} -``` - -And if you'd like to use syntax highlighting, include the language: - -```javascript -if (isAwesome){ - return true -} -``` - -GitHub supports many extras in Markdown that help you reference and link to people. If you ever want to direct a comment at someone, you can prefix their name with an @ symbol: Hey @kneath — love your sweater! - -But I have to admit, tasks lists are my favorite: - -- [x] This is a complete item -- [ ] This is an incomplete item - -When you include a task list in the first comment of an Issue, you will see a helpful progress bar in your list of issues. It works in Pull Requests, too! - -And, of course emoji! -GitHub supports many extras in Markdown that help you reference and link to people. If you ever want to direct a comment at someone, you can prefix their name with an @ symbol: Hey @kneath — love your sweater! - -But I have to admit, tasks lists are my favorite: - - This is a complete item - This is an incomplete item -When you include a task list in the first comment of an Issue, you will see a helpful progress bar in your list of issues. It works in Pull Requests, too! - -And, of course emoji! 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.Test/DfgStructureParser.Test.csproj b/src/DfgStructureParser.Test/DfgStructureParser.Test.csproj new file mode 100644 index 0000000000000000000000000000000000000000..b1e7f4640b59e891a625ed47d68b85e29977123d --- /dev/null +++ b/src/DfgStructureParser.Test/DfgStructureParser.Test.csproj @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="..\packages\NUnit.3.12.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" /> + <Import Project="..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props')" /> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{C6E18029-9B5A-4FA0-94EA-B29F06028C1F}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>DfgStructureParser.Test</RootNamespace> + <AssemblyName>DfgStructureParser.Test</AssemblyName> + <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion> + <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath> + <IsCodedUITest>False</IsCodedUITest> + <TestProjectType>UnitTest</TestProjectType> + <NuGetPackageImportStamp> + </NuGetPackageImportStamp> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> + </Reference> + <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath> + </Reference> + <Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL"> + <HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core" /> + </ItemGroup> + <ItemGroup> + <Compile Include="UnitTest1.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\DfgStructureParser\DfgStructureParser.csproj"> + <Project>{a7518778-2f46-4566-bfdb-ef68e1b3e4ee}</Project> + <Name>DfgStructureParser</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> + <PropertyGroup> + <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> + </PropertyGroup> + <Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props'))" /> + <Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets'))" /> + <Error Condition="!Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.12.0\build\NUnit.props'))" /> + </Target> + <Import Project="..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets')" /> +</Project> \ No newline at end of file diff --git a/src/DfgStructureParser.Test/Properties/AssemblyInfo.cs b/src/DfgStructureParser.Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000000000000000000000000000000..4350fd45c5c06b9e0a1a6cda914394cac78b9410 --- /dev/null +++ b/src/DfgStructureParser.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by Cake. +// </auto-generated> +//------------------------------------------------------------------------------ +using System.Reflection; + +[assembly: AssemblyTitle("DfgStructureParser.Test")] +[assembly: AssemblyDescription("DfgStructureParser.Test is a part of the CoScInE group.")] +[assembly: AssemblyCompany("IT Center, RWTH Aachen University")] +[assembly: AssemblyProduct("DfgStructureParser.Test")] +[assembly: AssemblyVersion("1.0.0")] +[assembly: AssemblyFileVersion("1.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0-beta0002")] +[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")] + diff --git a/src/DfgStructureParser.Test/UnitTest1.cs b/src/DfgStructureParser.Test/UnitTest1.cs new file mode 100644 index 0000000000000000000000000000000000000000..a370069760da201ceda380bf3e2301bf2b5af9d5 --- /dev/null +++ b/src/DfgStructureParser.Test/UnitTest1.cs @@ -0,0 +1,15 @@ +using System; +using NUnit.Framework; + +namespace DfgStructureParser.Test +{ + [TestFixture] + public class DfgStructureParserTest + { + [Test] + public void TestMethod1() + { + Assert.True(true); + } + } +} diff --git a/src/DfgStructureParser.Test/packages.config b/src/DfgStructureParser.Test/packages.config new file mode 100644 index 0000000000000000000000000000000000000000..7d932168602c4b0211974eda8c4dc8c2c7a74748 --- /dev/null +++ b/src/DfgStructureParser.Test/packages.config @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="MSTest.TestAdapter" version="2.1.1" targetFramework="net472" /> + <package id="MSTest.TestFramework" version="2.1.1" targetFramework="net472" /> + <package id="NUnit" version="3.12.0" targetFramework="net472" /> +</packages> \ No newline at end of file diff --git a/src/DfgStructureParser.sln b/src/DfgStructureParser.sln new file mode 100644 index 0000000000000000000000000000000000000000..8478dfe9f26db1987e3f2159e286c84b4f341332 --- /dev/null +++ b/src/DfgStructureParser.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30413.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DfgStructureParser", "DfgStructureParser\DfgStructureParser.csproj", "{A7518778-2F46-4566-BFDB-EF68E1B3E4EE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DfgStructureParser.Test", "DfgStructureParser.Test\DfgStructureParser.Test.csproj", "{C6E18029-9B5A-4FA0-94EA-B29F06028C1F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A7518778-2F46-4566-BFDB-EF68E1B3E4EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7518778-2F46-4566-BFDB-EF68E1B3E4EE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7518778-2F46-4566-BFDB-EF68E1B3E4EE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7518778-2F46-4566-BFDB-EF68E1B3E4EE}.Release|Any CPU.Build.0 = Release|Any CPU + {C6E18029-9B5A-4FA0-94EA-B29F06028C1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C6E18029-9B5A-4FA0-94EA-B29F06028C1F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C6E18029-9B5A-4FA0-94EA-B29F06028C1F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C6E18029-9B5A-4FA0-94EA-B29F06028C1F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4AF25AB9-2762-464C-AACA-EEA0CF2D16C3} + EndGlobalSection +EndGlobal diff --git a/src/DfgStructureParser/App.config b/src/DfgStructureParser/App.config new file mode 100644 index 0000000000000000000000000000000000000000..56efbc7b5f15b5166cc89dae0406895b57de0b67 --- /dev/null +++ b/src/DfgStructureParser/App.config @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> + </startup> +</configuration> \ No newline at end of file diff --git a/src/DfgStructureParser/DfgStructureParser.csproj b/src/DfgStructureParser/DfgStructureParser.csproj new file mode 100644 index 0000000000000000000000000000000000000000..dd4691cd4842c5749a14e8fe4c4ac40e655c4459 --- /dev/null +++ b/src/DfgStructureParser/DfgStructureParser.csproj @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{A7518778-2F46-4566-BFDB-EF68E1B3E4EE}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>DfgStructureParser</RootNamespace> + <AssemblyName>DfgStructureParser</AssemblyName> + <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL"> + <HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath> + </Reference> + <Reference Include="Coscine.Configuration, Version=1.5.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL"> + <HintPath>..\packages\Coscine.Configuration.1.5.0\lib\net461\Coscine.Configuration.dll</HintPath> + </Reference> + <Reference Include="dotNetRDF, Version=2.6.0.0, Culture=neutral, PublicKeyToken=6055ffe4c97cc780, processorArchitecture=MSIL"> + <HintPath>..\packages\dotNetRDF.2.6.0\lib\net40\dotNetRDF.dll</HintPath> + </Reference> + <Reference Include="HtmlAgilityPack, Version=1.11.24.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL"> + <HintPath>..\packages\HtmlAgilityPack.1.11.24\lib\Net45\HtmlAgilityPack.dll</HintPath> + </Reference> + <Reference Include="NDesk.Options, Version=0.2.1.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll</HintPath> + </Reference> + <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Configuration" /> + <Reference Include="System.Core" /> + <Reference Include="System.Net.Http.WebRequest" /> + <Reference Include="System.Security" /> + <Reference Include="System.Web" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xml" /> + <Reference Include="VDS.Common, Version=1.10.0.0, Culture=neutral, PublicKeyToken=ab5f4eb908061bf0, processorArchitecture=MSIL"> + <HintPath>..\packages\VDS.Common.1.10.0\lib\net40-client\VDS.Common.dll</HintPath> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + <None Include="packages.config" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project> \ No newline at end of file diff --git a/src/DfgStructureParser/Program.cs b/src/DfgStructureParser/Program.cs new file mode 100644 index 0000000000000000000000000000000000000000..b7ab9b3bbec3116277d9469853b9fd21d75f81a5 --- /dev/null +++ b/src/DfgStructureParser/Program.cs @@ -0,0 +1,214 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VDS.RDF; +using VDS.RDF.Writing; +using NDesk.Options; +using Coscine.Configuration; +using System.Net; +using System.IO; +using VDS.RDF.Parsing.Contexts; + +namespace DfgStructureParser +{ + class Program + { + static void Main(string[] args) + { + bool showHelp = false; + bool remoteSource = false; + string source = null; + string target = null; + var configuration = new ConsulConfiguration(); + + var optionSet = new OptionSet() { + { "source=", "Source path of the rdf input file.", + x => source = x }, + { "target=", "Target path of the ttl output.", + x => target = x }, + { "h|help", "show help and exit", + x => showHelp = x != null }, + }; + + List<string> extra; + try + { + extra = optionSet.Parse(args); + } + catch (OptionException e) + { + Console.WriteLine(e.Message); + Console.WriteLine("Try '--help' for more information."); + return; + } + + if (showHelp) + { + foreach (var option in optionSet) + { + Console.WriteLine($"{option}: {option.Description}"); + } + return; + } + + source = string.IsNullOrWhiteSpace(source) ? configuration.GetString("coscine/global/metadata_vocabularies/dfg_structure") : source; + if (string.IsNullOrWhiteSpace(source)) + { + Console.WriteLine("No value for source provided."); + } + + target = string.IsNullOrWhiteSpace(target) ? configuration.GetString("coscine/global/metadata_vocabularies/output") : target; + if (string.IsNullOrWhiteSpace(target)) + { + target = "./index.ttl"; + Console.WriteLine("No value for target provided."); + } + + if (source.StartsWith("https://git.rwth-aachen.de/")) { + source = LoadSourceFromGitlab(source, configuration); + remoteSource = true; + } + + IGraph g = new Graph(); + g.LoadFromFile(source); + + g.BaseUri = new Uri("http://www.dfg.de/dfg_profil/gremien/fachkollegien/faecher/"); + + if (remoteSource) + { + File.Delete(source); + } + + AdjustDfgStructureRootNode(g); + + //transform node classifier + var conceptNodesTriples = g.GetTriples(new Uri("http://www.w3.org/2004/02/skos/core#Concept")); + var conceptNodesTriplesList = conceptNodesTriples.ToList(); + foreach (var triple in conceptNodesTriplesList) + { + var newTriple = new Triple(triple.Subject, triple.Predicate, triple.Subject); + g.Retract(triple); + g.Assert(newTriple); + } + + // transform subclasses + var broaderTriples = g.GetTriples(new Uri("http://www.w3.org/2004/02/skos/core#broader")).ToList(); + var subClassNode = g.CreateUriNode(new Uri("http://www.w3.org/2000/01/rdf-schema#subClassOf")); + ReplacePredicate(g, broaderTriples, subClassNode); + + 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 + var conceptSchemeTriples = g.GetTriples(new Uri("http://www.w3.org/2004/02/skos/core#ConceptScheme")).ToList(); + RemoveTriples(g, conceptSchemeTriples); + + // remove top concept + var topConceptTriples = g.GetTriples(new Uri("http://www.w3.org/2004/02/skos/core#hasTopConcept")).ToList(); + RemoveTriples(g, topConceptTriples); + + // transform labels + var preflabeltriples = g.GetTriples(new Uri("http://www.w3.org/2004/02/skos/core#prefLabel")).ToList(); + var labelNode = g.CreateUriNode(new Uri("http://www.w3.org/2000/01/rdf-schema#label")); + ReplacePredicate(g, preflabeltriples, labelNode); + + WriteTurtle(g, target); + + Console.WriteLine("File Written!"); + } + + private static string LoadSourceFromGitlab(string source, ConsulConfiguration configuration) + { + string gitlab_token = configuration.GetString("coscine/global/gitlabtoken"); + WebClient webClient = new WebClient(); + string webSource = $"{source}&private_token={gitlab_token}"; + source = "./source.rdf"; + + webClient.DownloadFile(webSource, source); + + return source; + } + + public static void ReplacePredicate(IGraph graph, List<Triple> triples, INode replacement) + { + foreach (var triple in triples) + { + var newTriple = new Triple(triple.Subject, replacement, triple.Object); + graph.Retract(triple); + graph.Assert(newTriple); + } + } + + public static void ReplaceSubject(IGraph graph, List<Triple> triples, INode replacement) + { + foreach (var triple in triples) + { + var newTriple = new Triple(replacement, triple.Predicate, triple.Object); + graph.Retract(triple); + graph.Assert(newTriple); + } + } + + 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) + { + graph.Retract(triple); + } + } + + public static void WriteTurtle(IGraph graph, string targetLocation) + { + IRdfWriter writer = new CompressingTurtleWriter(VDS.RDF.Parsing.TurtleSyntax.Original); + + ((IPrettyPrintingWriter)writer).PrettyPrintMode = true; + ((ICompressingWriter)writer).CompressionLevel = WriterCompressionLevel.High; + + writer.Save(graph, targetLocation); + } + + public static void AdjustDfgStructureRootNode(IGraph graph) + { + 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); + + // 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); + } + } +} diff --git a/src/DfgStructureParser/Properties/AssemblyInfo.cs b/src/DfgStructureParser/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000000000000000000000000000000..4953f890c2e757aca7855f7b19a8205329f5e247 --- /dev/null +++ b/src/DfgStructureParser/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by Cake. +// </auto-generated> +//------------------------------------------------------------------------------ +using System.Reflection; + +[assembly: AssemblyTitle("DfgStructureParser")] +[assembly: AssemblyDescription("DfgStructureParser is a part of the CoScInE group.")] +[assembly: AssemblyCompany("IT Center, RWTH Aachen University")] +[assembly: AssemblyProduct("DfgStructureParser")] +[assembly: AssemblyVersion("1.0.0")] +[assembly: AssemblyFileVersion("1.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0-beta0002")] +[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")] + diff --git a/src/DfgStructureParser/packages.config b/src/DfgStructureParser/packages.config new file mode 100644 index 0000000000000000000000000000000000000000..4ed7616e65fbd2eacfaf3578aa46fee3bd29cdb2 --- /dev/null +++ b/src/DfgStructureParser/packages.config @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Consul" version="0.7.2.6" targetFramework="net472" /> + <package id="Coscine.Configuration" version="1.5.0" targetFramework="net472" /> + <package id="dotNetRDF" version="2.6.0" targetFramework="net472" /> + <package id="HtmlAgilityPack" version="1.11.24" targetFramework="net472" /> + <package id="NDesk.Options" version="0.2.1" targetFramework="net472" /> + <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" /> + <package id="VDS.Common" version="1.10.0" targetFramework="net472" /> +</packages> \ No newline at end of file