Skip to content

Commit

Permalink
Dokonceni uspesnosti integracnich testov, doplneni nacteni IRI pro va…
Browse files Browse the repository at this point in the history
…icnasobny parameter(object1.object2...objectn.attribute)
  • Loading branch information
krupama3 committed Dec 24, 2019
1 parent d603e02 commit 8d063da
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
Zoznam čo nieje implementované:
1. v klauzule WHERE niesu rozoznávané zátvorky v súvislosti s logickými operátormi
2. implementácia zatiaľ nevie vyľadať IRI, pokiaľ má attribut viac ako 2 fragmenty
(funkčné: object.attribute, nefunkčné: object1.object2.attribute)
3. konštruktor CONSTRUCT
4. je možné vyľadávať len jeden objekt => "SELECT ?x ?y" to zatiaľ nevytvorí, "SELECT ?attribute" to tiež nevytvorí
2. konštruktor CONSTRUCT
3. je možné vyľadávať len jeden objekt => "SELECT ?x ?y" to zatiaľ nevytvorí, "SELECT ?attribute" to tiež nevytvorí
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package cz.cvut.kbss.jopa.query.soql;
import cz.cvut.kbss.jopa.model.MetamodelImpl;
import cz.cvut.kbss.jopa.model.metamodel.AbstractAttribute;
import cz.cvut.kbss.jopa.model.metamodel.EntityType;
import cz.cvut.kbss.jopa.model.metamodel.EntityTypeImpl;
import cz.cvut.kbss.jopa.model.annotations.CascadeType;
import cz.cvut.kbss.jopa.model.metamodel.*;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ErrorNode;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNode;

import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -412,20 +412,32 @@ private EntityTypeImpl<?> getEntityType(String name){
return null;
}

private EntityTypeImpl<?> getEntityType(Type<?> type){
if(metamodel == null){
return null;
}
Iterator<EntityType<?>> iterator = metamodel.getEntities().iterator();
while(iterator.hasNext()){
EntityTypeImpl<?> entityType = (EntityTypeImpl<?>) iterator.next();
if(entityType.equals(type)){
return entityType;
}
}
return null;
}

private void setAllNodesIris(EntityTypeImpl<?> entityType, SoqlNode node){
AbstractAttribute abstractAttribute = entityType.getAttribute(node.getValue());
SingularAttributeImpl abstractAttribute = (SingularAttributeImpl) entityType.getAttribute(node.getValue());
//not implemented case of 3 or more fragments (chained SoqlNodes)
// if(node.hasNextChild()){
if(false) {
// from abstractAttribute get name of Java Class of abstractAttribute
String className = "";
EntityTypeImpl<?> attrEntityType = getEntityType(className);
node.setIri(abstractAttribute.getIRI().toString());
if(node.hasNextChild()){
// if(false) {
Type<?> type = abstractAttribute.getType();
EntityTypeImpl<?> attrEntityType = getEntityType(type);
if(attrEntityType == null){
return;
}
setAllNodesIris(attrEntityType, node.getChild());
}else{
node.setIri(abstractAttribute.getIRI().toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void testFindByObjectPropertyAttribute() {
final OWLClassD expected = Generators.getRandomItem(QueryTestEnvironment.getData(OWLClassD.class));
final OWLClassD result = getEntityManager()
.createQuery("SELECT d FROM OWLClassD d WHERE d.owlClassA = :a", OWLClassD.class)
.setParameter("a", expected.getOwlClassA()).getSingleResult();
.setParameter("a", expected.getOwlClassA().getUri()).getSingleResult();
assertEquals(expected.getUri(), result.getUri());
assertEquals(expected.getOwlClassA().getUri(), result.getOwlClassA().getUri());
}
Expand All @@ -61,7 +61,7 @@ public void testFindByConjunctionOfAttributes() {
final List<OWLClassT> result = getEntityManager()
.createQuery("SELECT t FROM OWLClassT t WHERE t.owlClassA = :a AND t.intAttribute <= :intAtt",
OWLClassT.class)
.setParameter("a", sample.getOwlClassA())
.setParameter("a", sample.getOwlClassA().getUri())
.setParameter("intAtt", sample.getIntAttribute()).getResultList();
assertFalse(result.isEmpty());
for (OWLClassT item : result) {
Expand Down Expand Up @@ -89,7 +89,7 @@ public void testFindByDisjunctionOfAttributes() {
final List<OWLClassT> result = getEntityManager()
.createQuery("SELECT t FROM OWLClassT t WHERE t.owlClassA = :a OR t.intAttribute <= :intAtt",
OWLClassT.class)
.setParameter("a", sample.getOwlClassA())
.setParameter("a", sample.getOwlClassA().getUri())
.setParameter("intAtt", sample.getIntAttribute()).getResultList();
assertFalse(result.isEmpty());
for (OWLClassT item : result) {
Expand All @@ -99,7 +99,7 @@ public void testFindByDisjunctionOfAttributes() {
}
}

@Disabled //problem wit chained attribute IRI, impl cant get entityType of object as attribute
// @Disabled //problem wit chained attribute IRI, impl cant get entityType of object as attribute
@Test
public void testFindByTransitiveAttributeValue() {
final OWLClassD expected = Generators.getRandomItem(QueryTestEnvironment.getData(OWLClassD.class));
Expand Down

0 comments on commit 8d063da

Please sign in to comment.