diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/ClassId.java b/src/fr/inrialpes/exmo/align/impl/edoal/ClassId.java index 60426584ea5823968be45de9e6a96d9b2883d863..d6b48a9c9c119d43105c0420a59fb6a7203dbfc8 100644 --- a/src/fr/inrialpes/exmo/align/impl/edoal/ClassId.java +++ b/src/fr/inrialpes/exmo/align/impl/edoal/ClassId.java @@ -3,7 +3,7 @@ * * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck * Sourceforge version 1.5 - 2006 - * Copyright (C) INRIA, 2009 + * Copyright (C) INRIA, 2009-2010 * * 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 @@ -44,6 +44,11 @@ public class ClassId extends ClassExpression implements Id { URI uri; + /** + * Creates an anonymous class pattern + */ + public ClassId() {} + public ClassId(final String id) throws AlignmentException { if (id == null) { throw new NullPointerException("The id must not be null"); diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/InstanceId.java b/src/fr/inrialpes/exmo/align/impl/edoal/InstanceId.java index fc945cffbdd110ef0e7e7e8fa01bf26215f01eff..df8d9073a2367e2333e017f4a4b064846bf9af0e 100644 --- a/src/fr/inrialpes/exmo/align/impl/edoal/InstanceId.java +++ b/src/fr/inrialpes/exmo/align/impl/edoal/InstanceId.java @@ -3,7 +3,7 @@ * * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck * Sourceforge version 1.4 - 2006 -- then InstanceExpr - * Copyright (C) INRIA, 2009 + * Copyright (C) INRIA, 2009-2010 * * 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 @@ -44,6 +44,11 @@ public class InstanceId extends InstanceExpression implements Id { uri = u; } + /** + * Creates an anonymous instance pattern + */ + public InstanceId() {} + /** * Constructs a InstanceId. * diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/PropertyId.java b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyId.java index e6012fc36d62333cf2ac8e14db27738c47c5ce8d..67ad461f45485943884b2cc4b09ddb0da50c7dde 100644 --- a/src/fr/inrialpes/exmo/align/impl/edoal/PropertyId.java +++ b/src/fr/inrialpes/exmo/align/impl/edoal/PropertyId.java @@ -3,7 +3,7 @@ * * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck * Sourceforge version 1.7 - 2006 -- then AttributeExpr.java - * Copyright (C) INRIA, 2009 + * Copyright (C) INRIA, 2009-2010 * * 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 @@ -43,6 +43,11 @@ public class PropertyId extends PropertyExpression implements Id { URI uri; + /** + * Creates an anonymous property pattern + */ + public PropertyId() {} + public PropertyId( final URI u ) { if ( u == null ) { throw new NullPointerException("The URI must not be null"); diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/RelationId.java b/src/fr/inrialpes/exmo/align/impl/edoal/RelationId.java index 3255100ff3217f53a0e28506b99326ad9da642e4..33a989e7cf0558e8484f776a2eaab0a3f0241a8d 100644 --- a/src/fr/inrialpes/exmo/align/impl/edoal/RelationId.java +++ b/src/fr/inrialpes/exmo/align/impl/edoal/RelationId.java @@ -3,7 +3,7 @@ * * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck * Sourceforge version 1.5 - 2006 -- then RelationExpr - * Copyright (C) INRIA, 2009 + * Copyright (C) INRIA, 2009-2010 * * 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 @@ -39,6 +39,11 @@ public class RelationId extends RelationExpression implements Id { URI uri; + /** + * Creates an anonymous relation pattern + */ + public RelationId() {} + public RelationId(final String id) throws AlignmentException { if (id == null) { throw new NullPointerException("The id must not be null"); diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java index 0892954ae3b963b346739dbc79ee22be52b92315..c2db45dbad0f10b789b71ecb77e842c488754c86 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java @@ -361,8 +361,10 @@ public class RDFRendererVisitor implements AlignmentVisitor { // DONE+TESTED public void visit( final ClassId e ) throws AlignmentException { indentedOutput("<"+SyntaxElement.CLASS_EXPR.print(DEF)); - writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF)); - writer.print("=\""+e.getURI()+"\""); + if ( e.getURI() != null ) { + writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF)); + writer.print("=\""+e.getURI()+"\""); + } if ( isPattern ) renderVariables( e ); writer.print("/>"); } @@ -512,8 +514,10 @@ public class RDFRendererVisitor implements AlignmentVisitor { // DONE public void visit(final PropertyId e) throws AlignmentException { indentedOutput("<"+SyntaxElement.PROPERTY_EXPR.print(DEF)); - writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF)); - writer.print("=\""+e.getURI()+"\""); + if ( e.getURI() != null ){ + writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF)); + writer.print("=\""+e.getURI()+"\""); + } if ( isPattern ) renderVariables( e ); writer.print("/>"); } @@ -621,8 +625,10 @@ public class RDFRendererVisitor implements AlignmentVisitor { // DONE public void visit( final RelationId e ) throws AlignmentException { indentedOutput("<"+SyntaxElement.RELATION_EXPR.print(DEF)); - writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF)); - writer.print("=\""+e.getURI()+"\""); + if ( e.getURI() != null ) { + writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF)); + writer.print("=\""+e.getURI()+"\""); + } if ( isPattern ) renderVariables( e ); writer.print("/>"); } @@ -704,8 +710,10 @@ public class RDFRendererVisitor implements AlignmentVisitor { // DONE+TESTED public void visit( final InstanceId e ) throws AlignmentException { indentedOutput("<"+SyntaxElement.INSTANCE_EXPR.print(DEF)); - writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF)); - writer.print("=\""+e.getURI()+"\""); + if ( e.getURI() != null ) { + writer.print(" "+SyntaxElement.RDF_ABOUT.print(DEF)); + writer.print("=\""+e.getURI()+"\""); + } if ( isPattern ) renderVariables( e ); writer.print("/>"); } diff --git a/src/fr/inrialpes/exmo/align/parser/RDFParser.java b/src/fr/inrialpes/exmo/align/parser/RDFParser.java index cf634ba31cd66f8c69e15e19126362671a4b8611..5a946617c5ccd522af75823723d64c72c1315755 100644 --- a/src/fr/inrialpes/exmo/align/parser/RDFParser.java +++ b/src/fr/inrialpes/exmo/align/parser/RDFParser.java @@ -420,9 +420,8 @@ public class RDFParser { } else { throw new AlignmentException("There is no parser for entity "+rdfType.getLocalName()); } - //2010 test for variable? if yes store it! if ( isPattern ) { - StmtIterator stmtIt = node.listProperties((Property)SyntaxElement.VAR.resource ); + StmtIterator stmtIt = node.listProperties( (Property)SyntaxElement.VAR.resource ); if ( stmtIt.hasNext() ) { final String varname = stmtIt.nextStatement().getString(); final Variable var = alignment.recordVariable( varname, result ); @@ -459,7 +458,11 @@ public class RDFParser { op = SyntaxElement.NOT.getOperator(); stmt = node.getProperty( (Property)SyntaxElement.NOT.resource ); } else { - throw new AlignmentException( "Class statement must containt one constructor or Id : "+node ); + if ( isPattern ) { // not necessarily with a variable (real patterns) + return new ClassId(); + } else { + throw new AlignmentException( "Class statement must containt one constructor or Id : "+node ); + } } //JE2010MUSTCHECK Resource coll = stmt.getResource(); //JE2010MUSTCHECK @@ -599,7 +602,11 @@ public class RDFParser { op = SyntaxElement.NOT.getOperator(); stmt = node.getProperty( (Property)SyntaxElement.NOT.resource ); } else { - throw new AlignmentException( "Property statement must containt one constructor or Id : "+node ); + if ( isPattern ) { // not necessarily with a variable (real patterns) + return new PropertyId(); + } else { + throw new AlignmentException( "Property statement must containt one constructor or Id : "+node ); + } } Resource coll = stmt.getResource(); //JE2010MUSTCHECK if ( op == SyntaxElement.NOT.getOperator() ) { @@ -720,7 +727,11 @@ public class RDFParser { op = SyntaxElement.TRANSITIVE.getOperator(); stmt = node.getProperty( (Property)SyntaxElement.TRANSITIVE.resource ); } else { - throw new AlignmentException( "Relation statement must containt one constructor or Id : "+node ); + if ( isPattern ) { // not necessarily with a variable (real patterns) + return new RelationId(); + } else { + throw new AlignmentException( "Relation statement must containt one constructor or Id : "+node ); + } } Resource coll = stmt.getResource(); //JE2010MUSTCHECK if ( op == SyntaxElement.NOT.getOperator() || @@ -768,6 +779,8 @@ public class RDFParser { URI id = getNodeId( node ); if ( id != null ) return new InstanceId( id ); else throw new AlignmentException("Cannot parse anonymous individual"); + } else if ( isPattern ) { // not necessarily with a variable (real patterns) + return new InstanceId(); } else { throw new AlignmentException("There is no pasrser for entity "+rdfType.getLocalName()); }