diff --git a/pom.xml b/pom.xml
index 4769ffd..c1d7d3f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,9 +2,9 @@
4.0.0
- com.github.tennaito
+ br.com.elotech
rsql-jpa
- 2.0.3-SNAPSHOT
+ 2.0.4-SNAPSHOT
jar
@@ -30,15 +30,16 @@
- https://github.com/tennaito/rsql-jpa/
- scm:git:https://github.com/tennaito/rsql-jpa.git
- scm:git:https://github.com/tennaito/rsql-jpa.git
- HEAD
+ https://github.com/Elotech-Dev/rsql-jpa.git
+ scm:git:https://github.com/Elotech-Dev/rsql-jpa.git
+ scm:git:https://github.com/Elotech-Dev/rsql-jpa.git
+ 2.0.3
+ -Xdoclint:none
UTF-8
@@ -112,8 +113,8 @@
1.6.3
true
- ossrh
- https://oss.sonatype.org/
+ nexus
+ https://nexus.elotech.com.br/
false
@@ -142,20 +143,9 @@
-
-
- org.apache.maven.plugins
- maven-gpg-plugin
- 1.5
-
-
- sign-artifacts
- verify
-
- sign
-
-
-
+
+ -Xdoclint:none
+
@@ -267,20 +257,12 @@
- ossrh
- https://oss.sonatype.org/content/repositories/snapshots
+ nexus
+ http://nexus.elotech.com.br/repository/snapshots/
- ossrh
- https://oss.sonatype.org/service/local/staging/deploy/maven2/
+ nexus
+ http://nexus.elotech.com.br/repository/releases/
-
-
- travis
- https://travis-ci.org/tennaito/rsql-jpa
-
-
- GitHub
- https://github.com/tennaito/rsql-jpa/issues
-
+
diff --git a/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java b/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java
index 01b7c89..e2aa518 100755
--- a/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java
+++ b/src/main/java/com/github/tennaito/rsql/jpa/PredicateBuilder.java
@@ -24,12 +24,15 @@
*/
package com.github.tennaito.rsql.jpa;
-import com.github.tennaito.rsql.builder.BuilderTools;
-import com.github.tennaito.rsql.parser.ast.ComparisonOperatorProxy;
-import cz.jirutka.rsql.parser.ast.ComparisonNode;
-import cz.jirutka.rsql.parser.ast.ComparisonOperator;
-import cz.jirutka.rsql.parser.ast.LogicalNode;
-import cz.jirutka.rsql.parser.ast.Node;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.function.Consumer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
@@ -43,13 +46,14 @@
import javax.persistence.metamodel.ManagedType;
import javax.persistence.metamodel.Metamodel;
import javax.persistence.metamodel.PluralAttribute;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
+import com.github.tennaito.rsql.builder.BuilderTools;
+import com.github.tennaito.rsql.parser.ast.ComparisonOperatorProxy;
+
+import cz.jirutka.rsql.parser.ast.ComparisonNode;
+import cz.jirutka.rsql.parser.ast.ComparisonOperator;
+import cz.jirutka.rsql.parser.ast.LogicalNode;
+import cz.jirutka.rsql.parser.ast.Node;
/**
* PredicateBuilder
@@ -58,7 +62,8 @@
*
* @author AntonioRabelo
*
- * Based from CriterionBuilders of rsql-hibernate created by Jakub Jirutka .
+ * Based from CriterionBuilders of rsql-hibernate created by Jakub
+ * Jirutka .
*
* @since 2015-02-05
*/
@@ -66,590 +71,716 @@ public final class PredicateBuilder {
private static final Logger LOG = Logger.getLogger(PredicateBuilder.class.getName());
- public static final Character LIKE_WILDCARD = '*';
-
- private static final Date START_DATE;
- private static final Date END_DATE;
-
- static {
- //
- // Use a date range that Oracle can cope with - apparently the years around 1 BC and 1 AD are messed up in Oracle - known bug
- //
- Calendar cal = Calendar.getInstance();
- cal.set( 9999, Calendar.DECEMBER, 31);
- END_DATE = cal.getTime();
- cal.set( 5, Calendar.JANUARY, 1); // Use Jan 1, 5 AD, since that's where the Roman's sort of got it together with leap years.
- START_DATE = cal.getTime();
- }
-
- /**
- * Private constructor.
- */
- private PredicateBuilder(){
- super();
- }
-
- /**
- * Create a Predicate from the RSQL AST node.
- *
- * @param node RSQL AST node.
- * @param root From that predicate expression paths depends on.
- * @param entity The main entity of the query.
- * @param manager JPA EntityManager.
- * @param misc Facade with all necessary tools for predicate creation.
- * @return Predicate a predicate representation of the Node.
- */
- public static Predicate createPredicate(Node node, From root, Class entity, EntityManager manager, BuilderTools misc) {
- LOG.log(Level.INFO, "Creating Predicate for: {0}", node);
-
- if (node instanceof LogicalNode) {
- return createPredicate((LogicalNode)node, root, entity, manager, misc);
- }
-
- if (node instanceof ComparisonNode) {
- return createPredicate((ComparisonNode)node, root, entity, manager, misc);
- }
-
- throw new IllegalArgumentException("Unknown expression type: " + node.getClass());
- }
-
- /**
- * Create a Predicate from the RSQL AST logical node.
- *
- * @param logical RSQL AST logical node.
- * @param root From that predicate expression paths depends on.
- * @param entity The main entity of the query.
- * @param entityManager JPA EntityManager.
- * @param misc Facade with all necessary tools for predicate creation.
- * @return Predicate a predicate representation of the Node.
- */
- public static Predicate createPredicate(LogicalNode logical, From root, Class entity, EntityManager entityManager, BuilderTools misc) {
- LOG.log(Level.INFO, "Creating Predicate for logical node: {0}", logical);
-
- CriteriaBuilder builder = entityManager.getCriteriaBuilder();
-
- List predicates = new ArrayList();
-
- LOG.log(Level.INFO, "Creating Predicates from all children nodes.");
- for (Node node : logical.getChildren()) {
- predicates.add(createPredicate(node, root, entity, entityManager, misc));
+ public static final Character LIKE_WILDCARD = '*';
+
+ private static final Date START_DATE;
+ private static final Date END_DATE;
+
+ static {
+ //
+ // Use a date range that Oracle can cope with - apparently the years
+ // around 1 BC and 1 AD are messed up in Oracle - known bug
+ //
+ Calendar cal = Calendar.getInstance();
+ cal.set(9999, Calendar.DECEMBER, 31);
+ END_DATE = cal.getTime();
+ cal.set(5, Calendar.JANUARY, 1); // Use Jan 1, 5 AD, since that's where
+ // the Roman's sort of got it together
+ // with leap years.
+ START_DATE = cal.getTime();
+ }
+
+ /**
+ * Private constructor.
+ */
+ private PredicateBuilder() {
+ super();
+ }
+
+ /**
+ * Create a Predicate from the RSQL AST node.
+ *
+ * @param node
+ * RSQL AST node.
+ * @param root
+ * From that predicate expression paths depends on.
+ * @param entity
+ * The main entity of the query.
+ * @param manager
+ * JPA EntityManager.
+ * @param misc
+ * Facade with all necessary tools for predicate creation.
+ * @return Predicate a predicate representation of the Node.
+ */
+ public static Predicate createPredicate(Node node, From root, Class entity, EntityManager manager,
+ BuilderTools misc) {
+ LOG.log(Level.INFO, "Creating Predicate for: {0}", node);
+
+ if (node instanceof LogicalNode) {
+ return createPredicate((LogicalNode) node, root, entity, manager, misc);
+ }
+
+ if (node instanceof ComparisonNode) {
+ return createPredicate((ComparisonNode) node, root, entity, manager, misc);
+ }
+
+ throw new IllegalArgumentException("Unknown expression type: " + node.getClass());
+ }
+
+ /**
+ * Create a Predicate from the RSQL AST logical node.
+ *
+ * @param logical
+ * RSQL AST logical node.
+ * @param root
+ * From that predicate expression paths depends on.
+ * @param entity
+ * The main entity of the query.
+ * @param entityManager
+ * JPA EntityManager.
+ * @param misc
+ * Facade with all necessary tools for predicate creation.
+ * @return Predicate a predicate representation of the Node.
+ */
+ public static Predicate createPredicate(LogicalNode logical, From root, Class entity,
+ EntityManager entityManager, BuilderTools misc) {
+ LOG.log(Level.INFO, "Creating Predicate for logical node: {0}", logical);
+
+ CriteriaBuilder builder = entityManager.getCriteriaBuilder();
+
+ List predicates = new ArrayList();
+
+ LOG.log(Level.INFO, "Creating Predicates from all children nodes.");
+ for (Node node : logical.getChildren()) {
+ predicates.add(createPredicate(node, root, entity, entityManager, misc));
+ }
+
+ switch (logical.getOperator()) {
+ case AND:
+ return builder.and(predicates.toArray(new Predicate[predicates.size()]));
+ case OR:
+ return builder.or(predicates.toArray(new Predicate[predicates.size()]));
}
- switch (logical.getOperator()) {
- case AND : return builder.and(predicates.toArray(new Predicate[predicates.size()]));
- case OR : return builder.or(predicates.toArray(new Predicate[predicates.size()]));
- }
-
- throw new IllegalArgumentException("Unknown operator: " + logical.getOperator());
- }
-
- /**
- * Create a Predicate from the RSQL AST comparison node.
- *
- * @param comparison RSQL AST comparison node.
- * @param startRoot From that predicate expression paths depends on.
- * @param entity The main entity of the query.
- * @param entityManager JPA EntityManager.
- * @param misc Facade with all necessary tools for predicate creation.
- * @return Predicate a predicate representation of the Node.
- */
- public static Predicate createPredicate(ComparisonNode comparison, From startRoot, Class entity, EntityManager entityManager, BuilderTools misc) {
- if (startRoot == null) {
- String msg = "From root node was undefined.";
- LOG.log(Level.SEVERE, msg);
- throw new IllegalArgumentException(msg);
- }
- LOG.log(Level.INFO, "Creating Predicate for comparison node: {0}", comparison);
-
- LOG.log(Level.INFO, "Property graph path : {0}", comparison.getSelector());
- Expression propertyPath = findPropertyPath(comparison.getSelector(), startRoot, entityManager, misc);
+ throw new IllegalArgumentException("Unknown operator: " + logical.getOperator());
+ }
+
+ /**
+ * Create a Predicate from the RSQL AST comparison node.
+ *
+ * @param comparison
+ * RSQL AST comparison node.
+ * @param startRoot
+ * From that predicate expression paths depends on.
+ * @param entity
+ * The main entity of the query.
+ * @param entityManager
+ * JPA EntityManager.
+ * @param misc
+ * Facade with all necessary tools for predicate creation.
+ * @return Predicate a predicate representation of the Node.
+ */
+ public static Predicate createPredicate(ComparisonNode comparison, From startRoot, Class entity,
+ EntityManager entityManager, BuilderTools misc) {
+ if (startRoot == null) {
+ String msg = "From root node was undefined.";
+ LOG.log(Level.SEVERE, msg);
+ throw new IllegalArgumentException(msg);
+ }
+ LOG.log(Level.INFO, "Creating Predicate for comparison node: {0}", comparison);
+
+ LOG.log(Level.INFO, "Property graph path : {0}", comparison.getSelector());
+ Expression propertyPath = findPropertyPath(comparison.getSelector(), startRoot, entityManager, misc);
LOG.log(Level.INFO, "Cast all arguments to type {0}.", propertyPath.getJavaType().getName());
- List