-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43c248f
commit cbef85b
Showing
21 changed files
with
438 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
37
src/main/java/org/aksw/sparqlmap/cli/SparqlMapCliConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
||
} |
Oops, something went wrong.