Compare commits
No commits in common. "d3115719a19cc3b53822243f71a23a0b1f28028c" and "9a3035098adf7b1ce4e63fa6493564139635b765" have entirely different histories.
d3115719a1
...
9a3035098a
30 changed files with 270 additions and 740 deletions
19
build.gradle
19
build.gradle
|
@ -1,12 +1,6 @@
|
|||
|
||||
plugins {
|
||||
id "pmd"
|
||||
id 'maven-publish'
|
||||
id 'signing'
|
||||
id "io.github.gradle-nexus.publish-plugin" version "2.0.0-rc-1"
|
||||
//id "com.github.spotbugs" version "6.0.0-beta.3"
|
||||
id "org.cyclonedx.bom" version "1.7.4"
|
||||
id "org.xbib.gradle.plugin.asciidoctor" version "3.0.0"
|
||||
id "de.marcphilipp.nexus-publish" version "0.4.0"
|
||||
id "io.codearte.nexus-staging" version "0.21.1"
|
||||
}
|
||||
|
||||
wrapper {
|
||||
|
@ -30,12 +24,9 @@ ext {
|
|||
}
|
||||
|
||||
subprojects {
|
||||
apply from: rootProject.file('gradle/repositories/maven.gradle')
|
||||
apply from: rootProject.file('gradle/ide/idea.gradle')
|
||||
apply from: rootProject.file('gradle/compile/java.gradle')
|
||||
apply from: rootProject.file('gradle/test/junit5.gradle')
|
||||
apply from: rootProject.file('gradle/documentation/asciidoc.gradle')
|
||||
apply from: rootProject.file('gradle/quality/pmd.gradle')
|
||||
apply from: rootProject.file('gradle/publish/maven.gradle')
|
||||
apply from: rootProject.file('gradle/publishing/publication.gradle')
|
||||
}
|
||||
apply from: rootProject.file('gradle/publish/sonatype.gradle')
|
||||
apply from: rootProject.file('gradle/quality/cyclonedx.gradle')
|
||||
apply from: rootProject.file('gradle/publishing/sonatype.gradle')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
group = org.xbib
|
||||
name = z3950
|
||||
version = 6.0.0
|
||||
version = 5.1.1
|
||||
|
||||
org.gradle.warning.mode = ALL
|
||||
|
|
|
@ -2,12 +2,17 @@
|
|||
apply plugin: 'java-library'
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
modularity.inferModulePath.set(true)
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
compileJava {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
compileTestJava {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
jar {
|
||||
|
@ -16,9 +21,21 @@ jar {
|
|||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
classifier 'sources'
|
||||
from sourceSets.main.allSource
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
classifier 'javadoc'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar, javadocJar
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.fork = true
|
||||
options.forkOptions.jvmArgs += ['-Duser.language=en','-Duser.country=US']
|
||||
options.compilerArgs.add('-Xlint:all,-exports')
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
|
|
@ -1,5 +1,26 @@
|
|||
apply plugin: 'org.xbib.gradle.plugin.asciidoctor'
|
||||
|
||||
configurations {
|
||||
asciidoclet
|
||||
}
|
||||
|
||||
dependencies {
|
||||
asciidoclet "org.asciidoctor:asciidoclet:${project.property('asciidoclet.version')}"
|
||||
}
|
||||
|
||||
/*
|
||||
javadoc {
|
||||
options.docletpath = configurations.asciidoclet.files.asType(List)
|
||||
options.doclet = 'org.asciidoctor.Asciidoclet'
|
||||
//options.overview = "src/docs/asciidoclet/overview.adoc"
|
||||
options.addStringOption "-base-dir", "${projectDir}"
|
||||
options.addStringOption "-attribute",
|
||||
"name=${project.name},version=${project.version},title-link=https://github.com/xbib/${project.name}"
|
||||
configure(options) {
|
||||
noTimestamp = true
|
||||
}
|
||||
}*/
|
||||
|
||||
asciidoctor {
|
||||
attributes 'source-highlighter': 'coderay',
|
||||
toc: 'left',
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
|
||||
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
|
||||
nexusPublishing {
|
||||
repositories {
|
||||
sonatype {
|
||||
username = project.property('ossrhUsername')
|
||||
password = project.property('ossrhPassword')
|
||||
packageGroup = "org.xbib"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,13 @@
|
|||
|
||||
apply plugin: "de.marcphilipp.nexus-publish"
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
"${project.name}"(MavenPublication) {
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java
|
||||
artifact sourcesJar
|
||||
artifact javadocJar
|
||||
pom {
|
||||
artifactId = project.name
|
||||
name = project.name
|
||||
description = rootProject.ext.description
|
||||
url = rootProject.ext.url
|
||||
|
@ -46,6 +49,18 @@ publishing {
|
|||
if (project.hasProperty("signing.keyId")) {
|
||||
apply plugin: 'signing'
|
||||
signing {
|
||||
sign publishing.publications."${project.name}"
|
||||
sign publishing.publications.mavenJava
|
||||
}
|
||||
}
|
||||
|
||||
if (project.hasProperty("ossrhUsername")) {
|
||||
nexusPublishing {
|
||||
repositories {
|
||||
sonatype {
|
||||
username = project.property('ossrhUsername')
|
||||
password = project.property('ossrhPassword')
|
||||
packageGroup = "org.xbib"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
gradle/publishing/sonatype.gradle
Normal file
11
gradle/publishing/sonatype.gradle
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
|
||||
|
||||
apply plugin: 'io.codearte.nexus-staging'
|
||||
|
||||
nexusStaging {
|
||||
username = project.property('ossrhUsername')
|
||||
password = project.property('ossrhPassword')
|
||||
packageGroup = "org.xbib"
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
tasks.withType(Checkstyle) {
|
||||
ignoreFailures = true
|
||||
reports {
|
||||
xml.getRequired().set(true)
|
||||
html.getRequired().set(true)
|
||||
}
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
configFile = rootProject.file('gradle/quality/checkstyle.xml')
|
||||
ignoreFailures = true
|
||||
showViolations = true
|
||||
checkstyleMain {
|
||||
source = sourceSets.main.allSource
|
||||
}
|
||||
}
|
|
@ -1,333 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
|
||||
<!-- This is a checkstyle configuration file. For descriptions of
|
||||
what the following rules do, please see the checkstyle configuration
|
||||
page at http://checkstyle.sourceforge.net/config.html -->
|
||||
|
||||
<module name="Checker">
|
||||
|
||||
<module name="BeforeExecutionExclusionFileFilter">
|
||||
<property name="fileNamePattern" value=".*(Example|Test|module-info)(\$.*)?"/>
|
||||
</module>
|
||||
|
||||
<module name="FileTabCharacter">
|
||||
<!-- Checks that there are no tab characters in the file.
|
||||
-->
|
||||
</module>
|
||||
|
||||
<module name="NewlineAtEndOfFile">
|
||||
<property name="lineSeparator" value="lf"/>
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<!-- Checks that FIXME is not used in comments. TODO is preferred.
|
||||
-->
|
||||
<property name="format" value="((//.*)|(\*.*))FIXME" />
|
||||
<property name="message" value='TODO is preferred to FIXME. e.g. "TODO(johndoe): Refactor when v2 is released."' />
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<!-- Checks that TODOs are named. (Actually, just that they are followed
|
||||
by an open paren.)
|
||||
-->
|
||||
<property name="format" value="((//.*)|(\*.*))TODO[^(]" />
|
||||
<property name="message" value='All TODOs should be named. e.g. "TODO(johndoe): Refactor when v2 is released."' />
|
||||
</module>
|
||||
|
||||
<module name="JavadocPackage">
|
||||
<!-- Checks that each Java package has a Javadoc file used for commenting.
|
||||
Only allows a package-info.java, not package.html. -->
|
||||
</module>
|
||||
|
||||
<!-- All Java AST specific tests live under TreeWalker module. -->
|
||||
<module name="TreeWalker">
|
||||
|
||||
<!--
|
||||
|
||||
IMPORT CHECKS
|
||||
|
||||
-->
|
||||
|
||||
<module name="RedundantImport">
|
||||
<!-- Checks for redundant import statements. -->
|
||||
<property name="severity" value="error"/>
|
||||
</module>
|
||||
|
||||
<module name="ImportOrder">
|
||||
<!-- Checks for out of order import statements. -->
|
||||
|
||||
<property name="severity" value="warning"/>
|
||||
<!-- <property name="tokens" value="IMPORT, STATIC_IMPORT"/> -->
|
||||
<property name="separated" value="false"/>
|
||||
<property name="groups" value="*"/>
|
||||
<!-- <property name="option" value="above"/> -->
|
||||
<property name="sortStaticImportsAlphabetically" value="true"/>
|
||||
</module>
|
||||
|
||||
<module name="CustomImportOrder">
|
||||
<!-- <property name="customImportOrderRules" value="THIRD_PARTY_PACKAGE###SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE###STATIC"/> -->
|
||||
<!-- <property name="specialImportsRegExp" value="^javax\."/> -->
|
||||
<!-- <property name="standardPackageRegExp" value="^java\."/> -->
|
||||
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
||||
<property name="separateLineBetweenGroups" value="false"/>
|
||||
</module>
|
||||
|
||||
<!--
|
||||
|
||||
JAVADOC CHECKS
|
||||
|
||||
-->
|
||||
|
||||
<!-- Checks for Javadoc comments. -->
|
||||
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
|
||||
<module name="JavadocMethod">
|
||||
<property name="accessModifiers" value="protected"/>
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
</module>
|
||||
|
||||
<module name="JavadocType">
|
||||
<property name="scope" value="protected"/>
|
||||
<property name="severity" value="error"/>
|
||||
</module>
|
||||
|
||||
<module name="JavadocStyle">
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<!--
|
||||
|
||||
NAMING CHECKS
|
||||
|
||||
-->
|
||||
|
||||
<!-- Item 38 - Adhere to generally accepted naming conventions -->
|
||||
|
||||
<module name="PackageName">
|
||||
<!-- Validates identifiers for package names against the
|
||||
supplied expression. -->
|
||||
<!-- Here the default checkstyle rule restricts package name parts to
|
||||
seven characters, this is not in line with common practice at Google.
|
||||
-->
|
||||
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="TypeNameCheck">
|
||||
<!-- Validates static, final fields against the
|
||||
expression "^[A-Z][a-zA-Z0-9]*$". -->
|
||||
<metadata name="altname" value="TypeName"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="ConstantNameCheck">
|
||||
<!-- Validates non-private, static, final fields against the supplied
|
||||
public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
|
||||
<metadata name="altname" value="ConstantName"/>
|
||||
<property name="applyToPublic" value="true"/>
|
||||
<property name="applyToProtected" value="true"/>
|
||||
<property name="applyToPackage" value="true"/>
|
||||
<property name="applyToPrivate" value="false"/>
|
||||
<property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="StaticVariableNameCheck">
|
||||
<!-- Validates static, non-final fields against the supplied
|
||||
expression "^[a-z][a-zA-Z0-9]*_?$". -->
|
||||
<metadata name="altname" value="StaticVariableName"/>
|
||||
<property name="applyToPublic" value="true"/>
|
||||
<property name="applyToProtected" value="true"/>
|
||||
<property name="applyToPackage" value="true"/>
|
||||
<property name="applyToPrivate" value="true"/>
|
||||
<property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="MemberNameCheck">
|
||||
<!-- Validates non-static members against the supplied expression. -->
|
||||
<metadata name="altname" value="MemberName"/>
|
||||
<property name="applyToPublic" value="true"/>
|
||||
<property name="applyToProtected" value="true"/>
|
||||
<property name="applyToPackage" value="true"/>
|
||||
<property name="applyToPrivate" value="true"/>
|
||||
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="MethodNameCheck">
|
||||
<!-- Validates identifiers for method names. -->
|
||||
<metadata name="altname" value="MethodName"/>
|
||||
<property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="ParameterName">
|
||||
<!-- Validates identifiers for method parameters against the
|
||||
expression "^[a-z][a-zA-Z0-9]*$". -->
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="LocalFinalVariableName">
|
||||
<!-- Validates identifiers for local final variables against the
|
||||
expression "^[a-z][a-zA-Z0-9]*$". -->
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="LocalVariableName">
|
||||
<!-- Validates identifiers for local variables against the
|
||||
expression "^[a-z][a-zA-Z0-9]*$". -->
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
LENGTH and CODING CHECKS
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<module name="LeftCurly">
|
||||
<!-- Checks for placement of the left curly brace ('{'). -->
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="RightCurly">
|
||||
<!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
|
||||
the same line. e.g., the following example is fine:
|
||||
<pre>
|
||||
if {
|
||||
...
|
||||
} else
|
||||
</pre>
|
||||
-->
|
||||
<!-- This next example is not fine:
|
||||
<pre>
|
||||
if {
|
||||
...
|
||||
}
|
||||
else
|
||||
</pre>
|
||||
-->
|
||||
<property name="option" value="same"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<!-- Checks for braces around if and else blocks -->
|
||||
<module name="NeedBraces">
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
|
||||
</module>
|
||||
|
||||
<module name="UpperEll">
|
||||
<!-- Checks that long constants are defined with an upper ell.-->
|
||||
<property name="severity" value="error"/>
|
||||
</module>
|
||||
|
||||
<module name="FallThrough">
|
||||
<!-- Warn about falling through to the next case statement. Similar to
|
||||
javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
|
||||
on the last non-blank line preceding the fallen-into case contains 'fall through' (or
|
||||
some other variants which we don't publicized to promote consistency).
|
||||
-->
|
||||
<property name="reliefPattern"
|
||||
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
|
||||
<property name="severity" value="error"/>
|
||||
</module>
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
MODIFIERS CHECKS
|
||||
|
||||
-->
|
||||
|
||||
<module name="ModifierOrder">
|
||||
<!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
|
||||
8.4.3. The prescribed order is:
|
||||
public, protected, private, abstract, static, final, transient, volatile,
|
||||
synchronized, native, strictfp
|
||||
-->
|
||||
</module>
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
WHITESPACE CHECKS
|
||||
|
||||
-->
|
||||
|
||||
<module name="WhitespaceAround">
|
||||
<!-- Checks that various tokens are surrounded by whitespace.
|
||||
This includes most binary operators and keywords followed
|
||||
by regular or curly braces.
|
||||
-->
|
||||
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
|
||||
BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
|
||||
EQUAL, GE, GT, LAND, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
|
||||
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
|
||||
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
|
||||
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
|
||||
SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
|
||||
<property name="severity" value="error"/>
|
||||
</module>
|
||||
|
||||
<module name="WhitespaceAfter">
|
||||
<!-- Checks that commas, semicolons and typecasts are followed by
|
||||
whitespace.
|
||||
-->
|
||||
<property name="tokens" value="COMMA, SEMI, TYPECAST"/>
|
||||
</module>
|
||||
|
||||
<module name="NoWhitespaceAfter">
|
||||
<!-- Checks that there is no whitespace after various unary operators.
|
||||
Linebreaks are allowed.
|
||||
-->
|
||||
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
|
||||
UNARY_PLUS"/>
|
||||
<property name="allowLineBreaks" value="true"/>
|
||||
<property name="severity" value="error"/>
|
||||
</module>
|
||||
|
||||
<module name="NoWhitespaceBefore">
|
||||
<!-- Checks that there is no whitespace before various unary operators.
|
||||
Linebreaks are allowed.
|
||||
-->
|
||||
<property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
|
||||
<property name="allowLineBreaks" value="true"/>
|
||||
<property name="severity" value="error"/>
|
||||
</module>
|
||||
|
||||
<module name="ParenPad">
|
||||
<!-- Checks that there is no whitespace before close parens or after
|
||||
open parens.
|
||||
-->
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
|
||||
<module name="LineLength">
|
||||
<!-- Checks if a line is too long. -->
|
||||
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="128"/>
|
||||
<property name="severity" value="error"/>
|
||||
|
||||
<!--
|
||||
The default ignore pattern exempts the following elements:
|
||||
- import statements
|
||||
- long URLs inside comments
|
||||
-->
|
||||
|
||||
<property name="ignorePattern"
|
||||
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
|
||||
default="^(package .*;\s*)|(import .*;\s*)|( *(\*|//).*https?://.*)$"/>
|
||||
</module>
|
||||
</module>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
cyclonedxBom {
|
||||
includeConfigs = [ 'runtimeClasspath' ]
|
||||
skipConfigs = [ 'compileClasspath', 'testCompileClasspath' ]
|
||||
projectType = "library"
|
||||
schemaVersion = "1.4"
|
||||
destination = file("build/reports")
|
||||
outputName = "bom"
|
||||
outputFormat = "json"
|
||||
includeBomSerialNumber = true
|
||||
componentVersion = "2.0.0"
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
|
||||
apply plugin: 'pmd'
|
||||
|
||||
tasks.withType(Pmd) {
|
||||
ignoreFailures = true
|
||||
reports {
|
||||
xml.getRequired().set(true)
|
||||
html.getRequired().set(true)
|
||||
}
|
||||
}
|
||||
|
||||
pmd {
|
||||
ignoreFailures = true
|
||||
consoleOutput = false
|
||||
toolVersion = "6.51.0"
|
||||
ruleSetFiles = rootProject.files('gradle/quality/pmd/category/java/bestpractices.xml')
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
|
||||
sonarqube {
|
||||
properties {
|
||||
property "sonar.projectName", "${project.group} ${project.name}"
|
||||
property "sonar.sourceEncoding", "UTF-8"
|
||||
property "sonar.tests", "src/test/java"
|
||||
property "sonar.scm.provider", "git"
|
||||
property "sonar.junit.reportsPath", "build/test-results/test/"
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
|
||||
apply plugin: 'com.github.spotbugs'
|
||||
|
||||
spotbugs {
|
||||
effort = "max"
|
||||
reportLevel = "low"
|
||||
ignoreFailures = true
|
||||
}
|
||||
|
||||
spotbugsMain {
|
||||
reports {
|
||||
xml.getRequired().set(false)
|
||||
html.getRequired().set(true)
|
||||
}
|
||||
}
|
|
@ -1,10 +1,8 @@
|
|||
dependencies {
|
||||
testImplementation testLibs.junit.jupiter.api
|
||||
testImplementation testLibs.junit.jupiter.params
|
||||
testImplementation testLibs.hamcrest
|
||||
testRuntimeOnly testLibs.junit.jupiter.engine
|
||||
testRuntimeOnly testLibs.junit.jupiter.vintage
|
||||
testRuntimeOnly testLibs.junit.jupiter.platform.launcher
|
||||
testImplementation libs.junit.jupiter.api
|
||||
testImplementation libs.junit.jupiter.params
|
||||
testImplementation libs.hamcrest
|
||||
testRuntimeOnly libs.junit.jupiter.engine
|
||||
}
|
||||
|
||||
test {
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,7 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
35
gradlew
vendored
35
gradlew
vendored
|
@ -55,7 +55,7 @@
|
|||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
|
@ -80,11 +80,13 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
@ -131,29 +133,22 @@ location of your Java installation."
|
|||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
|
@ -198,15 +193,11 @@ if "$cygwin" || "$msys" ; then
|
|||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
|
1
gradlew.bat
vendored
1
gradlew.bat
vendored
|
@ -26,7 +26,6 @@ if "%OS%"=="Windows_NT" setlocal
|
|||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
|
|
|
@ -1,31 +1,22 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral {
|
||||
metadataSources {
|
||||
mavenPom()
|
||||
artifact()
|
||||
ignoreGradleMetadataRedirection()
|
||||
}
|
||||
}
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
libs {
|
||||
version('gradle', '8.5')
|
||||
version('groovy', '4.0.16')
|
||||
version('netty', '4.1.101.Final')
|
||||
library('cql-common', 'org.xbib', 'cql-common').version('5.1.1')
|
||||
library('marc', 'org.xbib', 'marc').version('2.14.1')
|
||||
library('charactersets', 'org.xbib', 'bibliographic-character-sets').version('2.0.0')
|
||||
version('gradle', '7.5.1')
|
||||
version('groovy', '4.0.7')
|
||||
version('junit', '5.9.2')
|
||||
version('junit4', '4.13.2')
|
||||
version('netty', '4.1.89.Final')
|
||||
library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
|
||||
library('junit-jupiter-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit')
|
||||
library('junit-jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit')
|
||||
library('junit-jupiter-vintage', 'org.junit.vintage', 'junit-vintage-engine').versionRef('junit4')
|
||||
library('hamcrest', 'org.hamcrest', 'hamcrest-library').version('2.2')
|
||||
library('cql-common', 'org.xbib', 'cql-common').version('5.0.0')
|
||||
library('netty-transport', 'io.netty', 'netty-transport').versionRef('netty')
|
||||
library('netty-handler', 'io.netty', 'netty-handler').versionRef('netty')
|
||||
library('netty-common', 'io.netty', 'netty-common').versionRef('netty')
|
||||
library('netty-buffer', 'io.netty', 'netty-buffer').versionRef('netty')
|
||||
library('charactersets', 'org.xbib', 'bibliographic-character-sets').version('2.0.0')
|
||||
library('groovy', 'org.apache.groovy', 'groovy').versionRef('groovy')
|
||||
library('groovy-xml', 'org.apache.groovy', 'groovy-xml').versionRef('groovy')
|
||||
library('groovy-json', 'org.apache.groovy', 'groovy-json').versionRef('groovy')
|
||||
|
@ -34,16 +25,7 @@ dependencyResolutionManagement {
|
|||
library('groovy-macro', 'org.apache.groovy', 'groovy-macro').versionRef('groovy')
|
||||
library('groovy-templates', 'org.apache.groovy', 'groovy-templates').versionRef('groovy')
|
||||
library('groovy-test', 'org.apache.groovy', 'groovy-test').versionRef('groovy')
|
||||
}
|
||||
testLibs {
|
||||
version('junit', '5.10.0')
|
||||
version('junit4', '4.13.2')
|
||||
library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
|
||||
library('junit-jupiter-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit')
|
||||
library('junit-jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit')
|
||||
library('junit-jupiter-vintage', 'org.junit.vintage', 'junit-vintage-engine').versionRef('junit')
|
||||
library('junit-jupiter-platform-launcher', 'org.junit.platform', 'junit-platform-launcher').version('1.10.0')
|
||||
library('hamcrest', 'org.hamcrest', 'hamcrest-library').version('2.2')
|
||||
library('marc', 'org.xbib', 'marc').version('2.9.15')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class JDKZClient implements Client, Closeable {
|
|||
lock.lock();
|
||||
SearchOperation searchOperation = new SearchOperation(berReader, berWriter,
|
||||
builder.resultSetName, builder.databases, builder.host);
|
||||
boolean success = searchOperation.executeCQL(StandardCharsets.UTF_8, query, builder.wordListSupported);
|
||||
boolean success = searchOperation.executeCQL(query);
|
||||
if (!success) {
|
||||
logger.log(Level.WARNING, MessageFormat.format("search was not a success [{0}]", query));
|
||||
} else {
|
||||
|
@ -130,7 +130,7 @@ public class JDKZClient implements Client, Closeable {
|
|||
lock.lock();
|
||||
SearchOperation searchOperation = new SearchOperation(berReader, berWriter,
|
||||
builder.resultSetName, builder.databases, builder.host);
|
||||
searchOperation.executePQF(StandardCharsets.UTF_8, query);
|
||||
searchOperation.executePQF(query, StandardCharsets.UTF_8);
|
||||
if (!searchOperation.isSuccess()) {
|
||||
logger.log(Level.WARNING, MessageFormat.format("search was not a success [{0}]", query));
|
||||
} else {
|
||||
|
@ -410,8 +410,6 @@ public class JDKZClient implements Client, Closeable {
|
|||
|
||||
private InitListener initListener;
|
||||
|
||||
private boolean wordListSupported;
|
||||
|
||||
private Builder() {
|
||||
this.timeout = 5000;
|
||||
this.preferredRecordSyntax = "1.2.840.10003.5.10"; // marc21
|
||||
|
@ -423,7 +421,6 @@ public class JDKZClient implements Client, Closeable {
|
|||
this.preferredMessageSize = 10 * 1024 * 1024;
|
||||
this.implementationName = "Java Z Client";
|
||||
this.implementationVersion = "1.00";
|
||||
this.wordListSupported = true;
|
||||
}
|
||||
|
||||
public Builder setHost(String host) {
|
||||
|
@ -509,11 +506,6 @@ public class JDKZClient implements Client, Closeable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder wordListSupported(boolean wordListSupported) {
|
||||
this.wordListSupported = wordListSupported;
|
||||
return this;
|
||||
}
|
||||
|
||||
public JDKZClient build() {
|
||||
return new JDKZClient(this);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.xbib.z3950.client.jdk.test;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xbib.z3950.client.jdk.JDKZClient;
|
||||
import org.xbib.z3950.common.operations.SortOperation;
|
||||
|
@ -15,9 +14,8 @@ class LVIZClientTest {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(LVIZClientTest.class.getName());
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
void testPQF() {
|
||||
void testLVI() {
|
||||
String query = "@attr 1=4 @attr 4=6 \"Köln strafrecht\"";
|
||||
int offset = 1;
|
||||
int size = 10;
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package org.xbib.z3950.client.jdk.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Collections;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -13,14 +16,15 @@ class SWBClientTest {
|
|||
|
||||
@Test
|
||||
void testCQL() {
|
||||
//String query = "bib.identifierISSN = 00280836";
|
||||
String query = "bib.any all test";
|
||||
String serviceName = "SWB";
|
||||
String query = "bib.identifierISSN = 00280836";
|
||||
int from = 1;
|
||||
int size = 10;
|
||||
try (JDKZClient client = newZClient()) {
|
||||
try (JDKZClient client = newZClient(serviceName)) {
|
||||
logger.log(Level.INFO, "executing CQL " + serviceName);
|
||||
int count = client.searchCQL(query, from, size, null,
|
||||
(status, total, returned, elapsedMillis) ->
|
||||
logger.log(Level.INFO, "total results = " + total),
|
||||
logger.log(Level.INFO, serviceName + " total results = " + total),
|
||||
record -> logger.log(Level.INFO, "record = " + record),
|
||||
() -> logger.log(Level.INFO, "timeout"));
|
||||
logger.log(Level.INFO, "returned records = " + count);
|
||||
|
@ -31,13 +35,15 @@ class SWBClientTest {
|
|||
|
||||
@Test
|
||||
void testPQF() {
|
||||
String serviceName = "SWB";
|
||||
String query = "@attr 1=8 \"00280836\"";
|
||||
int from = 1;
|
||||
int size = 10;
|
||||
try (JDKZClient client = newZClient()) {
|
||||
try (JDKZClient client = newZClient(serviceName)) {
|
||||
logger.log(Level.INFO, "executing PQF " + serviceName);
|
||||
int count = client.searchPQF(query, from, size, null,
|
||||
(status, total, returned, elapsedMillis) ->
|
||||
logger.log(Level.INFO, "status = " + status + " total results = " + total),
|
||||
logger.log(Level.INFO, serviceName + " status = " + status + " total results = " + total),
|
||||
record -> logger.log(Level.INFO, "record = " + record.toString(Charset.forName(client.getEncoding()))),
|
||||
() -> logger.log(Level.WARNING, "timeout"));
|
||||
logger.log(Level.INFO, "returned records = " + count);
|
||||
|
@ -46,19 +52,53 @@ class SWBClientTest {
|
|||
}
|
||||
}
|
||||
|
||||
private JDKZClient newZClient() {
|
||||
JDKZClient.Builder builder = JDKZClient.builder()
|
||||
.setHost("z3950.bsz-bw.de")
|
||||
.setPort(20210)
|
||||
.setTimeout(10000L)
|
||||
.setDatabases(Collections.singletonList("swb_fl"))
|
||||
.setElementSetName("xf")
|
||||
.setPreferredRecordSyntax("marc21")
|
||||
.setResultSetName("default")
|
||||
.setEncoding("UTF-8")
|
||||
.setFormat("Marc21")
|
||||
.setType("Bibliographic")
|
||||
.wordListSupported(false);
|
||||
private JDKZClient newZClient(String name) throws IOException {
|
||||
return newZClient(getProperties(name));
|
||||
}
|
||||
|
||||
private Properties getProperties(String name) throws IOException {
|
||||
Properties properties = new Properties();
|
||||
try (InputStream inputStream = getClass().getResourceAsStream(name + ".properties")) {
|
||||
properties.load(inputStream);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
private static JDKZClient newZClient(Properties properties) {
|
||||
JDKZClient.Builder builder = JDKZClient.builder();
|
||||
if (properties.containsKey("host")) {
|
||||
builder.setHost(properties.getProperty("host"));
|
||||
}
|
||||
if (properties.containsKey("port")) {
|
||||
builder.setPort(Integer.parseInt(properties.getProperty("port")));
|
||||
}
|
||||
if (properties.containsKey("user")) {
|
||||
builder.setUser(properties.getProperty("user"));
|
||||
}
|
||||
if (properties.containsKey("pass")) {
|
||||
builder.setPass(properties.getProperty("pass"));
|
||||
}
|
||||
if (properties.containsKey("database")) {
|
||||
builder.setDatabases(Collections.singletonList(properties.getProperty("database")));
|
||||
}
|
||||
if (properties.containsKey("elementsetname")) {
|
||||
builder.setElementSetName(properties.getProperty("elementsetname"));
|
||||
}
|
||||
if (properties.containsKey("preferredrecordsyntax")) {
|
||||
builder.setPreferredRecordSyntax(properties.getProperty("preferredrecordsyntax"));
|
||||
}
|
||||
if (properties.containsKey("resultsetname")) {
|
||||
builder.setResultSetName(properties.getProperty("resultsetname"));
|
||||
}
|
||||
if (properties.containsKey("encoding")) {
|
||||
builder.setEncoding(properties.getProperty("encoding"));
|
||||
}
|
||||
if (properties.containsKey("format")) {
|
||||
builder.setFormat(properties.getProperty("format"));
|
||||
}
|
||||
if (properties.containsKey("type")) {
|
||||
builder.setType(properties.getProperty("type"));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
plugins {
|
||||
id 'org.xbib.gradle.plugin.jflex' version '3.0.2'
|
||||
id 'org.xbib.gradle.plugin.jacc' version '3.0.2'
|
||||
id 'org.xbib.gradle.plugin.jflex' version '1.4.0'
|
||||
id 'org.xbib.gradle.plugin.jacc' version '1.4.0'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -11,11 +11,7 @@ dependencies {
|
|||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDirs "build/generated-src"
|
||||
srcDirs 'build/generated-src'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named('sourcesJar').configure {
|
||||
dependsOn('generateJflex', 'generateJacc')
|
||||
}
|
||||
|
|
|
@ -32,15 +32,12 @@ import org.xbib.z3950.common.v3.Operator;
|
|||
import org.xbib.z3950.common.v3.RPNQuery;
|
||||
import org.xbib.z3950.common.v3.RPNStructure;
|
||||
import org.xbib.z3950.common.v3.RPNStructureRpnRpnOp;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Stack;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* This is a RPN (Type-1 query) generator for CQL queries.
|
||||
|
@ -49,9 +46,19 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public final class CQLRPNGenerator implements Visitor {
|
||||
|
||||
private final Charset charset;
|
||||
|
||||
private final Map<String, Map<String, String>> contexts;
|
||||
/**
|
||||
* Context map.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
private final Map<String, ResourceBundle> contexts = new HashMap<>() {
|
||||
{
|
||||
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"));
|
||||
put("gbv", ResourceBundle.getBundle("org.xbib.z3950.common.cql.gbv"));
|
||||
}
|
||||
};
|
||||
|
||||
private final Stack<AttributeElement> attributeElements;
|
||||
|
||||
|
@ -59,41 +66,16 @@ public final class CQLRPNGenerator implements Visitor {
|
|||
|
||||
private RPNQuery rpnQuery;
|
||||
|
||||
private boolean wordListSupported;
|
||||
|
||||
public CQLRPNGenerator() {
|
||||
this(StandardCharsets.ISO_8859_1, null, true);
|
||||
this(null);
|
||||
}
|
||||
|
||||
public CQLRPNGenerator(Charset charset) {
|
||||
this(charset, null, true);
|
||||
}
|
||||
|
||||
public CQLRPNGenerator(Charset charset, Collection<AttributeElement> attributeElements, boolean wordListSupported) {
|
||||
this.charset = charset;
|
||||
public CQLRPNGenerator(Collection<AttributeElement> attributeElements) {
|
||||
this.attributeElements = new Stack<>();
|
||||
if (attributeElements != null) {
|
||||
this.attributeElements.addAll(attributeElements);
|
||||
}
|
||||
this.result = new Stack<>();
|
||||
this.contexts = new HashMap<>();
|
||||
addContext("default", ResourceBundle.getBundle("org.xbib.z3950.common.cql.default"));
|
||||
addContext("cql", ResourceBundle.getBundle("org.xbib.z3950.common.cql.cql"));
|
||||
addContext("rec", ResourceBundle.getBundle("org.xbib.z3950.common.cql.rec"));
|
||||
addContext("bib", ResourceBundle.getBundle("org.xbib.z3950.common.cql.bib-1"));
|
||||
addContext("dc", ResourceBundle.getBundle("org.xbib.z3950.common.cql.dc"));
|
||||
addContext("gbv", ResourceBundle.getBundle("org.xbib.z3950.common.cql.gbv"));
|
||||
this.wordListSupported = wordListSupported;
|
||||
}
|
||||
|
||||
public void addContext(String context, ResourceBundle bundle) {
|
||||
addContext(context, bundle.keySet().stream()
|
||||
.map(k -> Map.entry(k, bundle.getString(k)))
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
public void addContext(String context, Map<String, String> map) {
|
||||
contexts.put(context, map);
|
||||
}
|
||||
|
||||
public RPNQuery getQueryResult() {
|
||||
|
@ -218,8 +200,7 @@ public final class CQLRPNGenerator implements Visitor {
|
|||
}
|
||||
operand.attrTerm.attributes = new AttributeList();
|
||||
operand.attrTerm.attributes.value = attributeElements.stream()
|
||||
.filter(ae -> ae.attributeValue != null)
|
||||
.toArray(AttributeElement[]::new);
|
||||
.filter(ae -> ae.attributeValue != null).toArray(AttributeElement[]::new);
|
||||
RPNStructure rpn = new RPNStructure();
|
||||
rpn.c_op = operand;
|
||||
result.push(rpn);
|
||||
|
@ -230,29 +211,37 @@ public final class CQLRPNGenerator implements Visitor {
|
|||
if (node.getModifierList() != null) {
|
||||
node.getModifierList().accept(this);
|
||||
}
|
||||
int attributeType = 2;
|
||||
int attributeValue = 3; // EQUALS, 2=3
|
||||
switch (node.getComparitor()) {
|
||||
case LESS -> // 2=1
|
||||
push(attributeElements, createAttributeElement(2, 1));
|
||||
attributeValue = 1;
|
||||
case LESS_EQUALS -> // 2=2
|
||||
push(attributeElements, createAttributeElement(2, 2));
|
||||
case EQUALS -> // 2=3
|
||||
push(attributeElements, createAttributeElement(2, 3));
|
||||
attributeValue = 2;
|
||||
case GREATER_EQUALS -> // 2=4
|
||||
push(attributeElements, createAttributeElement(2, 4));
|
||||
attributeValue = 4;
|
||||
case GREATER -> // 2=5
|
||||
push(attributeElements, createAttributeElement(2, 5));
|
||||
case NOT_EQUALS ->
|
||||
push(attributeElements, createAttributeElement(2, 6));
|
||||
case ALL, ANY -> {
|
||||
push(attributeElements, createAttributeElement(2, 3));
|
||||
// 4=6 word list
|
||||
if (wordListSupported) {
|
||||
replace(attributeElements, createAttributeElement(4, 6));
|
||||
attributeValue = 5;
|
||||
case NOT_EQUALS -> // 2=6
|
||||
attributeValue = 6;
|
||||
case ALL -> { // 4=6
|
||||
attributeType = 4;
|
||||
attributeValue = 6;
|
||||
}
|
||||
case ANY -> { // 4=104
|
||||
attributeType = 4;
|
||||
attributeValue = 104;
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
if (attributeValue != 3) {
|
||||
AttributeElement ae = new AttributeElement();
|
||||
ae.attributeType = new ASN1Integer(attributeType);
|
||||
ae.attributeValue = new AttributeElementAttributeValue();
|
||||
ae.attributeValue.numeric = new ASN1Integer(attributeValue);
|
||||
result.push(ae);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -274,6 +263,7 @@ public final class CQLRPNGenerator implements Visitor {
|
|||
|
||||
@Override
|
||||
public void visit(Term term) {
|
||||
// the value
|
||||
ASN1OctetString s = transformTerm(term);
|
||||
result.push(s);
|
||||
}
|
||||
|
@ -296,47 +286,40 @@ public final class CQLRPNGenerator implements Visitor {
|
|||
}
|
||||
|
||||
int attributeType = 1; // use attribute set: bib-1 = 1
|
||||
Integer attributeValue = getUseAttr(context, index.getName());
|
||||
if (attributeValue == null) {
|
||||
throw new SyntaxException("undefined attribute value for " + index.getName());
|
||||
}
|
||||
|
||||
// date --> use year attribute
|
||||
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;
|
||||
}
|
||||
int attributeValue = getUseAttr(context, index.getName());
|
||||
|
||||
push(attributeElements, createAttributeElement(attributeType, attributeValue));
|
||||
}
|
||||
|
||||
private Integer getUseAttr(String context, String attrName) {
|
||||
if (!contexts.containsKey(context)) {
|
||||
throw new SyntaxException("unknown use attribute '" + attrName + "' for context " + context);
|
||||
private int getUseAttr(String context, String attrName) {
|
||||
try {
|
||||
return Integer.parseInt(contexts.get(context).getString(attrName));
|
||||
} catch (MissingResourceException e) {
|
||||
throw new SyntaxException("unknown use attribute '" + attrName + "' for context " + context, e);
|
||||
}
|
||||
String string = contexts.get(context).get(attrName);
|
||||
return string != null ? Integer.parseInt(string) : null;
|
||||
}
|
||||
|
||||
private ASN1OctetString transformTerm(Term term) {
|
||||
|
||||
int firstAttributeValue = 0;
|
||||
if (!attributeElements.isEmpty()) {
|
||||
AttributeElement attributeElement = attributeElements.peek();
|
||||
if (attributeElement.attributeType.get() == 1) {
|
||||
firstAttributeValue = attributeElement.attributeValue.numeric.get();
|
||||
}
|
||||
}
|
||||
|
||||
String v = term.getValue();
|
||||
// let's derive basic attributes from the search term syntax
|
||||
// let's derive attributes from the search term syntax
|
||||
|
||||
// relation attribute = 2
|
||||
int attributeType = 2;
|
||||
int attributeValue = 3; // equal 2=3
|
||||
push(attributeElements, createAttributeElement(attributeType, attributeValue));
|
||||
|
||||
// position attribute = 3
|
||||
int attributeType = 3;
|
||||
int attributeValue = 3; // any position = 3
|
||||
attributeType = 3;
|
||||
attributeValue = 3; // any position = 3
|
||||
if (v.startsWith("^")) {
|
||||
attributeValue = 1; // first posiiton
|
||||
v = v.substring(1);
|
||||
|
@ -345,11 +328,17 @@ public final class CQLRPNGenerator implements Visitor {
|
|||
|
||||
// structure attribute = 4
|
||||
attributeType = 4;
|
||||
attributeValue = 2; // phrase = 1, word = 2, word list = 6
|
||||
attributeValue = 2; // phrase = 1, word = 2
|
||||
if (v.startsWith("\"") && v.endsWith("\"")) {
|
||||
attributeValue = 1; // phrase
|
||||
v = v.substring(1, v.length()-1);
|
||||
}
|
||||
if (firstAttributeValue == 31) {
|
||||
attributeValue = 5; // date (normalized) = 5
|
||||
}
|
||||
if (firstAttributeValue == 1016) {
|
||||
attributeValue = 6; // word list
|
||||
}
|
||||
push(attributeElements, createAttributeElement(attributeType, attributeValue));
|
||||
|
||||
// truncation attribute = 5
|
||||
|
@ -378,7 +367,15 @@ public final class CQLRPNGenerator implements Visitor {
|
|||
}
|
||||
push(attributeElements, createAttributeElement(attributeType, attributeValue));
|
||||
|
||||
return new ASN1OctetString(v, charset);
|
||||
return new ASN1OctetString(v);
|
||||
}
|
||||
|
||||
private static void push(Stack<AttributeElement> stack, AttributeElement attributeElement) {
|
||||
if (attributeElement != null) {
|
||||
if (!stack.contains(attributeElement)) {
|
||||
stack.push(attributeElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static AttributeElement createAttributeElement(Integer attributeType, Integer attributeValue) {
|
||||
|
@ -392,21 +389,4 @@ public final class CQLRPNGenerator implements Visitor {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void push(Stack<AttributeElement> stack, AttributeElement attributeElement) {
|
||||
if (attributeElement != null) {
|
||||
stack.push(attributeElement);
|
||||
}
|
||||
}
|
||||
|
||||
private static void replace(Stack<AttributeElement> stack, AttributeElement attributeElement) {
|
||||
if (attributeElement != null) {
|
||||
int pos = stack.indexOf(attributeElement);
|
||||
if (pos >= 0) {
|
||||
stack.remove(pos);
|
||||
}
|
||||
stack.push(attributeElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,12 +54,12 @@ public class SearchOperation extends AbstractOperation<SearchResponse, SearchReq
|
|||
this.status = false;
|
||||
}
|
||||
|
||||
public boolean executePQF(Charset charset, String pqf) throws IOException {
|
||||
return execute(createRPNQueryFromPQF(charset, pqf));
|
||||
public boolean executePQF(String pqf, Charset charset) throws IOException {
|
||||
return execute(createRPNQueryFromPQF(pqf, charset));
|
||||
}
|
||||
|
||||
public boolean executeCQL(Charset charset, String cql, boolean wordListSupported) throws IOException {
|
||||
return execute(createRPNQueryFromCQL(charset, cql, wordListSupported));
|
||||
public boolean executeCQL(String cql) throws IOException {
|
||||
return execute(createRPNQueryFromCQL(cql));
|
||||
}
|
||||
|
||||
public boolean execute(RPNQuery rpn) throws IOException {
|
||||
|
@ -118,15 +118,15 @@ public class SearchOperation extends AbstractOperation<SearchResponse, SearchReq
|
|||
return status;
|
||||
}
|
||||
|
||||
private RPNQuery createRPNQueryFromCQL(Charset charset, String query, boolean wordListSupported) {
|
||||
CQLRPNGenerator generator = new CQLRPNGenerator(charset, null, wordListSupported);
|
||||
private RPNQuery createRPNQueryFromCQL(String query) {
|
||||
CQLRPNGenerator generator = new CQLRPNGenerator();
|
||||
CQLParser parser = new CQLParser(query);
|
||||
parser.parse();
|
||||
parser.getCQLQuery().accept(generator);
|
||||
return generator.getQueryResult();
|
||||
}
|
||||
|
||||
private RPNQuery createRPNQueryFromPQF(Charset charset, String query) {
|
||||
private RPNQuery createRPNQueryFromPQF(String query, Charset charset) {
|
||||
PQFRPNGenerator generator = new PQFRPNGenerator(charset);
|
||||
PQFParser parser = new PQFParser(new StringReader(query));
|
||||
parser.parse();
|
||||
|
|
|
@ -164,14 +164,4 @@ public final class AttributeElement extends ASN1Any implements Comparable<Attrib
|
|||
public int compareTo(AttributeElement o) {
|
||||
return attributeType.toString().compareTo(o.attributeType.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return attributeType.toString().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof AttributeElement && attributeType.toString().equals(((AttributeElement) obj).attributeType.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,6 @@ dateAcquisition=32
|
|||
dateComposition=1196
|
||||
dateConference=1054
|
||||
datePublication=31
|
||||
datePublished=31
|
||||
dateRecordStatus=1055
|
||||
dateRecording=1197
|
||||
dateTimeAddedDB=1011
|
||||
|
@ -163,8 +162,6 @@ musicalKeyCurrent=1195
|
|||
musicalKeyOriginal=1194
|
||||
musicalTheme=1206
|
||||
name=1002
|
||||
namePersonal=1
|
||||
nameCorporate=2
|
||||
nameAndTitle=57
|
||||
nameGeographic=58
|
||||
nationality=1217
|
||||
|
@ -266,8 +263,6 @@ timePeriod=1125
|
|||
timePeriodStructured=1127
|
||||
timePeriodTextual=1126
|
||||
title=4
|
||||
titlePhrase=4
|
||||
titleComplete=4
|
||||
titleAbbreviated=43
|
||||
titleAddedTitlePage=37
|
||||
titleCaption=38
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
id=12
|
|
@ -6,8 +6,6 @@ import org.xbib.asn1.ASN1Integer;
|
|||
import org.xbib.cql.CQLParser;
|
||||
import org.xbib.z3950.common.v3.AttributeElement;
|
||||
import org.xbib.z3950.common.v3.AttributeElementAttributeValue;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
|
||||
class CQL2RPNTest {
|
||||
|
@ -20,7 +18,7 @@ class CQL2RPNTest {
|
|||
CQLRPNGenerator generator = new CQLRPNGenerator();
|
||||
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 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 \"Test\"}}}}}", q);
|
||||
assertEquals("{attributeSetId 1.2.840.10003.3.1, rpn {op {attrTerm {attributes {{attributeType 2, attributeValue {numeric 3}}{attributeType 4, attributeValue {numeric 2}}{attributeType 5, attributeValue {numeric 100}}{attributeType 1, attributeValue {numeric 4}}}, term {general \"Test\"}}}}}", q);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -31,87 +29,22 @@ class CQL2RPNTest {
|
|||
CQLRPNGenerator generator = new CQLRPNGenerator();
|
||||
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 4, attributeValue {numeric 1}}{attributeType 5, attributeValue {numeric 100}}{attributeType 6, attributeValue {numeric 1}}{attributeType 1, attributeValue {numeric 4}}{attributeType 2, attributeValue {numeric 3}}}, term {general \"a phrase\"}}}}}", q);
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithCustomAttribute() {
|
||||
void testWithOverridingAnAttribute() {
|
||||
AttributeElement ae = new AttributeElement();
|
||||
ae.attributeType = new ASN1Integer(7);
|
||||
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(StandardCharsets.UTF_8, Collections.singleton(ae), true);
|
||||
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 7, attributeValue {numeric 4}}{attributeType 3, attributeValue {numeric 3}}{attributeType 4, attributeValue {numeric 1}}{attributeType 5, attributeValue {numeric 100}}{attributeType 6, attributeValue {numeric 1}}{attributeType 1, attributeValue {numeric 4}}{attributeType 2, attributeValue {numeric 3}}}, term {general \"a phrase\"}}}}}", q);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRecContext() {
|
||||
String cql = "rec.id = 123";
|
||||
CQLParser parser = new CQLParser(cql);
|
||||
parser.parse();
|
||||
CQLRPNGenerator generator = new CQLRPNGenerator();
|
||||
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 4, attributeValue {numeric 2}}{attributeType 5, attributeValue {numeric 100}}{attributeType 6, attributeValue {numeric 1}}{attributeType 1, attributeValue {numeric 12}}{attributeType 2, attributeValue {numeric 3}}}, term {general \"123\"}}}}}", q);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAll() {
|
||||
String cql = "bib.any all \"zeitschrift umweltrecht\"";
|
||||
CQLParser parser = new CQLParser(cql);
|
||||
parser.parse();
|
||||
CQLRPNGenerator generator = new CQLRPNGenerator();
|
||||
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 6, attributeValue {numeric 1}}{attributeType 1, attributeValue {numeric 1016}}{attributeType 2, attributeValue {numeric 3}}{attributeType 4, attributeValue {numeric 6}}}, term {general \"zeitschrift umweltrecht\"}}}}}", q);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDate() {
|
||||
String cql = "bib.datePublication = 2023";
|
||||
CQLParser parser = new CQLParser(cql);
|
||||
parser.parse();
|
||||
CQLRPNGenerator generator = new CQLRPNGenerator();
|
||||
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 6, attributeValue {numeric 1}}{attributeType 4, attributeValue {numeric 5}}{attributeType 1, attributeValue {numeric 31}}{attributeType 2, attributeValue {numeric 3}}}, term {general \"2023\"}}}}}", q);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUTF8() {
|
||||
String cql = "bib.title = Köln";
|
||||
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 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);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ apply from: rootProject.file('gradle/compile/groovy.gradle')
|
|||
dependencies {
|
||||
api project(':z3950-client-jdk')
|
||||
api libs.groovy.xml
|
||||
testRuntimeOnly libs.junit.jupiter.vintage
|
||||
testImplementation libs.groovy
|
||||
testImplementation libs.groovy.json
|
||||
testImplementation libs.groovy.nio
|
||||
|
|
Loading…
Reference in a new issue