Skip to content

Commit

Permalink
#148 add a profile for including geosparql functions
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-asprino committed Dec 19, 2024
1 parent 9ae9b25 commit c192f65
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 8 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ and constructing knowledge graphs.
**NOTE**: SPARQL Anything is built on Apache Jena, see a list of supported functions on
the [Apache Jena documentation](https://jena.apache.org/documentation/query/library-function.html).

Moreover, if you run the geosparql distribution of the CLI or the server, you can also use the [GeoSPARQL functions provided by Apache Jena](https://jena.apache.org/documentation/geosparql/index.html).

| Name | Function/Magic Property | Input | Output | Description |
|-----------------------------------------------------------------------------------------------------------------------|-------------------------|----------------------------------------|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [fx:anySlot](FUNCTIONS_AND_MAGIC_PROPERTIES.md#fxanyslot) | Magic Property | - | - | This property matches the RDF container membership properties (e.g. ``rdf:_1``, ``rdf:_2`` ...). |
Expand Down Expand Up @@ -690,6 +692,12 @@ You can generate executable files of the command line interface and server with
mvn clean install -Dgenerate-cli-jar=true -Dgenerate-server-jar=true
```

You can generate the executable files of the SPARQL Anything geosparql distribution featuring the [Apache Jena's GeoSPARQL functions](https://jena.apache.org/documentation/geosparql/index.html).

```
mvn clean install -Dgenerate-cli-jar-geosparql=true -Dgenerate-server-jar-geosparql=true
```

## Licence

SPARQL Anything is distributed under [Apache 2.0 License](LICENSE)
Expand Down
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@
<version>${jena.version}</version>
</dependency>

<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-geosparql</artifactId>
<version>${jena.version}</version>
</dependency>

<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
Expand Down Expand Up @@ -475,7 +481,8 @@
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
<!--version>2.3.2</version-->
<version>4.0.1</version>
</dependency>

<!-- BEGIN: Tika -->
Expand Down
86 changes: 81 additions & 5 deletions sparql-anything-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
<parent>
<groupId>io.github.sparql-anything</groupId>
<artifactId>sparql-anything-parent</artifactId>
<version>${revision}</version>
</parent>
<properties>
<revision>1.0.0-SNAPSHOT</revision>
</properties>
<version>${revision}</version>
</parent>
<properties>
<revision>1.0.0-SNAPSHOT</revision>
</properties>

<artifactId>sparql-anything-cli</artifactId>

Expand Down Expand Up @@ -147,9 +147,11 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

</dependencies>

<profiles>

<profile>
<id>generate-cli-jar</id>
<activation>
Expand Down Expand Up @@ -210,6 +212,80 @@
</plugins>
</build>
</profile>

<profile>
<id>generate-cli-jar-geosparql</id>
<activation>
<property>
<name>generate-cli-jar-geosparql</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>sparql-anything</id>
<configuration>
<outputFile>target/sparql-anything-${project.version}-geosparql.jar</outputFile>
<shadedArtifactAttached>false</shadedArtifactAttached>

<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>io.github.sparqlanything.cli.SPARQLAnything</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
<addHeader>false</addHeader>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>com.github.spice-h2020:sparql.anything.fuseki</exclude>
<exclude>junit:junit</exclude>
<exclude>org.apache.maven:lib:tests</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<!-- Additional configuration. -->
</configuration>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-geosparql</artifactId>
</dependency>

<dependency>
<!-- module jakarta.xml.bind -->
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
</dependencies>
</profile>

</profiles>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import org.slf4j.LoggerFactory;

import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
Expand All @@ -66,6 +68,22 @@ public class SPARQLAnything {
// TODO This should be moved to the engine module
private static void initSPARQLAnythingEngine() {
JenaSystem.init();

// Setting up the Geosparql module if the dependency is included
try {
Class<?> k = Class.forName("org.apache.jena.geosparql.configuration.GeoSPARQLConfig");
Method m = k.getMethod("setupMemoryIndex");
m.invoke(null);
} catch (ClassNotFoundException e) {
logger.warn("jena-geosparql dependency not available");
} catch (NoSuchMethodException e) {
logger.warn("NoSuchMethodException");
} catch (InvocationTargetException e) {
logger.warn("InvocationTargetException");
} catch (IllegalAccessException e) {
logger.warn("IllegalAccessException");
}

// Register the JSON-LD parser factory for extension .json
ReaderRIOTFactory parserFactoryJsonLD = new RiotUtils.ReaderRIOTFactoryJSONLD();
RDFParserRegistry.registerLangTriples(RiotUtils.JSON, parserFactoryJsonLD);
Expand Down
67 changes: 67 additions & 0 deletions sparql-anything-fuseki/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,73 @@
</plugins>
</build>
</profile>
<profile>
<id>generate-cli-jar-geosparql</id>
<activation>
<property>
<name>generate-server-jar-geosparql</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>sparql-anything</id>
<configuration>
<outputFile>target/sparql-anything-server-${project.version}-geosparql.jar</outputFile>
<shadedArtifactAttached>false</shadedArtifactAttached>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>io.github.sparqlanything.fuseki.Endpoint</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
<addHeader>false</addHeader>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-geosparql</artifactId>
</dependency>

<dependency>
<!-- module jakarta.xml.bind -->
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
import io.github.sparqlanything.model.*;
import io.github.sparqlanything.model.annotations.Example;
import io.github.sparqlanything.model.annotations.Option;
import org.apache.jena.datatypes.xsd.XSDDatatype;
import jakarta.xml.bind.DatatypeConverter;
import org.apache.jena.graph.NodeFactory;
import org.apache.poi.ss.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.net.URL;
import java.util.*;
Expand Down

0 comments on commit c192f65

Please sign in to comment.