Search in sources :

Example 1 with Dominance

use of annis.sqlgen.model.Dominance in project ANNIS by korpling.

the class JoinListener method enterDirectDominance.

@Override
public void enterDirectDominance(AqlParser.DirectDominanceContext ctx) {
    QueryNode left = relationChain.get(relationIdx);
    QueryNode right = relationChain.get(relationIdx + 1);
    String layer = getLayerName(ctx.NAMED_DOMINANCE());
    Join j;
    if (ctx.LEFT_CHILD() != null) {
        j = new LeftDominance(right, layer);
    } else if (ctx.RIGHT_CHILD() != null) {
        j = new RightDominance(right, layer);
    } else {
        j = new Dominance(right, layer, 1);
    }
    left.addOutgoingJoin(addParsedLocation(ctx, j));
    if (ctx.anno != null) {
        LinkedList<QueryAnnotation> annotations = fromRelationAnnotation(ctx.anno);
        for (QueryAnnotation a : annotations) {
            j.addEdgeAnnotation(a);
        }
    }
}
Also used : QueryNode(annis.model.QueryNode) QueryAnnotation(annis.model.QueryAnnotation) Join(annis.model.Join) RightDominance(annis.sqlgen.model.RightDominance) Dominance(annis.sqlgen.model.Dominance) LeftDominance(annis.sqlgen.model.LeftDominance) RightDominance(annis.sqlgen.model.RightDominance) LeftDominance(annis.sqlgen.model.LeftDominance)

Example 2 with Dominance

use of annis.sqlgen.model.Dominance in project ANNIS by korpling.

the class JoinListener method enterIndirectDominance.

@Override
public void enterIndirectDominance(AqlParser.IndirectDominanceContext ctx) {
    QueryNode left = relationChain.get(relationIdx);
    QueryNode right = relationChain.get(relationIdx + 1);
    String layer = getLayerName(ctx.NAMED_DOMINANCE());
    left.addOutgoingJoin(addParsedLocation(ctx, new Dominance(right, layer)));
}
Also used : QueryNode(annis.model.QueryNode) RightDominance(annis.sqlgen.model.RightDominance) Dominance(annis.sqlgen.model.Dominance) LeftDominance(annis.sqlgen.model.LeftDominance)

Example 3 with Dominance

use of annis.sqlgen.model.Dominance in project ANNIS by korpling.

the class TestDefaultWhereClauseGenerator method shouldGenerateWhereConditionsForNodeNamedDirectDominance.

/**
 * WHERE conditions for named direct dominance operator (> name).
 */
@Theory
public void shouldGenerateWhereConditionsForNodeNamedDirectDominance(String componentPredicate) {
    // given
    String componentName = uniqueString();
    node23.addOutgoingJoin(new Dominance(node42, componentName, 1));
    // then
    checkEdgeConditions(componentPredicate, "d", componentName, false, join("=", "_rank23.id", "_rank42.parent"));
}
Also used : RightDominance(annis.sqlgen.model.RightDominance) Dominance(annis.sqlgen.model.Dominance) LeftDominance(annis.sqlgen.model.LeftDominance) TestUtils.uniqueString(annis.test.TestUtils.uniqueString) SqlConstraints.sqlString(annis.sqlgen.SqlConstraints.sqlString) Theory(org.junit.experimental.theories.Theory)

Example 4 with Dominance

use of annis.sqlgen.model.Dominance in project ANNIS by korpling.

the class TestDefaultWhereClauseGenerator method whereClauseForNodeEdgeAnnotationNot.

@Test
public void whereClauseForNodeEdgeAnnotationNot() {
    Dominance j = new Dominance(node23);
    j.addEdgeAnnotation(new QueryAnnotation("namespace2", "name2", "value2", TextMatching.EXACT_NOT_EQUAL));
    j.addEdgeAnnotation(new QueryAnnotation("namespace3", "name3", "value3", TextMatching.REGEXP_NOT_EQUAL));
    node42.addOutgoingJoin(j);
    checkWhereConditions("_rank_annotation23_1.qannotext NOT LIKE 'namespace2:name2:value2'", "_rank_annotation23_1.qannotext LIKE 'namespace2:name2:%'", "_rank_annotation23_2.qannotext !~ '^(namespace3:name3:(value3))$'", "_rank_annotation23_2.qannotext LIKE 'namespace3:name3:%'");
}
Also used : QueryAnnotation(annis.model.QueryAnnotation) RightDominance(annis.sqlgen.model.RightDominance) Dominance(annis.sqlgen.model.Dominance) LeftDominance(annis.sqlgen.model.LeftDominance) Test(org.junit.Test)

Example 5 with Dominance

use of annis.sqlgen.model.Dominance in project ANNIS by korpling.

the class TestDefaultWhereClauseGenerator method shouldGenerateWhereConditionsForNamedAndAnnotatedDirectDominance.

/**
 * WHERE conditions for annotated named direct dominance (> name
 * [annotation]).
 */
@Theory
public void shouldGenerateWhereConditionsForNamedAndAnnotatedDirectDominance(String componentPredicate) {
    // given
    String componentName = uniqueString();
    Join j = new Dominance(node42, componentName, 1);
    node23.addOutgoingJoin(j);
    j.addEdgeAnnotation(new QueryAnnotation("namespace3", "name3", "value3", TextMatching.REGEXP_EQUAL));
    // then
    checkEdgeConditions(componentPredicate, "d", componentName, false, join("=", "_rank23.id", "_rank42.parent"));
    checkWhereConditions(node42, "_rank_annotation42.qannotext ~ '^(namespace3:name3:(value3))$'");
}
Also used : QueryAnnotation(annis.model.QueryAnnotation) SqlConstraints.numberJoin(annis.sqlgen.SqlConstraints.numberJoin) Join(annis.model.Join) RightDominance(annis.sqlgen.model.RightDominance) Dominance(annis.sqlgen.model.Dominance) LeftDominance(annis.sqlgen.model.LeftDominance) TestUtils.uniqueString(annis.test.TestUtils.uniqueString) SqlConstraints.sqlString(annis.sqlgen.SqlConstraints.sqlString) Theory(org.junit.experimental.theories.Theory)

Aggregations

Dominance (annis.sqlgen.model.Dominance)13 LeftDominance (annis.sqlgen.model.LeftDominance)12 RightDominance (annis.sqlgen.model.RightDominance)12 Theory (org.junit.experimental.theories.Theory)6 QueryAnnotation (annis.model.QueryAnnotation)5 QueryNode (annis.model.QueryNode)5 Join (annis.model.Join)4 SqlConstraints.sqlString (annis.sqlgen.SqlConstraints.sqlString)2 PointingRelation (annis.sqlgen.model.PointingRelation)2 TestUtils.uniqueString (annis.test.TestUtils.uniqueString)2 Test (org.junit.Test)2 AnnisQLSemanticsException (annis.exceptions.AnnisQLSemanticsException)1 SqlConstraints.numberJoin (annis.sqlgen.SqlConstraints.numberJoin)1 CommonAncestor (annis.sqlgen.model.CommonAncestor)1 EqualValue (annis.sqlgen.model.EqualValue)1 Identical (annis.sqlgen.model.Identical)1 Inclusion (annis.sqlgen.model.Inclusion)1 LeftAlignment (annis.sqlgen.model.LeftAlignment)1 LeftOverlap (annis.sqlgen.model.LeftOverlap)1 Near (annis.sqlgen.model.Near)1