diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/GraphPatternRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/GraphPatternRendererVisitor.java index 68b36572d0bcf6e4a06af1bbb6cc62241165b7ad..b49922371d3e9f54ea67aa8cfedf9a7dbae81d83 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/GraphPatternRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/GraphPatternRendererVisitor.java @@ -21,7 +21,6 @@ package fr.inrialpes.exmo.align.impl.renderer; import java.io.BufferedWriter; -import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; @@ -86,6 +85,9 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito Alignment alignment = null; Cell cell = null; Hashtable<String,String> nslist = null; + protected boolean ignoreerrors = false; + protected static boolean blanks = false; + protected boolean weakens = false; private String instance = null; private String value = ""; @@ -129,7 +131,12 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito public static void resetVariablesName(String s, String o) { count = 1; sub = "?" + s; - obj = "?" + o + count; + if ( blanks ) { + obj = "_:" + o + count; + } + else { + obj = "?" + o + count; + } } public void resetVariables(String s, String o) { @@ -389,7 +396,12 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito valueRestriction = null; obj = temp; if(op == Constructor.AND){ - obj = "?o" + ++count; + if ( blanks ) { + obj = "_:o" + ++count; + } + else { + obj = "?o" + ++count; + } } } @@ -589,10 +601,17 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito size--; if(size != 0){ sub = obj; - if(size == 1 && valueRestriction != null) + if( size == 1 && valueRestriction != null ) { obj = "\"" + valueRestriction.toString() + "\""; - else - obj = "?o" + ++count; + } + else { + if ( blanks ) { + obj = "_:o" + ++count; + } + else { + obj = "?o" + ++count; + } + } } } objectsRestriction.add(obj); @@ -614,7 +633,12 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito size--; objectsRestriction.add(obj); if(size != 0 && valueRestriction == null){ - obj = "?o" + ++count; + if ( blanks ) { + obj = "_:o" + ++count; + } + else { + obj = "?o" + ++count; + } } } } @@ -626,7 +650,12 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito } } op = null; - obj = "?o" + ++count; + if ( blanks ) { + obj = "_:o" + ++count; + } + else { + obj = "?o" + ++count; + } } // DONE @@ -861,8 +890,13 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito if(size == 1 && valueRestriction != null) obj = valueRestriction.toString(); else { - obj = "?o" + ++count; - objectsRestriction.add(obj); + if ( blanks ) { + obj = "_:o" + ++count; + } + else { + obj = "?o" + ++count; + objectsRestriction.add(obj); + } } } @@ -952,7 +986,12 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito size--; objectsRestriction.add(obj); if(size != 0 && valueRestriction == null){ - obj = "?o" + ++count; + if ( blanks ) { + obj = "_:o" + ++count; + } + else { + obj = "?o" + ++count; + } } } } @@ -965,7 +1004,12 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito } } op = null; - obj = "?o" + ++count; + if ( blanks ) { + obj = "_:o" + ++count; + } + else { + obj = "?o" + ++count; + } } // DONE @@ -1065,7 +1109,7 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito index = e.getType().lastIndexOf("#"); else index = e.getType().lastIndexOf("/"); - datatype = e.getType().substring(0, index+1); + datatype = e.getType().substring(index+1); } } diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLConstructRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLConstructRendererVisitor.java index 97da25e892843a0f22a549d742bf68dd866e3476..60303faf86b4571adb52605b3e4efdb052c4d735 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLConstructRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLConstructRendererVisitor.java @@ -62,6 +62,12 @@ public class SPARQLConstructRendererVisitor extends GraphPatternRendererVisitor public void init(Properties p) { if ( p.getProperty( "embedded" ) != null && !p.getProperty( "embedded" ).equals("") ) embedded = true; + if ( p.getProperty( "blanks" ) != null && !p.getProperty( "blanks" ).equals("") ) + blanks = true; + if ( p.getProperty( "weakens" ) != null && !p.getProperty( "weakens" ).equals("") ) + weakens = true; + if ( p.getProperty( "ignoreerrors" ) != null && !p.getProperty( "ignoreerrors" ).equals("") ) + ignoreerrors = true; split = ( p.getProperty( "split" ) != null && !p.getProperty( "split" ).equals("") ); if ( p.getProperty( "dir" ) != null && !p.getProperty( "dir" ).equals("") ) splitdir = p.getProperty( "dir" )+"/"; @@ -110,11 +116,10 @@ public class SPARQLConstructRendererVisitor extends GraphPatternRendererVisitor query += "PREFIX "+prefixList.get(k)+":<"+k+">"+NL; } query += "CONSTRUCT {"+NL; - query += listBGP1.get(listBGP1.size()-1)+NL; - + query += listBGP1.get(listBGP1.size()-1); query += "}"+NL; query += "WHERE {"+NL; - query += listBGP2.get(listBGP2.size()-1)+NL; + query += listBGP2.get(listBGP2.size()-1); query += "}"+NL; if( split ) { createQueryFile( splitdir, query ); @@ -125,7 +130,7 @@ public class SPARQLConstructRendererVisitor extends GraphPatternRendererVisitor query=""; /* - if(!listBGP2.get(listBGP2.size()-1).contains("UNION") && + if(!listBGP2.get(listBGP2.size()-1).contains("UNION") && !listBGP2.get(listBGP2.size()-1).contains("FILTER") && !listBGP2.get(listBGP2.size()-1).contains("MINUS")){ for ( Enumeration e = prefixList.keys() ; e.hasMoreElements(); ) { diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLSelectRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLSelectRendererVisitor.java index 61cd1c5bd188e163aea7c5d3c9c99bf4abf8de89..661d95741dff73754b717a233c43db20615241da 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLSelectRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/SPARQLSelectRendererVisitor.java @@ -57,6 +57,12 @@ public class SPARQLSelectRendererVisitor extends GraphPatternRendererVisitor imp public void init(Properties p) { if ( p.getProperty( "embedded" ) != null && !p.getProperty( "embedded" ).equals("") ) embedded = true; + if ( p.getProperty( "blanks" ) != null && !p.getProperty( "blanks" ).equals("") ) + blanks = true; + if ( p.getProperty( "weakens" ) != null && !p.getProperty( "weakens" ).equals("") ) + weakens = true; + if ( p.getProperty( "ignoreerrors" ) != null && !p.getProperty( "ignoreerrors" ).equals("") ) + ignoreerrors = true; split = ( p.getProperty( "split" ) != null && !p.getProperty( "split" ).equals("") ); if ( p.getProperty( "dir" ) != null && !p.getProperty( "dir" ).equals("") ) splitdir = p.getProperty( "dir" )+"/"; @@ -89,37 +95,36 @@ public class SPARQLSelectRendererVisitor extends GraphPatternRendererVisitor imp listCond1 = new ArrayList<String>(getCondition()); resetVariables("s", "o"); - ((Expression)(cell.getObject2())).accept( this ); - listBGP2 = new ArrayList<String>(getBGP()); - listCond2 = new ArrayList<String>(getCondition()); + ((Expression)(cell.getObject2())).accept( this ); + listBGP2 = new ArrayList<String>(getBGP()); + listCond2 = new ArrayList<String>(getCondition()); - for ( Enumeration e = prefixList.keys() ; e.hasMoreElements(); ) { - String k = (String)e.nextElement(); - query += "PREFIX "+prefixList.get(k)+":<"+k+">"+NL; - } - query += "SELECT ?s WHERE {"+NL; - query += listBGP1.get(listBGP1.size()-1)+NL; - query += "}"+NL; - if ( split ) { - createQueryFile( splitdir, query ); - } else { - indentedOutputln(query); - } - query=""; - for ( Enumeration e = prefixList.keys() ; e.hasMoreElements(); ) { - String k = (String)e.nextElement(); - query += "PREFIX "+prefixList.get(k)+":<"+k+">"+NL; - } - query += "SELECT ?s WHERE {"+NL; - query += listBGP2.get(listBGP2.size()-1)+NL; - query += "}"+NL; - if ( split ) { - createQueryFile( splitdir, query ); - } else { - indentedOutputln(query); - } - } - + for ( Enumeration e = prefixList.keys() ; e.hasMoreElements(); ) { + String k = (String)e.nextElement(); + query += "PREFIX "+prefixList.get(k)+":<"+k+">"+NL; + } + query += "SELECT ?s WHERE {"+NL; + query += listBGP1.get(listBGP1.size()-1); + query += "}"+NL; + if ( split ) { + createQueryFile( splitdir, query ); + } else { + indentedOutputln(query); + } + query=""; + for ( Enumeration e = prefixList.keys() ; e.hasMoreElements(); ) { + String k = (String)e.nextElement(); + query += "PREFIX "+prefixList.get(k)+":<"+k+">"+NL; + } + query += "SELECT ?s WHERE {"+NL; + query += listBGP2.get(listBGP2.size()-1); + query += "}"+NL; + if ( split ) { + createQueryFile( splitdir, query ); + } else { + indentedOutputln(query); + } + } } public void visit( Relation rel ) throws AlignmentException {