|
@@ -9,6 +9,7 @@ import java.util.Map;
|
|
|
|
|
|
import org.apache.jena.rdf.model.RDFNode;
|
|
|
import org.apache.log4j.Logger;
|
|
|
+import org.h2.util.StringUtils;
|
|
|
|
|
|
public class R2RMLUtil {
|
|
|
|
|
@@ -22,8 +23,7 @@ public class R2RMLUtil {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Utility function to check whether the string denoting a column name is
|
|
|
- * valid
|
|
|
+ * Utility function to check whether the string denoting a column name is valid
|
|
|
*
|
|
|
* @param columnName
|
|
|
* @return True if a valid column name
|
|
@@ -42,8 +42,7 @@ public class R2RMLUtil {
|
|
|
String pquery = parent.getLogicalTable().generateQuery();
|
|
|
|
|
|
if (!cquery.equals(pquery) && joins.isEmpty()) {
|
|
|
- logger.error(
|
|
|
- "If the child query and parent query of a referencing object map are not identical, then the referencing object map must have at least one join condition.");
|
|
|
+ logger.error("If the child query and parent query of a referencing object map are not identical, then the referencing object map must have at least one join condition.");
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -64,15 +63,26 @@ public class R2RMLUtil {
|
|
|
return query;
|
|
|
}
|
|
|
|
|
|
- public static String createJointQueryPreview(TriplesMap triplesMap, TriplesMap ptm, List<Join> joins,
|
|
|
- Map<String, Object> data) {
|
|
|
-
|
|
|
+ public static String createJointQueryPreview(TriplesMap triplesMap, TriplesMap ptm, List<Join> joins, Map<String, Object> data) {
|
|
|
+
|
|
|
String query = createJointQuery(triplesMap, ptm, joins);
|
|
|
|
|
|
for (Join join : joins) {
|
|
|
- query += " AND child." + join.getChild() + "=" + data.get(join.getChild());
|
|
|
+ Object value = data.get(join.getChild());
|
|
|
+ boolean isNumber = false;
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNumber(String.valueOf(value))) {
|
|
|
+ isNumber = true;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ if (isNumber)
|
|
|
+ query += " AND child." + join.getChild() + "=" + data.get(join.getChild());
|
|
|
+ else
|
|
|
+ query += " AND child." + join.getChild() + "='" + data.get(join.getChild()) + "'";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return query;
|
|
|
}
|
|
|
|