Skip to content

Commit c6d9f86

Browse files
authored
Merge pull request #16 from simonoakesepimorphics/initial-setup
Initial setup
2 parents b64bd79 + 6da6010 commit c6d9f86

File tree

19 files changed

+600
-19
lines changed

19 files changed

+600
-19
lines changed

.github/workflows/HelloWorldWorkflow.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/build.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This workflow will build a Java project with Maven
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
name: Java CI with Maven
4+
on: [push, pull_request]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Set up JDK 1.8
11+
uses: actions/setup-java@v1
12+
with:
13+
java-version: 1.8
14+
- name: Cache Maven packages
15+
uses: actions/cache@v2
16+
with:
17+
path: ~/.m2
18+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
19+
restore-keys: ${{ runner.os }}-m2
20+
- name: Install NetCDF tools
21+
run: sudo apt install netcdf-bin
22+
- name: Maven build and test
23+
run: mvn clean test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
target/
2+
13
# Compiled class file
24
*.class
35

README.md

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,66 @@
1-
# net.binary_array_ld.bald
2-
Java library for parsing, validating and managing binary array linked data files, e.g. HDF, netCDF.
1+
# Binary Array Linked Data
2+
3+
[Kotlin](https://kotlinlang.org/) library and CLI for Binary Array Linked Data (BALD) functionality.
4+
* NetCDF to RDF conversion according to [OGC draft specification](http://docs.opengeospatial.org/DRAFTS/19-002.html).
5+
6+
This project consists of the following modules:
7+
* **binary-array-ld-lib** Core library containing BALD functionality. In particular, binary array to linked data (RDF) conversion.
8+
RDF representations are provided by [Apache Jena](https://jena.apache.org/).
9+
* **binary-array-ld-netcdf** NetCDF implementation of binary array concepts.
10+
* **binary-array-ld-cli** Command line interface for converting NetCDF metadata to RDF.
11+
* **binary-array-ld-test** Common test utilities used by other modules.
12+
* **binary-array-ld-demo** Demonstrations of BALD API usage.
13+
14+
## Usage
15+
16+
This project can be used either as a library or as a command line application.
17+
18+
### Library
19+
20+
To use the BALD core library, add the following dependency to your Maven project:
21+
22+
```xml
23+
<dependency>
24+
<groupId>net.binary-array-ld</groupId>
25+
<artifactId>binary-array-ld-lib</artifactId>
26+
<version>${bald.version}</version>
27+
</dependency>
28+
```
29+
30+
You can implement the `net.bald.BinaryArray` interface with your own metadata representations and supply them to the API.
31+
32+
For NetCDF metadata files, you can use the pre-made NetCDF implementation in the `binary-array-ld-netcdf` module.
33+
To use this module, add the following dependency to your Maven project:
34+
35+
```xml
36+
<dependency>
37+
<groupId>net.binary-array-ld</groupId>
38+
<artifactId>binary-array-ld-netcdf</artifactId>
39+
<version>${bald.version}</version>
40+
</dependency>
41+
```
42+
43+
#### Example
44+
Kotlin:
45+
```kotlin
46+
val ba = NetCdfBinaryArray.create("/path/to/input.nc", "http://test.binary-array-ld.net/example")
47+
val model = ModelBinaryArrayConverter.convert(ba)
48+
File("/path/to/output.ttl").outputStream.use { output ->
49+
model.write(output, "ttl")
50+
}
51+
```
52+
Java:
53+
```
54+
BinaryArray ba = NetCdfBinaryArray.create("/path/to/input.ttl", "http://test.binary-array-ld.net/example");
55+
Model model = ModelBinaryArrayConverter.convert(ba);
56+
57+
try (OutputStream output = new FileOutputStream("/path/to/output.ttl")) {
58+
model.write(output, "ttl");
59+
}
60+
```
61+
62+
### Command Line Interface
63+
( TODO )
64+
65+
66+

binary-array-ld-cli/pom.xml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<artifactId>binary-array-ld</artifactId>
8+
<groupId>net.binary-array-ld</groupId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>binary-array-ld-cli</artifactId>
13+
<version>1.0.0-SNAPSHOT</version>
14+
<packaging>jar</packaging>
15+
16+
<name>Binary Array Linked Data - CLI</name>
17+
<description>Command line interface for Binary Array LD functionality.</description>
18+
19+
<dependencies>
20+
<!-- LIB -->
21+
<dependency>
22+
<groupId>commons-cli</groupId>
23+
<artifactId>commons-cli</artifactId>
24+
<version>1.4</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.apache.jena</groupId>
28+
<artifactId>jena-arq</artifactId>
29+
<version>${jena.version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>net.binary-array-ld</groupId>
33+
<artifactId>binary-array-ld-netcdf</artifactId>
34+
<version>${project.parent.version}</version>
35+
</dependency>
36+
<!-- TEST -->
37+
<dependency>
38+
<groupId>net.binary-array-ld</groupId>
39+
<artifactId>binary-array-ld-test</artifactId>
40+
<version>${project.parent.version}</version>
41+
<scope>test</scope>
42+
</dependency>
43+
</dependencies>
44+
<build>
45+
<plugins>
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-assembly-plugin</artifactId>
49+
<version>2.6</version>
50+
<executions>
51+
<execution>
52+
<id>make-assembly</id>
53+
<phase>package</phase>
54+
<goals>
55+
<goal>single</goal>
56+
</goals>
57+
<configuration>
58+
<archive>
59+
<manifest>
60+
<mainClass>net.bald.BinaryArrayConvertCliKt</mainClass>
61+
</manifest>
62+
</archive>
63+
<descriptorRefs>
64+
<descriptorRef>jar-with-dependencies</descriptorRef>
65+
</descriptorRefs>
66+
</configuration>
67+
</execution>
68+
</executions>
69+
</plugin>
70+
</plugins>
71+
</build>
72+
</project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package net.bald
2+
3+
/**
4+
* Command Line Interface for converting NetCDF metadata to Linked Data graphs.
5+
*/
6+
class BinaryArrayConvertCli {
7+
fun run(vararg args: String) {
8+
TODO()
9+
}
10+
}
11+
12+
fun main(args: Array<String>) {
13+
BinaryArrayConvertCli().run(*args)
14+
}

binary-array-ld-demo/pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>binary-array-ld</artifactId>
7+
<groupId>net.binary-array-ld</groupId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>binary-array-ld-demo</artifactId>
13+
<version>1.0.0-SNAPSHOT</version>
14+
15+
<name>Binary Array Linked Data - Demos</name>
16+
<description>Examples of Binary Array to Linked Data API usage.</description>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>net.binary-array-ld</groupId>
21+
<artifactId>binary-array-ld-netcdf</artifactId>
22+
<version>${project.parent.version}</version>
23+
</dependency>
24+
</dependencies>
25+
</project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package net.bald;
2+
3+
import net.bald.model.ModelBinaryArrayConverter;
4+
import net.bald.netcdf.NetCdfBinaryArray;
5+
import org.apache.jena.rdf.model.Model;
6+
7+
import java.io.FileOutputStream;
8+
import java.io.OutputStream;
9+
10+
/**
11+
* Demonstration of how to call the API in Java code.
12+
*/
13+
public class NetCdfConvertJava {
14+
public static void convert(String inputLoc, String outputLoc, String format) throws Exception {
15+
BinaryArray ba = NetCdfBinaryArray.create(inputLoc, "http://test.binary-array-ld.net/example");
16+
Model model = ModelBinaryArrayConverter.convert(ba);
17+
18+
try (OutputStream output = new FileOutputStream(outputLoc)) {
19+
model.write(output, format);
20+
}
21+
}
22+
23+
public static void convert() throws Exception {
24+
convert("/path/to/input.nc", "/path/to/output.ttl", "ttl");
25+
}
26+
}

binary-array-ld-lib/pom.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>net.binary-array-ld</groupId>
8+
<artifactId>binary-array-ld</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>binary-array-ld-lib</artifactId>
13+
<version>1.0.0-SNAPSHOT</version>
14+
<packaging>jar</packaging>
15+
16+
<name>Binary Array Linked Data - Library</name>
17+
<description>Core library for Binary Array LD functionality.</description>
18+
19+
<dependencies>
20+
<!-- LIB -->
21+
<dependency>
22+
<groupId>org.apache.jena</groupId>
23+
<artifactId>jena-core</artifactId>
24+
<version>${jena.version}</version>
25+
</dependency>
26+
<!-- TEST -->
27+
<dependency>
28+
<groupId>net.binary-array-ld</groupId>
29+
<artifactId>binary-array-ld-test</artifactId>
30+
<version>${project.parent.version}</version>
31+
<scope>test</scope>
32+
</dependency>
33+
<dependency>
34+
<groupId>com.nhaarman.mockitokotlin2</groupId>
35+
<artifactId>mockito-kotlin</artifactId>
36+
<version>${mockito.kt.version}</version>
37+
</dependency>
38+
</dependencies>
39+
</project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package net.bald
2+
3+
/**
4+
* Represents the metadata of a binary array dataset.
5+
* See https://www.opengis.net/def/binary-array-ld/Array
6+
*/
7+
interface BinaryArray {
8+
/**
9+
* The URI which identifies the dataset.
10+
*/
11+
val uri: String
12+
13+
/**
14+
* The root container.
15+
*/
16+
val root: Container
17+
}

0 commit comments

Comments
 (0)