Skip to content

Commit

Permalink
merged with development + fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
driesmarzougui committed Aug 16, 2018
2 parents da3e624 + 55da04a commit b2495dc
Show file tree
Hide file tree
Showing 501 changed files with 10,121 additions and 722 deletions.
14 changes: 14 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,17 @@ cache:
verify:
script:
- mvn test --batch-mode

services:
- postgres:10.4
- name: microsoft/mssql-server-linux:latest
alias: sqlserver

variables:
# Postgres
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
# SQLServer
ACCEPT_EULA: Y
SA_PASSWORD: "YourSTRONG!Passw0rd"
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,46 @@ try {
logger.error(e.getMessage(), e);
}
```

### Testing
#### RDBs
Make sure you have [Docker](https://www.docker.com) running.

Set the boolean constant ```LOCAL_TESTING``` in the file 'Mapper_RDBs_Test' to ```true``` for testing locally.
This causes the creation of the required Docker containers and adds the right connection string to the mapping files.

Set the boolean constant ```LOCAL_TESTING``` in the file 'Mapper_RDBs_Test' to ```false``` for testing on / pushing to GitLab.
This makes sure that the containers running on GitLab are used and adds the right connection strings to the mapping files.

##### Problems
* A problem with Docker (can't start the container) causes the SQLServer tests to fail locally. These tests have been turned off.
* A problem with Docker (can't start the container) causes the PostgreSQL tests to fail locally on windows 7 machines.

# Dependencies

| Dependency | License |
|:----------------------------------:|--------------------------------------------------------------------|
| com.spotify docker client | Apache License 2.0 |
| com.h2database h2 | Eclipse Public License 1.0 & Mozilla Public License 2.0 |
| com.googlecode.zohhak | GNU Lesser General Public License v3.0 |
| com.microsoft.sqlserver mssql-jdbc | MIT |
| ch.vorbuger.mariaDB4j | Apache License 2.0 |
| mysql-connector-java | GNU General Public License v2.0 |
| com.google.guava | Apache License 2.0 |
| javax.xml.parsers jaxp-api | Apache License 2.0 |
| com.jayway.jsonpath | Apache License 2.0 |
| junit | Eclipse Public License 1.0 |
| org.eclipse.rdf4j rdf4j-runtime | Eclipse Public License 1.0 |
| commons-cli | Apache License 2.0 |
| com.opencsv opencsv | Apache License 2.0 |
| commons-lang | Apache License 2.0 |
| ch.qos.logback | Eclipse Public License 1.0 & GNU Lesser General Public License 2.1 |

# UML Diagrams
## How to generate with IntelliJ IDEA
(Requires Ultimate edition)

* Right click on package: "be.ugent.rml"
* Diagrams > Show Diagram > Java Class Diagrams
* Choose what properties of the classes you want to show in the upper left corner
* Export to file > .png | Save diagram > .uml
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
771 changes: 771 additions & 0 deletions UML_diagrams/rmlmapper_uml_diagram_dependencies.uml

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
821 changes: 821 additions & 0 deletions UML_diagrams/rmlmapper_uml_diagram_everything.uml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions buildNumber.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Tue Aug 07 15:31:45 CEST 2018
buildNumber0=26
#Thu Aug 09 14:05:44 CEST 2018
buildNumber0=29
6 changes: 3 additions & 3 deletions config_example.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
verbose = true
mapping = path_to_mapping_file
output = path_to_output_file
help = true
mappingfile = path_to_mapping_file
outputfile = path_to_output_file
help = false
48 changes: 46 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,50 @@
<artifactId>guava</artifactId>
<version>23.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency>
<dependency>
<groupId>ch.vorburger.mariaDB4j</groupId>
<artifactId>mariaDB4j</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
<!-- jre version must be the same as the gitlab runner -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.4.0.jre8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.zohhak</groupId>
<artifactId>zohhak</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.197</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.spotify</groupId>
<artifactId>docker-client</artifactId>
<version>8.11.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.6</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -102,10 +146,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<!-- <configuration>
<parallel>methods</parallel>
<threadCount>10</threadCount>
</configuration>
</configuration>-->
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/be/ugent/rml/ApplyTemplateFunctionFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package be.ugent.rml;

import be.ugent.rml.functions.ApplyTemplateFunction;
import be.ugent.rml.functions.Function;
import be.ugent.rml.term.NamedNode;
import be.ugent.rml.term.Term;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class ApplyTemplateFunctionFactory {

static Function generate(String genericTemplate, Term termType) {
return ApplyTemplateFunctionFactory.generate(genericTemplate, termType.equals(new NamedNode(NAMESPACES.RR + "IRI")));
}

static Function generate(String genericTemplate, boolean encodeURI) {
HashMap<String, List<Template>> parameters = new HashMap<>();
ArrayList<Template> temp = new ArrayList<>();
temp.add(Utils.parseTemplate(genericTemplate));
parameters.put("_TEMPLATE", temp);
return new ApplyTemplateFunction(parameters, encodeURI);
}

static Function generateWithConstantValue(String value) {
HashMap<String, List<Template>> parameters = new HashMap<>();
List<Template> temp = new ArrayList<>();
Template temp2 = new Template();
temp2.addElement(new TemplateElement(value, TEMPLATETYPE.CONSTANT));
temp.add(temp2);

parameters.put("_TEMPLATE", temp);

return new ApplyTemplateFunction(parameters);
}
}
85 changes: 85 additions & 0 deletions src/main/java/be/ugent/rml/DatabaseType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package be.ugent.rml;

/*
NOTE: Oracle is disabled because there are multiple drivers possible: http://www.orafaq.com/wiki/JDBC
*/

public class DatabaseType {

public static final String MYSQL = "com.mysql.cj.jdbc.Driver";
public static final String POSTGRES = "org.postgresql.Driver";
public static final String SQL_SERVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
//public static final String ORACLE = "oracle.jdbc.driver.OracleDrive";
public static final String DB2 = "com.ibm.as400.access.AS400JDBCDriver";
/*
public static final String JAVA_DB = ;
public static final String SYBASE = ;
*/

/*
Used to abstract as much as possible
Name fields are used to create JDBC connection strings in @RDBs
*/
public enum Database {
MYSQL ("mysql"),
POSTGRES ("postgresql"),
SQL_SERVER ("sqlserver"),
//ORACLE (""),
DB2 ("as400");

private final String name;

private Database(String s) {
name = s;
}

public String toString() {
return this.name;
}
}

/*
Retrieves the Database enum type from a given (driver) string
*/
public static Database getDBtype(String db) {
String db_lower = db.toLowerCase();
if (db_lower.contains("mysql")) {
return Database.MYSQL;
} else if (db_lower.contains("postgres")) {
return Database.POSTGRES;
} else if (db_lower.contains("sqlserver")) {
return Database.SQL_SERVER;
// } else if (db_lower.contains("oracle")) {
// return Database.ORACLE;
} else if (db_lower.contains("ibm")) {
return Database.DB2;
} else {
throw new Error("Couldn't find a driver for the given DB: " + db);
}
}

/*
Retrieves the JDBC driver URL from a given Database enum type
*/
public static String getDriver(Database db) {
switch(db) {
case MYSQL:
return MYSQL;

case POSTGRES:
return POSTGRES;

case SQL_SERVER:
return SQL_SERVER;

// case ORACLE:
// return ORACLE;

case DB2:
return DB2;
default:
throw new Error("Couldn't find a driver for the given DB: " + db);
}
}
}
Loading

0 comments on commit b2495dc

Please sign in to comment.