Showing with 5,472 additions and 9 deletions.
  1. +1 −1 Jenkinsfile
  2. +11 −8 README.md
  3. +10 −0 aqlparser/checkstyle-suppressions.xml
  4. +54 −0 aqlparser/pom.xml
  5. +81 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/AQLOperator.java
  6. +56 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/AQLParser.java
  7. +88 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/AQLParserState.java
  8. +82 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLAtomicClause.java
  9. +55 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLAtomicClauseOperator.java
  10. +54 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLBooleanLiteral.java
  11. +67 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLClauseOperator.java
  12. +67 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLClauseWithNextOperator.java
  13. +57 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLClausesWithNextOperator.java
  14. +113 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLDateLiteral.java
  15. +69 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLFunctionCall.java
  16. +56 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLInExpression.java
  17. +55 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLNumberLiteral.java
  18. +67 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLOrderByClause.java
  19. +59 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLStatement.java
  20. +56 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AQLStringLiteral.java
  21. +37 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AbstractAQLAtomicValue.java
  22. +39 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AbstractAQLClause.java
  23. +52 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AbstractAQLNode.java
  24. +38 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/ast/AbstractAQLRightHandValue.java
  25. +126 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/exceptions/ParserException.java
  26. +201 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/internal/AQLReader.java
  27. +571 −0 aqlparser/src/main/java/org/xwiki/contrib/cql/aqlparser/internal/Parser.java
  28. +65 −0 pom.xml
  29. +10 −0 query/checkstyle-suppressions.xml
  30. +90 −0 query/pom.xml
  31. +41 −0 query/src/main/java/org/xwiki/contrib/cql/query/converters/CQLToSolrAtomConverter.java
  32. +193 −0 query/src/main/java/org/xwiki/contrib/cql/query/converters/CQLToSolrQueryConverter.java
  33. +44 −0 query/src/main/java/org/xwiki/contrib/cql/query/converters/CQLToSolrSortFieldConverter.java
  34. +41 −0 query/src/main/java/org/xwiki/contrib/cql/query/converters/ConfluenceIdResolver.java
  35. +49 −0 query/src/main/java/org/xwiki/contrib/cql/query/converters/ConfluenceSpaceResolver.java
  36. +64 −0 query/src/main/java/org/xwiki/contrib/cql/query/converters/ConversionException.java
  37. +593 −0 query/src/main/java/org/xwiki/contrib/cql/query/converters/DefaultCQLToSolrAtomConverter.java
  38. +84 −0 .../src/main/java/org/xwiki/contrib/cql/query/converters/DefaultCQLToSolrSortParameterConverter.java
  39. +69 −0 query/src/main/java/org/xwiki/contrib/cql/query/converters/Utils.java
  40. +73 −0 ...c/main/java/org/xwiki/contrib/cql/query/converters/internal/AbstractIdCQLToSolrAtomConverter.java
  41. +70 −0 ...src/main/java/org/xwiki/contrib/cql/query/converters/internal/AncestorCQLToSolrAtomConverter.java
  42. +95 −0 ...java/org/xwiki/contrib/cql/query/converters/internal/ConfluencePageClassConfluenceIdResolver.java
  43. +63 −0 .../src/main/java/org/xwiki/contrib/cql/query/converters/internal/ContentCQLToSolrAtomConverter.java
  44. +82 −0 query/src/main/java/org/xwiki/contrib/cql/query/converters/internal/DefaultConfluenceIdResolver.java
  45. +120 −0 ...src/main/java/org/xwiki/contrib/cql/query/converters/internal/DefaultConfluenceSpaceResolver.java
  46. +70 −0 ...y/src/main/java/org/xwiki/contrib/cql/query/converters/internal/ParentCQLToSolrAtomConverter.java
  47. +173 −0 query/src/main/java/org/xwiki/contrib/cql/query/internal/CQLQueryExecutor.java
  48. +10 −0 query/src/main/resources/META-INF/components.txt
  49. +141 −0 query/src/test/java/org/xwiki/contrib/cql/query/CQLQueryExecutorTest.java
  50. +904 −0 query/src/test/java/org/xwiki/contrib/cql/query/CQLTest.java
  51. +58 −0 query/src/test/java/org/xwiki/contrib/cql/query/TestCQLToSolrAtomConverter.java
  52. +46 −0 query/src/test/java/org/xwiki/contrib/cql/query/TestCQLToSolrSortParameterConverter.java
  53. +2 −0 query/src/test/resources/META-INF/components.txt
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
xwikiModule {
// Note: Java 11+ is required for Sonar/Sonarcloud
goals = 'clean deploy jacoco:report sonar:sonar'
profiles = 'quality,integration-tests,docker'
profiles = 'quality'
sonar = true
}
*/
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# (project title)
# CQL (Confluence Query Language)

(project description).
The Confluence Query Language is used in Confluence to build complex document queries.
The cql family of extensions for XWiki brings support for this query language in XWiki,
which is especially useful to support people who migrated content from Confluence to XWiki
and have used Confluence macros such as contentbylabel which makes use of this language.

* Project Lead: [(name)](https://www.xwiki.org/xwiki/bin/view/XWiki/(profile id on xwiki.org))
* Documentation & Downloads: [Documentation & Download](https://extensions.xwiki.org/xwiki/bin/view/Extension/(extension name)))
* [Issue Tracker](https://jira.xwiki.org/browse/(jira id)
* Project Lead: [Raphaël Jakse](https://www.xwiki.org/xwiki/bin/view/XWiki/rjakse)
* Documentation & Downloads: [Documentation & Download](https://extensions.xwiki.org/xwiki/bin/view/Extension/CQL)
* [Issue Tracker](https://jira.xwiki.org/browse/CQL)
* Communication: [Forum](https://forum.xwiki.org/), [Chat](https://dev.xwiki.org/xwiki/bin/view/Community/Chat)
* [Development Practices](https://dev.xwiki.org)
* Minimal XWiki version supported: XWiki (minimal xwiki version)
* Minimal XWiki version supported: XWiki 13.10
* License: LGPL 2.1
* Translations: N/A
* Sonar Dashboard: [![Status](https://sonarcloud.io/api/project_badges/measure?project=(group id):(artifact id)&metric=alert_status)](https://sonarcloud.io/dashboard?id=(group id):(artifact id))
* Continuous Integration Status: [![Build Status](https://ci.xwiki.org/job/XWiki%20Contrib/job/(project id on ci)/job/master/badge/icon)](https://ci.xwiki.org/job/XWiki%20Contrib/job/(projct id on ci)/job/master/)
* Sonar Dashboard: N/A
* Continuous Integration Status: [![Build Status](https://ci.xwiki.org/job/XWiki%20Contrib/job/cql/job/master/badge/icon)](https://ci.xwiki.org/job/XWiki%20Contrib/job/cql/job/master/)
10 changes: 10 additions & 0 deletions aqlparser/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">

<suppressions>
<suppress checks="CyclomaticComplexity|NPathComplexity"
files="src/main/java/org/xwiki/contrib/cql/aqlparser/internal/Parser\.java$"/>
</suppressions>
54 changes: 54 additions & 0 deletions aqlparser/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.contrib.cql</groupId>
<artifactId>cql</artifactId>
<version>0.0.2-SNAPSHOT</version>
</parent>
<artifactId>aqlparser</artifactId>
<name>Confluence Query Language (CQL) - AQL Parser</name>
<description>Parse queries written using the AQL (Atlassian Query Language) grammar, including
CQL (Confluence Query Language) and JQL (Jira Query Language)</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-oldcore</artifactId>
<version>${platform.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
</configuration>
</plugin>
</plugins>
</build>
</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.contrib.cql.aqlparser;

import org.xwiki.stability.Unstable;

/**
* The CQL operators that can appear inside an atomic clause.
* @version $Id$
* @since 0.0.1
*/
@Unstable
public enum AQLOperator
{
/**
* The IN operator.
*/
IN,

/**
* The NOT IN operator.
*/
NOT_IN,

/**
* The equals ('=') operator.
*/
EQ,

/**
* The not equals ('!=') operator.
*/
NEQ,

/**
* The greater than ('&gt;') operator.
*/
GT,

/**
* The greater than or equals ('&gt;=') operator.
*/
GTE,

/**
* The lower than ('&lt;') operator.
*/
LT,

/**
* The lower than or equals ('&lt;=') operator.
*/
LTE,

/**
* The contains ('~') operator.
*/
CONTAINS,

/**
* The does not contain ('!~') operator.
*/
DOES_NOT_CONTAIN
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.contrib.cql.aqlparser;

import java.io.IOException;

import org.xwiki.contrib.cql.aqlparser.exceptions.ParserException;
import org.xwiki.contrib.cql.aqlparser.internal.Parser;
import org.xwiki.contrib.cql.aqlparser.ast.AQLStatement;
import org.xwiki.stability.Unstable;

/**
* The AQL Parser.
* It allows parsing CQL (Confluence Query Language) and most likely JQL (Jira Query Language) statements (both
* language are very similar and likely to be implemented using the same parser in Confluence and Jira).
* @version $Id$
* @since 0.0.1
*/
@Unstable
public final class AQLParser
{
private AQLParser()
{
}

/**
* Parse the AQL statement passed as parameter.
*
* @param stmt the statement containing the AQL content to parse
* @return the parsed result as an AST tree
* @throws ParserException if a parse error happens
* @throws IOException in case a IO error happens, though it shouldn't
* @since 0.0.1
*/
public static AQLStatement parse(String stmt) throws ParserException, IOException
{
return new Parser(stmt).parse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.contrib.cql.aqlparser;

import java.io.Serializable;

import org.xwiki.stability.Unstable;

/**
* Represents the state of the reader at a given point during the parsing of an CQL statement.
* @version $Id$
* @since 0.0.1
*/
@Unstable
public class AQLParserState implements Serializable
{
private static final long serialVersionUID = 1L;

private final long pos;

private final long line;

private final long col;

/**
*
* @param pos The 0-indexed position, in characters, in the CQL string.
* @param line The (1-indexed) line number in the CQL string.
* @param col The (1-indexed) column position the CQL string (in the line whose number is returned by #getLine()).
* @since 0.0.1
*/
public AQLParserState(long pos, long line, long col)
{
this.pos = pos;
this.line = line;
this.col = col;
}

/**
* @return The 0-indexed position, in characters, in the CQL string.
* @since 0.0.1
*/
public long getPos()
{
return pos;
}

/**
* @return The (1-indexed) line number in the CQL string.
* @since 0.0.1
*/
public long getLine()
{
return line;
}

/**
* @return The (1-indexed) column position the CQL string (in the line whose number is returned by #getLine()).
* @since 0.0.1
*/
public long getCol()
{
return col;
}

@Override
public String toString()
{
return String.format("line %d, col %d, pos %d", getLine(), getCol(), getPos());
}
}
Loading