Skip to content

Commit

Permalink
add time vocabulary
Browse files Browse the repository at this point in the history
  • Loading branch information
autermann committed May 28, 2020
1 parent 125595c commit 659af9a
Show file tree
Hide file tree
Showing 13 changed files with 290 additions and 194 deletions.
106 changes: 18 additions & 88 deletions shetland/rdf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,18 @@
limitations under the License.
-->
<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/xsd/maven-4.0.0.xsd">
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.n52.arctic-sea</groupId>
<artifactId>shetland-parent</artifactId>
<version>7.5.0-SNAPSHOT</version>
</parent>

<artifactId>shetland-rdf</artifactId>
<name>52°North Shetland RDF</name>
<description>52°North RDF Framework</description>
<dependencies>
<!-- Testing dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
Expand All @@ -69,64 +37,26 @@
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-core</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.jena</groupId>
<artifactId>jena-shaded-guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.jena</groupId>
<artifactId>jena-shaded-guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>
<profiles>
<profile>
<id>since-jdk9</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${version.maven-javadoc-plugin}</version>
<dependencies>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>javax.xml.soap-api</artifactId>
<version>${version.javax-xml-soap}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>javax.xml.soap-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<classifier>tests</classifier>
<excludes>
<exclude>**/*Test.*</exclude>
<exclude>**/*$.*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public AbstractDatatype(String dataType, String value) {
@Override
public Resource addToResource(Model model, Resource parent) {
addNsPrefix(model);
parent.addProperty(getProperty(), getValue(), getDataType());
return parent;
return parent.addProperty(getProperty(), getValue(), getDataType());
}

public RDFDatatype getDataType() {
Expand Down
32 changes: 22 additions & 10 deletions shetland/rdf/src/main/java/org/n52/shetland/rdf/AbstractLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,38 @@
*/
package org.n52.shetland.rdf;

import com.google.common.base.Strings;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;

public abstract class AbstractLang extends AbstractValue {

private final String lang;
private final String language;

public AbstractLang(String value, String lang) {
public AbstractLang(String value) {
this(value, null);
}

public AbstractLang(String value, String language) {
super(value);
this.lang = lang;
this.language = language;
}

public String getLanguage() {
return language;
}

@Override
public boolean hasLanguage() {
return getLanguage() != null && !getLanguage().isEmpty();
}

public abstract Property getProperty();

public Resource addToResource(Model model, Resource parent) {
addNsPrefix(model);
if (lang != null) {
parent.addProperty(getProperty(), getValue(), lang);
} else {
parent.addProperty(getProperty(), getValue());
}
return parent;
return parent.addProperty(getProperty(),
getValue(),
Strings.nullToEmpty(getLanguage()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public AbstractResource(String value) {
@Override
public Resource addToResource(Model model, Resource parent) {
addNsPrefix(model);
parent.addProperty(getProperty(), model.createResource(getValue()));
return parent;
return parent.addProperty(getProperty(), model.createResource(getValue()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;

public abstract class AbstractValue implements ResourceAdder {
public abstract class AbstractValue implements RdfPrefix, ResourceAdder {

private final String value;

Expand All @@ -36,8 +36,7 @@ public String getValue() {

public Resource addToResource(Model model, Resource parent) {
addNsPrefix(model);
parent.addProperty(getProperty(), getValue());
return parent;
return parent.addProperty(getProperty(), getValue());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@

public interface RDFDataTypes {
RDFDatatype WKT_LITERAL = new BaseDatatype("http://www.opengis.net/ont/geosparql#wktLiteral");
RDFDatatype GML_LITERAL = new BaseDatatype("http://www.opengis.net/ont/geosparql#gmlLiteral");
RDFDatatype GEO_JSON = new BaseDatatype("https://www.iana.org/assignments/media-types/application/geo+json");
}
28 changes: 28 additions & 0 deletions shetland/rdf/src/main/java/org/n52/shetland/rdf/RDFMediaTypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2015-2020 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.n52.shetland.rdf;

public interface RDFMediaTypes {
String APPLICATION_RDF_XML = "application/rdf+xml";
String APPLICATION_N_TRIPLES = "application/n-triples";
String APPLICATION_LD_JSON = "application/ld+json";
String APPLICATION_RDF_JSON = "application/rdf+json";
String APPLICATION_N_QUADS = "application/n-quads";
String APPLICATION_TRIG = "application/trig";
String TEXT_TURTLE = "text/turtle";
String TEXT_N3 = "text/n3";
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@

import org.apache.jena.rdf.model.Property;
import org.apache.jena.vocabulary.DCAT;
import org.n52.shetland.rdf.AbstractValue;
import org.n52.shetland.rdf.AbstractLang;

public class Keyword extends AbstractValue implements DcatRdfPrefix {
public class Keyword extends AbstractLang implements DcatRdfPrefix {

public Keyword(String value) {
super(value);
}

public Keyword(String value, String language) {
super(value, language);
}

@Override
public Property getProperty() {
return DCAT.keyword;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.jena.datatypes.RDFDatatype;
import org.apache.jena.rdf.model.Property;
import org.n52.shetland.rdf.AbstractDatatype;
import org.n52.shetland.rdf.vocabulary.LOCN;

public class Geometry extends AbstractDatatype implements LocnRdfPrefix {

Expand All @@ -37,7 +38,7 @@ public Geometry(String dataType, String value) {

@Override
public Property getProperty() {
return LOCN.GEOMETRY_PROPERTY;
return LOCN.geometry;
}

}
86 changes: 0 additions & 86 deletions shetland/rdf/src/main/java/org/n52/shetland/rdf/locn/LOCN.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.n52.shetland.rdf.locn;

import org.n52.shetland.rdf.RdfPrefix;
import org.n52.shetland.rdf.vocabulary.LOCN;

public interface LocnRdfPrefix extends RdfPrefix {

Expand Down
Loading

0 comments on commit 659af9a

Please sign in to comment.