├── etc ├── image │ └── edmc-logo.jpg └── git-hook │ ├── make1cat.sh │ ├── install.md │ └── makecats.sh ├── src ├── test │ ├── resources │ │ ├── ontologies │ │ │ ├── rdf_turtle_spec │ │ │ │ ├── turtle-example-23.ttl │ │ │ │ ├── turtle-example-25.ttl │ │ │ │ ├── turtle-example-5.ttl │ │ │ │ ├── turtle-example-14.ttl │ │ │ │ ├── turtle-example-2.ttl │ │ │ │ ├── turtle-example-13.ttl │ │ │ │ ├── turtle-example-20.ttl │ │ │ │ ├── turtle-example-15.ttl │ │ │ │ ├── turtle-example-6.ttl │ │ │ │ ├── turtle-example-7.ttl │ │ │ │ ├── turtle-example-8.ttl │ │ │ │ ├── turtle-example-22.ttl │ │ │ │ ├── turtle-example-10.ttl │ │ │ │ ├── turtle-example-3.ttl │ │ │ │ ├── turtle-example-4.ttl │ │ │ │ ├── turtle-example-18.ttl │ │ │ │ ├── turtle-example-21.ttl │ │ │ │ ├── turtle-example-16.ttl │ │ │ │ ├── turtle-example-27.ttl │ │ │ │ ├── turtle-example-17.ttl │ │ │ │ ├── turtle-example-19.ttl │ │ │ │ ├── turtle-example-24.ttl │ │ │ │ ├── turtle-example-26.ttl │ │ │ │ ├── turtle-example-12.ttl │ │ │ │ ├── turtle-example-1.ttl │ │ │ │ ├── turtle-example-11.ttl │ │ │ │ └── turtle-example-9.ttl │ │ │ ├── literal │ │ │ │ ├── test1.jsonld │ │ │ │ ├── test1.ttl │ │ │ │ └── test1.rdf │ │ │ ├── avsl.conf │ │ │ ├── other │ │ │ │ └── topquadrant-extended-turtle-example.ttl │ │ │ ├── test-case-001.rdf │ │ │ ├── fibo-with-placeholder-iri │ │ │ │ └── fnd │ │ │ │ │ ├── Law │ │ │ │ │ └── AboutLaw.rdf │ │ │ │ │ ├── Accounting │ │ │ │ │ └── AboutAccounting.rdf │ │ │ │ │ ├── Arrangements │ │ │ │ │ └── AboutArrangements.rdf │ │ │ │ │ ├── Utilities │ │ │ │ │ └── AboutUtilities.rdf │ │ │ │ │ ├── Relations │ │ │ │ │ └── AboutRelations.rdf │ │ │ │ │ ├── Places │ │ │ │ │ └── AboutPlaces.rdf │ │ │ │ │ ├── AgentsAndPeople │ │ │ │ │ └── AboutAgentsAndPeople.rdf │ │ │ │ │ ├── GoalsAndObjectives │ │ │ │ │ └── AboutGoalsAndObjectives.rdf │ │ │ │ │ ├── OwnershipAndControl │ │ │ │ │ └── AboutOwnershipAndControl.rdf │ │ │ │ │ ├── DatesAndTimes │ │ │ │ │ └── AboutDatesAndTimes.rdf │ │ │ │ │ ├── Parties │ │ │ │ │ └── AboutParties.rdf │ │ │ │ │ └── Agreements │ │ │ │ │ └── AboutAgreements.rdf │ │ │ └── fibo │ │ │ │ └── ontology │ │ │ │ └── master │ │ │ │ └── latest │ │ │ │ ├── IND │ │ │ │ ├── ForeignExchange │ │ │ │ │ └── AboutForeignExchange.rdf │ │ │ │ ├── InterestRates │ │ │ │ │ └── AboutInterestRates.rdf │ │ │ │ └── Indicators │ │ │ │ │ └── AboutIndicators.rdf │ │ │ │ └── FND │ │ │ │ ├── Law │ │ │ │ └── AboutLaw.rdf │ │ │ │ ├── Accounting │ │ │ │ └── AboutAccounting.rdf │ │ │ │ ├── Quantities │ │ │ │ └── AboutQuantities.rdf │ │ │ │ ├── Arrangements │ │ │ │ └── AboutArrangements.rdf │ │ │ │ ├── Utilities │ │ │ │ └── AboutUtilities.rdf │ │ │ │ └── Relations │ │ │ │ └── AboutRelations.rdf │ │ └── logback-test.xml │ ├── java │ │ └── org │ │ │ └── edmcouncil │ │ │ └── rdf_toolkit │ │ │ ├── TestUtils.java │ │ │ ├── comparator │ │ │ ├── AbstractComparatorTest.java │ │ │ └── ComparisonUtilsTest.java │ │ │ ├── writer │ │ │ └── AbstractSortedWriterTest.java │ │ │ └── TestConstants.java │ └── scala │ │ └── org │ │ └── edmcouncil │ │ ├── test_util │ │ └── UnitSpec.scala │ │ └── rdf_toolkit │ │ ├── command │ │ ├── CommandProcesserSpec.scala │ │ ├── OntologyManagerSpec.scala │ │ └── ConfigFileSpec.scala │ │ └── rdf_serializer │ │ ├── PotentialFileSpec.scala │ │ ├── GitRepositorySpec.scala │ │ └── EdmCouncilOntologyIRISpec.scala └── main │ ├── resources │ └── logback.xml │ └── java │ └── org │ └── edmcouncil │ └── rdf_toolkit │ ├── runner │ ├── constant │ │ └── RunningMode.java │ └── exception │ │ └── RdfToolkitOptionHandlingException.java │ ├── model │ ├── SortedTurtlePredicateList.java │ ├── UnsortedTurtlePredicateList.java │ ├── ReverseNamespaceTable.java │ ├── SortedTurtlePredicateObjectMap.java │ ├── UnsortedTurtleObjectList.java │ ├── SortedTurtleResourceList.java │ ├── SortedTurtleBNodeList.java │ ├── SortedTurtleObjectList.java │ ├── UnsortedTurtleResourceList.java │ ├── UnsortedTurtleBNodeList.java │ ├── Pair.java │ ├── SortedTurtleSubjectPredicateObjectMap.java │ ├── UnsortedTurtlePredicateObjectMap.java │ ├── UnsortedTurtleSubjectPredicateObjectMap.java │ └── SortedHashMap.java │ ├── comparator │ ├── StringLengthComparator.java │ ├── ComparisonContext.java │ ├── CachedResourceComparator.java │ ├── IRIComparator.java │ └── TurtleObjectListComparator.java │ ├── util │ ├── ShortIriPreferences.java │ └── StringDataTypeOptions.java │ ├── RdfFormatter.java │ ├── io │ ├── RdfModelReader.java │ ├── format │ │ ├── TargetFormats.java │ │ └── SourceFormats.java │ └── DirectoryWalker.java │ └── writer │ └── IndentingWriter.java ├── RefactorRDF └── changed.bat ├── .gitignore ├── docs └── output-formats.md ├── .github └── workflows │ └── upload-assets.yml └── LICENSE.md /etc/image/edmc-logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edmcouncil/rdf-toolkit/HEAD/etc/image/edmc-logo.jpg -------------------------------------------------------------------------------- /etc/git-hook/make1cat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | 4 | cd "$1" || exit 1 5 | ../etc/infra/catalog/makecat.sh 6 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-23.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | (1 2.0 3E1) :p "w" . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-25.ttl: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | (1 [:p :q] ( 2 ) ) :p2 :q2 . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-5.ttl: -------------------------------------------------------------------------------- 1 | "Spiderman", "Человек-паук"@ru . -------------------------------------------------------------------------------- /RefactorRDF/changed.bat: -------------------------------------------------------------------------------- 1 | java -Xmx1g -cp "rdf-toolkit.jar" org.edmcouncil.rdf_toolkit.RdfFormatter --source "%~1" --target "%~1" --target-format rdf-xml --use-dtd-subset -ibn -ibi -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-14.ttl: -------------------------------------------------------------------------------- 1 | @prefix foaf: . 2 | 3 | _:alice foaf:knows _:bob . 4 | _:bob foaf:knows _:alice . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-2.ttl: -------------------------------------------------------------------------------- 1 | . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-13.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :isLandlocked false . # xsd:boolean -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-20.ttl: -------------------------------------------------------------------------------- 1 | PREFIX : 2 | :a :b ( "apple" "banana" ) .PREFIX : 3 | :a :b ( "apple" "banana" ) . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-15.ttl: -------------------------------------------------------------------------------- 1 | @prefix foaf: . 2 | 3 | # Someone knows someone else, who has the name "Bob". 4 | [] foaf:knows [ foaf:name "Bob" ] . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-6.ttl: -------------------------------------------------------------------------------- 1 | "Spiderman" . 2 | "Человек-паук"@ru . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-7.ttl: -------------------------------------------------------------------------------- 1 | @prefix somePrefix: . 2 | 3 | somePrefix:enemyOf . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-8.ttl: -------------------------------------------------------------------------------- 1 | PREFIX somePrefix: 2 | 3 | somePrefix:enemyOf . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-22.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :a :b "The first line\nThe second line\n more" . 4 | 5 | :a :b """The first line 6 | The second line 7 | more""" . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-10.ttl: -------------------------------------------------------------------------------- 1 | @prefix foaf: . 2 | 3 | foaf:name "Green Goblin" . 4 | 5 | foaf:name "Spiderman" . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-3.ttl: -------------------------------------------------------------------------------- 1 | ; 2 | "Spiderman" . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-4.ttl: -------------------------------------------------------------------------------- 1 | . 2 | "Spiderman" . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-18.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | # the object of this triple is the RDF collection blank node 3 | :subject :predicate ( :a :b :c ) . 4 | 5 | # an empty collection value - rdf:nil 6 | :subject :predicate2 () . -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | tmp/ 3 | logs/ 4 | project/project 5 | target/ 6 | dist 7 | .cache 8 | *.sublime-project 9 | *.sublime-workspace 10 | atlassian-ide-plugin.xml 11 | test-out*.rdf 12 | catalog-v001.xml 13 | test.rdf 14 | *.xpr 15 | 16 | # IntelliJ IDEA 17 | .idea 18 | *.iml -------------------------------------------------------------------------------- /etc/git-hook/install.md: -------------------------------------------------------------------------------- 1 | run git init 2 | Paste pre-commit, make1cat.sh, makecats.sh, serialize.sh in to .git/hooks folder 3 | Install Java 4 | Create ~/.bash_profile to set JAVA_HOME 5 | Put rdf-toolkit right in to the hooks directory 6 | Edit line in serialize.sh as directed in that file 7 | 8 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-21.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix rdf: . 3 | :a :b 4 | [ rdf:first "apple"; 5 | rdf:rest [ rdf:first "banana"; 6 | rdf:rest rdf:nil ] 7 | ] . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-16.ttl: -------------------------------------------------------------------------------- 1 | # [ABC] added "mailto:" to make this example valid. 2 | @prefix foaf: . 3 | 4 | [ foaf:name "Alice" ] foaf:knows [ 5 | foaf:name "Bob" ; 6 | foaf:knows [ 7 | foaf:name "Eve" ] ; 8 | foaf:mbox ] . -------------------------------------------------------------------------------- /etc/git-hook/makecats.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | 4 | 5 | gitdir=`git rev-parse --git-dir` 6 | root=`realpath $gitdir/..` 7 | 8 | 9 | find . -maxdepth 1 -mindepth 1 -type d \( -path ./etc -prune -o -path ./.git -prune -o -exec `(dirname $0)`/make1cat.sh {} \; \) 10 | find . -name 'catalog-v001.xml' -exec git add --update {} \; 11 | -------------------------------------------------------------------------------- /docs/output-formats.md: -------------------------------------------------------------------------------- 1 | # Supported Output Formats 2 | 3 | The `rdf-toolkit` supports the following output formats: 4 | 5 | | Format | Default File Extension | 6 | | ------ | -------------- | 7 | | RDF/XML | .rdf | 8 | | OWL/XML | .owl | 9 | | Turtle | .ttl | | | 10 | | [JSON-LD](http://www.w3.org/TR/json-ld/) | .jsonld | 11 | | N-Triples | .nt | 12 | | N3 | .n3 | 13 | | TriG | .trig | 14 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-27.ttl: -------------------------------------------------------------------------------- 1 | @prefix ericFoaf: . 2 | @prefix : . 3 | ericFoaf:ericP :givenName "Eric" ; 4 | :knows , 5 | [ :mbox ] , 6 | . -------------------------------------------------------------------------------- /src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-17.ttl: -------------------------------------------------------------------------------- 1 | # [ABC] added "mailto:" to make this example valid. 2 | _:a "Alice" . 3 | _:a _:b . 4 | _:b "Bob" . 5 | _:b _:c . 6 | _:c "Eve" . 7 | _:b . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-19.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdf: . 2 | @prefix dc: . 3 | @prefix ex: . 4 | 5 | 6 | dc:title "RDF/XML Syntax Specification (Revised)" ; 7 | ex:editor [ 8 | ex:fullname "Dave Beckett"; 9 | ex:homePage 10 | ] . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-24.ttl: -------------------------------------------------------------------------------- 1 | # Added default prefix to make this example valid. 2 | @prefix : . 3 | @prefix rdf: . 4 | _:b0 rdf:first 1 ; 5 | rdf:rest _:b1 . 6 | _:b1 rdf:first 2.0 ; 7 | rdf:rest _:b2 . 8 | _:b2 rdf:first 3E1 ; 9 | rdf:rest rdf:nil . 10 | _:b0 :p "w" . -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-26.ttl: -------------------------------------------------------------------------------- 1 | # Added default prefix to make this example valid. 2 | @prefix : . 3 | @prefix rdf: . 4 | _:b0 rdf:first 1 ; 5 | rdf:rest _:b1 . 6 | _:b1 rdf:first _:b2 . 7 | _:b2 :p :q . 8 | _:b1 rdf:rest _:b3 . 9 | _:b3 rdf:first _:b4 . 10 | _:b4 rdf:first 2 ; 11 | rdf:rest rdf:nil . 12 | _:b3 rdf:rest rdf:nil . -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-12.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | 3 | :atomicNumber 2 ; # xsd:integer 4 | :atomicMass 4.002602 ; # xsd:decimal 5 | :specificGravity 1.663E-4 . # xsd:double -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-1.ttl: -------------------------------------------------------------------------------- 1 | @base . 2 | @prefix rdf: . 3 | @prefix rdfs: . 4 | @prefix foaf: . 5 | @prefix rel: . 6 | 7 | <#green-goblin> 8 | rel:enemyOf <#spiderman> ; 9 | a foaf:Person ; # in the context of the Marvel universe 10 | foaf:name "Green Goblin" . 11 | 12 | <#spiderman> 13 | rel:enemyOf <#green-goblin> ; 14 | a foaf:Person ; 15 | foaf:name "Spiderman", "Человек-паук"@ru . -------------------------------------------------------------------------------- /src/test/resources/ontologies/literal/test1.jsonld: -------------------------------------------------------------------------------- 1 | [ { 2 | "@id" : "https://example.com/test1", 3 | "@type" : [ "http://www.w3.org/2002/07/owl#Ontology" ] 4 | }, { 5 | "@id" : "https://example.com/test1#ClassA", 6 | "@type" : [ "http://www.w3.org/2002/07/owl#Class" ], 7 | "http://www.w3.org/2000/01/rdf-schema#label" : [ { 8 | "@value" : "label1" 9 | }, { 10 | "@language" : "en", 11 | "@value" : "label2" 12 | }, { 13 | "@language" : "pl", 14 | "@value" : "label3" 15 | }, { 16 | "@value" : "label4" 17 | }, { 18 | "@type" : "http://www.w3.org/2001/XMLSchema#token", 19 | "@value" : "label5" 20 | }, { 21 | "@value" : "label6" 22 | } ] 23 | } ] -------------------------------------------------------------------------------- /src/test/resources/ontologies/avsl.conf: -------------------------------------------------------------------------------- 1 | [logger_root] 2 | level: debug 3 | handlers: h1 4 | 5 | [logger_RDFParserRegistry] 6 | pattern: org.eclipse.rdf4j.rio.RDFParserRegistry 7 | level: error 8 | handlers: hnull 9 | 10 | [logger_DatatypeHandlerRegistry] 11 | pattern: org.eclipse.rdf4j.rio.DatatypeHandlerRegistry 12 | level: error 13 | handlers: hnull 14 | 15 | [logger_LanguageHandlerRegistry] 16 | pattern: org.eclipse.rdf4j.rio.LanguageHandlerRegistry 17 | level: error 18 | handlers: hnull 19 | 20 | [logger_XMLReader] 21 | pattern: org.xml.sax.XMLReader 22 | level: error 23 | handlers: hnull 24 | 25 | [logger_Manifests] 26 | pattern: com.jcabi.manifests.Manifests 27 | level: error 28 | handlers: hnull 29 | 30 | [handler_h1] 31 | level: debug 32 | class: ConsoleHandler 33 | formatter: f1 34 | 35 | [handler_hnull] 36 | level: debug 37 | class: NullHandler 38 | formatter: fnull 39 | 40 | [formatter_f1] 41 | class: DefaultFormatter 42 | format: (%l) %t 43 | 44 | [formatter_fnull] 45 | class: DefaultFormatter 46 | format: 47 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/literal/test1.ttl: -------------------------------------------------------------------------------- 1 | @prefix : . 2 | @prefix owl: . 3 | @prefix rdf: . 4 | @prefix xml: . 5 | @prefix xsd: . 6 | @prefix rdfs: . 7 | @base . 8 | 9 | rdf:type owl:Ontology . 10 | 11 | ################################################################# 12 | # Classes 13 | ################################################################# 14 | 15 | ### https://example.com/test1#ClassA 16 | :ClassA rdf:type owl:Class ; 17 | rdfs:label "label1" , 18 | "label2"@en , 19 | "label3"@pl , 20 | "label4" , 21 | "label5"^^xsd:token , 22 | "label6" . 23 | 24 | 25 | ### Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi 26 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-11.ttl: -------------------------------------------------------------------------------- 1 | @prefix rdfs: . 2 | @prefix show: . 3 | @prefix xsd: . 4 | 5 | show:218 rdfs:label "That Seventies Show"^^xsd:string . # literal with XML Schema string datatype 6 | show:218 rdfs:label "That Seventies Show"^^ . # same as above 7 | show:218 rdfs:label "That Seventies Show" . # same again 8 | show:218 show:localName "That Seventies Show"@en . # literal with a language tag 9 | show:218 show:localName 'Cette Série des Années Soixante-dix'@fr . # literal delimited by single quote 10 | show:218 show:localName "Cette Série des Années Septante"@fr-be . # literal with a region subtag 11 | show:218 show:blurb '''This is a multi-line # literal with embedded new lines and quotes 12 | literal with many quotes (""""") 13 | and up to two sequential apostrophes ('').''' . -------------------------------------------------------------------------------- /src/test/resources/ontologies/other/topquadrant-extended-turtle-example.ttl: -------------------------------------------------------------------------------- 1 | # Based on: http://composing-the-semantic-web.blogspot.co.uk/2013/06/an-extended-turtle-format.html 2 | 3 | @prefix schema: . 4 | @prefix ui: . 5 | @prefix html: . 6 | @prefix swa: . 7 | @prefix arg: . 8 | @prefix default: . 9 | @prefix spin: . 10 | 11 | schema:Person 12 | a owl:Class ; 13 | rdfs:label "Person"^^xsd:string ; 14 | rdfs:subClassOf owl:Thing ; 15 | ui:instanceView 16 | [ a html:Div ; 17 | default:subject spin:_this ; 18 | ui:child 19 | [ a swa:Object ; 20 | arg:predicate schema:familyName ; 21 | ui:childIndex 1 22 | ] ; 23 | ui:child 24 | [ a swa:Object ; 25 | arg:predicate schema:givenName ; 26 | ui:childIndex 0 27 | ] 28 | ] ; 29 | . -------------------------------------------------------------------------------- /.github/workflows/upload-assets.yml: -------------------------------------------------------------------------------- 1 | name: upload-assets 2 | 3 | on: 4 | push: 5 | tags: 6 | - "*" 7 | 8 | env: 9 | ASSET: rdf-toolkit.jar 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - 16 | name: Checkout 17 | uses: actions/checkout@v4 18 | - 19 | name: Set up JDK 20 | uses: actions/setup-java@v4 21 | with: 22 | distribution: 'temurin' 23 | java-version: '21' 24 | - 25 | name: Run the Maven verify phase 26 | run: mvn --batch-mode --update-snapshots verify 27 | - 28 | name: Get JAR filename 29 | run: echo "FILENAME=$(mvn -q exec:exec -Dexec.executable='echo' -Dexec.args='${project.build.directory}/${project.build.finalName}.${project.packaging}' -DforceStdout)" >> "$GITHUB_ENV" 30 | - 31 | name: Copy JAR as "${{ env.ASSET }}" 32 | run: cp -avf "${FILENAME}" "${{ env.ASSET }}" 33 | - 34 | name: Upload "${{ env.ASSET }}" 35 | run: gh release upload "${{ github.ref_name }}" "${{ env.ASSET }}" 36 | env: 37 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 38 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Enterprise Data Management Council 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/rdf_turtle_spec/turtle-example-9.ttl: -------------------------------------------------------------------------------- 1 | # A triple with all absolute IRIs 2 | . 3 | 4 | @base . 5 | . # relative IRIs, e.g. http://one.example/subject2 6 | 7 | BASE 8 | . # relative IRIs, e.g. http://one.example/subject2 9 | 10 | @prefix p: . 11 | p:subject3 p:predicate3 p:object3 . # prefixed name, e.g. http://two.example/subject3 12 | 13 | PREFIX p: 14 | p:subject3 p:predicate3 p:object3 . # prefixed name, e.g. http://two.example/subject3 15 | 16 | @prefix p: . # prefix p: now stands for http://one.example/path/ 17 | p:subject4 p:predicate4 p:object4 . # prefixed name, e.g. http://one.example/path/subject4 18 | 19 | @prefix : . # empty prefix 20 | :subject5 :predicate5 :object5 . # prefixed name, e.g. http://another.example/subject5 21 | 22 | :subject6 a :subject7 . # same as :subject6 :subject7 . 23 | 24 | a :subject8 . # a multi-script subject IRI . -------------------------------------------------------------------------------- /src/test/resources/ontologies/literal/test1.rdf: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | label2 28 | label3 29 | label1 30 | label4 31 | label6 32 | label5 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/runner/constant/RunningMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit.runner.constant; 25 | 26 | public enum RunningMode { 27 | EXIT, 28 | PRINT_AND_EXIT, 29 | PRINT_USAGE_AND_EXIT, 30 | RUN_ON_DIRECTORY, 31 | RUN_ON_FILE; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/runner/exception/RdfToolkitOptionHandlingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.runner.exception; 26 | 27 | public class RdfToolkitOptionHandlingException extends Exception { 28 | 29 | public RdfToolkitOptionHandlingException(String message) { 30 | super(message); 31 | } 32 | } -------------------------------------------------------------------------------- /src/test/java/org/edmcouncil/rdf_toolkit/TestUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit; 25 | 26 | import java.io.File; 27 | import java.util.Set; 28 | 29 | public class TestUtils { 30 | 31 | public static boolean doesNotContains(File file, Set phrases) { 32 | return phrases.stream() 33 | .filter(phrase -> file.getName().contains(phrase)) 34 | .findFirst() 35 | .isEmpty(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/SortedTurtlePredicateList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit.model; 25 | 26 | import org.eclipse.rdf4j.model.IRI; 27 | import org.edmcouncil.rdf_toolkit.comparator.IRIComparator; 28 | import java.util.TreeSet; 29 | 30 | /** 31 | * A sorted list of RDF IRI values. 32 | */ 33 | public class SortedTurtlePredicateList extends TreeSet { 34 | 35 | public SortedTurtlePredicateList() { 36 | super(new IRIComparator()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/UnsortedTurtlePredicateList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit.model; 25 | 26 | import org.eclipse.rdf4j.model.IRI; 27 | import java.util.HashSet; 28 | 29 | /** 30 | * An unsorted list of RDF IRI values. 31 | */ 32 | public class UnsortedTurtlePredicateList extends HashSet { 33 | 34 | public SortedTurtlePredicateList toSorted() { 35 | SortedTurtlePredicateList sortedPList = new SortedTurtlePredicateList(); 36 | sortedPList.addAll(this); 37 | return sortedPList; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/scala/org/edmcouncil/test_util/UnitSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.test_util 26 | 27 | import java.io.OutputStream 28 | 29 | import org.scalatest.{ Matchers, WordSpecLike } 30 | 31 | abstract class UnitSpec extends WordSpecLike with Matchers with OutputSuppressor 32 | 33 | trait OutputSuppressor { 34 | def suppressOutput[T](thunk: ⇒ T): T = { 35 | 36 | val bitBucket = new OutputStream() { 37 | def write(b: Int) {} 38 | } 39 | 40 | Console.withOut(bitBucket) { 41 | return thunk 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/ReverseNamespaceTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit.model; 25 | 26 | import org.edmcouncil.rdf_toolkit.comparator.StringLengthComparator; 27 | import java.util.TreeMap; 28 | 29 | /** 30 | * A reverse namespace table with which returns the longest namespace IRIs first. Key is IRI string, value is prefix string. 31 | */ 32 | public class ReverseNamespaceTable extends TreeMap { 33 | 34 | public ReverseNamespaceTable() { 35 | super(new StringLengthComparator()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/scala/org/edmcouncil/rdf_toolkit/command/CommandProcesserSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.command 26 | 27 | import org.edmcouncil.test_util.UnitSpec 28 | 29 | /** 30 | * Test the CommandProcessor 31 | */ 32 | class CommandProcesserSpec extends UnitSpec { 33 | 34 | "The CommandProcessor" ignore { 35 | 36 | val ontology = CommandProcessor.ontology 37 | 38 | "load the ontology" in { 39 | assert(ontology != null) 40 | } 41 | 42 | "test the ontology" in { 43 | ontology.get.imports().toArray.length should be(2) 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/SortedTurtlePredicateObjectMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit.model; 25 | 26 | import org.eclipse.rdf4j.model.IRI; 27 | import org.edmcouncil.rdf_toolkit.comparator.IRIComparator; 28 | 29 | /** 30 | * A sorted map from predicate IRIs to lists of object values. 31 | */ 32 | public class SortedTurtlePredicateObjectMap extends SortedHashMap { 33 | 34 | public SortedTurtlePredicateObjectMap() { 35 | super(new IRIComparator()); 36 | } 37 | 38 | public int fullSize() { 39 | return keySet().stream().mapToInt(pred -> get(pred).size()).sum(); 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/UnsortedTurtleObjectList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.model; 26 | 27 | import org.eclipse.rdf4j.model.Value; 28 | import org.edmcouncil.rdf_toolkit.comparator.ComparisonContext; 29 | import java.util.HashSet; 30 | 31 | /** 32 | * An unsorted list of RDF object values. 33 | */ 34 | public class UnsortedTurtleObjectList extends HashSet { 35 | 36 | public SortedTurtleObjectList toSorted(Class collectionClass, ComparisonContext comparisonContext) { 37 | var sortedObjectList = new SortedTurtleObjectList(collectionClass, comparisonContext); 38 | sortedObjectList.addAll(this); 39 | return sortedObjectList; 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/SortedTurtleResourceList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit.model; 25 | 26 | import org.eclipse.rdf4j.model.Resource; 27 | import org.eclipse.rdf4j.model.Value; 28 | import org.edmcouncil.rdf_toolkit.comparator.ComparisonContext; 29 | import org.edmcouncil.rdf_toolkit.comparator.ResourceComparator; 30 | import java.util.TreeSet; 31 | 32 | /** 33 | * A sorted list of RDF resource values. 34 | */ 35 | public class SortedTurtleResourceList extends TreeSet { 36 | 37 | public SortedTurtleResourceList(Class collectionClass, ComparisonContext comparisonContext) { 38 | super(new ResourceComparator(collectionClass, comparisonContext)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/scala/org/edmcouncil/rdf_toolkit/command/OntologyManagerSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.command 26 | 27 | import org.edmcouncil.test_util.UnitSpec 28 | 29 | /** 30 | * Test the OntologyManager utility object 31 | */ 32 | class OntologyManagerSpec extends UnitSpec { 33 | 34 | "The OntologyManager " ignore { 35 | 36 | val ontologyManager = OntologyManager() 37 | 38 | "be able to create an OWLOntologyManager" in { 39 | 40 | assert(ontologyManager.isDefined) 41 | assert(ontologyManager.get != null) 42 | } 43 | 44 | "be able to run the reasoner" in { 45 | 46 | val ontology = OntologyManager.load() 47 | 48 | Reasoner(ontology.get) 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/SortedTurtleBNodeList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit.model; 25 | 26 | import org.eclipse.rdf4j.model.BNode; 27 | import org.eclipse.rdf4j.model.Value; 28 | import org.edmcouncil.rdf_toolkit.comparator.BNodeComparator; 29 | import org.edmcouncil.rdf_toolkit.comparator.ComparisonContext; 30 | import java.util.TreeSet; 31 | 32 | /** 33 | * A sorted list of RDF blank nodes. 34 | */ 35 | // TODO: why is this not a subclass of SortedTurtleResourceList? 36 | public class SortedTurtleBNodeList extends TreeSet { 37 | 38 | public SortedTurtleBNodeList(Class collectionClass, ComparisonContext comparisonContext) { 39 | super(new BNodeComparator(collectionClass, comparisonContext)); 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/SortedTurtleObjectList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.model; 26 | 27 | import org.eclipse.rdf4j.model.Value; 28 | import org.edmcouncil.rdf_toolkit.comparator.ComparisonContext; 29 | import org.edmcouncil.rdf_toolkit.comparator.ValueComparator; 30 | import java.util.TreeSet; 31 | 32 | /** 33 | * A sorted list of RDF object values. 34 | */ 35 | public class SortedTurtleObjectList extends TreeSet { 36 | 37 | public SortedTurtleObjectList(ComparisonContext comparisonContext) { 38 | super(new ValueComparator(comparisonContext)); 39 | } 40 | 41 | public SortedTurtleObjectList(Class collectionClass, ComparisonContext comparisonContext) { 42 | super(new ValueComparator(collectionClass, comparisonContext)); 43 | } 44 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/UnsortedTurtleResourceList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.model; 26 | 27 | import org.eclipse.rdf4j.model.Resource; 28 | import org.eclipse.rdf4j.model.Value; 29 | import org.edmcouncil.rdf_toolkit.comparator.ComparisonContext; 30 | import java.util.HashSet; 31 | 32 | /** 33 | * An unsorted list of RDF resource values. 34 | */ 35 | public class UnsortedTurtleResourceList extends HashSet { 36 | 37 | public SortedTurtleResourceList toSorted(Class collectionClass, ComparisonContext comparisonContext) { 38 | var sortedResourceList = new SortedTurtleResourceList( 39 | collectionClass, 40 | comparisonContext); 41 | sortedResourceList.addAll(this); 42 | return sortedResourceList; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/scala/org/edmcouncil/rdf_toolkit/rdf_serializer/PotentialFileSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.rdf_serializer 26 | 27 | import org.edmcouncil.test_util.UnitSpec 28 | import org.edmcouncil.util.PotentialFile 29 | 30 | /** 31 | * Test the PotentialFile class 32 | */ 33 | class PotentialFileSpec extends UnitSpec { 34 | 35 | "A PotentialFile" must { 36 | "Accept a given partial path name for a file" in { 37 | val name = "src/test/resources/food.rdf" 38 | val pf = PotentialFile(name) 39 | assert(pf.fileExists, s"File $name does not exist") 40 | 41 | info(s"Filename is ${pf.fileName}") 42 | info(s"Path is ${pf.path}") 43 | info(s"URI is ${pf.uri}") 44 | info(s"Path is ${pf.path}") 45 | pf.printLog() 46 | } 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/UnsortedTurtleBNodeList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit.model; 25 | 26 | import org.eclipse.rdf4j.model.BNode; 27 | import org.eclipse.rdf4j.model.Value; 28 | import org.edmcouncil.rdf_toolkit.comparator.ComparisonContext; 29 | import java.util.HashSet; 30 | 31 | /** 32 | * An unsorted list of RDF blank nodes. 33 | */ 34 | // TODO: why is this not a subclass of UnsortedTurtleResourceList? 35 | public class UnsortedTurtleBNodeList extends HashSet { 36 | 37 | public SortedTurtleBNodeList toSorted(Class collectionClass, ComparisonContext comparisonContext) { 38 | SortedTurtleBNodeList sortedBNList = new SortedTurtleBNodeList(collectionClass, comparisonContext); 39 | sortedBNList.addAll(this); 40 | return sortedBNList; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/comparator/StringLengthComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.comparator; 26 | 27 | import java.util.Comparator; 28 | 29 | /** 30 | * Comparator for Strings that shorts longer strings first. 31 | */ 32 | public class StringLengthComparator implements Comparator { 33 | 34 | @Override 35 | public int compare(String str1, String str2) { 36 | if (str1 == null) { 37 | throw new NullPointerException("cannot compare null to String"); 38 | } 39 | if (str2 == null) { 40 | throw new NullPointerException("cannot compare String to null"); 41 | } 42 | if (str1.length() > str2.length()) { 43 | return -1; 44 | } else if (str1.length() < str2.length()) { 45 | return 1; 46 | } else { // if same length 47 | return str1.compareTo(str2); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/test/scala/org/edmcouncil/rdf_toolkit/command/ConfigFileSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.command 26 | 27 | import org.edmcouncil.test_util.UnitSpec 28 | 29 | /** 30 | * Test the ConfigFile utility object 31 | */ 32 | class ConfigFileSpec extends UnitSpec { 33 | 34 | "The ConfigFile " should { 35 | 36 | val configFile = ConfigFile() 37 | 38 | "find the config file" in { 39 | 40 | configFile.isDefined should be(true) 41 | 42 | configFile.get.getName should be("rdf-toolkit.ttl") 43 | 44 | info("Found config file: " + configFile.get.getName) 45 | 46 | configFile.get.canRead should be(true) 47 | } 48 | 49 | "find the root directory" in { 50 | val root = ConfigFile.rootDirectory 51 | 52 | assert(root.isDefined == true) 53 | 54 | info("Root directory is " + root) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/comparator/ComparisonContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.comparator; 26 | 27 | import org.edmcouncil.rdf_toolkit.model.UnsortedTurtleSubjectPredicateObjectMap; 28 | 29 | public class ComparisonContext { 30 | 31 | private final boolean shouldInlineBlankNodes; 32 | private final UnsortedTurtleSubjectPredicateObjectMap unsortedTripleMap; 33 | 34 | public ComparisonContext(boolean shouldInlineBlankNodesX, UnsortedTurtleSubjectPredicateObjectMap unsortedTripleMap) { 35 | this.shouldInlineBlankNodes = shouldInlineBlankNodesX; 36 | this.unsortedTripleMap = unsortedTripleMap; 37 | } 38 | 39 | public boolean getShouldInlineBlankNodes() { 40 | return shouldInlineBlankNodes; 41 | } 42 | 43 | public UnsortedTurtleSubjectPredicateObjectMap getUnsortedTripleMap() { 44 | return unsortedTripleMap; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit.model; 25 | 26 | import java.util.Objects; 27 | 28 | public class Pair { 29 | 30 | private final F first; 31 | private final S second; 32 | 33 | public Pair(F first, S second) { 34 | this.first = first; 35 | this.second = second; 36 | } 37 | 38 | public F getFirst() { 39 | return first; 40 | } 41 | 42 | public S getSecond() { 43 | return second; 44 | } 45 | 46 | @Override 47 | public boolean equals(Object o) { 48 | if (this == o) { 49 | return true; 50 | } 51 | if (o == null || getClass() != o.getClass()) { 52 | return false; 53 | } 54 | Pair pair = (Pair) o; 55 | return first.equals(pair.first) && second.equals(pair.second); 56 | } 57 | 58 | @Override 59 | public int hashCode() { 60 | return Objects.hash(first, second); 61 | } 62 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/SortedTurtleSubjectPredicateObjectMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.model; 26 | 27 | import org.eclipse.rdf4j.model.Resource; 28 | import org.eclipse.rdf4j.model.Value; 29 | import org.edmcouncil.rdf_toolkit.comparator.CachedResourceComparator; 30 | import org.edmcouncil.rdf_toolkit.comparator.ComparisonContext; 31 | 32 | /** 33 | * A sorted map from subject resources to predicate/object pairs. 34 | */ 35 | public class SortedTurtleSubjectPredicateObjectMap extends SortedHashMap { 36 | 37 | public SortedTurtleSubjectPredicateObjectMap(Class collectionClass, ComparisonContext comparisonContext) { 38 | super(new CachedResourceComparator(collectionClass, comparisonContext)); 39 | } 40 | 41 | public int fullSize() { 42 | var result = 0; 43 | for (Entry subj : entrySet()) { 44 | result += subj.getValue().fullSize(); 45 | } 46 | return result; 47 | } 48 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/comparator/CachedResourceComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.comparator; 26 | 27 | import org.eclipse.rdf4j.model.Resource; 28 | import org.eclipse.rdf4j.model.Value; 29 | import org.edmcouncil.rdf_toolkit.model.Pair; 30 | import java.util.Comparator; 31 | import java.util.HashMap; 32 | import java.util.Map; 33 | 34 | /** 35 | * Cached comparator for Sesame Resource objects. 36 | */ 37 | public class CachedResourceComparator implements Comparator { 38 | 39 | private final Map, Integer> cache = new HashMap<>(); 40 | private final ResourceComparator comparator; 41 | 42 | public CachedResourceComparator(Class collectionClass, ComparisonContext comparisonContext) { 43 | this.comparator = new ResourceComparator(collectionClass, comparisonContext); 44 | } 45 | 46 | @Override 47 | public int compare(Resource resource1, Resource resource2) { 48 | Pair key = new Pair<>(resource1, resource2); 49 | if (cache.containsKey(key)) { 50 | return cache.get(key); 51 | } else { 52 | int result = comparator.compare(resource1, resource2); 53 | cache.put(key, result); 54 | return result; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/comparator/IRIComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit.comparator; 25 | 26 | import org.eclipse.rdf4j.model.IRI; 27 | import java.util.ArrayList; 28 | import java.util.Comparator; 29 | import java.util.List; 30 | 31 | /** 32 | * Comparator for Sesame IRI objects. 33 | */ 34 | public class IRIComparator implements Comparator { 35 | 36 | @Override 37 | public int compare(IRI iri1, IRI iri2) { 38 | return compare(iri1, iri2, new ArrayList<>()); 39 | } 40 | 41 | public int compare(IRI iri1, IRI iri2, List excludedList) { 42 | if ((iri1 == null) || excludedList.contains(iri1)) { 43 | if ((iri2 == null) || excludedList.contains(iri2)) { 44 | return 0; // two null/excluded IRIs are equal 45 | } else { 46 | return -1; // null/excluded IRI comes before non-null/excluded IRI 47 | } 48 | } else { 49 | if ((iri2 == null) || excludedList.contains(iri2)) { 50 | return 1; // non-null/excluded IRI comes before null/excluded IRI 51 | } else { 52 | if (iri1 == iri2) { 53 | return 0; 54 | } else { 55 | return iri1.stringValue().compareTo(iri2.stringValue()); 56 | } 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/test/scala/org/edmcouncil/rdf_toolkit/rdf_serializer/GitRepositorySpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.rdf_serializer 26 | 27 | import java.io.File 28 | import java.nio.file.Paths 29 | 30 | import org.edmcouncil.test_util.UnitSpec 31 | import org.edmcouncil.util.GitRepository 32 | 33 | /** 34 | * Test the GitRepository object 35 | */ 36 | class GitRepositorySpec extends UnitSpec { 37 | 38 | val resourcesDir = "src/test/resources" 39 | val someDir = Paths.get(new File(resourcesDir).getAbsolutePath) 40 | 41 | "A GitRepository" must { 42 | 43 | val repo = GitRepository(someDir) 44 | 45 | "be found and opened with any given sub-directory of the repository" in { 46 | 47 | assert(repo.isDefined, s"Could not find git repo for directory $someDir") 48 | 49 | repo.foreach { (repo) ⇒ 50 | info(s"Git repo is ${repo.baseDirectory}") 51 | info(s"Git url is ${repo.url}") 52 | } 53 | 54 | } 55 | 56 | "return the short SHA of the current HEAD" in { 57 | 58 | assert(repo.isDefined, s"Could not find git repo for directory $someDir") 59 | 60 | val shortSha = repo.get.shortSha 61 | 62 | //info(s"shortSha: $shortSha") 63 | 64 | assert(shortSha.length == 7) 65 | } 66 | 67 | repo.foreach(_.close()) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/util/ShortIriPreferences.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.util; 26 | 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | public enum ShortIriPreferences { 31 | 32 | PREFIX("prefix"), 33 | BASE_IRI("base-iri"); 34 | 35 | private static final ShortIriPreferences defaultEnum = PREFIX; 36 | 37 | private final String optionValue; 38 | 39 | ShortIriPreferences(String optionValue) { 40 | this.optionValue = optionValue; 41 | } 42 | 43 | public String getOptionValue() { 44 | return optionValue; 45 | } 46 | 47 | public static ShortIriPreferences getByOptionValue(String optionValue) { 48 | if (optionValue == null) { 49 | return null; 50 | } 51 | for (ShortIriPreferences sup : ShortIriPreferences.values()) { 52 | if (optionValue.equals(sup.optionValue)) { 53 | return sup; 54 | } 55 | } 56 | return null; 57 | } 58 | 59 | public static String summarise() { 60 | List result = new ArrayList<>(); 61 | for (ShortIriPreferences sup : ShortIriPreferences.values()) { 62 | String value = sup.optionValue; 63 | if (defaultEnum.equals(sup)) { 64 | value += " [default]"; 65 | } 66 | result.add(value); 67 | } 68 | return String.join(", ", result); 69 | } 70 | } -------------------------------------------------------------------------------- /src/test/resources/ontologies/test-case-001.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 1 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/util/StringDataTypeOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.util; 26 | 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | public enum StringDataTypeOptions { 31 | EXPLICIT("explicit"), 32 | IMPLICIT("implicit"); 33 | 34 | public static final StringDataTypeOptions DEFAULT_STRING_DATA_TYPE = IMPLICIT; 35 | 36 | private final String optionValue; 37 | 38 | StringDataTypeOptions(String optionValue) { 39 | this.optionValue = optionValue; 40 | } 41 | 42 | public String getOptionValue() { 43 | return optionValue; 44 | } 45 | 46 | public static StringDataTypeOptions getByOptionValue(String optionValue) { 47 | if (optionValue == null) { 48 | return null; 49 | } 50 | for (StringDataTypeOptions dataTypeOption : StringDataTypeOptions.values()) { 51 | if (optionValue.equals(dataTypeOption.optionValue)) { 52 | return dataTypeOption; 53 | } 54 | } 55 | return null; 56 | } 57 | 58 | public static String summarise() { 59 | List result = new ArrayList<>(); 60 | for (StringDataTypeOptions dataTypeOption : StringDataTypeOptions.values()) { 61 | String value = dataTypeOption.optionValue; 62 | if (DEFAULT_STRING_DATA_TYPE.equals(dataTypeOption)) { 63 | value += " [default]"; 64 | } 65 | result.add(value); 66 | } 67 | return String.join(", ", result); 68 | } 69 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/UnsortedTurtlePredicateObjectMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.model; 26 | 27 | import org.eclipse.rdf4j.model.IRI; 28 | import org.eclipse.rdf4j.model.Value; 29 | import org.edmcouncil.rdf_toolkit.comparator.ComparisonContext; 30 | import java.util.HashMap; 31 | 32 | /** 33 | * An unsorted map from predicate IRIs to lists of object values. 34 | */ 35 | public class UnsortedTurtlePredicateObjectMap extends HashMap { 36 | 37 | public SortedTurtleObjectList getSorted(IRI predicate, Class collectionClass, 38 | ComparisonContext comparisonContext) { 39 | if (containsKey(predicate)) { 40 | return get(predicate).toSorted(collectionClass, comparisonContext); 41 | } else { 42 | return null; 43 | } 44 | } 45 | 46 | public SortedTurtlePredicateObjectMap toSorted(Class collectionClass, ComparisonContext comparisonContext) { 47 | SortedTurtlePredicateObjectMap sortedPOMap = new SortedTurtlePredicateObjectMap(); 48 | for (IRI predicate : keySet()) { 49 | sortedPOMap.put(predicate, getSorted(predicate, collectionClass, comparisonContext)); 50 | } 51 | return sortedPOMap; 52 | } 53 | 54 | public int fullSize() { 55 | return keySet().stream().mapToInt(pred -> get(pred).size()).sum(); 56 | } 57 | 58 | public boolean checkValid() { 59 | return keySet().stream().noneMatch(predicate -> get(predicate) == null); 60 | } 61 | } -------------------------------------------------------------------------------- /src/test/java/org/edmcouncil/rdf_toolkit/comparator/AbstractComparatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.comparator; 26 | 27 | import org.eclipse.rdf4j.model.Model; 28 | import org.eclipse.rdf4j.model.Resource; 29 | import org.eclipse.rdf4j.model.Statement; 30 | import org.edmcouncil.rdf_toolkit.model.UnsortedTurtleObjectList; 31 | import org.edmcouncil.rdf_toolkit.model.UnsortedTurtlePredicateObjectMap; 32 | import org.edmcouncil.rdf_toolkit.model.UnsortedTurtleSubjectPredicateObjectMap; 33 | 34 | abstract public class AbstractComparatorTest { 35 | 36 | public static final String IRI_PREFIX = "http://example.com/ont1/"; 37 | 38 | protected ComparisonContext prepareComparisonContext(Model model, boolean shouldInlineBlankNodes) { 39 | var tripleMap = new UnsortedTurtleSubjectPredicateObjectMap(); 40 | for (Statement statement : model) { 41 | Resource subject = statement.getSubject(); 42 | if (!tripleMap.containsKey(subject)) { 43 | tripleMap.put(subject, new UnsortedTurtlePredicateObjectMap()); 44 | } 45 | addStatement(tripleMap.get(subject), statement); 46 | } 47 | return new ComparisonContext(shouldInlineBlankNodes, tripleMap); 48 | } 49 | 50 | protected void addStatement(UnsortedTurtlePredicateObjectMap predicateObjectMap, Statement statement) { 51 | var predicate = statement.getPredicate(); 52 | if (!predicateObjectMap.containsKey(predicate)) { 53 | predicateObjectMap.put(predicate, new UnsortedTurtleObjectList()); 54 | } 55 | predicateObjectMap.get(predicate).add(statement.getObject()); 56 | } 57 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/RdfFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit; 26 | 27 | import java.io.PrintWriter; 28 | import java.io.StringWriter; 29 | import org.edmcouncil.rdf_toolkit.runner.RdfToolkitRunner; 30 | import org.slf4j.Logger; 31 | import org.slf4j.LoggerFactory; 32 | 33 | /** 34 | * RDF formatter that formats in a consistent order, friendly for version control systems. 35 | * Should not be used with files that are too large to be fully loaded into memory for sorting. 36 | * Run with "--help" option for help. 37 | */ 38 | public class RdfFormatter { 39 | 40 | private static final Logger logger = LoggerFactory.getLogger(RdfFormatter.class); 41 | 42 | /** 43 | * Main method for running the RDF formatter. Run with "--help" option for help. 44 | */ 45 | public static void main(String[] args) { 46 | try { 47 | run(args); 48 | System.exit(0); 49 | } catch (Exception ex) { 50 | logger.error("{}: stopped by unexpected exception: ", RdfFormatter.class.getSimpleName()); 51 | logger.error("{}: {}", ex.getClass().getSimpleName(), ex.getMessage()); 52 | var stackTraceWriter = new StringWriter(); 53 | ex.printStackTrace(new PrintWriter(stackTraceWriter)); 54 | logger.error(stackTraceWriter.toString()); 55 | System.exit(1); 56 | } 57 | } 58 | 59 | /** 60 | * Main method, but throws exceptions for use from inside other Java code. 61 | */ 62 | public static void run(String[] args) throws Exception { 63 | var rdfToolkitRunner = new RdfToolkitRunner(); 64 | rdfToolkitRunner.run(args); 65 | } 66 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/UnsortedTurtleSubjectPredicateObjectMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.model; 26 | 27 | import org.eclipse.rdf4j.model.Resource; 28 | import org.eclipse.rdf4j.model.Value; 29 | import org.edmcouncil.rdf_toolkit.comparator.ComparisonContext; 30 | import java.util.HashMap; 31 | 32 | /** 33 | * An unsorted map from subject resources to predicate/object pairs. 34 | */ 35 | public class UnsortedTurtleSubjectPredicateObjectMap extends HashMap { 36 | 37 | public SortedTurtlePredicateObjectMap getSorted(Resource subject, Class collectionClass, 38 | ComparisonContext comparisonContext) { 39 | if (containsKey(subject)) { 40 | return get(subject).toSorted(collectionClass, comparisonContext); 41 | } else { 42 | return null; 43 | } 44 | } 45 | 46 | public SortedTurtleSubjectPredicateObjectMap toSorted(Class collectionClass, 47 | ComparisonContext comparisonContext) { 48 | var sortedSPOMap = new SortedTurtleSubjectPredicateObjectMap(collectionClass, comparisonContext); 49 | for (Resource subject : keySet()) { 50 | sortedSPOMap.put(subject, getSorted(subject, collectionClass, comparisonContext)); 51 | } 52 | return sortedSPOMap; 53 | } 54 | 55 | public int fullSize() { 56 | var result = 0; 57 | for (UnsortedTurtlePredicateObjectMap value : values()) { 58 | result += value.fullSize(); 59 | } 60 | return result; 61 | } 62 | 63 | public boolean checkValid() { 64 | for (Resource subject : keySet()) { 65 | if ((get(subject) == null) || !get(subject).checkValid()) { 66 | return false; 67 | } 68 | } 69 | return true; 70 | } 71 | } -------------------------------------------------------------------------------- /src/test/scala/org/edmcouncil/rdf_toolkit/rdf_serializer/EdmCouncilOntologyIRISpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.rdf_serializer 26 | 27 | import org.edmcouncil.fibo.{ EdmCouncilVersionIRI, EdmCouncilOntologyIRI } 28 | import org.edmcouncil.test_util.UnitSpec 29 | 30 | /** 31 | * Test the EdmCouncilOntologyIRI classes 32 | */ 33 | class EdmCouncilOntologyIRISpec extends UnitSpec { 34 | 35 | import org.edmcouncil._ 36 | 37 | "EdmCouncilOntologyIRI" should { 38 | 39 | val fiboIri = EdmCouncilOntologyIRI(s"${edmcFiboNamespaceIRI}FND/Accounting/AboutAccounting/") 40 | 41 | "test 1" in { 42 | 43 | assert(fiboIri.family == "fibo") 44 | assert(fiboIri.domain == "fnd") 45 | assert(fiboIri.domainUC == "FND") 46 | assert(fiboIri.ontology == "AboutAccounting") 47 | assert(fiboIri.firstModule == "Accounting") 48 | } 49 | } 50 | 51 | "EdmCouncilVersionIRI" should { 52 | 53 | val fiboIri = EdmCouncilVersionIRI(s"${edmcFiboNamespaceIRI}FND/pink/Accounting/AboutAccounting/") 54 | 55 | "test 2" in { 56 | assert(fiboIri.family == "fibo") 57 | assert(fiboIri.version == "pink") 58 | assert(fiboIri.domain == "fnd") 59 | assert(fiboIri.domainUC == "FND") 60 | assert(fiboIri.ontology == "AboutAccounting") 61 | assert(fiboIri.firstModule == "Accounting") 62 | 63 | val fiboNewIri = fiboIri.withVersion("yellow") 64 | 65 | assert(fiboNewIri.family == "fibo") 66 | assert(fiboNewIri.version == "yellow") 67 | assert(fiboNewIri.domain == "fnd") 68 | assert(fiboNewIri.domainUC == "FND") 69 | assert(fiboNewIri.ontology == "AboutAccounting") 70 | assert(fiboNewIri.firstModule == "Accounting") 71 | } 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/test/java/org/edmcouncil/rdf_toolkit/writer/AbstractSortedWriterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.writer; 26 | 27 | import com.fasterxml.jackson.core.JsonProcessingException; 28 | import com.fasterxml.jackson.databind.JsonNode; 29 | import com.fasterxml.jackson.databind.ObjectMapper; 30 | 31 | import java.io.File; 32 | import java.io.FileInputStream; 33 | import java.io.FileNotFoundException; 34 | import java.io.InputStreamReader; 35 | import java.nio.charset.StandardCharsets; 36 | 37 | abstract public class AbstractSortedWriterTest { 38 | 39 | protected static final String JSONLD_LANGUAGE = "@language"; 40 | protected static final String JSONLD_VALUE = "@value"; 41 | 42 | private static final String RDFS_LABEL_SHORT = "rdfs:label"; 43 | 44 | public InputStreamReader prepareInputStream(File sourceFile) throws FileNotFoundException { 45 | return new InputStreamReader(new FileInputStream(sourceFile), StandardCharsets.UTF_8); 46 | } 47 | 48 | protected String getTrimmedLineContainingString(String content, String string) { 49 | return content.lines() 50 | .filter(line -> line.contains(string)) 51 | .findFirst() 52 | .orElseThrow(IllegalArgumentException::new) 53 | .trim(); 54 | } 55 | 56 | protected JsonNode getJsonObjectForLabel(String content, String label) throws JsonProcessingException { 57 | ObjectMapper objectMapper = new ObjectMapper(); 58 | JsonNode root = objectMapper.readTree(content); 59 | JsonNode arrayOfLabels = root.get(1).get(RDFS_LABEL_SHORT); 60 | for (JsonNode arrayOfLabel : arrayOfLabels) { 61 | if (arrayOfLabel.get(JSONLD_VALUE).asText().equals(label)) { 62 | return arrayOfLabel; 63 | } 64 | } 65 | return null; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/io/RdfModelReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit.io; 25 | 26 | import org.eclipse.rdf4j.model.Model; 27 | import org.eclipse.rdf4j.model.ValueFactory; 28 | import org.eclipse.rdf4j.model.impl.LinkedHashModel; 29 | import org.eclipse.rdf4j.rio.RDFFormat; 30 | import org.eclipse.rdf4j.rio.helpers.AbstractRDFParser; 31 | import org.eclipse.rdf4j.rio.helpers.ContextStatementCollector; 32 | import org.eclipse.rdf4j.rio.jsonld.JSONLDParser; 33 | import org.eclipse.rdf4j.rio.rdfxml.RDFXMLParser; 34 | import org.eclipse.rdf4j.rio.turtle.TurtleParser; 35 | import org.eclipse.rdf4j.sail.memory.model.MemValueFactory; 36 | import java.io.IOException; 37 | import java.io.InputStream; 38 | 39 | public class RdfModelReader { 40 | 41 | private final AbstractRDFParser parser; 42 | private final ValueFactory valueFactory; 43 | 44 | public RdfModelReader(RDFFormat rdfFormat) { 45 | this.valueFactory = new MemValueFactory(); 46 | 47 | switch (rdfFormat.getName()) { 48 | case "RDF/XML": 49 | this.parser = new RDFXMLParser(valueFactory); 50 | break; 51 | case "Turtle": 52 | this.parser = new TurtleParser(valueFactory); 53 | break; 54 | case "JSON-LD": 55 | this.parser = new JSONLDParser(valueFactory); 56 | break; 57 | default: 58 | throw new IllegalStateException("Not supported format: " + rdfFormat.getName()); 59 | } 60 | } 61 | 62 | public Model read(InputStream sourceInputStream, String baseIriString) throws IOException { 63 | Model result = new LinkedHashModel(); 64 | parser.setRDFHandler(new ContextStatementCollector(result, valueFactory)); 65 | parser.parse(sourceInputStream, baseIriString); 66 | return result; 67 | } 68 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/io/format/TargetFormats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.io.format; 26 | 27 | import org.eclipse.rdf4j.rio.RDFFormat; 28 | import java.util.ArrayList; 29 | 30 | public enum TargetFormats { 31 | JSON_LD("json-ld", "(JSON-LD)", RDFFormat.JSONLD), 32 | RDF_XML("rdf-xml", "(RDF/XML)", RDFFormat.RDFXML), 33 | TURTLE("turtle", "(Turtle)", RDFFormat.TURTLE); 34 | 35 | public static final TargetFormats DEFAULT_FORMAT = TURTLE; 36 | 37 | private final String optionValue; 38 | private final String optionComment; 39 | private final RDFFormat rdfFormat; 40 | 41 | TargetFormats(String optionValue, String optionComment, RDFFormat rdfFormat) { 42 | this.optionValue = optionValue; 43 | this.optionComment = optionComment; 44 | this.rdfFormat = rdfFormat; 45 | } 46 | 47 | public String getOptionValue() { 48 | return optionValue; 49 | } 50 | 51 | public String getOptionComment() { 52 | return optionComment; 53 | } 54 | 55 | public RDFFormat getRDFFormat() { 56 | return rdfFormat; 57 | } 58 | 59 | public static TargetFormats getByOptionValue(String optionValue) { 60 | if (optionValue == null) { 61 | return null; 62 | } 63 | for (TargetFormats tfmt : values()) { 64 | if (optionValue.equals(tfmt.optionValue)) { 65 | return tfmt; 66 | } 67 | } 68 | return null; 69 | } 70 | 71 | public static String summarise() { 72 | ArrayList result = new ArrayList<>(); 73 | for (TargetFormats tfmt : values()) { 74 | String value = tfmt.optionValue; 75 | if (tfmt.optionComment != null) { 76 | value += " " + tfmt.optionComment; 77 | } 78 | if (DEFAULT_FORMAT.equals(tfmt)) { 79 | value += " [default]"; 80 | } 81 | result.add(value); 82 | } 83 | return String.join(", ", result); 84 | } 85 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/model/SortedHashMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.model; 26 | 27 | import java.util.ArrayList; 28 | import java.util.Comparator; 29 | import java.util.HashMap; 30 | import java.util.LinkedList; 31 | import java.util.List; 32 | import java.util.Objects; 33 | 34 | /** 35 | * Like java.util.HashMap, but able to return the keys in sorted order. 36 | */ 37 | public class SortedHashMap extends HashMap { 38 | 39 | private final transient Comparator comparator; 40 | private transient List sortedKeys = new ArrayList<>(); 41 | private transient boolean dirty = true; 42 | 43 | public SortedHashMap(Comparator comparator) { 44 | this.comparator = comparator; 45 | } 46 | 47 | private void updateSortedKeys() { 48 | sortedKeys = new LinkedList<>(); 49 | sortedKeys.addAll(keySet()); 50 | sortedKeys.sort(comparator); 51 | } 52 | 53 | @Override 54 | public V put(K key, V value) { 55 | V result = super.put(key, value); 56 | dirty = true; 57 | return result; 58 | } 59 | 60 | @Override 61 | public boolean remove(Object key, Object value) { 62 | boolean result = super.remove(key, value); 63 | dirty = true; 64 | return result; 65 | } 66 | 67 | public Iterable sortedKeys() { 68 | if (dirty) { 69 | updateSortedKeys(); 70 | } 71 | return new LinkedList<>(sortedKeys); 72 | } 73 | 74 | @Override 75 | public boolean equals(Object o) { 76 | if (this == o) { 77 | return true; 78 | } 79 | if (!(o instanceof SortedHashMap)) { 80 | return false; 81 | } 82 | if (!super.equals(o)) { 83 | return false; 84 | } 85 | SortedHashMap that = (SortedHashMap) o; 86 | return Objects.equals(comparator, that.comparator) && Objects.equals(sortedKeys(), that.sortedKeys()); 87 | } 88 | 89 | @Override 90 | public int hashCode() { 91 | return Objects.hash(super.hashCode(), comparator, sortedKeys()); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/test/java/org/edmcouncil/rdf_toolkit/TestConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit; 26 | 27 | import static org.edmcouncil.rdf_toolkit.util.Constants.XML_SCHEMA_NS_URI; 28 | import java.util.Set; 29 | 30 | public class TestConstants { 31 | 32 | public static final String XS_STRING = XML_SCHEMA_NS_URI + "string"; 33 | 34 | /** 35 | * Exclusion list for tests related to inferring the base IRI of an ontology. 36 | */ 37 | public static final Set IBI_EXCLUSION_SET = Set.of("food.rdf", "wine.rdf"); 38 | 39 | public static final Set JSON_LD_INLINE_BLANK_NODES_EXCLUSION_SET = Set.of( 40 | "allemang-FunctionalEntities.rdf", 41 | "turtle-example-14.ttl", 42 | "turtle-example-25.ttl", 43 | "turtle-example-26.ttl"); 44 | 45 | public static final Set TURTLE_INLINE_BLANK_NODES_EXCLUSION_SET = Set.of( 46 | "allemang-FunctionalEntities.rdf", 47 | "turtle-example-14.ttl", 48 | "turtle-example-25.ttl", 49 | "turtle-example-26.ttl"); 50 | 51 | /** 52 | * Exclusion list of examples where the ontology IRI is different to the base IRI. 53 | */ 54 | public static final Set INFERRED_BASE_IRI_EXCLUSION_SET = Set.of("food.rdf", "wine.rdf"); 55 | 56 | /** 57 | * Return exclusion set of examples that can't be represented directly in RDF/XML. 58 | */ 59 | public static final Set RDFXML_EXCLUSION_SET = Set.of( 60 | "allemang-test-a.ttl", 61 | "allemang-test-b.ttl", 62 | "turtle-example-2.ttl", 63 | "turtle-example-3.ttl", 64 | "turtle-example-4.ttl", 65 | "turtle-example-5.ttl", 66 | "turtle-example-6.ttl", 67 | "turtle-example-9.ttl", 68 | "turtle-example-17.ttl", 69 | "turtle-example-22.ttl"); 70 | 71 | public static final Set INLINE_BLANK_NODES_EXCLUSION_SET = Set.of( 72 | "allemang-FunctionalEntities.rdf", 73 | "turtle-example-14.ttl", 74 | "turtle-example-25.ttl", 75 | "turtle-example-26.ttl"); 76 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/io/format/SourceFormats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.io.format; 26 | 27 | import org.eclipse.rdf4j.rio.RDFFormat; 28 | import java.util.ArrayList; 29 | 30 | public enum SourceFormats { 31 | AUTO("auto", "(select by filename)", null), 32 | BINARY("binary", null, RDFFormat.BINARY), 33 | JSON_LD("json-ld", "(JSON-LD)", RDFFormat.JSONLD), 34 | N3("n3", null, RDFFormat.N3), 35 | N_QUADS("n-quads", "(N-quads)", RDFFormat.NQUADS), 36 | N_TRIPLES("n-triples", "(N-triples)", RDFFormat.NTRIPLES), 37 | RDF_A("rdf-a", "(RDF/A)", RDFFormat.RDFA), 38 | RDF_JSON("rdf-json", "(RDF/JSON)", RDFFormat.RDFJSON), 39 | RDF_XML("rdf-xml", "(RDF/XML)", RDFFormat.RDFXML), 40 | TRIG("trig", "(TriG)", RDFFormat.TRIG), 41 | TRIX("trix", "(TriX)", RDFFormat.TRIX), 42 | TURTLE("turtle", "(Turtle)", RDFFormat.TURTLE); 43 | 44 | private static final SourceFormats defaultEnum = AUTO; 45 | 46 | private final String optionValue; 47 | private final String optionComment; 48 | private final RDFFormat rdfFormat; 49 | 50 | SourceFormats(String optionValue, String optionComment, RDFFormat rdfFormat) { 51 | this.optionValue = optionValue; 52 | this.optionComment = optionComment; 53 | this.rdfFormat = rdfFormat; 54 | } 55 | 56 | public String getOptionValue() { 57 | return optionValue; 58 | } 59 | 60 | public String getOptionComment() { 61 | return optionComment; 62 | } 63 | 64 | public RDFFormat getRDFFormat() { 65 | return rdfFormat; 66 | } 67 | 68 | public static SourceFormats getByOptionValue(String optionValue) { 69 | if (optionValue == null) { 70 | return null; 71 | } 72 | for (SourceFormats sfmt : values()) { 73 | if (optionValue.equals(sfmt.optionValue)) { 74 | return sfmt; 75 | } 76 | } 77 | return null; 78 | } 79 | 80 | public static String summarise() { 81 | ArrayList result = new ArrayList<>(); 82 | for (SourceFormats sfmt : values()) { 83 | String value = sfmt.optionValue; 84 | if (sfmt.optionComment != null) { 85 | value += " " + sfmt.optionComment; 86 | } 87 | if (defaultEnum.equals(sfmt)) { 88 | value += " [default]"; 89 | } 90 | result.add(value); 91 | } 92 | return String.join(", ", result); 93 | } 94 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/writer/IndentingWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package org.edmcouncil.rdf_toolkit.writer; 25 | 26 | import java.io.IOException; 27 | import java.io.Writer; 28 | 29 | public class IndentingWriter extends Writer { 30 | 31 | protected final Writer out; 32 | protected int indentationLevel = 0; 33 | private String indentationString = "\t"; 34 | private boolean indentationWritten = false; 35 | private String lineEnd; 36 | private String defaultLanguage; // TODO remove 37 | 38 | public IndentingWriter(Writer out) { 39 | this.out = out; 40 | } 41 | 42 | public void setIndentationString(String indentString) { 43 | this.indentationString = indentString; 44 | } 45 | 46 | public String getIndentationString() { 47 | return this.indentationString; 48 | } 49 | 50 | public int getIndentationLevel() { 51 | return this.indentationLevel; 52 | } 53 | 54 | public void setIndentationLevel(int indentationLevel) { 55 | this.indentationLevel = indentationLevel; 56 | } 57 | 58 | public void increaseIndentation() { 59 | ++this.indentationLevel; 60 | } 61 | 62 | public void decreaseIndentation() { 63 | --this.indentationLevel; 64 | } 65 | 66 | public String getLineEnd() { 67 | return this.lineEnd; 68 | } 69 | 70 | public void setLineEnd(String lineEnd) { 71 | this.lineEnd = lineEnd; 72 | } 73 | 74 | public String getDefaultLanguage() { 75 | return this.defaultLanguage; 76 | } 77 | 78 | public void setDefaultLanguage(String defaultLanguage) { 79 | this.defaultLanguage = defaultLanguage; 80 | } 81 | 82 | public void writeEOL() throws IOException { 83 | this.write(getLineEnd()); 84 | this.indentationWritten = false; 85 | } 86 | 87 | public void close() throws IOException { 88 | this.out.close(); 89 | } 90 | 91 | public void flush() throws IOException { 92 | this.out.flush(); 93 | } 94 | 95 | public void write(char[] charBuffer, int off, int len) throws IOException { 96 | if (!this.indentationWritten) { 97 | for(var i = 0; i < this.indentationLevel; ++i) { 98 | this.out.write(this.indentationString); 99 | } 100 | 101 | this.indentationWritten = true; 102 | } 103 | 104 | this.out.write(charBuffer, off, len); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo-with-placeholder-iri/fnd/Law/AboutLaw.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Law Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014 EDM Council, Inc. 35 | Copyright (c) 2014 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutLaw.rdf 42 | fibo-fnd-law-mod 43 | 44 | 45 | 2014-08-19T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | FIBO FND Law Module 66 | individual representing metadata about the FIBO FND law module 67 | Law 68 | FIBO-FND-LAW 69 | 1.0 70 | This module includes several ontologies defining legal concepts, including constitutions, laws and jurisdictions. It also includes the definition of legal capacities such as signatory capacity, contractual capability and the like. 71 | 72 | http://www.edmcouncil.org/ 73 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 74 | https://spec.edmcouncil.org/fibo/FND/AboutFND/ 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/comparator/TurtleObjectListComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.comparator; 26 | 27 | import java.util.ArrayList; 28 | import java.util.Collection; 29 | import java.util.Comparator; 30 | import java.util.Iterator; 31 | import java.util.List; 32 | import org.eclipse.rdf4j.model.Value; 33 | import org.edmcouncil.rdf_toolkit.model.SortedTurtleObjectList; 34 | 35 | /** 36 | * Comparator for TurtleObjectList objects. 37 | */ 38 | public class TurtleObjectListComparator implements Comparator { 39 | 40 | private final ValueComparator valueComparator; 41 | 42 | public TurtleObjectListComparator(Class collectionClass, ComparisonContext comparisonContext) { 43 | this.valueComparator = new ValueComparator(collectionClass, comparisonContext); 44 | } 45 | 46 | @Override 47 | public int compare(SortedTurtleObjectList list1, SortedTurtleObjectList list2) { 48 | return compare(list1, list2, new ArrayList<>()); 49 | } 50 | 51 | public int compare(Collection list1, Collection list2, List excludedList) { 52 | if ((list1 == null) || excludedList.contains(list1)) { 53 | if ((list2 == null) || excludedList.contains(list2)) { 54 | return 0; // two null/excluded lists are equal 55 | } else { 56 | return -1; // null/excluded list comes before non-null/excluded list 57 | } 58 | } else { 59 | if ((list2 == null) || excludedList.contains(list2)) { 60 | return 1; // non-null/excluded list comes before null/excluded list 61 | } else { 62 | if (list1 == list2) { 63 | return 0; 64 | } else { 65 | Iterator iter1 = list1.iterator(); 66 | Iterator iter2 = list2.iterator(); 67 | return compare(list1, iter1, list2, iter2, excludedList); 68 | } 69 | } 70 | } 71 | } 72 | 73 | private int compare(Collection list1, Iterator iter1, 74 | Collection list2, Iterator iter2, 75 | List excludedList) { 76 | if (iter1.hasNext()) { 77 | if (iter2.hasNext()) { 78 | var value1 = iter1.next(); 79 | var value2 = iter2.next(); 80 | 81 | excludedList.add(list1); 82 | excludedList.add(list2); 83 | int cmp = valueComparator.compare(value1, value2, excludedList); 84 | if (cmp != 0) { 85 | return cmp; 86 | } else { // values are the same, try the next values in the lists 87 | return compare(list1, iter1, list2, iter2, excludedList); 88 | } 89 | } else { // only iter1 has a next value 90 | return 1; // list1 comes after list2 91 | } 92 | } else { 93 | if (iter2.hasNext()) { // only iter2 has a next value 94 | return -1; // list1 comes before list2 95 | } else { // both iterators have no next value 96 | return 0; 97 | } 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /src/main/java/org/edmcouncil/rdf_toolkit/io/DirectoryWalker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.io; 26 | 27 | import java.io.File; 28 | import java.util.ArrayList; 29 | import java.util.Collection; 30 | import java.util.List; 31 | import java.util.regex.Pattern; 32 | 33 | /** 34 | * Utility class for iterating over directory trees. 35 | */ 36 | public class DirectoryWalker { 37 | 38 | private final File rootDir; 39 | private final Pattern relativePathPattern; 40 | 41 | public static class DirectoryWalkerResult { 42 | private final File file; 43 | private final String relativePath; 44 | 45 | public DirectoryWalkerResult(File file, String relativePath) { 46 | this.file = file; 47 | this.relativePath = relativePath; 48 | } 49 | 50 | public File getFile() { 51 | return file; 52 | } 53 | 54 | public String getRelativePath() { 55 | return relativePath; 56 | } 57 | } 58 | 59 | /** 60 | * Constructor that takes a root directory and a relative file path pattern. 61 | */ 62 | public DirectoryWalker(File rootDir, Pattern relativePathPattern) { 63 | this.rootDir = rootDir; 64 | this.relativePathPattern = relativePathPattern; 65 | if (!rootDir.exists()) { 66 | throw new IllegalArgumentException(String.format("directory does not exist: %s", rootDir.getAbsolutePath())); 67 | } 68 | if (!rootDir.isDirectory()) { 69 | throw new IllegalArgumentException(String.format("file is not a directory: %s", rootDir.getAbsolutePath())); 70 | } 71 | if (!rootDir.canRead()) { 72 | throw new IllegalArgumentException(String.format("directory cannot be read: %s", rootDir.getAbsolutePath())); 73 | } 74 | } 75 | 76 | /** 77 | * Returns all file matches for the directory walker. 78 | */ 79 | public Collection pathMatches() { 80 | return pathMatches(rootDir); 81 | } 82 | 83 | /** 84 | * Returns all file matches for the directory walker, starting at a particular directory. 85 | */ 86 | private Collection pathMatches(File startDir) { 87 | if (startDir == null) { 88 | throw new IllegalStateException("startDir cannot be bull."); 89 | } 90 | 91 | List matches = new ArrayList<>(); 92 | 93 | var rootPath = rootDir.toPath(); 94 | var files = startDir.listFiles(); 95 | if (files != null) { 96 | for (File child : files) { 97 | if (child.isDirectory()) { 98 | matches.addAll(pathMatches(child)); 99 | } else { 100 | var childPath = child.toPath(); 101 | var relativePath = rootPath.relativize(childPath).toString(); 102 | var relativePathMatcher = relativePathPattern.matcher(relativePath); 103 | if (relativePathMatcher.matches()) { 104 | matches.add(new DirectoryWalkerResult(child, relativePath)); 105 | } 106 | } 107 | } 108 | } 109 | return matches; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo-with-placeholder-iri/fnd/Accounting/AboutAccounting.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Accounting Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014 EDM Council, Inc. 35 | Copyright (c) 2014 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutAccounting.rdf 42 | fibo-fnd-acc-mod 43 | 44 | 45 | 2014-08-19T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | FIBO FND Accounting Module 66 | individual representing metadata about the FIBO FND accounting module 67 | Accounting 68 | FIBO-FND-ACC 69 | 1.0 70 | This module contains ontologies of general accounting concepts including debt, equity, interest and so on, as well as currency amounts. 71 | 72 | http://www.edmcouncil.org/ 73 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 74 | https://spec.edmcouncil.org/fibo/FND/AboutFND/ 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/test/java/org/edmcouncil/rdf_toolkit/comparator/ComparisonUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2015 Enterprise Data Management Council 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package org.edmcouncil.rdf_toolkit.comparator; 26 | 27 | import static org.edmcouncil.rdf_toolkit.comparator.ComparisonUtils.isCollection; 28 | import static org.junit.jupiter.api.Assertions.assertFalse; 29 | import static org.junit.jupiter.api.Assertions.assertTrue; 30 | import org.eclipse.rdf4j.model.BNode; 31 | import org.eclipse.rdf4j.model.IRI; 32 | import org.eclipse.rdf4j.model.Model; 33 | import org.eclipse.rdf4j.model.Value; 34 | import org.eclipse.rdf4j.model.ValueFactory; 35 | import org.eclipse.rdf4j.model.impl.SimpleValueFactory; 36 | import org.eclipse.rdf4j.model.util.ModelBuilder; 37 | import org.eclipse.rdf4j.model.util.RDFCollections; 38 | import org.eclipse.rdf4j.model.vocabulary.FOAF; 39 | import org.eclipse.rdf4j.model.vocabulary.RDF; 40 | import org.junit.jupiter.api.Test; 41 | import java.util.List; 42 | 43 | class ComparisonUtilsTest extends AbstractComparatorTest { 44 | 45 | @Test 46 | void shouldReturnFalseWhenBlankNodeDoesNotRepresentCollection() { 47 | var valueFactory = SimpleValueFactory.getInstance(); 48 | var model = prepareModel(valueFactory); 49 | 50 | var actualResult = isCollection( 51 | prepareComparisonContext(model, true), 52 | valueFactory.createBNode("bnode01"), 53 | Value.class); 54 | 55 | assertFalse(actualResult); 56 | } 57 | 58 | @Test 59 | void shouldReturnTrueWhenBlankNodeRepresentsCollection() { 60 | var valueFactory = SimpleValueFactory.getInstance(); 61 | var pets = List.of( 62 | valueFactory.createIRI(IRI_PREFIX, "Punk"), 63 | valueFactory.createIRI(IRI_PREFIX, "Kitty"), 64 | valueFactory.createIRI(IRI_PREFIX, "Sharky")); 65 | 66 | var johnPets = valueFactory.createBNode("bnode03"); 67 | var model = prepareModel(valueFactory); 68 | RDFCollections.asRDF(pets, johnPets, model); 69 | 70 | var actualResult = isCollection( 71 | prepareComparisonContext(model, true), 72 | johnPets, 73 | Value.class); 74 | 75 | assertTrue(actualResult); 76 | } 77 | 78 | private Model prepareModel(ValueFactory valueFactory) { 79 | IRI cityIri = valueFactory.createIRI(IRI_PREFIX + "city"); 80 | IRI streetIri = valueFactory.createIRI(IRI_PREFIX + "street"); 81 | BNode johnAddressNode = valueFactory.createBNode("bnode01"); 82 | BNode bobAddressNode = valueFactory.createBNode("bnode02"); 83 | ModelBuilder modelBuilder = new ModelBuilder(); 84 | return modelBuilder 85 | .setNamespace("ex", IRI_PREFIX) 86 | .setNamespace(FOAF.NS) 87 | .defaultGraph() 88 | .add("ex:john", RDF.TYPE, FOAF.PERSON) 89 | .add("ex:john", "ex:address", johnAddressNode) 90 | .add(johnAddressNode, cityIri, valueFactory.createLiteral("Paris")) 91 | .add(johnAddressNode, streetIri, valueFactory.createLiteral("Avenue Victor Hugo")) 92 | .add("ex:bob", RDF.TYPE, FOAF.PERSON) 93 | .add("ex:bob", "ex:address", bobAddressNode) 94 | .add(bobAddressNode, cityIri, valueFactory.createLiteral("Berlin")) 95 | .add(bobAddressNode, streetIri, valueFactory.createLiteral("Unter den Linden")) 96 | .build(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo-with-placeholder-iri/fnd/Arrangements/AboutArrangements.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Arrangements Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014 EDM Council, Inc. 35 | Copyright (c) 2014 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutArrangements.rdf 42 | fibo-fnd-arr-mod 43 | 44 | 45 | 2014-08-19T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | FIBO FND Arrangements Module 66 | individual representing metadata about the FIBO FND arrangements module 67 | Arrangements 68 | FIBO-FND-ARR 69 | 1.0 70 | This module contains ontologies that define abstract concepts, structures and schemata, such as identifiers and identification schemes, indices and indexing schemes, codes and coding schemes, classification strategies, and quantities. 71 | 72 | http://www.edmcouncil.org/ 73 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 74 | https://spec.edmcouncil.org/fibo/FND/AboutFND/ 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo-with-placeholder-iri/fnd/Utilities/AboutUtilities.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Utilities Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014 EDM Council, Inc. 35 | Copyright (c) 2014 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutUtilities.rdf 42 | fibo-fnd-utl-mod 43 | 44 | 45 | 2014-08-19T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | FIBO FND Utilities Module 66 | individual representing metadata about the FIBO FND utilities module 67 | Utilities 68 | FIBO-FND-UTL 69 | 1.0 70 | Ontologies which provide annotations and business facing datatypes to be used in other ontologies. These ontologies are not expected to be used directly by business stakeholders and are for the definition of material which is used by semantic modelers in Foundations and in other FIBO ontologies. 71 | 72 | http://www.edmcouncil.org/ 73 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 74 | https://spec.edmcouncil.org/fibo/FND/AboutFND/ 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo-with-placeholder-iri/fnd/Relations/AboutRelations.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Relations Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014 EDM Council, Inc. 35 | Copyright (c) 2014 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutRelations.rdf 42 | fibo-fnd-rel-mod 43 | 44 | 45 | 2014-08-19T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | FIBO FND Relations Module 66 | individual representing metadata about the FIBO FND relations module 67 | Relations 68 | FIBO-FND-REL 69 | 1.0 70 | This module contains an ontology defining a number of reusable relationships. These are used, refined or restricted to define relationships among more specific concepts in other FIBO ontologies. Some of these relationships stand in for relationships which are defined in external standards ontologies. 71 | 72 | http://www.edmcouncil.org/ 73 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 74 | https://spec.edmcouncil.org/fibo/FND/AboutFND/ 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo-with-placeholder-iri/fnd/Places/AboutPlaces.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Places Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014 EDM Council, Inc. 35 | Copyright (c) 2014 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutPlaces.rdf 42 | fibo-fnd-plc-mod 43 | 44 | 45 | 2014-08-19T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | FIBO FND Places Module 66 | individual representing metadata about the FIBO FND places module 67 | Places 68 | FIBO-FND-PLC 69 | 1.0 70 | This module includes ontologies defining concepts to do with real or virtual places and the addresses to such places. Note that most of these terms are proxies for terms which exist or which are expected to be published in the future in formal ontologies for those concepts (e.g. geophysical, geopolitical, as well as the address components in physical standards like VCard). 71 | 72 | http://www.edmcouncil.org/ 73 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 74 | https://spec.edmcouncil.org/fibo/FND/AboutFND/ 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo/ontology/master/latest/IND/ForeignExchange/AboutForeignExchange.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Indices and Indicators (IND) Foreign Exchange Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2015 EDM Council, Inc. 35 | Copyright (c) 2015 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutForeignExchange.rdf 42 | fibo-ind-fx-mod 43 | 44 | 45 | 2015-05-18T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | 64 | 65 | 66 | FIBO IND Foreign Exchange Module 67 | individual representing metadata about the FIBO IND foreign exchange module 68 | ForeignExchange 69 | FIBO-IND-FX 70 | 1.0 71 | This module includes ontologies defining concepts to do with foreign exchange. 72 | 73 | http://www.edmcouncil.org/ 74 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 75 | https://spec.edmcouncil.org/fibo/ontology/master/latest/IND/AboutIND/ 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo-with-placeholder-iri/fnd/AgentsAndPeople/AboutAgentsAndPeople.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Agents and People Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014 EDM Council, Inc. 35 | Copyright (c) 2014 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutAgentsAndPeople.rdf 42 | fibo-fnd-aap-mod 43 | 44 | 45 | 2014-08-19T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | FIBO FND Agents And People Module 66 | individual representing metadata about the FIBO FND agents and people module 67 | AgentsAndPeople 68 | FIBO-FND-AAP 69 | 1.0 70 | This module contains ontologies of concepts relating to types of autonomous entity, that is things in the world which are able to determine their own behavior. Includes ontologies for people and for autononomous entities in general. 71 | 72 | http://www.edmcouncil.org/ 73 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 74 | https://spec.edmcouncil.org/fibo/FND/AboutFND/ 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo/ontology/master/latest/FND/Law/AboutLaw.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Law Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014-2017 EDM Council, Inc. 35 | Copyright (c) 2014-2017 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutLaw.rdf 42 | fibo-fnd-law-mod 43 | 44 | 45 | 2017-02-20T18:00:00 46 | The https://spec.edmcouncil.org/fibo/ontology/master/latest/FND/Law/AboutLaw.rdf version of this ontology was modified per issue resolutions identified in the FIBO FND 1.2 RTF report. 47 | 48 | http://www.w3.org/standards/techs/owl#w3c_all 49 | http://www.omg.org/spec/ODM/ 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | 64 | 65 | 66 | FIBO FND Law Module 67 | individual representing metadata about the FIBO FND law module 68 | Law 69 | FIBO-FND-LAW 70 | 1.0 71 | This module includes several ontologies defining legal concepts, including constitutions, laws and jurisdictions. It also includes the definition of legal capacities such as signatory capacity, contractual capability and the like. 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo/ontology/master/latest/FND/Accounting/AboutAccounting.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Accounting Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014-2017 EDM Council, Inc. 35 | Copyright (c) 2014-2017 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutAccounting.rdf 42 | fibo-fnd-acc-mod 43 | 44 | 45 | 2017-02-20T18:00:00 46 | The https://spec.edmcouncil.org/fibo/ontology/master/latest/FND/Accounting/AboutAccounting.rdf version of this ontology was modified per issue resolutions identified in the FIBO FND 1.2 RTF report. 47 | 48 | http://www.w3.org/standards/techs/owl#w3c_all 49 | http://www.omg.org/spec/ODM/ 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | 64 | 65 | 66 | FIBO FND Accounting Module 67 | individual representing metadata about the FIBO FND accounting module 68 | Accounting 69 | FIBO-FND-ACC 70 | 1.0 71 | This module contains ontologies of general accounting concepts including debt, equity, interest and so on, as well as currency amounts. 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo-with-placeholder-iri/fnd/GoalsAndObjectives/AboutGoalsAndObjectives.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Goals and Objectives Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014 EDM Council, Inc. 35 | Copyright (c) 2014 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutGoalsAndObjectives.rdf 42 | fibo-fnd-gao-mod 43 | 44 | 45 | 2014-08-19T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | FIBO FND Goals and Objectives Module 66 | individual representing metadata about the FIBO FND goals and objectives module 67 | Goals and Objectives 68 | FIBO-FND-GAO 69 | 1.0 70 | This module includes ontologies for goals and objectives which may be pursued by people or organizations. Goals form the basis for the definition of an organization, and objectives and related concepts are required for describing business plans. 71 | 72 | http://www.edmcouncil.org/ 73 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 74 | https://spec.edmcouncil.org/fibo/FND/AboutFND/ 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo/ontology/master/latest/IND/InterestRates/AboutInterestRates.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Indices and Indicators (IND) Interest Rates Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2015 EDM Council, Inc. 35 | Copyright (c) 2015 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutInterestRates.rdf 42 | fibo-ind-ir-mod 43 | 44 | 45 | 2015-05-18T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | 64 | 65 | 66 | FIBO IND Interest Rates Module 67 | individual representing metadata about the FIBO IND interest rates module 68 | InterestRates 69 | FIBO-IND-IR 70 | 1.0 71 | This module includes ontologies defining concepts to do with interest rates, that is rates of interest paid on capital by banks and other lenders, including inter-bank lending rates and rates of certain representative debt instruments. 72 | 73 | http://www.edmcouncil.org/ 74 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 75 | https://spec.edmcouncil.org/fibo/ontology/master/latest/IND/AboutIND/ 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo/ontology/master/latest/FND/Quantities/AboutQuantities.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Quantities Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014-2017 EDM Council, Inc. 35 | Copyright (c) 2014-2017 Object Management Group, Inc. 36 | http://www.omg.org/techprocess/ab/SpecificationMetadata/MITLicense 37 | 38 | 39 | 40 | 41 | AboutQuantities.rdf 42 | fibo-fnd-qt-mod 43 | 44 | 45 | 2017-02-20T18:00:00 46 | The https://spec.edmcouncil.org/fibo/ontology/master/latest/FND/Quantities/AboutQuantities.rdf version of this ontology was modified per issue resolutions identified in the FIBO FND 1.2 RTF report. 47 | 48 | http://www.w3.org/standards/techs/owl#w3c_all 49 | http://www.omg.org/spec/ODM/ 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | 64 | 65 | 66 | FIBO FND Quantities Module 67 | individual representing metadata about the FIBO FND quantities module 68 | Quantities 69 | FIBO-FND-QT 70 | 1.0 71 | This module contains ontologies that define concepts related to quantities, units, dimensions, and quantity values. 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo-with-placeholder-iri/fnd/OwnershipAndControl/AboutOwnershipAndControl.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Ownership and Control Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014 EDM Council, Inc. 35 | Copyright (c) 2014 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutOwnershipAndControl.rdf 42 | fibo-fnd-oac-mod 43 | 44 | 45 | 2014-08-19T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | FIBO FND Ownership and Control Module 66 | individual representing metadata about the FIBO FND ownership and control module 67 | Ownership and Control 68 | FIBO-FND-OAC 69 | 1.0 70 | This module includes ontologies defining the meanings of ownership, asset and owner, and of types of control such as de jure and de facto control. These form the basis of ownership and control relationship hierarchies as well as what it means to own or to control something. 71 | 72 | http://www.edmcouncil.org/ 73 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 74 | https://spec.edmcouncil.org/fibo/FND/AboutFND/ 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo/ontology/master/latest/IND/Indicators/AboutIndicators.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Indices and Indicators (IND) Indicators Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2015 EDM Council, Inc. 35 | Copyright (c) 2015 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutIndicators.rdf 42 | fibo-ind-ind-mod 43 | 44 | 45 | 2015-05-18T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | 64 | 65 | 66 | FIBO IND Indicators Module 67 | individual representing metadata about the FIBO IND indicators module 68 | Indicators 69 | FIBO-IND-IND 70 | 1.0 71 | This module includes ontologies for concepts common to all types of market index and market indicator or economic measure. These are all types of numeric parameter which vary over time, and are published by some source. These are divided into concepts descriptive of the numeric parameter, and concepts descriptive of the values which those parameters take over time. 72 | 73 | http://www.edmcouncil.org/ 74 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 75 | https://spec.edmcouncil.org/fibo/ontology/master/latest/IND/AboutIND/ 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo-with-placeholder-iri/fnd/DatesAndTimes/AboutDatesAndTimes.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Dates and Times Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014 EDM Council, Inc. 35 | Copyright (c) 2014 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutDatesAndTimes.rdf 42 | fibo-fnd-dt-mod 43 | 44 | 45 | 2014-11-10T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | FIBO FND Dates and Times Module 66 | individual representing metadata about the FIBO FND dates and times module 67 | DatesAndTimes 68 | FIBO-FND-DT 69 | 1.0 70 | This module includes ontologies describing date and time concepts which are of specific reference in financial services. These cover foundational date and time concepts in a form usable for financial subject matter ontologies, including occurrences and conventions for business days and the like. The business day convention concepts are to be further extended in specialized ontologies for securities and derivatives, building on the ontologies in this module. 71 | 72 | http://www.edmcouncil.org/ 73 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 74 | https://spec.edmcouncil.org/fibo/FND/AboutFND/ 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo/ontology/master/latest/FND/Arrangements/AboutArrangements.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Arrangements Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014-2017 EDM Council, Inc. 35 | Copyright (c) 2014-2017 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutArrangements.rdf 42 | fibo-fnd-arr-mod 43 | 44 | 45 | 2017-02-20T18:00:00 46 | The https://spec.edmcouncil.org/fibo/ontology/master/latest/FND/Arrangements/AboutArrangements.rdf version of this ontology was modified per issue resolutions identified in the FIBO FND 1.2 RTF report. 47 | 48 | http://www.w3.org/standards/techs/owl#w3c_all 49 | http://www.omg.org/spec/ODM/ 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | 64 | 65 | 66 | FIBO FND Arrangements Module 67 | individual representing metadata about the FIBO FND arrangements module 68 | Arrangements 69 | FIBO-FND-ARR 70 | 1.0 71 | This module contains ontologies that define abstract concepts, structures and schemata, such as identifiers and identification schemes, indices and indexing schemes, codes and coding schemes, and classification strategies. 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo-with-placeholder-iri/fnd/Parties/AboutParties.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Parties Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014 EDM Council, Inc. 35 | Copyright (c) 2014 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutParties.rdf 42 | fibo-fnd-pty-mod 43 | 44 | 45 | 2014-08-19T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | FIBO FND Parties Module 66 | individual representing metadata about the FIBO FND parties module 67 | Parties 68 | FIBO-FND-PTY 69 | 1.0 70 | This module includes ontologies defining concepts that are highly contextual in nature, such as the meaning of a party in a role, an agent playing a role, and so on. Also covers independent roles themselves. 71 | 72 | The definitions for agents and parties in roles provide general, reusable patterns for talking about agents performing roles in specific contexts. For example the same person in the context of aviation could be a pilot, and in the context of family could be a mother. These pattern will be refined in other FIBO ontologies to define concepts such as issuer, counterparty, underwriter, etc. 73 | 74 | http://www.edmcouncil.org/ 75 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 76 | https://spec.edmcouncil.org/fibo/FND/AboutFND/ 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo/ontology/master/latest/FND/Utilities/AboutUtilities.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Utilities Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014-2017 EDM Council, Inc. 35 | Copyright (c) 2014-2017 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutUtilities.rdf 42 | fibo-fnd-utl-mod 43 | 44 | 45 | 2017-02-20T18:00:00 46 | The https://spec.edmcouncil.org/fibo/ontology/master/latest/FND/Utilities/AboutUtilities.rdf version of this ontology was modified per issue resolutions identified in the FIBO FND 1.2 RTF report. 47 | 48 | http://www.w3.org/standards/techs/owl#w3c_all 49 | http://www.omg.org/spec/ODM/ 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | 64 | 65 | 66 | FIBO FND Utilities Module 67 | individual representing metadata about the FIBO FND utilities module 68 | Utilities 69 | FIBO-FND-UTL 70 | 1.0 71 | Ontologies which provide annotations and business facing datatypes to be used in other ontologies. These ontologies are not expected to be used directly by business stakeholders and are for the definition of material which is used by semantic modelers in Foundations and in other FIBO ontologies. 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo-with-placeholder-iri/fnd/Agreements/AboutAgreements.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Agreements Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014 EDM Council, Inc. 35 | Copyright (c) 2014 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutAgreements.rdf 42 | fibo-fnd-agr-mod 43 | 44 | 45 | 2014-08-19T18:00:00 46 | 47 | http://www.w3.org/standards/techs/owl#w3c_all 48 | http://www.omg.org/spec/ODM/ 49 | 50 | 51 | 52 | 53 | 54 | 55 | 62 | 63 | 64 | 65 | FIBO FND Agreements Module 66 | individual representing metadata about the FIBO FND agreements module 67 | Agreements 68 | FIBO-FND-AGR 69 | 1.0 70 | This module includes ontologies describing agreements between parties and contracts that formalize those agreements. These cover written and verbal contracts, including contracts which may be transferred from one party to another. The latter form the basis for financial securities contracts. The Contracts ontology also describes fundamental properties of contracts such as contractual terms, contract parties and so on, many of which form the basis for more specialized financial industry concepts such as interest payment terms, bond issuers and so on. 71 | 72 | http://www.edmcouncil.org/ 73 | https://spec.edmcouncil.org/fibo/AboutTheEDMC-FIBOFamily/ 74 | https://spec.edmcouncil.org/fibo/FND/AboutFND/ 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/test/resources/ontologies/fibo/ontology/master/latest/FND/Relations/AboutRelations.rdf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ]> 14 | 15 | 26 | 27 | 28 | 29 | About the EDMC-FIBO Foundations (FND) Relations Module 30 | 31 | 32 | 33 | 34 | Copyright (c) 2014-2017 EDM Council, Inc. 35 | Copyright (c) 2014-2017 Object Management Group, Inc. 36 | 37 | 38 | 39 | 40 | 41 | AboutRelations.rdf 42 | fibo-fnd-rel-mod 43 | 44 | 45 | 2017-02-20T18:00:00 46 | The https://spec.edmcouncil.org/fibo/ontology/master/latest/FND/Relations/AboutRelations.rdf version of this ontology was modified per issue resolutions identified in the FIBO FND 1.2 RTF report. 47 | 48 | http://www.w3.org/standards/techs/owl#w3c_all 49 | http://www.omg.org/spec/ODM/ 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | 64 | 65 | 66 | FIBO FND Relations Module 67 | individual representing metadata about the FIBO FND relations module 68 | Relations 69 | FIBO-FND-REL 70 | 1.0 71 | This module contains an ontology defining a number of reusable relationships. These are used, refined or restricted to define relationships among more specific concepts in other FIBO ontologies. Some of these relationships stand in for relationships which are defined in external standards ontologies. 72 | 73 | 74 | 75 | 76 | 77 | 78 | --------------------------------------------------------------------------------