Skip to content

Commit

Permalink
updated to fit to version 0.7.*
Browse files Browse the repository at this point in the history
  • Loading branch information
tomatophantastico committed Nov 13, 2016
1 parent 43c248f commit cbef85b
Show file tree
Hide file tree
Showing 21 changed files with 438 additions and 659 deletions.
23 changes: 18 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
language: java
jdk:
- openjdk8

services:
- docker
before_install:
- git clone https://github.com/tomatophantastico/sparqlmap-core/ && cd sparqlmap-core && gradle publishToMavenLocal
- git clone https://github.com/tomatophantastico/metamodel.git && cd metamodel && git checkout feature/quoteColumns && mvn install

jdk:
- openjdk7
- oraclejdk7
script:
gradle distZip

deploy:
provider: releases
api_key:
secure: mXH/7qvtMnUetwsyypbXMoehwBbC8Ldfe5c9/WrNkZ8B5STLklB+YgSvama0sSMrmAeXCVua5fQfp9jev9tQjibKvhYVlZArp5S9ihzc5HFKHD1yH/OkKQxIno+5F4F7OL4ZPaGZ1rtZ8bGiXNPB/4QvwOlcfjtfXEq93wXk89qL2hH9iCoKmEpcECaOt7e0RYFge80iEdHW4ebTZ6x6F2yeOvM4IU0sCygreRCcUi51sEnz9Es+baXMWdMZ8+nPICJ9sffD0eFVoByROXJKqKVEx3qTNt8EX1Nx7mGUWh5BYKH50hBeuV3GH+rPpbjRsiE5ScxCZPdZgPBfmRD4F/VxkkmiP52kMCzuLjczNr08bJi7PZT6ojr/vPjaX3JTccLa1FfyrDaNdHjkLZ8JRHPSyMESsUQwwuYPymA1bZHDGsK/jTJe5KxArGF8v8CJtZSSnbQaGEuPWga77eYhdpPNnBGYIjvujOsIVuPT8NomNqZ94HQ4De0WPV9r3cY3ieO9vhKMwsbO+WQR0sfe8DlkipF3QmIxpCBU8dQJMfjvzinNA9DWCuubh1eO7u5huT0Ixb3sUWsZy6h0t3trJrqJ4yZGwYVdqg/vM4yhAe6CHcz/OgMCFFReJ2cDHje86ARtUn1mV2cvJQdCnx4wXevrU01aZFo9RhV5633r7FQ=
file: build/distributions/sparqlmap.zip
on:
repo: tomatophantastico/sparqlmap
branch: develop
tags: true
skip_cleanup: true
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM java:openjdk-7-jdk

COPY . /usr/sparqlmap
WORKDIR /usr/sparqlmap

RUN ./gradlew clean installDist

CMD /usr/sparqlmap/build/install/sparqlmap/bin/sparqlmap -dburl $DB_URL -dbuser $DB_USER -dbpassword $DB_PASS
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,21 @@ cd sparqlmap-core
```



## Using with MongoDB

ds.location the host and port of the mongodb server, e.g.: localhost:11111
ds.identifier the database name
ds.username username
ds.password password


## Using with a JDBC database
First, make sure that a JDBC4 driver is in the classpath. SparqlMap already contains drivers for the most important FOSS RDBMs, for closed source RDBMs, they have to be added manually.


ds.location the full jdbc url, e.g. jdbc:mysql://localhost:3306/test
ds.identifier ** not used **
ds.username username of the RDBMS
ds.password password of the RDBMS
ds.maxPoolSize max number of connections to the RDBMs, defaults to 10
72 changes: 35 additions & 37 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
repositories {
mavenLocal()
mavenCentral()
maven { url "http://maven.aksw.org/archiva/repository/internal" }
maven { url "http://maven.aksw.org/archiva/repository/snapshots" }
}

buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.2.RELEASE")
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE")
}
}


repositories{
mavenLocal()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}


}
apply plugin: 'spring-boot'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'distribution'
apply plugin: 'spring-boot'
apply plugin: 'maven-publish'
apply plugin: 'application'


// We use Java 7
// We use Java 8
sourceCompatibility = 1.8
targetCompatibility = 1.8

//
ext {
sparqlMapVersion = '0.7.0-SNAPSHOT'
}


// deal with the changing dependency of sparqlmap
configurations.all {
// check for updates every build
Expand All @@ -34,35 +46,16 @@ configurations{
}


// maven publication

publishing {
publications {
maven(MavenPublication) {
groupId 'org.aksw.sparqlmap'
artifactId 'sparqlmap-client'
version '0.6.4'

from components.java
}
}
}

springBoot {
mainClass = "org.aksw.sparqlmap.web.spring.SparqlmapWebApplication"
}

jar {
baseName = 'sparqlmap'
version = '0.7.0-SNAPSHOT'
version = sparqlMapVersion
}

repositories {
mavenLocal()
mavenCentral()
maven { url "http://maven.aksw.org/archiva/repository/internal" }
maven { url "http://maven.aksw.org/archiva/repository/snapshots" }
}


dependencies {
compile("org.springframework.boot:spring-boot-starter-web") {
Expand All @@ -74,22 +67,27 @@ dependencies {
compile("org.springframework:spring-tx")
compile("org.springframework.boot:spring-boot-starter-jetty")

compileOnly "org.projectlombok:lombok:1.16.10"


compile("org.springframework.boot:spring-boot-starter-actuator"){
exclude module: "logback-classic"
}

compile group: "org.aksw.sparqlmap", name: "sparqlmap-core", version: "0.7.0-SNAPSHOT", changing: true
compile 'commons-cli:commons-cli:1.2'
compile 'com.beust:jcommander:1.58'
compile group: "org.aksw.sparqlmap", name: "sparqlmap-core", version: sparqlMapVersion, changing: true
compile 'commons-cli:commons-cli:1.3.1'
compile "com.zaxxer:HikariCP:2.5.1"

testCompile("junit:junit")
testCompile 'org.springframework:spring-jdbc:4.1.5.RELEASE'

}



startScripts {
classpath = files()
mainClassName = 'sparqlmap'
mainClassName = 'org.aksw.sparqlmap.cli.SparqlMapCli'
applicationName = 'sparqlmap'
doLast {
def windowsScriptFile = file getWindowsScript()
Expand Down
113 changes: 113 additions & 0 deletions src/main/java/org/aksw/sparqlmap/cli/SparqlMapCli.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package org.aksw.sparqlmap.cli;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;

import org.aksw.sparqlmap.common.BaseConfigValidator;
import org.aksw.sparqlmap.common.SparqlMapSetup;
import org.aksw.sparqlmap.core.SparqlMap;
import org.aksw.sparqlmap.core.TranslationContext;
import org.aksw.sparqlmap.core.translate.metamodel.MetaModelQueryDump;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.ResultSetFormatter;
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.riot.RDFFormat;
import org.apache.jena.riot.RDFLanguages;
import org.apache.jena.sparql.resultset.ResultsFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.Validator;

@Configuration
@EnableAutoConfiguration
@ComponentScan
public class SparqlMapCli implements ApplicationRunner{


//expose for testing and for custom interactions
public static OutputStream out = System.out;
public static OutputStream err = System.err;

@Autowired
SparqlMapCliConfig cliConf;

@Autowired
SparqlMap sm;




@Override
public void run(ApplicationArguments args) throws Exception {
OutputStream out;
if(cliConf.getDumpLocation()==null){
out = SparqlMapCli.out;
}else{
out = new FileOutputStream(new File(cliConf.getDumpLocation()));
}
switch(cliConf.getAction()){
case DIRECTMAPPING:
RDFFormat dmtargetLang = new RDFFormat(RDFLanguages.nameToLang(cliConf.getOutputFormat()));
RDFDataMgr.write(
out,
sm.getMapping().getR2rmlMapping(),
dmtargetLang.getLang());
break;
case DUMP:
RDFFormat dtargetLang = new RDFFormat(RDFLanguages.nameToLang(cliConf.getOutputFormat()));
sm.getDumpExecution().dump(cliConf.getMappings(), cliConf.isFast()).forEach(graphmap->
RDFDataMgr.write(
out,
MetaModelQueryDump.convert(graphmap),
dtargetLang)
);
break;
case QUERY:
TranslationContext tcon = new TranslationContext();
tcon.setQueryString(cliConf.getQuery());
tcon.setQueryName("cliquery");
QueryExecution qexec = sm.execute(tcon);
int queryType = tcon.getQuery().getQueryType();
if(Query.QueryTypeAsk == queryType){
ResultSetFormatter.out(out, qexec.execAsk());
}
if(Query.QueryTypeSelect == queryType){
ResultsFormat selectoutputFormat = ResultsFormat.lookup(cliConf.getOutputFormat());
ResultSetFormatter.output(out, qexec.execSelect(), selectoutputFormat);
}
if(Query.QueryTypeDescribe == queryType){
RDFFormat descTargetLang = new RDFFormat(RDFLanguages.nameToLang(cliConf.getOutputFormat()));
RDFDataMgr.write(out, qexec.execDescribe(), descTargetLang);

}
if(Query.QueryTypeConstruct == queryType){
RDFFormat constTargetLang = new RDFFormat(RDFLanguages.nameToLang(cliConf.getOutputFormat()));
RDFDataMgr.write(out, qexec.execConstruct(), constTargetLang);
}
}

out.close();


}

@Bean
public Validator getValidator(){
return new BaseConfigValidator();
}

public static void main(String[] args) {
SpringApplication springApp = new SpringApplication(SparqlMapCli.class,SparqlMapSetup.class);
springApp.setWebEnvironment(false);
springApp.run(args).close();
}


}
5 changes: 5 additions & 0 deletions src/main/java/org/aksw/sparqlmap/cli/SparqlMapCliAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.aksw.sparqlmap.cli;

public enum SparqlMapCliAction {
DIRECTMAPPING, DUMP, QUERY
}
37 changes: 37 additions & 0 deletions src/main/java/org/aksw/sparqlmap/cli/SparqlMapCliConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.aksw.sparqlmap.cli;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import com.google.common.base.Joiner;

import lombok.Data;

@Configuration
@ConfigurationProperties
@Data
public class SparqlMapCliConfig {




@NotNull(message="Specify what you want to do, either: DIRECTMAPPING, DUMP, QUERY" )
private SparqlMapCliAction action;

private String query;

private String dumpLocation;

private String outputFormat;

private List<String> mappings;

private boolean fast = false;



}
37 changes: 37 additions & 0 deletions src/main/java/org/aksw/sparqlmap/common/BaseConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.aksw.sparqlmap.common;

import javax.validation.constraints.NotNull;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import lombok.Data;

@Configuration
@ConfigurationProperties
@Data
public class BaseConfig {


private String dsUsername;
private String dsPassword;
@NotNull(message="Define the location of the data source, according to the Data Source type, for example a file location or a JDBC-URL")
private String dsLocation;
private String dsIdentifier;
private Integer maxPoolSize = 10;

@NotNull(message="Provide a Data Source Type e.g. JDBC, CSV or ACCESS")
private DataSourceType dsType;

private String baseiri;

private String r2rmlfile;

private String dmBaseUriPrefix;
private String dmMappingUriPrefix;
private String dmVocabUriPrefix;
private String dmInstanceUriPrefix;
private String dmSeparatorChar;


}
Loading

0 comments on commit cbef85b

Please sign in to comment.