Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjustments to support marklogic working store #600

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
<artifactId>jetty-server</artifactId>
<version>${jetty.server.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.3</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package cz.cuni.mff.xrg.odcs.commons.app.rdf;

import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.PostConstruct;
import cz.cuni.mff.xrg.odcs.commons.app.resource.MissingResourceException;
import cz.cuni.mff.xrg.odcs.commons.app.resource.ResourceManager;
import eu.unifiedviews.commons.rdf.repository.ManagableRepository;
import eu.unifiedviews.commons.rdf.repository.RDFException;
import eu.unifiedviews.commons.rdf.repository.RepositoryFactory;
import org.openrdf.repository.Repository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import cz.cuni.mff.xrg.odcs.commons.app.resource.MissingResourceException;
import cz.cuni.mff.xrg.odcs.commons.app.resource.ResourceManager;
import eu.unifiedviews.commons.rdf.repository.ManagableRepository;
import eu.unifiedviews.commons.rdf.repository.RDFException;
import eu.unifiedviews.commons.rdf.repository.RepositoryFactory;
import javax.annotation.PostConstruct;
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
* Provide access to repositories.
Expand Down Expand Up @@ -87,6 +86,9 @@ protected void init() {
case "remoteRDF":
repositoryType = ManagableRepository.Type.REMOTE_RDF;
break;
case "marklogic":
repositoryType = ManagableRepository.Type.MARKLOGIC;
break;
default:
throw new RuntimeException("Unknown repository type.");
}
Expand Down
10 changes: 10 additions & 0 deletions dataunit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,16 @@
<artifactId>com.openlinksw.virtuoso.virtjdbc4_1</artifactId>
<version>${virtuoso.jdbc.version}</version>
</dependency>
<dependency>
<groupId>com.marklogic</groupId>
<artifactId>marklogic-sesame</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.marklogic</groupId>
<artifactId>java-client-api</artifactId>
<version>3.0.6</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ public ConnectionSourceImpl(Repository repository, boolean retryOnFailure) {
this.retryOnFailure = retryOnFailure;
}

/**
* Used repository.
*
* @param repository
*/
public ConnectionSourceImpl(Repository repository) {
this.repository = repository;
this.retryOnFailure = false;
}

@Override
public RepositoryConnection getConnection() throws RepositoryException {
return repository.getConnection();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.unifiedviews.commons.rdf.repository;

import java.io.File;
import eu.unifiedviews.commons.dataunit.core.ConnectionSource;
import eu.unifiedviews.dataunit.DataUnitException;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.config.RepositoryConfig;
Expand All @@ -10,8 +11,7 @@
import org.openrdf.repository.sail.config.SailRepositoryConfig;
import org.openrdf.sail.memory.config.MemoryStoreConfig;

import eu.unifiedviews.commons.dataunit.core.ConnectionSource;
import eu.unifiedviews.dataunit.DataUnitException;
import java.io.File;

/**
*
Expand Down Expand Up @@ -53,7 +53,7 @@ public InMemoryRDF(String repositoryPath) throws RDFException {

@Override
public ConnectionSource getConnectionSource() {
return new ConnectionSourceImpl(repository, false);
return new ConnectionSourceImpl(repository);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package eu.unifiedviews.commons.rdf.repository;

import java.io.File;

import eu.unifiedviews.commons.dataunit.core.ConnectionSource;
import eu.unifiedviews.dataunit.DataUnitException;
import org.apache.commons.io.FileUtils;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.sail.SailRepository;
import org.openrdf.sail.nativerdf.NativeStore;

import eu.unifiedviews.commons.dataunit.core.ConnectionSource;
import eu.unifiedviews.dataunit.DataUnitException;
import java.io.File;

/**
*
Expand Down Expand Up @@ -41,7 +40,7 @@ public LocalRDF(String repositoryPath) throws RDFException {

@Override
public ConnectionSource getConnectionSource() {
return new ConnectionSourceImpl(repository, false);
return new ConnectionSourceImpl(repository);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public static enum Type {
LOCAL_RDF,
INMEMORY_RDF,
REMOTE_RDF,
VIRTUOSO
VIRTUOSO,
MARKLOGIC
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package eu.unifiedviews.commons.rdf.repository;

import com.marklogic.client.DatabaseClient;
import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.semantics.sesame.MarkLogicRepository;
import eu.unifiedviews.commons.dataunit.core.ConnectionSource;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Created by tomasknap on 18/10/16.
*/
public class MarkLogic implements ManagableRepository {

private static final Logger log = LoggerFactory.getLogger(RepositoryFactory.class);

private final Repository repository;


public MarkLogic(String url, String user, String password) throws RDFException {

String port = url.substring(url.lastIndexOf(":")+1);
int portNumber = Integer.valueOf(port);
log.info("Port number: {}", portNumber);

String host = url.substring(0,url.lastIndexOf(":"));
log.info("Host: {}", host);

DatabaseClient adminClient =
DatabaseClientFactory.newClient(host, portNumber,
user, password, DatabaseClientFactory.Authentication.DIGEST);

// create repo and init
repository = new MarkLogicRepository(adminClient);

try {
repository.initialize();
} catch (RepositoryException ex) {
throw new RDFException("Could not initialize repository", ex);
}
}


@Override
public ConnectionSource getConnectionSource() {
return new ConnectionSourceImpl(repository);
}


@Override
public void release() throws RDFException {
try {
repository.shutDown();
} catch (RepositoryException ex) {
throw new RDFException("Can't shutDown repository.", ex);
}
}

@Override
public void delete() throws RDFException {
// Do nothing here.
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public RemoteRDF(String url, String user, String password, Long executionId) thr

@Override
public ConnectionSource getConnectionSource() {
return new ConnectionSourceImpl(repository, false);
return new ConnectionSourceImpl(repository);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public ManagableRepository create(Long executionId, ManagableRepository.Type typ
case VIRTUOSO:
repository = new Virtuoso(uri, user, password);
break;
case MARKLOGIC:
repository = new MarkLogic(uri, user, password);
break;
default:
throw new RDFException("Unknown repository type: " + type.toString());
}
Expand Down
6 changes: 3 additions & 3 deletions lib/lib-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.6.0</version>
<version>2.8.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.0</version>
<version>2.8.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.0</version>
<version>2.8.3</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
Expand Down