Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 607e9ddb authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- Fixed a mistake in comparison generation (Property/Relation inverted)

parent 6f47a6a6
No related branches found
No related tags found
No related merge requests found
...@@ -293,29 +293,29 @@ public class SPARQLLinkkerRendererVisitor extends GraphPatternRendererVisitor im ...@@ -293,29 +293,29 @@ public class SPARQLLinkkerRendererVisitor extends GraphPatternRendererVisitor im
public void processInLinkKey( final LinkkeyBinding binding ) throws AlignmentException { public void processInLinkKey( final LinkkeyBinding binding ) throws AlignmentException {
if ( (binding.getExpression1() instanceof PropertyExpression) || (binding.getExpression2() instanceof PropertyExpression) ) { if ( (binding.getExpression1() instanceof PropertyExpression) || (binding.getExpression2() instanceof PropertyExpression) ) {
//?x p'i ?zi . ?y q'i ?zi . //Literal values
emptyGP(); emptyGP();
String o1 = createVarName(); String o1 = createVarName();
resetVariables( lkvar1, o1 ); resetVariables( lkvar1, o1 );
binding.getExpression1().accept( this ); binding.getExpression1().accept( this );
lkpattern += wrapInNamedGraph( onto1NamedGraph, getGP() ); lkpattern += wrapInNamedGraph( onto1NamedGraph, getGP() );
emptyGP(); emptyGP();
resetVariables( lkvar2, o1 ); String o2 = createVarName();
resetVariables( lkvar2, o2 );
binding.getExpression2().accept( this ); binding.getExpression2().accept( this );
lkpattern += wrapInNamedGraph( onto2NamedGraph, getGP() ); lkpattern += wrapInNamedGraph( onto2NamedGraph, getGP() );
lkpattern += "FILTER( lcase(str("+o1+")) = lcase(str("+o2+")) )"+NL;
} else { } else {
//Literal values //?x p'i ?zi . ?y q'i ?zi .
emptyGP(); emptyGP();
String o1 = createVarName(); String o1 = createVarName();
resetVariables( lkvar1, o1 ); resetVariables( lkvar1, o1 );
binding.getExpression1().accept( this ); binding.getExpression1().accept( this );
lkpattern += wrapInNamedGraph( onto1NamedGraph, getGP() ); lkpattern += wrapInNamedGraph( onto1NamedGraph, getGP() );
emptyGP(); emptyGP();
String o2 = createVarName(); resetVariables( lkvar2, o1 );
resetVariables( lkvar2, o2 );
binding.getExpression2().accept( this ); binding.getExpression2().accept( this );
lkpattern += wrapInNamedGraph( onto2NamedGraph, getGP() ); lkpattern += wrapInNamedGraph( onto2NamedGraph, getGP() );
lkpattern += "FILTER( lcase(str("+o1+")) = lcase(str("+o2+")) ) "+NL;
} }
} }
......
...@@ -52,7 +52,7 @@ import org.testng.annotations.Test; ...@@ -52,7 +52,7 @@ import org.testng.annotations.Test;
public class SPARQLLinkkerRendererVisitorTest { public class SPARQLLinkkerRendererVisitorTest {
// JE2015-Tosee // JE2015:
// This is a test which has no sense, because there is no linkkey // This is a test which has no sense, because there is no linkkey
// In this case, my new SPARQLLinkkey does not return a query // In this case, my new SPARQLLinkkey does not return a query
// It would link all pairs of RootElement / MusicalWork // It would link all pairs of RootElement / MusicalWork
...@@ -213,13 +213,14 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -213,13 +213,14 @@ System.err.println( renderer.getQuery( cell ) );
+ "PREFIX ns0:<http://exmo.inrialpes.fr/connectors-core/>\n" + "PREFIX ns0:<http://exmo.inrialpes.fr/connectors-core/>\n"
+ "PREFIX owl:<http://www.w3.org/2002/07/owl#>\n" + "PREFIX owl:<http://www.w3.org/2002/07/owl#>\n"
+ "PREFIX ns1:<http://xmlns.com/foaf/0.1/>\n" + "PREFIX ns1:<http://xmlns.com/foaf/0.1/>\n"
+ "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n\n" + "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n\n"
+ "CONSTRUCT { ?s1 owl:sameAs ?s2 }\n" + "CONSTRUCT { ?s1 owl:sameAs ?s2 }\n"
+ "WHERE {\n" + "WHERE {\n"
+ "?s1 rdf:type ns0:Personne .\n" + "?s1 rdf:type ns0:Personne .\n"
+ "?s2 rdf:type ns1:Person .\n" + "?s2 rdf:type ns1:Person .\n"
+ "?s1 ns0:nom ?o3 .\n" + "?s1 ns0:nom ?o3 .\n"
+ "?s2 ns1:givenName ?o3 .\n" + "?s2 ns1:givenName ?o4 .\n"
+ "FILTER( lcase(str(?o3)) = lcase(str(?o4)) )\n"
+ "}\n"; + "}\n";
String query = renderer.getQuery( cell ); String query = renderer.getQuery( cell );
assertEquals( query, expectedQuery0 ); assertEquals( query, expectedQuery0 );
...@@ -233,13 +234,14 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -233,13 +234,14 @@ System.err.println( renderer.getQuery( cell ) );
String expectedQuery = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" String expectedQuery = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
+ "PREFIX ns0:<http://exmo.inrialpes.fr/connectors-core/>\n" + "PREFIX ns0:<http://exmo.inrialpes.fr/connectors-core/>\n"
+ "PREFIX ns1:<http://xmlns.com/foaf/0.1/>\n" + "PREFIX ns1:<http://xmlns.com/foaf/0.1/>\n"
+ "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n\n" + "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n\n"
+ "SELECT DISTINCT ?s1 ?s2\n" + "SELECT DISTINCT ?s1 ?s2\n"
+ "WHERE {\n" + "WHERE {\n"
+ "?s1 rdf:type ns0:Personne .\n" + "?s1 rdf:type ns0:Personne .\n"
+ "?s2 rdf:type ns1:Person .\n" + "?s2 rdf:type ns1:Person .\n"
+ "?s1 ns0:nom ?o3 .\n" + "?s1 ns0:nom ?o3 .\n"
+ "?s2 ns1:givenName ?o3 .\n" + "?s2 ns1:givenName ?o4 .\n"
+ "FILTER( lcase(str(?o3)) = lcase(str(?o4)) )\n"
+ "}\n"; + "}\n";
query = renderer.getQuery(cell); query = renderer.getQuery(cell);
assertEquals( query, expectedQuery ); assertEquals( query, expectedQuery );
...@@ -319,7 +321,7 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -319,7 +321,7 @@ System.err.println( renderer.getQuery( cell ) );
String expectedQuery = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" String expectedQuery = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
+ "PREFIX ns0:<http://exmo.inrialpes.fr/connectors-core/>\n" + "PREFIX ns0:<http://exmo.inrialpes.fr/connectors-core/>\n"
+ "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n" + "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n"
+ "PREFIX ns1:<http://xmlns.com/foaf/0.1/>\n" + "PREFIX ns1:<http://xmlns.com/foaf/0.1/>\n"
+ "SELECT DISTINCT ?s1 ?s2\n\n" + "SELECT DISTINCT ?s1 ?s2\n\n"
+ "WHERE {\n" + "WHERE {\n"
...@@ -412,15 +414,17 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -412,15 +414,17 @@ System.err.println( renderer.getQuery( cell ) );
String expectedQuery = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" String expectedQuery = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
+ "PREFIX ns0:<http://exmo.inrialpes.fr/connectors-core/>\n" + "PREFIX ns0:<http://exmo.inrialpes.fr/connectors-core/>\n"
+ "PREFIX ns1:<http://xmlns.com/foaf/0.1/>\n" + "PREFIX ns1:<http://xmlns.com/foaf/0.1/>\n"
+ "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n\n" + "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n\n"
+ "SELECT DISTINCT ?s1 ?s2\n" + "SELECT DISTINCT ?s1 ?s2\n"
+ "WHERE {\n" + "WHERE {\n"
+ "?s1 rdf:type ns0:Personne .\n" + "?s1 rdf:type ns0:Personne .\n"
+ "?s2 rdf:type ns1:Person .\n" + "?s2 rdf:type ns1:Person .\n"
+ "?s1 ns0:connait ?o3 .\n" + "?s1 ns0:connait ?o3 .\n"
+ "?o4 rdf:type ns1:Person .\n" + "?o5 rdf:type ns1:Person .\n"
+ "?s2 ns1:knows ?o4 .\n" + "?s2 ns1:knows ?o5 .\n"
+ "?o4 ns1:givenName ?o3 .\n" + "?o5 ns1:givenName ?o4 .\n"
// JE2015: Here we have a URI (o3) compared to a string (o4)
+ "FILTER( lcase(str(?o3)) = lcase(str(?o4)) )\n"
+ "}\n" + "}\n"
+ ""; + "";
assertEquals( query, expectedQuery ); assertEquals( query, expectedQuery );
...@@ -494,7 +498,7 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -494,7 +498,7 @@ System.err.println( renderer.getQuery( cell ) );
String expectedQuery = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" String expectedQuery = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
+ "PREFIX ns0:<http://exmo.inrialpes.fr/connectors-core/>\n" + "PREFIX ns0:<http://exmo.inrialpes.fr/connectors-core/>\n"
+ "PREFIX ns1:<http://xmlns.com/foaf/0.1/>\n" + "PREFIX ns1:<http://xmlns.com/foaf/0.1/>\n"
+ "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n\n" + "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n\n"
+ "SELECT DISTINCT ?s1 ?s2\n" + "SELECT DISTINCT ?s1 ?s2\n"
+ "WHERE {\n" + "WHERE {\n"
+ "GRAPH <http://exmo.inrialpes.fr/connectors/onto1-graph> {\n" + "GRAPH <http://exmo.inrialpes.fr/connectors/onto1-graph> {\n"
...@@ -507,8 +511,9 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -507,8 +511,9 @@ System.err.println( renderer.getQuery( cell ) );
+ "?s1 ns0:nom ?o3 .\n" + "?s1 ns0:nom ?o3 .\n"
+ "}\n" + "}\n"
+ "GRAPH <http://exmo.inrialpes.fr/connectors/onto2-graph> {\n" + "GRAPH <http://exmo.inrialpes.fr/connectors/onto2-graph> {\n"
+ "?s2 ns1:givenName ?o3 .\n" + "?s2 ns1:givenName ?o4 .\n"
+ "}\n" + "}\n"
+ "FILTER( lcase(str(?o3)) = lcase(str(?o4)) )\n"
+ "}\n"; + "}\n";
assertEquals( renderer.getQuery(cell), expectedQuery ); assertEquals( renderer.getQuery(cell), expectedQuery );
...@@ -516,7 +521,7 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -516,7 +521,7 @@ System.err.println( renderer.getQuery( cell ) );
expectedQuery = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" expectedQuery = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
+ "PREFIX ns1:<http://exmo.inrialpes.fr/connectors-core/>\n" + "PREFIX ns1:<http://exmo.inrialpes.fr/connectors-core/>\n"
+ "PREFIX ns0:<http://xmlns.com/foaf/0.1/>\n" + "PREFIX ns0:<http://xmlns.com/foaf/0.1/>\n"
+ "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n\n" + "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n\n"
+ "SELECT DISTINCT ?s1 ?s2\n" + "SELECT DISTINCT ?s1 ?s2\n"
+ "WHERE {\n" + "WHERE {\n"
+ "GRAPH <http://exmo.inrialpes.fr/connectors/onto2-graph> {\n" + "GRAPH <http://exmo.inrialpes.fr/connectors/onto2-graph> {\n"
...@@ -529,8 +534,9 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -529,8 +534,9 @@ System.err.println( renderer.getQuery( cell ) );
+ "?s1 ns0:givenName ?o3 .\n" + "?s1 ns0:givenName ?o3 .\n"
+ "}\n" + "}\n"
+ "GRAPH <http://exmo.inrialpes.fr/connectors/onto1-graph> {\n" + "GRAPH <http://exmo.inrialpes.fr/connectors/onto1-graph> {\n"
+ "?s2 ns1:nom ?o3 .\n" + "?s2 ns1:nom ?o4 .\n"
+ "}\n" + "}\n"
+ "FILTER( lcase(str(?o3)) = lcase(str(?o4)) )\n"
+ "}\n"; + "}\n";
EDOALAlignment inval = alignment.inverse(); EDOALAlignment inval = alignment.inverse();
properties.setProperty( "graphName1", onto2NamedGraph ); properties.setProperty( "graphName1", onto2NamedGraph );
...@@ -565,7 +571,8 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -565,7 +571,8 @@ System.err.println( renderer.getQuery( cell ) );
+ "GRAPH <http://exmo.inrialpes.fr/connectors/onto1-graph> {\n" + "GRAPH <http://exmo.inrialpes.fr/connectors/onto1-graph> {\n"
+ "?s1 ns0:nom ?o3 .\n" + "?s1 ns0:nom ?o3 .\n"
+ "}\n" + "}\n"
+ "?s2 ns1:givenName ?o3 .\n" + "?s2 ns1:givenName ?o4 .\n"
+ "FILTER( lcase(str(?o3)) = lcase(str(?o4)) )\n"
+ "}\n"; + "}\n";
assertEquals(renderer.getQuery(cell), expectedQuery); assertEquals(renderer.getQuery(cell), expectedQuery);
...@@ -582,8 +589,9 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -582,8 +589,9 @@ System.err.println( renderer.getQuery( cell ) );
+ "}\n" + "}\n"
+ "?s1 ns0:givenName ?o3 .\n" + "?s1 ns0:givenName ?o3 .\n"
+ "GRAPH <http://exmo.inrialpes.fr/connectors/onto1-graph> {\n" + "GRAPH <http://exmo.inrialpes.fr/connectors/onto1-graph> {\n"
+ "?s2 ns1:nom ?o3 .\n" + "?s2 ns1:nom ?o4 .\n"
+ "}\n" + "}\n"
+ "FILTER( lcase(str(?o3)) = lcase(str(?o4)) )\n"
+ "}\n"; + "}\n";
renderer = new SPARQLLinkkerRendererVisitor(writer); renderer = new SPARQLLinkkerRendererVisitor(writer);
properties = new Properties(); properties = new Properties();
...@@ -606,8 +614,9 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -606,8 +614,9 @@ System.err.println( renderer.getQuery( cell ) );
+ "}\n" + "}\n"
+ "?s1 ns0:nom ?o3 .\n" + "?s1 ns0:nom ?o3 .\n"
+ "GRAPH <http://exmo.inrialpes.fr/connectors/onto2-graph> {\n" + "GRAPH <http://exmo.inrialpes.fr/connectors/onto2-graph> {\n"
+ "?s2 ns1:givenName ?o3 .\n" + "?s2 ns1:givenName ?o4 .\n"
+ "}\n" + "}\n"
+ "FILTER( lcase(str(?o3)) = lcase(str(?o4)) )\n"
+ "}\n"; + "}\n";
renderer = new SPARQLLinkkerRendererVisitor(writer); renderer = new SPARQLLinkkerRendererVisitor(writer);
properties = new Properties(); properties = new Properties();
...@@ -624,7 +633,7 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -624,7 +633,7 @@ System.err.println( renderer.getQuery( cell ) );
expectedQuery = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" expectedQuery = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
+ "PREFIX ns1:<http://exmo.inrialpes.fr/connectors-core/>\n" + "PREFIX ns1:<http://exmo.inrialpes.fr/connectors-core/>\n"
+ "PREFIX ns0:<http://xmlns.com/foaf/0.1/>\n" + "PREFIX ns0:<http://xmlns.com/foaf/0.1/>\n"
+ "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n\n" + "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>\n\n"
+ "SELECT DISTINCT ?s1 ?s2\n" + "SELECT DISTINCT ?s1 ?s2\n"
+ "WHERE {\n" + "WHERE {\n"
+ "GRAPH <http://exmo.inrialpes.fr/connectors/onto2-graph> {\n" + "GRAPH <http://exmo.inrialpes.fr/connectors/onto2-graph> {\n"
...@@ -634,7 +643,8 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -634,7 +643,8 @@ System.err.println( renderer.getQuery( cell ) );
+ "GRAPH <http://exmo.inrialpes.fr/connectors/onto2-graph> {\n" + "GRAPH <http://exmo.inrialpes.fr/connectors/onto2-graph> {\n"
+ "?s1 ns0:givenName ?o3 .\n" + "?s1 ns0:givenName ?o3 .\n"
+ "}\n" + "}\n"
+ "?s2 ns1:nom ?o3 .\n" + "?s2 ns1:nom ?o4 .\n"
+ "FILTER( lcase(str(?o3)) = lcase(str(?o4)) )\n"
+ "}\n"; + "}\n";
renderer = new SPARQLLinkkerRendererVisitor(writer); renderer = new SPARQLLinkkerRendererVisitor(writer);
properties = new Properties(); properties = new Properties();
...@@ -678,10 +688,12 @@ System.err.println( renderer.getQuery( cell ) ); ...@@ -678,10 +688,12 @@ System.err.println( renderer.getQuery( cell ) );
+ "?s1 ns0:connait ?o3 .\n" + "?s1 ns0:connait ?o3 .\n"
+ "}\n" + "}\n"
+ "GRAPH <http://exmo.inrialpes.fr/connectors/onto2-graph> {\n" + "GRAPH <http://exmo.inrialpes.fr/connectors/onto2-graph> {\n"
+ "?o4 rdf:type ns1:Person .\n" + "?o5 rdf:type ns1:Person .\n"
+ "?s2 ns1:knows ?o4 .\n" + "?s2 ns1:knows ?o5 .\n"
+ "?o4 ns1:givenName ?o3 .\n" + "?o5 ns1:givenName ?o4 .\n"
+ "}\n" + "}\n"
// JE2015: Here we have a URI (o3) compared to a string (o4)
+ "FILTER( lcase(str(?o3)) = lcase(str(?o4)) )\n"
+ "}\n"; + "}\n";
assertEquals( query, expectedQuery ); assertEquals( query, expectedQuery );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment