├── 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