Skip to content
Snippets Groups Projects
Commit cb1e164c authored by Andreas Schärtl's avatar Andreas Schärtl
Browse files

remove src/uloimport

- It was the seperate Importer compontent written in Java.

- It is not necessary anymore as we do it directly from REST
  in luoweb.
parent 78d3bff1
Branches week20/dockercompose week20/uloimport
No related tags found
No related merge requests found
target
.idea
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>info.kwarc.uloimport</groupId>
<artifactId>uloimport</artifactId>
<version>indev</version>
<properties>
<!-- https://stackoverflow.com/questions/59601077/intellij-errorjava-error-release-version-5-not-supported -->
<maven.compiler.source>1.11</maven.compiler.source>
<maven.compiler.target>1.11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
</dependency>
<dependency>
<groupId>com.ontotext.graphdb</groupId>
<artifactId>graphdb-free-runtime</artifactId>
<version>9.2.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package info.kwarc.uloimport;
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
package info.kwarc.uloimport.importer;
import org.eclipse.rdf4j.repository.Repository;
import org.eclipse.rdf4j.repository.RepositoryConnection;
import org.eclipse.rdf4j.repository.manager.RemoteRepositoryManager;
import org.eclipse.rdf4j.repository.manager.RepositoryManager;
import java.io.InputStream;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* {@link Importer} that uploads imported data to a GraphDB instance.
*/
public class GraphDbImporter implements Importer {
private final String serverUrl;
private final String repository;
/**
* Construct a new GraphDbImporter that imports its data to a remote
* GraphDB instance.
*
* @param serverUrl The URL under which GraphDB is running.
* @param repository The name of the repository to dump to.
*/
public GraphDbImporter(String serverUrl, String repository) {
this.serverUrl = checkNotNull(serverUrl);
this.repository = checkNotNull(repository);
}
@Override
public void importRdfFile(InputStream is) throws ImportException {
final RepositoryManager manager;
final Repository repository;
final RepositoryConnection connection;
try {
manager = new RemoteRepositoryManager(this.serverUrl);
manager.init();
repository = manager.getRepository(this.repository);
if (repository == null) {
throw new ImportException("could not connect to repository=%s", this.repository);
}
connection = repository.getConnection();
} catch (Exception e) {
throw new ImportException("could not initialize database connection", e);
}
// TODO: Handle errors during initialization. This is quite annoying
// to do with this API.
}
}
package info.kwarc.uloimport.importer;
/**
* An Exception caused by an import of ULO/RDF data.
*/
public class ImportException extends RuntimeException {
/**
* Construct a new {@link ImportException} with just a message.
*
* @param message The message associated with this exception.
*/
public ImportException(String message) {
super(message);
}
/**
* Construct a new {@link ImportException} with a formatted message.
*
* @param format Format string of the message.
* @param args Arguments for the format string.
*/
public ImportException(String format, Object... args) {
super(String.format(format, args));
}
/**
* Construct a new {@link ImportException} with a message and a cause
* that caused this exception.
*
* @param message The message associated with this exception.
* @param cause The underlying cause of the import error.
*/
public ImportException(String message, Throwable cause) {
super(message, cause);
}
}
package info.kwarc.uloimport.importer;
import java.io.InputStream;
public interface Importer {
/**
* Import the (single) ULO/RDF file at the given input stream to the
* storage underlying this {@link Importer}.
*
* @param is The stream from which to read a single ULO/RDF file.
* @throws ImportException When the import failed.
*/
void importRdfFile(InputStream is) throws ImportException;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment