Search in sources :

Example 6 with ParseFieldsResult

use of org.folio.services.util.parser.ParseFieldsResult in project mod-source-record-storage by folio-org.

the class SearchExpressionParserUnitTest method shouldParseFieldsSearchExpression_for_SubFieldOperand_IsAbsentOperator.

@Test
public void shouldParseFieldsSearchExpression_for_SubFieldOperand_IsAbsentOperator() {
    // given
    String fieldsSearchExpression = "035.z is 'absent'";
    // when
    ParseFieldsResult result = parseFieldsSearchExpression(fieldsSearchExpression);
    // then
    assertTrue(result.isEnabled());
    assertEquals(emptyList(), result.getBindingParams());
    assertEquals(emptySet(), result.getFieldsToJoin());
    assertEquals("(id not in (select marc_id from marc_indexers_035 where subfield_no = 'z')) ", result.getWhereExpression());
}
Also used : ParseFieldsResult(org.folio.services.util.parser.ParseFieldsResult) Test(org.junit.Test)

Example 7 with ParseFieldsResult

use of org.folio.services.util.parser.ParseFieldsResult in project mod-source-record-storage by folio-org.

the class SearchExpressionParserUnitTest method shouldParseFieldsSearchExpression_for_PositionOperand_EqualsOperator.

@Test
public void shouldParseFieldsSearchExpression_for_PositionOperand_EqualsOperator() {
    // given
    String fieldsSearchExpression = "005.00_04 = '2014'";
    // when
    ParseFieldsResult result = parseFieldsSearchExpression(fieldsSearchExpression);
    // then
    assertTrue(result.isEnabled());
    assertEquals(singletonList("2014"), result.getBindingParams());
    assertEquals(new HashSet<>(singletonList("005")), result.getFieldsToJoin());
    assertEquals("substring(\"i005\".\"value\", 1, 4) = ?", result.getWhereExpression());
}
Also used : ParseFieldsResult(org.folio.services.util.parser.ParseFieldsResult) Test(org.junit.Test)

Example 8 with ParseFieldsResult

use of org.folio.services.util.parser.ParseFieldsResult in project mod-source-record-storage by folio-org.

the class SearchExpressionParserUnitTest method shouldParseFieldsSearchExpression_for_SubFieldOperand_LeftAnchoredEqualsOperator.

@Test
public void shouldParseFieldsSearchExpression_for_SubFieldOperand_LeftAnchoredEqualsOperator() {
    // given
    String fieldsSearchExpression = "035.a ^= '(OCoLC)'";
    // when
    ParseFieldsResult result = parseFieldsSearchExpression(fieldsSearchExpression);
    // then
    assertTrue(result.isEnabled());
    assertEquals(singletonList("(OCoLC)%"), result.getBindingParams());
    assertEquals(new HashSet<>(singletonList("035")), result.getFieldsToJoin());
    assertEquals("(\"i035\".\"subfield_no\" = 'a' and \"i035\".\"value\" like ?)", result.getWhereExpression());
}
Also used : ParseFieldsResult(org.folio.services.util.parser.ParseFieldsResult) Test(org.junit.Test)

Example 9 with ParseFieldsResult

use of org.folio.services.util.parser.ParseFieldsResult in project mod-source-record-storage by folio-org.

the class SearchExpressionParserUnitTest method shouldParseFieldsSearchExpression_for_IndicatorOperand_IsAbsentOperator.

@Test
public void shouldParseFieldsSearchExpression_for_IndicatorOperand_IsAbsentOperator() {
    // given
    String fieldsSearchExpression = "050.ind2 is 'absent'";
    // when
    ParseFieldsResult result = parseFieldsSearchExpression(fieldsSearchExpression);
    // then
    assertTrue(result.isEnabled());
    assertEquals(emptyList(), result.getBindingParams());
    assertEquals(emptySet(), result.getFieldsToJoin());
    assertEquals("(id in (select marc_id from marc_indexers_050 where ind2 = '#')) ", result.getWhereExpression());
}
Also used : ParseFieldsResult(org.folio.services.util.parser.ParseFieldsResult) Test(org.junit.Test)

Example 10 with ParseFieldsResult

use of org.folio.services.util.parser.ParseFieldsResult in project mod-source-record-storage by folio-org.

the class SearchExpressionParserUnitTest method shouldParseFieldsSearchExpression_for_SubFieldOperand_EqualsOperator.

@Test
public void shouldParseFieldsSearchExpression_for_SubFieldOperand_EqualsOperator() {
    // given
    String fieldsSearchExpression = "035.a = '(OCoLC)63611770'";
    // when
    ParseFieldsResult result = parseFieldsSearchExpression(fieldsSearchExpression);
    // then
    assertTrue(result.isEnabled());
    assertEquals(singletonList("(OCoLC)63611770"), result.getBindingParams());
    assertEquals(new HashSet<>(singletonList("035")), result.getFieldsToJoin());
    assertEquals("(\"i035\".\"subfield_no\" = 'a' and \"i035\".\"value\" = ?)", result.getWhereExpression());
}
Also used : ParseFieldsResult(org.folio.services.util.parser.ParseFieldsResult) Test(org.junit.Test)

Aggregations

ParseFieldsResult (org.folio.services.util.parser.ParseFieldsResult)26 Test (org.junit.Test)24 Lists (com.google.common.collect.Lists)1 ReactiveClassicGenericQueryExecutor (io.github.jklingsporn.vertx.jooq.classic.reactivepg.ReactiveClassicGenericQueryExecutor)1 QueryResult (io.github.jklingsporn.vertx.jooq.shared.internal.QueryResult)1 Flowable (io.reactivex.Flowable)1 Future (io.vertx.core.Future)1 Promise (io.vertx.core.Promise)1 PgPool (io.vertx.reactivex.pgclient.PgPool)1 Row (io.vertx.sqlclient.Row)1 String.format (java.lang.String.format)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 ZoneOffset (java.time.ZoneOffset)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1