Skip to content

Commit

Permalink
[Enhancement #176] Extend SOQL grammar with MEMBER OF, add parser tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ledsoft committed Jul 20, 2023
1 parent dd280ee commit 4ecb097
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ simpleConditionalExpression
: comparisonExpression
| likeExpression
| inExpression
| memberOfExpression
;

inExpression
Expand All @@ -78,9 +79,13 @@ literal
;

likeExpression
: stringExpression ('NOT')? LIKE whereClauseValue
: stringExpression (NOT)? LIKE whereClauseValue
;

memberOfExpression
: inItem (NOT)? MEMBEROF whereClauseParam
;

comparisonExpression
: stringExpression COMPARISON_OPERATOR stringExpression
| simpleArithmeticExpression COMPARISON_OPERATOR simpleArithmeticExpression
Expand Down Expand Up @@ -182,6 +187,8 @@ LIKE: 'LIKE' ;

IN: 'IN' ;

MEMBEROF: 'MEMBER OF' ;

COMPARISON_OPERATOR: '>' | '<' | '>=' | '<=' | '=' | '<>' | '!=' ;

DOT: '.' ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public class OWLClassF {
@OWLDataProperty(iri = Vocabulary.p_f_stringAttribute)
private String secondStringAttribute;

@Sequence(type = SequenceType.simple, ObjectPropertyHasNextIRI = "http://krizik.felk.cvut.cz/ontologies/jopa/attributes#F-hasSimpleNext")
@OWLObjectProperty(iri = "http://krizik.felk.cvut.cz/ontologies/jopa/attributes#F-hasSimpleSequence")
@OWLObjectProperty(iri = Vocabulary.p_f_setAttribute)
private Set<OWLClassA> simpleSet;

public OWLClassF() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Vocabulary {
public static final String c_Phone = CLASS_BASE + "Phone";

public static final String p_f_stringAttribute = ATTRIBUTE_BASE + "f-stringAttribute";
public static final String p_f_setAttribute = ATTRIBUTE_BASE + "f-hasA";

public static final String p_g_hasH = ATTRIBUTE_BASE + "hasH";
public static final String p_h_hasA = ATTRIBUTE_BASE + "hasA";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ public static void initOWLClassFMocks(IdentifiableEntityType<OWLClassF> etMock,
when(etMock.getIdentifier()).thenReturn(idMock);
when(idMock.getJavaField()).thenReturn(OWLClassF.class.getDeclaredField("uri"));
when(idMock.getDeclaringType()).thenReturn(etMock);
when(idMock.getName()).thenReturn("uri");
when(etMock.getLifecycleListenerManager()).thenReturn(EntityLifecycleListenerManager.empty());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
* Copyright (C) 2023 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
* version.
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.jopa.query.soql;

Expand Down Expand Up @@ -733,6 +731,13 @@ void parseQueryWithTypesAndMemberOf() {
parseAndAssertEquality(soql, expectedSparql);
}

@Test
void parseQueryWithMemberOfPluralAttribute() {
final String soql = "SELECT f FROM OWLClassF f WHERE :aInstance MEMBER OF f.simpleSet";
final String expectedSparql = "SELECT ?x WHERE { ?x a " + strUri(Vocabulary.c_OwlClassF) + " . ?x " + strUri(Vocabulary.p_f_setAttribute) + " ?aInstance . }";
parseAndAssertEquality(soql, expectedSparql);
}

/**
* Bug #178
*/
Expand Down

0 comments on commit 4ecb097

Please sign in to comment.