add extra handling of titlePhrase/titleComplete for CQL->RPN

This commit is contained in:
Jörg Prante 2023-04-19 19:05:35 +02:00
parent 2bd1d28c21
commit 736c4c4f65
4 changed files with 41 additions and 3 deletions

View file

@ -1,5 +1,5 @@
group = org.xbib
name = z3950
version = 5.1.7
version = 5.1.8
org.gradle.warning.mode = ALL

View file

@ -59,7 +59,7 @@ public final class CQLRPNGenerator implements Visitor {
private RPNQuery rpnQuery;
private final boolean wordListSupported;
private boolean wordListSupported;
public CQLRPNGenerator() {
this(StandardCharsets.ISO_8859_1, null, true);
@ -243,8 +243,9 @@ public final class CQLRPNGenerator implements Visitor {
push(attributeElements, createAttributeElement(2, 5));
case NOT_EQUALS ->
push(attributeElements, createAttributeElement(2, 6));
case ALL, ANY -> { // 4=6 word list
case ALL, ANY -> {
push(attributeElements, createAttributeElement(2, 3));
// 4=6 word list
if (wordListSupported) {
replace(attributeElements, createAttributeElement(4, 6));
}
@ -304,6 +305,19 @@ public final class CQLRPNGenerator implements Visitor {
if (attributeValue == 31) {
replace(attributeElements, createAttributeElement(4, 5));
}
// titlePhrase --> use phrase attribute
if ("titlePhrase".equals(index.getName())) {
replace(attributeElements, createAttributeElement(4, 1));
replace(attributeElements, createAttributeElement(6, 1));
wordListSupported = false;
}
// titleComplete --> use phrase attribute and use structure completeness
if ("titleComplete".equals(index.getName())) {
replace(attributeElements, createAttributeElement(4, 1));
replace(attributeElements, createAttributeElement(6, 3));
wordListSupported = false;
}
push(attributeElements, createAttributeElement(attributeType, attributeValue));
}

View file

@ -266,6 +266,8 @@ timePeriod=1125
timePeriodStructured=1127
timePeriodTextual=1126
title=4
titlePhrase=4
titleComplete=4
titleAbbreviated=43
titleAddedTitlePage=37
titleCaption=38

View file

@ -92,4 +92,26 @@ class CQL2RPNTest {
String q = generator.getQueryResult().toString();
assertEquals("{attributeSetId 1.2.840.10003.3.1, rpn {op {attrTerm {attributes {{attributeType 3, attributeValue {numeric 3}}{attributeType 4, attributeValue {numeric 2}}{attributeType 5, attributeValue {numeric 100}}{attributeType 6, attributeValue {numeric 1}}{attributeType 1, attributeValue {numeric 4}}{attributeType 2, attributeValue {numeric 3}}}, term {general \"K\\703\\666ln\"}}}}}", q);
}
@Test
void testTitlePhrase() {
String cql = "bib.titlePhrase = \"Die Berufsfreiheit\"";
CQLParser parser = new CQLParser(cql);
parser.parse();
CQLRPNGenerator generator = new CQLRPNGenerator(StandardCharsets.UTF_8);
parser.getCQLQuery().accept(generator);
String q = generator.getQueryResult().toString();
assertEquals("{attributeSetId 1.2.840.10003.3.1, rpn {op {attrTerm {attributes {{attributeType 3, attributeValue {numeric 3}}{attributeType 5, attributeValue {numeric 100}}{attributeType 4, attributeValue {numeric 1}}{attributeType 6, attributeValue {numeric 1}}{attributeType 1, attributeValue {numeric 4}}{attributeType 2, attributeValue {numeric 3}}}, term {general \"Die Berufsfreiheit\"}}}}}", q);
}
@Test
void testTitleComplete() {
String cql = "bib.titleComplete all \"Die Berufsfreiheit\"";
CQLParser parser = new CQLParser(cql);
parser.parse();
CQLRPNGenerator generator = new CQLRPNGenerator(StandardCharsets.UTF_8);
parser.getCQLQuery().accept(generator);
String q = generator.getQueryResult().toString();
assertEquals("{attributeSetId 1.2.840.10003.3.1, rpn {op {attrTerm {attributes {{attributeType 3, attributeValue {numeric 3}}{attributeType 5, attributeValue {numeric 100}}{attributeType 4, attributeValue {numeric 1}}{attributeType 6, attributeValue {numeric 3}}{attributeType 1, attributeValue {numeric 4}}{attributeType 2, attributeValue {numeric 3}}}, term {general \"Die Berufsfreiheit\"}}}}}", q);
}
}