Skip to content

Commit f67163f

Browse files
Merge branch 'master' of github.com:binary-array-ld/net.binary_array_ld.bald
2 parents 10c7c22 + a2798bf commit f67163f

File tree

11 files changed

+45
-18
lines changed

11 files changed

+45
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Binary Array Linked Data
22

33
[Kotlin](https://kotlinlang.org/) library and CLI for Binary Array Linked Data (BALD) functionality.
4-
* [GitHub Pages](https://binary-array-ld.github.io/net.binary_array_ld.bald/)
4+
* [GitHub Pages](http://kotlin.binary-array-ld.net)
55

66
This project consists of the following modules:
77
* **binary-array-ld-lib** Core library containing BALD functionality. In particular, binary array to linked data (RDF) conversion.
@@ -13,7 +13,7 @@ RDF representations are provided by [Apache Jena](https://jena.apache.org/).
1313

1414
## Usage
1515

16-
See the [GitHub pages](https://binary-array-ld.github.io/net.binary_array_ld.bald/usage.html) for usage documentation.
16+
See the [GitHub pages](http://kotlin.binary-array-ld.net/usage.html) for usage documentation.
1717

1818
## Development
1919

binary-array-ld-cli/src/test/kotlin/net/bald/BinaryArrayConvertCliTest.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class BinaryArrayConvertCliTest {
5454

5555
val model = createDefaultModel().read(outputFile.toURI().toString(), "ttl")
5656
ModelVerifier(model).apply {
57+
prefix("this", "$inputFileUri/")
5758
// A-1
5859
resource("$inputFileUri/") {
5960
format()
@@ -81,6 +82,7 @@ class BinaryArrayConvertCliTest {
8182

8283
val model = createDefaultModel().read(outputFile.toURI().toString(), "ttl")
8384
ModelVerifier(model).apply {
85+
prefix("this", "http://test.binary-array-ld.net/example/")
8486
// A-1
8587
resource("http://test.binary-array-ld.net/example/") {
8688
format()
@@ -163,6 +165,7 @@ class BinaryArrayConvertCliTest {
163165
ModelVerifier(model).apply {
164166
prefix("bald", BALD.prefix)
165167
prefix("skos", SKOS.uri)
168+
prefix("this", "http://test.binary-array-ld.net/example/")
166169
resource("http://test.binary-array-ld.net/example/") {
167170
format()
168171
statement(RDF.type, BALD.Container)
@@ -173,7 +176,6 @@ class BinaryArrayConvertCliTest {
173176
statement(BALD.contains, model.createResource("http://test.binary-array-ld.net/example/var1")) {
174177
statement(RDF.type, BALD.Resource)
175178
}
176-
statement(BALD.isPrefixedBy, createPlainLiteral("prefix_list"))
177179
}
178180
}
179181
}
@@ -273,7 +275,6 @@ class BinaryArrayConvertCliTest {
273275
statement(BALD.contains, model.createResource("http://test.binary-array-ld.net/example/var1")) {
274276
statement(RDF.type, BALD.Resource)
275277
}
276-
statement(BALD.isPrefixedBy, createPlainLiteral("prefix_list"))
277278
}
278279
}
279280
}
@@ -316,7 +317,6 @@ class BinaryArrayConvertCliTest {
316317
statement(BALD.contains, model.createResource("http://test.binary-array-ld.net/example/var1")) {
317318
statement(RDF.type, BALD.Resource)
318319
}
319-
statement(BALD.isPrefixedBy, createPlainLiteral("prefix_list"))
320320
}
321321
}
322322
}
@@ -361,7 +361,6 @@ class BinaryArrayConvertCliTest {
361361
statement(BALD.contains, model.createResource("http://test.binary-array-ld.net/example/var1")) {
362362
statement(RDF.type, BALD.Resource)
363363
}
364-
statement(BALD.isPrefixedBy, createPlainLiteral("prefix_list"))
365364
}
366365
}
367366
}
@@ -432,7 +431,6 @@ class BinaryArrayConvertCliTest {
432431
statement(BALD.contains, createResource("http://test.binary-array-ld.net/example/var0")) {
433432
statement(RDF.type, BALD.Resource)
434433
}
435-
statement(BALD.isPrefixedBy, createPlainLiteral("prefix_list"))
436434
}
437435
}
438436
}
@@ -576,7 +574,6 @@ class BinaryArrayConvertCliTest {
576574
list(15)
577575
}
578576
}
579-
statement(BALD.isPrefixedBy, createPlainLiteral("prefix_list"))
580577
}
581578
}
582579
}

binary-array-ld-lib/src/main/kotlin/net/bald/model/ModelBinaryArrayBuilder.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ class ModelBinaryArrayBuilder(
1919
) {
2020
fun addBinaryArray(ba: BinaryArray) {
2121
val root = ba.root
22-
val res = model.createResource(root.uri)
22+
val rootUri = root.uri
23+
val res = model.createResource(rootUri)
2324

24-
addPrefixMapping(ba.prefixMapping)
25+
addPrefixMapping(ba.prefixMapping, rootUri)
2526
addFormat(ba, res)
2627
addDistribution(ba, res)
2728
containerFct.forRoot(model).addContainer(root)
@@ -51,10 +52,14 @@ class ModelBinaryArrayBuilder(
5152
}
5253
}
5354

54-
private fun addPrefixMapping(prefixMapping: PrefixMapping) {
55+
private fun addPrefixMapping(prefixMapping: PrefixMapping, rootUri: String) {
5556
prefixMapping.nsPrefixMap.onEach { (prefix, uri) ->
5657
validatePrefixMapping(prefix, uri)
5758
}.let(model::setNsPrefixes)
59+
60+
if (model.getNsPrefixURI("this") == null) {
61+
model.setNsPrefix("this", rootUri)
62+
}
5863
}
5964

6065
private fun validatePrefixMapping(prefix: String, uri: String) {

binary-array-ld-lib/src/test/kotlin/net/bald/model/ModelBinaryArrayBuilderTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class ModelBinaryArrayBuilderTest {
5858
ModelVerifier(model).apply {
5959
prefix("bald", BALD.prefix)
6060
prefix("skos", SKOS.uri)
61+
prefix("this", "http://test.binary-array-ld.net/example/")
6162
}
6263
}
6364

binary-array-ld-netcdf/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
<link>
5151
<url>https://www.unidata.ucar.edu/software/netcdf-java/v4.5/javadoc/</url>
5252
</link>
53+
<link>
54+
<url>http://kotlin.binary-array-ld.net/javadoc/binary-array-ld-lib</url>
55+
</link>
5356
</externalDocumentationLinks>
5457
</configuration>
5558
</plugin>

binary-array-ld-netcdf/src/main/kotlin/net/bald/netcdf/NetCdfContainer.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ abstract class NetCdfContainer(
4040
}
4141

4242
override fun subContainers(): Sequence<Container> {
43-
return group.groups.asSequence().filter(::acceptGroup).map(::subContainer)
43+
return group.groups.asSequence()
44+
.filter(::acceptGroup)
45+
.map(::subContainer)
4446
}
4547

4648
private fun subContainer(group: Group): NetCdfContainer {
@@ -55,8 +57,15 @@ abstract class NetCdfContainer(
5557
return true
5658
}
5759

60+
open fun acceptAttr(attr: Attribute): Boolean {
61+
return true
62+
}
63+
5864
override fun attributes(): Sequence<Attribute> {
59-
return group.attributes().let(::source).attributes()
65+
return group.attributes()
66+
.let(::source)
67+
.attributes()
68+
.filter(::acceptAttr)
6069
}
6170

6271
fun subContainer(name: String): NetCdfContainer? {

binary-array-ld-netcdf/src/main/kotlin/net/bald/netcdf/NetCdfRootContainer.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package net.bald.netcdf
22

3+
import net.bald.Attribute
34
import ucar.nc2.Group
45
import ucar.nc2.Variable
56
import net.bald.Container
67
import net.bald.alias.AliasDefinition
8+
import net.bald.vocab.BALD
79

810
/**
911
* NetCDF implementation of [Container] based on the root group.
@@ -31,6 +33,10 @@ class NetCdfRootContainer(
3133
return prefixSrc != v.shortName
3234
}
3335

36+
override fun acceptAttr(attr: Attribute): Boolean {
37+
return BALD.isPrefixedBy.hasURI(attr.uri).not()
38+
}
39+
3440
override fun childUri(name: String): String {
3541
return uri + name
3642
}

binary-array-ld-netcdf/src/test/kotlin/net/bald/netcdf/NetCdfBinaryArrayTest.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ class NetCdfBinaryArrayTest {
222222
val ctx = ModelContext.create(prefix)
223223
val ba = fromCdl("/netcdf/attributes.cdl", "http://test.binary-array-ld.net/attributes.nc", ctx)
224224
ContainerVerifier(ba.root).attributes {
225-
attribute(BALD.isPrefixedBy.uri, createPlainLiteral("prefix_list"))
226225
attribute(SKOS.prefLabel.uri, createPlainLiteral("Attributes metadata example"))
227226
attribute(DCTerms.publisher.uri, createResource("${BALD.prefix}Organisation"))
228227
attribute("http://test.binary-array-ld.net/attributes.nc/date", createPlainLiteral("2020-10-29"))
@@ -273,7 +272,6 @@ class NetCdfBinaryArrayTest {
273272
val ba = fromCdl("/netcdf/alias.cdl", "http://test.binary-array-ld.net/alias.nc", ctx, alias)
274273
ContainerVerifier(ba.root).apply {
275274
attributes {
276-
attribute(BALD.isPrefixedBy.uri, createPlainLiteral("prefix_list"))
277275
attribute(SKOS.prefLabel.uri, createPlainLiteral("Alias metadata example"))
278276
attribute(DCTerms.publisher.uri, createResource("${BALD.prefix}Organisation"))
279277
attribute("http://test.binary-array-ld.net/alias.nc/date", createPlainLiteral("2020-10-29"))
@@ -309,7 +307,6 @@ class NetCdfBinaryArrayTest {
309307

310308
ContainerVerifier(ba.root).apply {
311309
attributes {
312-
attribute(BALD.isPrefixedBy.uri, createPlainLiteral("prefix_list"))
313310
attribute(SKOS.prefLabel.uri, createPlainLiteral("Variable reference metadata example"))
314311
attribute(TestVocab.rootVar.uri, createResource("http://test.binary-array-ld.net/var-ref.nc/var0"))
315312
attribute(TestVocab.unorderedVar.uri) {

binary-array-ld-test/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@
4444
</dependency>
4545
</dependencies>
4646

47+
<build>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.jetbrains.dokka</groupId>
51+
<artifactId>dokka-maven-plugin</artifactId>
52+
</plugin>
53+
</plugins>
54+
</build>
55+
4756
<repositories>
4857
<repository>
4958
<id>unidata-all</id>

docs/lib.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Library
22

3-
Javadocs are available [here](todo).
3+
Javadocs are available [here](http://kotlin.binary-array-ld.net/javadoc).
44
You can find Java examples [here](https://github.com/binary-array-ld/net.binary_array_ld.bald/tree/master/binary-array-ld-demo/src/main/java/net/bald).
55

66
To use the BALD core library in your Maven project, add the following dependency:

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
<plugin>
124124
<groupId>org.jetbrains.dokka</groupId>
125125
<artifactId>dokka-maven-plugin</artifactId>
126-
<version>1.4.30</version>
126+
<version>1.5.0</version>
127127
<executions>
128128
<execution>
129129
<phase>package</phase>

0 commit comments

Comments
 (0)