new CQL default context
This commit is contained in:
parent
7475a5f565
commit
1a0ff7d6c8
6 changed files with 31 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
group = org.xbib
|
||||
name = z3950
|
||||
version = 2.3.0
|
||||
version = 2.3.1
|
||||
|
||||
gradle.wrapper.version = 6.6.1
|
||||
netty.version = 4.1.65.Final
|
||||
|
|
|
@ -53,6 +53,7 @@ public final class CQLRPNGenerator implements Visitor {
|
|||
private static final long serialVersionUID = 8199395368653216950L;
|
||||
|
||||
{
|
||||
put("default", ResourceBundle.getBundle("org.xbib.z3950.common.cql.default"));
|
||||
put("cql", ResourceBundle.getBundle("org.xbib.z3950.common.cql.cql"));
|
||||
put("bib", ResourceBundle.getBundle("org.xbib.z3950.common.cql.bib-1"));
|
||||
put("dc", ResourceBundle.getBundle("org.xbib.z3950.common.cql.dc"));
|
||||
|
@ -67,13 +68,14 @@ public final class CQLRPNGenerator implements Visitor {
|
|||
private RPNQuery rpnQuery;
|
||||
|
||||
public CQLRPNGenerator() {
|
||||
this.attributeElements = new Stack<>();
|
||||
this.result = new Stack<>();
|
||||
this(null);
|
||||
}
|
||||
|
||||
public CQLRPNGenerator(Collection<AttributeElement> attributeElements) {
|
||||
this.attributeElements = new Stack<>();
|
||||
this.attributeElements.addAll(attributeElements);
|
||||
if (attributeElements != null) {
|
||||
this.attributeElements.addAll(attributeElements);
|
||||
}
|
||||
this.result = new Stack<>();
|
||||
}
|
||||
|
||||
|
@ -294,7 +296,7 @@ public final class CQLRPNGenerator implements Visitor {
|
|||
public void visit(Index index) {
|
||||
String context = index.getContext();
|
||||
if (context == null) {
|
||||
context = "dc"; // default context
|
||||
context = "default"; // default context
|
||||
}
|
||||
int attributeType = 1; // use attribute set: bib-1 = 1
|
||||
int attributeValue = getUseAttr(context, index.getName());
|
||||
|
|
|
@ -3,4 +3,4 @@ publisher=1018
|
|||
allRecords=1035
|
||||
allIndexes=1035
|
||||
anyIndexes=1035
|
||||
keywords=1016
|
||||
keywords=1016
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
title=4
|
||||
identifier=12
|
||||
date=31
|
||||
creator=1003
|
||||
publisher=1018
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
# Default properties
|
||||
# this is a mashup of all common search keys
|
||||
identifier=12
|
||||
publisher=1018
|
||||
all=1035
|
||||
keywords=1016
|
||||
title=4
|
||||
date=31
|
||||
creator=1003
|
||||
format=1220
|
||||
author=1003
|
||||
intitle=5
|
||||
isbn=7
|
||||
issn=8
|
||||
doi=1094
|
||||
type=1031
|
|
@ -22,7 +22,7 @@ class CQL2RPNTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testPhrase() {
|
||||
void testPhraseWithDoubleQuotes() {
|
||||
String cql = "dc.title = \"a phrase\"";
|
||||
CQLParser parser = new CQLParser(cql);
|
||||
parser.parse();
|
||||
|
@ -33,15 +33,18 @@ class CQL2RPNTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testWithAttribute() {
|
||||
void testWithOverridingAnAttribute() {
|
||||
AttributeElement ae = new AttributeElement();
|
||||
ae.attributeType = new ASN1Integer(2);
|
||||
ae.attributeValue = new AttributeElementAttributeValue();
|
||||
ae.attributeValue.numeric = new ASN1Integer(4);
|
||||
String cql = "dc.title = \"a phrase\"";
|
||||
CQLParser parser = new CQLParser(cql);
|
||||
parser.parse();
|
||||
CQLRPNGenerator generator = new CQLRPNGenerator(Collections.singleton(ae));
|
||||
parser.getCQLQuery().accept(generator);
|
||||
String q = generator.getQueryResult().toString();
|
||||
assertEquals("{attributeSetId 1.2.840.10003.3.1, rpn {op {attrTerm {attributes {{attributeType 2, attributeValue {numeric 3}}{attributeType 4, attributeValue {numeric 1}}{attributeType 5, attributeValue {numeric 100}}{attributeType 1, attributeValue {numeric 4}}}, term {general \"a phrase\"}}}}}", q);
|
||||
// not really working, it adds, not override
|
||||
assertEquals("{attributeSetId 1.2.840.10003.3.1, rpn {op {attrTerm {attributes {{attributeType 2, attributeValue {numeric 4}}{attributeType 2, attributeValue {numeric 3}}{attributeType 4, attributeValue {numeric 1}}{attributeType 5, attributeValue {numeric 100}}{attributeType 1, attributeValue {numeric 4}}}, term {general \"a phrase\"}}}}}", q);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue