Mentions légales du service

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

- Merged with version r1906. Hopefully improve variable treatments

parent 39675f85
No related branches found
No related tags found
No related merge requests found
/* /*
* $Id$ * $Id$
* *
* Copyright (C) INRIA, 2012-2013 * Copyright (C) INRIA, 2012-2014
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
...@@ -94,7 +94,7 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito ...@@ -94,7 +94,7 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
private Integer nbCardinality = null; private Integer nbCardinality = null;
private String opOccurence = ""; private String opOccurence = "";
private static int numberNs; private static int numberNs;
private static int number = 1; private static int number = 1;
private static String sub = ""; private static String sub = "";
protected String obj = ""; protected String obj = "";
private String strBGP = ""; private String strBGP = "";
...@@ -182,13 +182,11 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito ...@@ -182,13 +182,11 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
} }
private void createObjectVarName() { private void createObjectVarName() {
if ( blanks ) { if ( blanks ) {
obj = "_:o" + ++count; obj = "_:o" + ++count;
} else {
obj = "?o" + ++count;
} }
else {
obj = "?o" + ++count;
}
} }
public void visit( final ClassId e ) throws AlignmentException { public void visit( final ClassId e ) throws AlignmentException {
...@@ -298,7 +296,7 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito ...@@ -298,7 +296,7 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
inClassRestriction = false; inClassRestriction = false;
obj = temp; obj = temp;
if( op == Constructor.AND ){ if( op == Constructor.AND ){
this.createObjectVarName(); createObjectVarName();
} }
} }
...@@ -387,95 +385,96 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito ...@@ -387,95 +385,96 @@ public abstract class GraphPatternRendererVisitor extends IndentedRendererVisito
public void visit( final PropertyId e ) throws AlignmentException { public void visit( final PropertyId e ) throws AlignmentException {
if ( e.getURI() != null ) { if ( e.getURI() != null ) {
String prefix = getPrefixDomain( e.getURI() ); String prefix = getPrefixDomain( e.getURI() );
String tag = getPrefixName( e.getURI() ); String tag = getPrefixName( e.getURI() );
String shortCut=getOrGenerateNSPrefix(prefix); String shortCut = getOrGenerateNSPrefix( prefix );
String temp = obj; String temp = obj;
if( valueRestriction != null && !inClassRestriction && op != Constructor.COMP && flagRestriction == 1 ) if( valueRestriction != null && !inClassRestriction && op != Constructor.COMP && flagRestriction == 1 )
obj = "\"" + valueRestriction.toString() + "\""; obj = "\"" + valueRestriction.toString() + "\"";
if ( flagRestriction == 1 && inClassRestriction ) if ( flagRestriction == 1 && inClassRestriction )
objectsRestriction.add(obj); objectsRestriction.add( obj );
createObjectVarName();
createObjectVarName(); strBGP += sub + " " + shortCut + ":"+ tag + " " + obj + " ." +NL;
strBGP += sub + " " + shortCut + ":"+ tag + " " + obj + " ." +NL; strBGP_Weaken += sub + " " + shortCut + ":"+ tag + " " + obj + " ." +NL;
strBGP_Weaken += sub + " " + shortCut + ":"+ tag + " " + obj + " ." +NL; obj = temp;
obj = temp; }
}
} }
public void visit( final PropertyConstruction e ) throws AlignmentException { public void visit( final PropertyConstruction e ) throws AlignmentException {
op = e.getOperator(); op = e.getOperator();
if ( op == Constructor.OR ){ if ( op == Constructor.OR ){
int size = e.getComponents().size(); if ( valueRestriction != null && !inClassRestriction )
if ( valueRestriction != null && !inClassRestriction ) obj = "\"" + valueRestriction.toString() + "\"";
obj = "\"" + valueRestriction.toString() + "\""; int size = e.getComponents().size();
for ( final PathExpression re : e.getComponents() ) { for ( final PathExpression re : e.getComponents() ) {
strBGP += "{" +NL; strBGP += "{" +NL;
strBGP_Weaken += "{" +NL; strBGP_Weaken += "{" +NL;
re.accept( this ); re.accept( this );
size--; size--;
if( size != 0 ){ if( size != 0 ){
strBGP += "}" + " UNION " + NL; strBGP += "}" + " UNION " + NL;
strBGP_Weaken += "}" + " UNION " + NL; strBGP_Weaken += "}" + " UNION " + NL;
} } else {
else { strBGP += "}" +NL;
strBGP += "}" +NL; strBGP_Weaken += "}" +NL;
strBGP_Weaken += "}" +NL;
}
}
objectsRestriction.add( obj );
} }
else if ( op == Constructor.NOT ) { }
strBGP += "FILTER (NOT EXISTS {" + NL; objectsRestriction.add( obj );
strBGP_Weaken += "FILTER (NOT EXISTS {" + NL; } else if ( op == Constructor.NOT ) {
for ( final PathExpression re : e.getComponents() ) { strBGP += "FILTER (NOT EXISTS {" + NL;
re.accept( this ); strBGP_Weaken += "FILTER (NOT EXISTS {" + NL;
} for ( final PathExpression re : e.getComponents() ) {
strBGP += "})" + NL; re.accept( this );
strBGP_Weaken += "})" + NL; }
strBGP += "})" + NL;
strBGP_Weaken += "})" + NL;
} else if ( op == Constructor.COMP ){
String tempSub = sub;
//if ( blanks && this.getClass() == SPARQLConstructRendererVisitor.class ) {
// obj = "_:o" + ++count;
//}
String tempObj = obj;
int size = e.getComponents().size();
for ( final PathExpression re : e.getComponents() ) {
size--;
// next object
if ( size == 0 ) { // last step
if ( valueRestriction != null && !inClassRestriction ) {
obj = "\"" + valueRestriction.toString() + "\"";
} else {
obj = tempObj;
} // otherwise, generating intermediate variables...
} else if ( blanks && this.getClass() == SPARQLConstructRendererVisitor.class ) {
obj = "_:o" + ++count;
} else {
obj = "?o" + ++count;
} }
else if ( op == Constructor.COMP ){ // sub = last obj; obj = obj if last, var or blank otherwise
int size = e.getComponents().size(); re.accept( this ); // p
String tempSub = sub; sub = obj; // sub <= last object
//if (this.getClass() == SPARQLConstructRendererVisitor.class ) { }
createObjectVarName(); objectsRestriction.add( obj );
//} obj = tempObj;
for ( final PathExpression re : e.getComponents() ) { sub = tempSub;
re.accept( this ); } else {
size--; if ( valueRestriction != null && !inClassRestriction )
if ( size != 0 ) { obj = "\"" + valueRestriction.toString() + "\"";
sub = obj; int size = e.getComponents().size();
if( size == 1 && valueRestriction != null && !inClassRestriction ) { for ( final PathExpression re : e.getComponents() ) {
obj = "\"" + valueRestriction.toString() + "\""; re.accept( this );
} size--;
else { objectsRestriction.add( obj );
if ( this.getClass() == SPARQLConstructRendererVisitor.class ) { if( size != 0 && valueRestriction == null ){
createObjectVarName(); //createObjectVarName();
} obj = "?o" + ++count;
}
}
}
objectsRestriction.add( obj );
sub = tempSub;
}
else {
int size = e.getComponents().size();
if ( valueRestriction != null && !inClassRestriction )
obj = "\"" + valueRestriction.toString() + "\"";
for ( final PathExpression re : e.getComponents() ) {
re.accept( this );
size--;
objectsRestriction.add( obj );
/*if( size != 0 && valueRestriction == null ){
obj = "?o" + ++count;
}*/
if ( !strBGP_Weaken.equals("") && !inClassRestriction ) {
listBGP.add(strBGP_Weaken);
strBGP_Weaken = "";
}
}
} }
//obj = "?o" + ++count; if ( !strBGP_Weaken.equals("") && !inClassRestriction ) {
listBGP.add(strBGP_Weaken);
strBGP_Weaken = "";
}
}
}
obj = "?o" + ++count;
} }
public void visit( final PropertyValueRestriction c ) throws AlignmentException { public void visit( final PropertyValueRestriction c ) throws AlignmentException {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment