diff --git a/jnosql-criteria-extension/pom.xml b/jnosql-criteria-extension/pom.xml deleted file mode 100644 index 83f69456..00000000 --- a/jnosql-criteria-extension/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - 4.0.0 - - - org.eclipse.jnosql.mapping - jnosql-mapping-extensions - 1.1.1-SNAPSHOT - - - jnosql-criteria-extension - Eclipse JNoSQL criteria extension - - - - ${project.groupId} - jnosql-metamodel-extension - ${project.version} - - - ${project.groupId} - jnosql-metamodel-processor-extension - ${project.version} - true - - - diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/AbstractCompositionPredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/AbstractCompositionPredicate.java deleted file mode 100644 index f6ae631a..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/AbstractCompositionPredicate.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.CompositionPredicate; -import org.eclipse.jnosql.mapping.criteria.api.Predicate; -import java.util.Collection; - -/** - * Abstract class to extend for composing {@link Predicate}s - * - * @param The Entity type whose fetching is to be be restricted - */ -public abstract class AbstractCompositionPredicate extends AbstractPredicate implements CompositionPredicate { - - private final Collection> predicates; - - public AbstractCompositionPredicate(Collection> predicates) { - this.predicates = predicates; - } - - @Override - public Collection> getPredicates() { - return this.predicates; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/AbstractPredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/AbstractPredicate.java deleted file mode 100644 index baad6c66..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/AbstractPredicate.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.ConjunctionPredicate; -import org.eclipse.jnosql.mapping.criteria.api.DisjunctionPredicate; -import org.eclipse.jnosql.mapping.criteria.api.NegationPredicate; -import org.eclipse.jnosql.mapping.criteria.api.Predicate; -import java.util.Arrays; - -/** - * Abstract class for {@link Predicate} implementations. - * Supports basic operations such as negation, conjunction and disjunction. - * - * @param The Entity type whose fetching is to be be restricted - */ -public abstract class AbstractPredicate implements Predicate{ - - @Override - public NegationPredicate not() { - return new DefaultNegationPredicate(this); - } - - @Override - public ConjunctionPredicate and(Predicate restriction) { - return new DefaultConjunctionPredicate<>( - Arrays.asList( - this, - restriction - ) - ); - } - - @Override - public DisjunctionPredicate or(Predicate restriction) { - return new DefaultDisjunctionPredicate<>( - Arrays.asList( - this, - restriction - ) - ); - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/AbstractRestrictedQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/AbstractRestrictedQuery.java deleted file mode 100644 index 8c35fe7d..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/AbstractRestrictedQuery.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.Predicate; -import org.eclipse.jnosql.mapping.criteria.api.RestrictedQuery; -import org.eclipse.jnosql.mapping.criteria.api.CriteriaQueryResult; -import java.util.Arrays; -import java.util.Collection; - -/** - * Abstract class to extend for {@link RestrictedQuery} implementations - * - * @param the type of the root entity - * @param the type of the query result - * @param the type of the restricted query - */ -public abstract class AbstractRestrictedQuery, Q extends AbstractRestrictedQuery> extends DefaultCriteriaQuery { - - private Collection> restrictions; - - public AbstractRestrictedQuery(Class type) { - super(type); - } - - public Q where(Predicate... restrictions) { - this.restrictions = Arrays.asList(restrictions); - return (Q) this; - } - - public Collection> getRestrictions() { - return restrictions; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/CriteriaQueryUtils.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/CriteriaQueryUtils.java deleted file mode 100644 index bfe82c7a..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/CriteriaQueryUtils.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import jakarta.data.Sort; -import org.eclipse.jnosql.communication.document.DocumentCondition; -import org.eclipse.jnosql.mapping.criteria.api.BinaryPredicate; -import org.eclipse.jnosql.mapping.criteria.api.CompositionPredicate; -import org.eclipse.jnosql.mapping.criteria.api.DisjunctionPredicate; -import org.eclipse.jnosql.mapping.criteria.api.Expression; -import org.eclipse.jnosql.mapping.criteria.api.ExpressionQuery; -import org.eclipse.jnosql.mapping.criteria.api.NegationPredicate; -import org.eclipse.jnosql.mapping.criteria.api.Order; -import org.eclipse.jnosql.mapping.criteria.api.Path; -import org.eclipse.jnosql.mapping.criteria.api.Predicate; -import org.eclipse.jnosql.mapping.criteria.api.RangePredicate; -import org.eclipse.jnosql.mapping.criteria.api.Root; -import org.eclipse.jnosql.communication.document.DocumentQuery; -import org.eclipse.jnosql.mapping.criteria.api.SelectQuery; -import java.util.ArrayDeque; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Deque; -import java.util.Objects; -import static java.util.Objects.requireNonNull; -import java.util.Optional; -import java.util.function.BiFunction; -import java.util.function.Function; - -/** - * Utility to convert {@link Predicate}s in {@link DocumentCondition}s - */ -public class CriteriaQueryUtils { - - private CriteriaQueryUtils() { - } - - public static String join(String... values) { - return String.join(".", values); - } - - public static String unfold(Path path) { - Path tmp = path; - Deque attributes = new ArrayDeque(); - while (Objects.nonNull(tmp) && !(tmp instanceof Root)) { - attributes.add( - tmp.getAttribute().getName() - ); - tmp = tmp.getParent(); - } - return join( - attributes.stream().filter( - value -> isNotBlank(value.trim() - ) - ).toArray( - String[]::new - ) - ); - } - - public static String unfold(Expression expression) { - return join( - Arrays.asList( - unfold( - expression.getPath() - ), - expression.getAttribute().getName() - ).stream().filter( - value -> !Objects.equals( - 0, - value.trim().length() - ) - ).toArray( - String[]::new - ) - ); - } - - public static DocumentCondition computeCondition(Predicate predicate) { - DocumentCondition result = null; - if (predicate instanceof CompositionPredicate) { - Collection restrictions = CompositionPredicate.class.cast(predicate).getPredicates(); - Function function = predicate instanceof DisjunctionPredicate - ? DocumentCondition::or - : DocumentCondition::and; - result = function.apply( - restrictions.stream().map( - CriteriaQueryUtils::computeCondition - ).toArray( - DocumentCondition[]::new - ) - ); - } else if (predicate instanceof NegationPredicate) { - result = computeCondition( - NegationPredicate.class.cast(predicate).getPredicate() - ).negate(); - } else if (predicate instanceof BinaryPredicate) { - BinaryPredicate cast = BinaryPredicate.class.cast(predicate); - String lhs = unfold( - cast.getLeft() - ); - Object rhs = cast.getRight(); - if (rhs instanceof Expression) { - throw new UnsupportedOperationException("Not supported yet."); - } else { - BiFunction bifunction; - switch (cast.getOperator()) { - case EQUAL: - bifunction = DocumentCondition::eq; - break; - case GREATER_THAN: - bifunction = DocumentCondition::gt; - break; - case GREATER_THAN_OR_EQUAL: - bifunction = DocumentCondition::gte; - break; - case LESS_THAN: - bifunction = DocumentCondition::lt; - break; - case LESS_THAN_OR_EQUAL: - bifunction = DocumentCondition::lte; - break; - case IN: - bifunction = DocumentCondition::in; - break; - case LIKE: - bifunction = DocumentCondition::like; - break; - default: - throw new UnsupportedOperationException("Not supported yet."); - } - result = bifunction.apply(lhs, rhs); - } - } else if (predicate instanceof RangePredicate) { - RangePredicate cast = RangePredicate.class.cast(predicate); - String lhs = unfold( - cast.getLeft() - ); - Object from = cast.getFrom(); - Object to = cast.getTo(); - if (from instanceof Expression || to instanceof Expression) { - throw new UnsupportedOperationException("Not supported yet."); - } else { - BiFunction bifunction; - switch (cast.getOperator()) { - case EXCLUSIVE_BETWEEN: - case INCLUSIVE_BETWEEN: - bifunction = DocumentCondition::between; - break; - default: - throw new UnsupportedOperationException("Not supported yet."); - } - result = bifunction.apply(lhs, Arrays.asList(from, to)); - } - } - if (Objects.isNull(result)) { - throw new UnsupportedOperationException("Not supported yet."); - } - return result; - } - - public static DocumentQuery convert(SelectQuery selectQuery) { - requireNonNull(selectQuery, "query is required"); - - DocumentQuery.DocumentQueryBuilder builder; - - if (selectQuery instanceof ExpressionQuery) { - ExpressionQuery expressionQuery = ExpressionQuery.class.cast(selectQuery); - builder = DocumentQuery.builder( - expressionQuery.getExpressions().stream().map( - CriteriaQueryUtils::unfold - ).toArray( - String[]::new - ) - ); - } else { - builder = DocumentQuery.builder(); - } - - DocumentQuery.DocumentQueryBuilder where = builder.from( - selectQuery.getType().getSimpleName() - ).where( - DocumentCondition.and( - Optional.ofNullable( - selectQuery.getRestrictions() - ).orElse( - Collections.>emptyList() - ).stream().map( - CriteriaQueryUtils::computeCondition - ).toArray( - DocumentCondition[]::new - ) - ) - ).sort( - Optional.ofNullable( - selectQuery.getOrderBy() - ).orElse( - Collections.>emptyList() - ).stream().map( - orderBy -> { - String unfold = unfold(orderBy.getExpression()); - return orderBy.isAscending() ? Sort.asc(unfold) : Sort.desc(unfold); - } - ).toArray( - Sort[]::new - ) - ); - - DocumentQuery.DocumentQueryBuilder limit = Optional.ofNullable( - selectQuery.getMaxResults() - ).map( - where::limit - ).orElse(where); - - DocumentQuery.DocumentQueryBuilder skip = Optional.ofNullable( - selectQuery.getFirstResult() - ).map( - limit::skip - ).orElse(limit); - - return skip.build(); - } - - - private static boolean isBlank(final CharSequence cs) { - if (cs == null || cs.isEmpty()) { - return true; - } - - for (int i = 0; i < cs.length(); i++) { - if (!Character.isWhitespace(cs.charAt(i))) { - return false; - } - } - return true; - } - - private static boolean isNotBlank(final CharSequence cs) { - return !isBlank(cs); - } -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultAggregatedQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultAggregatedQuery.java deleted file mode 100644 index 6b392cc7..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultAggregatedQuery.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.communication.Value; -import org.eclipse.jnosql.mapping.criteria.api.AggregatedQuery; -import org.eclipse.jnosql.mapping.criteria.api.AggregatedQueryResult; -import org.eclipse.jnosql.mapping.criteria.api.Expression; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.stream.Stream; -import org.eclipse.jnosql.mapping.AbstractGenericType; - -/** - * Default implementation for {@link AggregatedQuery} - * - * @param the type of the root entity - */ -public class DefaultAggregatedQuery extends AbstractGenericType implements AggregatedQuery { - - private final Collection> groupings; - - public DefaultAggregatedQuery(Class type, Expression... groupings) { - super(type); - this.groupings = Arrays.asList(groupings); - } - - public Collection> getGroupings() { - return groupings; - } - - @Override - public AggregatedQueryResult getResult() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public AggregatedQuery feed(Stream> results) { - return this; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultAggregatedQueryResult.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultAggregatedQueryResult.java deleted file mode 100644 index 044f4e23..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultAggregatedQueryResult.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.AggregatedQueryResult; - -/** - * Default implementation for {@link AggregatedQueryResult} - * A container for aggregated results - * - * @param the type of the root entity - */ -public class DefaultAggregatedQueryResult extends DefaultFunctionQueryResult implements AggregatedQueryResult { - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultBinaryPredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultBinaryPredicate.java deleted file mode 100644 index 0d283f61..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultBinaryPredicate.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.BinaryPredicate; -import org.eclipse.jnosql.mapping.criteria.api.Expression; - -/** - * Default implementation for {@link BinaryPredicate} - * This holds the operator, the expression and the right hand side - * - * @param The root type - * @param The left hand side type - * @param The right hand side type - */ -public class DefaultBinaryPredicate extends AbstractPredicate implements BinaryPredicate { - - private final Operator operator; - private final Expression left; - private final RHS right; - - public DefaultBinaryPredicate(Operator operator, Expression left, RHS right) { - this.operator = operator; - this.left = left; - this.right = right; - } - - @Override - public Operator getOperator() { - return this.operator; - } - - @Override - public Expression getLeft() { - return left; - } - - @Override - public RHS getRight() { - return right; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultComparableExpression.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultComparableExpression.java deleted file mode 100644 index 4d238bfb..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultComparableExpression.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.BinaryPredicate; -import org.eclipse.jnosql.mapping.criteria.api.ComparableExpression; -import org.eclipse.jnosql.mapping.criteria.api.Expression; -import org.eclipse.jnosql.mapping.criteria.api.Order; -import org.eclipse.jnosql.mapping.criteria.api.Path; -import org.eclipse.jnosql.mapping.criteria.api.RangePredicate; -import org.eclipse.jnosql.mapping.metamodel.api.ComparableAttribute; - -/** - * Default implementation for {@link ComparableExpression} - * - * @param the root type - * @param the entity type - * @param the comparable type of the expression - */ -public class DefaultComparableExpression extends DefaultExpression implements ComparableExpression { - - public DefaultComparableExpression(Path path, ComparableAttribute attribute) { - super(path, attribute); - } - - @Override - public BinaryPredicate> greaterThan(Expression expression) { - return new DefaultBinaryPredicate(BinaryPredicate.Operator.GREATER_THAN, this, expression); - } - - @Override - public BinaryPredicate greaterThan(T y) { - return new DefaultBinaryPredicate(BinaryPredicate.Operator.GREATER_THAN, this, y); - } - - @Override - public BinaryPredicate> greaterThanOrEqualTo(Expression expression) { - return new DefaultBinaryPredicate(BinaryPredicate.Operator.GREATER_THAN_OR_EQUAL, this, expression); - } - - @Override - public BinaryPredicate greaterThanOrEqualTo(T y) { - return new DefaultBinaryPredicate(BinaryPredicate.Operator.GREATER_THAN_OR_EQUAL, this, y); - } - - @Override - public BinaryPredicate> lessThan(Expression expression) { - return new DefaultBinaryPredicate(BinaryPredicate.Operator.LESS_THAN, this, expression); - } - - @Override - public BinaryPredicate lessThan(T y) { - return new DefaultBinaryPredicate(BinaryPredicate.Operator.LESS_THAN, this, y); - } - - @Override - public BinaryPredicate> lessThanOrEqualTo(Expression expression) { - return new DefaultBinaryPredicate(BinaryPredicate.Operator.LESS_THAN_OR_EQUAL, this, expression); - } - - @Override - public BinaryPredicate lessThanOrEqualTo(T y) { - return new DefaultBinaryPredicate(BinaryPredicate.Operator.LESS_THAN_OR_EQUAL, this, y); - } - - @Override - public RangePredicate> exclusiveBetween(Expression from, Expression to) { - return new DefaultRangePredicate(RangePredicate.Operator.EXCLUSIVE_BETWEEN, this, from, to); - } - - @Override - public RangePredicate exclusiveBetween(T from, T to) { - return new DefaultRangePredicate(RangePredicate.Operator.EXCLUSIVE_BETWEEN, this, from, to); - } - - @Override - public RangePredicate> inclusiveBetween(Expression from, Expression to) { - return new DefaultRangePredicate(RangePredicate.Operator.INCLUSIVE_BETWEEN, this, from, to); - } - - @Override - public RangePredicate inclusiveBetween(T from, T to) { - return new DefaultRangePredicate(RangePredicate.Operator.INCLUSIVE_BETWEEN, this, from, to); - } - - @Override - public Order asc() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody - } - - @Override - public Order desc() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultConjunctionPredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultConjunctionPredicate.java deleted file mode 100644 index 6002ba96..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultConjunctionPredicate.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.ConjunctionPredicate; -import org.eclipse.jnosql.mapping.criteria.api.Predicate; -import java.util.Collection; - -/** - * Default implementation for {@link ConjunctionPredicate} - * - * @param The Entity type whose fetching is to be be restricted - */ -public class DefaultConjunctionPredicate extends AbstractCompositionPredicate implements ConjunctionPredicate { - - public DefaultConjunctionPredicate(Collection> predicates) { - super(predicates); - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultCriteriaDocumentTemplate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultCriteriaDocumentTemplate.java deleted file mode 100644 index 369698f6..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultCriteriaDocumentTemplate.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.communication.document.DocumentEntity; -import org.eclipse.jnosql.communication.document.DocumentManager; -import org.eclipse.jnosql.communication.document.DocumentQuery; -import org.eclipse.jnosql.mapping.core.Converters; -import org.eclipse.jnosql.mapping.document.DocumentEntityConverter; -import org.eclipse.jnosql.mapping.document.DocumentEventPersistManager; -import static java.util.Objects.requireNonNull; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.eclipse.jnosql.mapping.criteria.api.CriteriaQueryResult; -import org.eclipse.jnosql.mapping.criteria.api.EntityQuery; -import org.eclipse.jnosql.mapping.criteria.api.ExecutableQuery; -import org.eclipse.jnosql.mapping.criteria.api.ExpressionQuery; -import org.eclipse.jnosql.mapping.criteria.api.SelectQuery; -import org.eclipse.jnosql.mapping.criteria.api.CriteriaDocumentTemplate; -import org.eclipse.jnosql.mapping.document.AbstractDocumentTemplate; -import org.eclipse.jnosql.mapping.metadata.EntitiesMetadata; - -/** - * This class provides a delegating implementation of the - * {@link CriteriaDocumentTemplate} interface, to augment the wrapped - * DocumentTemplate with criteria API capabilities. - * - */ -public class DefaultCriteriaDocumentTemplate extends AbstractDocumentTemplate implements CriteriaDocumentTemplate { - - private DocumentManager manager; - - private DocumentEntityConverter converter; - - private EntitiesMetadata entities; - - private Converters converters; - - private DocumentEventPersistManager persistManager; - - public DefaultCriteriaDocumentTemplate( - DocumentManager manager, - DocumentEntityConverter converter, - EntitiesMetadata entities, - Converters converters, - DocumentEventPersistManager persistManager) { - this.manager = manager; - this.converter = converter; - this.entities = entities; - this.converters = converters; - this.persistManager = persistManager; - } - - @Override - public , Q extends ExecutableQuery, F> R executeQuery(ExecutableQuery criteriaQuery) { - requireNonNull(criteriaQuery, "query is required"); - if (criteriaQuery instanceof SelectQuery) { - SelectQuery selectQuery = SelectQuery.class.cast(criteriaQuery); - DocumentQuery documentQuery = CriteriaQueryUtils.convert(selectQuery); - Stream entityStream = this.getManager().select( - documentQuery - ); - - if (selectQuery instanceof EntityQuery) { - EntityQuery.class.cast(selectQuery).feed( - entityStream.map( - documentEntity -> this.getConverter().toEntity( - documentEntity - ) - ) - ); - } else if (selectQuery instanceof ExpressionQuery) { - ExpressionQuery.class.cast(selectQuery).feed( - entityStream.map( - documentEntity -> documentEntity.documents().stream().map( - document -> document.value() - ).collect( - Collectors.toList() - ) - ) - ); - } - } else { - throw new UnsupportedOperationException("Not supported yet."); - } - return criteriaQuery.getResult(); - } - - @Override - protected DocumentEntityConverter getConverter() { - return converter; - } - - @Override - protected DocumentManager getManager() { - return manager; - } - - @Override - protected DocumentEventPersistManager getEventManager() { - return persistManager; - } - - @Override - protected EntitiesMetadata getEntities() { - return entities; - } - - @Override - protected Converters getConverters() { - return converters; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultCriteriaDocumentTemplateProducer.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultCriteriaDocumentTemplateProducer.java deleted file mode 100644 index 206d0468..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultCriteriaDocumentTemplateProducer.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import jakarta.enterprise.context.ApplicationScoped; -import org.eclipse.jnosql.mapping.document.DocumentEntityConverter; -import org.eclipse.jnosql.mapping.document.DocumentEventPersistManager; -import jakarta.inject.Inject; -import org.eclipse.jnosql.communication.document.DocumentManager; -import org.eclipse.jnosql.mapping.core.Converters; -import org.eclipse.jnosql.mapping.criteria.api.CriteriaDocumentTemplate; -import org.eclipse.jnosql.mapping.criteria.api.CriteriaDocumentTemplateProducer; -import org.eclipse.jnosql.mapping.metadata.EntitiesMetadata; - -@ApplicationScoped -public class DefaultCriteriaDocumentTemplateProducer implements CriteriaDocumentTemplateProducer { - - @Inject - private DocumentEntityConverter converter; - - @Inject - private EntitiesMetadata entities; - - @Inject - private Converters converters; - - @Inject - private DocumentEventPersistManager persistManager; - - @Override - public CriteriaDocumentTemplate get(DocumentManager dm) { - return new DefaultCriteriaDocumentTemplate( - dm, - converter, - entities, - converters, - persistManager - ); - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultCriteriaQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultCriteriaQuery.java deleted file mode 100644 index c0ace83f..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultCriteriaQuery.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.CriteriaFunction; -import org.eclipse.jnosql.mapping.criteria.api.CriteriaQuery; -import org.eclipse.jnosql.mapping.criteria.api.EntityQuery; -import org.eclipse.jnosql.mapping.criteria.api.Expression; -import org.eclipse.jnosql.mapping.criteria.api.ExpressionQuery; -import org.eclipse.jnosql.mapping.criteria.api.FunctionQuery; -import org.eclipse.jnosql.mapping.criteria.api.Root; -import org.eclipse.jnosql.mapping.AbstractGenericType; - -/** - * Default implementation for {@link CriteriaQuery} - * - * @param the type of the root entity - */ -public class DefaultCriteriaQuery extends AbstractGenericType implements CriteriaQuery { - - private final Root from; - - public DefaultCriteriaQuery(Class type) { - super(type); - this.from = new DefaultRoot<>(type); - } - - @Override - public Root from() { - return this.from; - } - - @Override - public EntityQuery select() { - return new DefaultEntityQuery<>(this.getType()); - } - - @Override - public FunctionQuery select(CriteriaFunction... functions) { - return new DefaultFunctionQuery<>(this.getType(), functions); - } - - @Override - public ExpressionQuery select(Expression... expressions) { - return new DefaultExpressionQuery<>(this.getType(), expressions); - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultDisjunctionPredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultDisjunctionPredicate.java deleted file mode 100644 index e816ba45..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultDisjunctionPredicate.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.DisjunctionPredicate; -import org.eclipse.jnosql.mapping.criteria.api.Predicate; -import java.util.Collection; - -/** - * Default implementation for {@link DisjunctionPredicate} - * - * @param The Entity type whose fetching is to be be restricted - */ -public class DefaultDisjunctionPredicate extends AbstractCompositionPredicate implements DisjunctionPredicate { - - public DefaultDisjunctionPredicate(Collection> predicates) { - super(predicates); - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultEntityQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultEntityQuery.java deleted file mode 100644 index eeada914..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultEntityQuery.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.EntityQuery; -import java.util.stream.Stream; - -/** - * Default implementation for {@link EntityQuery} - * This holds the expressions to retrieve. - * - * @param the type of the expression - */ -public class DefaultEntityQuery extends DefaultSelectQuery, DefaultEntityQuery> implements EntityQuery { - - public DefaultEntityQuery(Class type) { - super(type); - } - - @Override - public EntityQuery feed(Stream results) { - this.setResult( - new DefaultEntityQueryResult(results) - ); - return this; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultEntityQueryResult.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultEntityQueryResult.java deleted file mode 100644 index 3a877f1f..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultEntityQueryResult.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import java.util.stream.Stream; -import org.eclipse.jnosql.mapping.criteria.api.EntityQueryResult; - -/** - * Default implementation for {@link EntityQueryResult} - * This holds the results entity stream - * - * @param the type of the root entity - */ -public class DefaultEntityQueryResult implements EntityQueryResult { - - private final Stream results; - - public DefaultEntityQueryResult(Stream results) { - this.results = results; - } - - @Override - public Stream getEntities() { - return this.results; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpression.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpression.java deleted file mode 100644 index 861b9d1a..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpression.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.BinaryPredicate; -import org.eclipse.jnosql.mapping.criteria.api.Expression; -import org.eclipse.jnosql.mapping.criteria.api.Path; -import org.eclipse.jnosql.mapping.metamodel.api.Attribute; -import java.util.Collection; - -/** - * Default implementation for {@link Expression} - * This holds the attribute and the path to the entity the attribute belongs to. - * - * @param the root type - * @param the entity type - * @param the type of the expression - */ -public class DefaultExpression implements Expression { - - private final Path path; - private final Attribute attribute; - - public DefaultExpression(Path path, Attribute attribute) { - this.path = path; - this.attribute = attribute; - } - - @Override - public Path getPath() { - return path; - } - - @Override - public Attribute getAttribute() { - return attribute; - } - - @Override - public BinaryPredicate> equal(Expression expression) { - return new DefaultBinaryPredicate(BinaryPredicate.Operator.EQUAL, this, expression); - } - - @Override - public BinaryPredicate equal(T value) { - return new DefaultBinaryPredicate(BinaryPredicate.Operator.EQUAL, this, value); - } - - @Override - public BinaryPredicate> in(Collection values) { - return new DefaultBinaryPredicate(BinaryPredicate.Operator.IN, this, values); - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpressionFunction.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpressionFunction.java deleted file mode 100644 index fcb46ee2..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpressionFunction.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.Expression; -import org.eclipse.jnosql.mapping.criteria.api.ExpressionFunction; - -/** - * Default implementation for {@link ExpressionFunction} - * This holds the function and the expression the function is applied to. - * - * @param the root type - * @param the entity type - * @param the type of the expression - */ -public class DefaultExpressionFunction implements ExpressionFunction { - - private final Expression expression; - private final Function function; - - public DefaultExpressionFunction(Expression expression, Function function) { - this.expression = expression; - this.function = function; - } - - @Override - public Expression getExpression() { - return expression; - } - - @Override - public Function getFunction() { - return function; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpressionQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpressionQuery.java deleted file mode 100644 index 03bb16c8..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpressionQuery.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.communication.Value; -import org.eclipse.jnosql.mapping.criteria.api.Expression; -import org.eclipse.jnosql.mapping.criteria.api.ExpressionQuery; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * Default implementation for {@link ExpressionQuery} This holds the expressions - * to retrieve. - * - * @param the type of the expression - */ -public class DefaultExpressionQuery extends DefaultSelectQuery, DefaultExpressionQuery> implements ExpressionQuery { - - private final List> expressions; - - public DefaultExpressionQuery(Class type, Expression... expressions) { - super(type); - this.expressions = Arrays.asList(expressions); - } - - @Override - public List> getExpressions() { - return expressions; - } - - @Override - public ExpressionQuery feed(Stream> results) { - this.setResult( - new DefaultExpressionQueryResult( - results.map( - result -> new DefaultExpressionQueryResultRow( - this.expressions.stream().collect( - Collectors.toMap( - expression -> expression, - expression -> result.get( - this.expressions.indexOf(expression) - ) - ) - ) - ) - ) - ) - ); - return this; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpressionQueryResult.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpressionQueryResult.java deleted file mode 100644 index 9b1c78fc..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpressionQueryResult.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.EntityQueryResult; -import org.eclipse.jnosql.mapping.criteria.api.ExpressionQueryResult; -import org.eclipse.jnosql.mapping.criteria.api.ExpressionQueryResultRow; -import java.util.stream.Stream; - -/** - * Default implementation for {@link EntityQueryResult} - * This contains the results {@link ExpressionQueryResultRow} stream - * - * @param the type of the root entity - */ -public class DefaultExpressionQueryResult implements ExpressionQueryResult { - - private final Stream> rows; - - public DefaultExpressionQueryResult(Stream> rows) { - this.rows = rows; - } - - @Override - public Stream> getRows() { - return this.rows; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpressionQueryResultRow.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpressionQueryResultRow.java deleted file mode 100644 index 9efeef2c..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultExpressionQueryResultRow.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.communication.Value; -import org.eclipse.jnosql.mapping.criteria.api.Expression; -import org.eclipse.jnosql.mapping.criteria.api.ExpressionQueryResultRow; -import java.util.Map; - -/** - * Default implementation for {@link ExpressionQueryResultRow} - * This holds a map to retrieve strongly typed values based on key expression - * - * @param the type of the root entity - */ -public class DefaultExpressionQueryResultRow implements ExpressionQueryResultRow { - - private final Map, Value> map; - - public DefaultExpressionQueryResultRow( - Map, Value> map - ) { - this.map = map; - } - - @Override - public T get(Expression expression) { - return this.map.get(expression).get( - expression.getAttribute().getAttributeType() - ); - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultFunctionQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultFunctionQuery.java deleted file mode 100644 index 93c24274..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultFunctionQuery.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.communication.Value; -import org.eclipse.jnosql.mapping.criteria.api.AggregatedQuery; -import org.eclipse.jnosql.mapping.criteria.api.CriteriaFunction; -import org.eclipse.jnosql.mapping.criteria.api.Expression; -import org.eclipse.jnosql.mapping.criteria.api.FunctionQuery; -import org.eclipse.jnosql.mapping.criteria.api.FunctionQueryResult; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.stream.Stream; - -/** - * Default implementation for {@link FunctionQuery} - * This holds the functions to retrieve. - * - * @param the type of the expression - */ -public class DefaultFunctionQuery extends AbstractRestrictedQuery, DefaultFunctionQuery> implements FunctionQuery { - - private final Collection> functions; - - public DefaultFunctionQuery(Class type, CriteriaFunction... functions) { - super(type); - this.functions = Arrays.asList(functions); - } - - @Override - public Collection> getFunctions() { - return functions; - } - - @Override - public AggregatedQuery groupBy(Expression... groupings) { - return new DefaultAggregatedQuery(this.getType(), groupings); - } - - @Override - public FunctionQueryResult getResult() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public FunctionQuery feed(Stream> results) { - return this; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultFunctionQueryResult.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultFunctionQueryResult.java deleted file mode 100644 index 50b79ce3..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultFunctionQueryResult.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.FunctionQueryResult; - -/** - * Default implementation for {@link FunctionQueryResult} - * This contains the results for this kind of query - * - * @param the type of the root entity - */ -public class DefaultFunctionQueryResult implements FunctionQueryResult { - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultNegationPredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultNegationPredicate.java deleted file mode 100644 index 6e4f2e52..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultNegationPredicate.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.NegationPredicate; -import org.eclipse.jnosql.mapping.criteria.api.Predicate; - -/** - * Default implementation for {@link NegationPredicate} - * This holds the predicate to negate. - * - * @param The Entity type whose fetching is to be be restricted - */ -public class DefaultNegationPredicate extends AbstractPredicate implements NegationPredicate { - - private final Predicate predicate; - - public DefaultNegationPredicate(Predicate predicate) { - this.predicate = predicate; - } - - @Override - public Predicate getPredicate() { - return this.predicate; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultNumberExpression.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultNumberExpression.java deleted file mode 100644 index a3ed9cc3..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultNumberExpression.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.ExpressionFunction; -import org.eclipse.jnosql.mapping.criteria.api.NumberExpression; -import org.eclipse.jnosql.mapping.criteria.api.Path; -import org.eclipse.jnosql.mapping.metamodel.api.NumberAttribute; - -/** - * Default implementation for {@link NumberExpression} - * - * @param the root type - * @param the entity type - * @param the number type of the expression - */ -public class DefaultNumberExpression extends DefaultComparableExpression implements NumberExpression { - - public DefaultNumberExpression(Path path, NumberAttribute attribute) { - super(path, attribute); - } - - @Override - public ExpressionFunction sum() { - return new DefaultExpressionFunction<>(this, ExpressionFunction.Function.SUM); - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultPath.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultPath.java deleted file mode 100644 index 5ba4622a..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultPath.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.Expression; -import org.eclipse.jnosql.mapping.criteria.api.Path; -import org.eclipse.jnosql.mapping.criteria.api.StringExpression; -import org.eclipse.jnosql.mapping.metamodel.api.ComparableAttribute; -import org.eclipse.jnosql.mapping.metamodel.api.EntityAttribute; -import org.eclipse.jnosql.mapping.metamodel.api.StringAttribute; -import org.eclipse.jnosql.mapping.metamodel.api.ValueAttribute; -import org.eclipse.jnosql.mapping.AbstractGenericType; -import org.eclipse.jnosql.mapping.criteria.api.ComparableExpression; -import org.eclipse.jnosql.mapping.criteria.api.NumberExpression; -import org.eclipse.jnosql.mapping.metamodel.api.Attribute; -import org.eclipse.jnosql.mapping.metamodel.api.NumberAttribute; - -/** - * Default implementation for for {@link Path} - * - * @param the entity type referenced by the root - * @param the destination type - */ -public class DefaultPath extends AbstractGenericType implements Path { - - private Path parent; - - private Attribute attribute; - - public DefaultPath(Class type) { - super(type); - } - - public DefaultPath(Class type, Path parent, Attribute attribute) { - super(type); - this.parent = parent; - this.attribute = attribute; - } - - @Override - public Path getParent() { - return this.parent; - } - - @Override - public Attribute getAttribute() { - return this.attribute; - } - - @Override - public Path get(EntityAttribute attribute) { - return new DefaultPath<>(this.getType(), this, attribute); - } - - @Override - public Expression get(ValueAttribute attribute) { - return new DefaultExpression<>(this, attribute); - } - - @Override - public StringExpression get(StringAttribute attribute) { - return new DefaultStringExpression<>(this, attribute); - } - - @Override - public ComparableExpression get(ComparableAttribute attribute) { - return new DefaultComparableExpression<>(this, attribute); - } - - @Override - public NumberExpression get(NumberAttribute attribute) { - return new DefaultNumberExpression<>(this, attribute); - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultPathFunction.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultPathFunction.java deleted file mode 100644 index 9baa4cbf..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultPathFunction.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.Path; -import org.eclipse.jnosql.mapping.criteria.api.PathFunction; - -/** - * Default implementation for {@link PathFunction} - * This holds the function and the path to apply the function to - * - * @param the root entity type - * @param the entity type - * @param the type of the attribute the function is applied to - * @param the return type of the function - */ -public class DefaultPathFunction implements PathFunction { - - private final Path path; - private final Function function; - - public DefaultPathFunction(Path path, Function function) { - this.path = path; - this.function = function; - } - - @Override - public Path getPath() { - return path; - } - - @Override - public Function getFunction() { - return function; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultRangePredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultRangePredicate.java deleted file mode 100644 index 7e2891ad..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultRangePredicate.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.Expression; -import org.eclipse.jnosql.mapping.criteria.api.RangePredicate; - -/** - * Default implementation for {@link RangePredicate} - * This holds the expression, the right hand side and the operator to apply to them - * - * @param The root type - * @param The left hand side type - * @param The right hand side type - */ -public class DefaultRangePredicate extends AbstractPredicate implements RangePredicate { - - private final Operator operator; - private final Expression left; - private final RHS from; - private final RHS to; - - public DefaultRangePredicate(Operator operator, Expression left, RHS from, RHS to) { - this.operator = operator; - this.left = left; - this.from = from; - this.to = to; - } - - @Override - public Operator getOperator() { - return this.operator; - } - - @Override - public Expression getLeft() { - return this.left; - } - - @Override - public RHS getFrom() { - return this.from; - } - - @Override - public RHS getTo() { - return this.to; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultRoot.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultRoot.java deleted file mode 100644 index d41dfbc6..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultRoot.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - *g - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.Path; -import org.eclipse.jnosql.mapping.criteria.api.PathFunction; -import org.eclipse.jnosql.mapping.criteria.api.Root; - -/** - * Default implementation for {@link Root} - * - * @param The Entity type whose fetching is to be be restricted - */ -public class DefaultRoot extends DefaultPath implements Root { - - public DefaultRoot(Class type) { - super(type); - } - - @Override - public Path getParent() { - return this; - } - - @Override - public PathFunction count() { - return new DefaultPathFunction<>(this, PathFunction.Function.COUNT); - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultSelectQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultSelectQuery.java deleted file mode 100644 index a0bd8e83..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultSelectQuery.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.CriteriaQueryResult; -import org.eclipse.jnosql.mapping.criteria.api.Order; -import org.eclipse.jnosql.mapping.criteria.api.SelectQuery; -import java.util.Arrays; -import java.util.List; - -/** - * Default implementation for {@link SelectQuery} - * - * @param the type of the root entity - * @param the type of the select query result - * @param select query implementation - */ -public abstract class DefaultSelectQuery, I extends DefaultSelectQuery> extends AbstractRestrictedQuery { - - private List> sortings; - private Integer maxResults; - private Integer firstResult; - private R result; - - public DefaultSelectQuery(Class type) { - super(type); - } - - public I orderBy(Order... sortings) { - this.sortings = Arrays.asList(sortings); - return (I) this; - } - - public List> getOrderBy() { - return this.sortings; - } - - public I setMaxResults(Integer maxResults) { - this.maxResults = maxResults; - return (I) this; - } - - public Integer getMaxResults() { - return maxResults; - } - - public I setFirstResult(Integer firstResult) { - this.firstResult = firstResult; - return (I) this; - } - - public Integer getFirstResult() { - return firstResult; - } - - protected void setResult(R result) { - this.result = result; - } - - public R getResult() { - return this.result; - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultStringExpression.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultStringExpression.java deleted file mode 100644 index 08e962fd..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/DefaultStringExpression.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import org.eclipse.jnosql.mapping.criteria.api.BinaryPredicate; -import org.eclipse.jnosql.mapping.criteria.api.Path; -import org.eclipse.jnosql.mapping.criteria.api.StringExpression; -import org.eclipse.jnosql.mapping.metamodel.api.StringAttribute; - -/** - * Default implementation for {@link StringExpression} - * - * @param the root type - * @param the entity type - */ -public class DefaultStringExpression extends DefaultExpression implements StringExpression { - - public DefaultStringExpression(Path path, StringAttribute attribute) { - super(path, attribute); - } - - @Override - public BinaryPredicate like(String pattern) { - return new DefaultBinaryPredicate(BinaryPredicate.Operator.LIKE, this, pattern); - } - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/AggregatedQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/AggregatedQuery.java deleted file mode 100644 index edf80c3c..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/AggregatedQuery.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import org.eclipse.jnosql.communication.Value; -import java.util.List; -import java.util.stream.Stream; - -/** - * The AggregatedQuery interface defines functionality that is - * specific to aggregated queries. - * - * @param the type of the root entity - */ -public interface AggregatedQuery extends ExecutableQuery, AggregatedQuery, Stream>> { - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/AggregatedQueryResult.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/AggregatedQueryResult.java deleted file mode 100644 index b13821be..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/AggregatedQueryResult.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * Allows retrieving of aggregated query results - * - * @param the type of the root entity - */ -public interface AggregatedQueryResult extends CriteriaQueryResult { - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/BinaryPredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/BinaryPredicate.java deleted file mode 100644 index f03d3d1c..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/BinaryPredicate.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * An {@link Predicate} to apply a binary operator - * - * @param The root type - * @param The left hand side type - * @param The right hand side type - */ -public interface BinaryPredicate extends Predicate { - - /** - * Supported binary operators - * - */ - enum Operator { - EQUAL, - IN, - GREATER_THAN, - GREATER_THAN_OR_EQUAL, - LESS_THAN, - LESS_THAN_OR_EQUAL, - LIKE - } - - /** - * Return the operator for this {@link Predicate}. - * - * @return negated predicate - */ - Operator getOperator(); - - /** - * Return the left hand side for this {@link Predicate}. - * - * @return negated predicate - */ - Expression getLeft(); - - /** - * Return the right hand side for this {@link Predicate}. - * - * @return negated predicate - */ - R getRight(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ComparableExpression.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ComparableExpression.java deleted file mode 100644 index cae371bb..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ComparableExpression.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * Type for query expressions representing a comparable Entity attribute - * - * @param the root type - * @param the entity type - * @param the comparable type of the expression - */ -public interface ComparableExpression extends Expression { - - /** - * Create a predicate for testing whether this expression is greater than - * the argument expression - * - * @param expression expression - * @return greater-than predicate - */ - BinaryPredicate> greaterThan(Expression expression); - - /** - * Create a predicate for testing whether this expression is greater than - * the argument value - * - * @param y value - * @return greater-than predicate - */ - BinaryPredicate greaterThan(T y); - - /** - * Create a predicate for testing whether this expression is greater than or - * equal to the argument expression - * - * @param expression expression - * @return greater-than-or-equal predicate - */ - BinaryPredicate> greaterThanOrEqualTo(Expression expression); - - /** - * Create a predicate for testing whether this expression is greater than or - * equal to the argument value - * - * @param y value - * @return greater-than-or-equal predicate - */ - BinaryPredicate greaterThanOrEqualTo(T y); - - /** - * Create a predicate for testing whether this expression is less than the - * argument expression - * - * @param expression expression - * @return greater-than-or-equal predicate - */ - BinaryPredicate> lessThan(Expression expression); - - /** - * Create a predicate for testing whether this expression is less than the - * argument value - * - * @param y value - * @return greater-than-or-equal predicate - */ - BinaryPredicate lessThan(T y); - - /** - * Create a predicate for testing whether this expression is less than or - * equal to the argument expression - * - * @param expression expression - * @return greater-than-or-equal predicate - */ - BinaryPredicate> lessThanOrEqualTo(Expression expression); - - /** - * Create a predicate for testing whether this expression is less than or - * equal to the argument value - * - * @param y value - * @return greater-than-or-equal predicate - */ - BinaryPredicate lessThanOrEqualTo(T y); - - /** - * Create a predicate for testing whether the this expression is between the - * first and second argument expressions in value - * - * @param exprsn1 expression - * @param exprsn2 expression - * @return between predicate - */ - RangePredicate> exclusiveBetween(Expression exprsn1, Expression exprsn2); - - /** - * Create a predicate for testing whether the this expression value is - * between the first and second argument values - * - * @param x value - * @param y value - * @return between predicate - */ - RangePredicate exclusiveBetween(T x, T y); - - /** - * Create a predicate for testing whether the this expression is between the - * first and second argument expressions in value - * - * @param exprsn1 expression - * @param exprsn2 expression - * @return between predicate - */ - RangePredicate> inclusiveBetween(Expression exprsn1, Expression exprsn2); - - /** - * Create a predicate for testing whether the this expression value is - * between the first and second argument values - * - * @param x value - * @param y value - * @return between predicate - */ - RangePredicate inclusiveBetween(T x, T y); - - /** - * Create an ordering by the ascending value of this expression - * - * @return ascending ordering corresponding to the expression - */ - Order asc(); - - /** - * Create an ordering by the descending value of the expression - * - * @return descending ordering corresponding to the expression - */ - Order desc(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CompositionPredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CompositionPredicate.java deleted file mode 100644 index 475cd732..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CompositionPredicate.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import java.util.Collection; - -/** - * Composition of {@link Predicate}s - * - * @param The Entity type whose fetching is to be be restricted - */ -public interface CompositionPredicate extends Predicate { - - /** - * Return the composed {@link Predicate}s. - * - * @return collection of predicates - */ - Collection> getPredicates(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ConjunctionPredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ConjunctionPredicate.java deleted file mode 100644 index a0fd2fb2..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ConjunctionPredicate.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * Conjunction of {@link Predicate}s - * - * @param The Entity type whose fetching is to be be restricted - */ -public interface ConjunctionPredicate extends CompositionPredicate { - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaDocumentTemplate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaDocumentTemplate.java deleted file mode 100644 index f2f62482..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaDocumentTemplate.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import jakarta.nosql.document.DocumentTemplate; -import org.eclipse.jnosql.mapping.criteria.DefaultCriteriaQuery; - -/** - * A criteria extension of {@link DocumentTemplate} - */ -public interface CriteriaDocumentTemplate extends DocumentTemplate { - - /** - * Create a CriteriaQuery object with the specified result - * type. - * - * @param type of the query result - * @param type type of the query result - * @return criteria query object - * @throws NullPointerException query is null - */ - default CriteriaQuery createQuery(Class type) { - return new DefaultCriteriaQuery<>(type); - } - - /** - * Executes a {@link CriteriaQuery} - * - * @param criteriaQuery - the query - * @param the instance type of the query - * {@link org.eclipse.jnosql.mapping.criteria.api.Root} - * @param the result type of the query - * @param the type of the actual query - * @param the type of data to feed the query with - * @return query result - * @throws NullPointerException when criteriaQuery is null - */ - , Q extends ExecutableQuery, F> R executeQuery(ExecutableQuery criteriaQuery); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaDocumentTemplateProducer.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaDocumentTemplateProducer.java deleted file mode 100644 index 03ca4bed..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaDocumentTemplateProducer.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import org.eclipse.jnosql.communication.document.DocumentManager; - -public interface CriteriaDocumentTemplateProducer { - -public T get(DocumentManager dm); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaFunction.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaFunction.java deleted file mode 100644 index 6b114213..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaFunction.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * A function to be used in a function query - * - * @param the root entity type - * @param the entity type - * @param the type of the attribute the function is applied to - * @param the return type of the function - */ -public interface CriteriaFunction { - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaQuery.java deleted file mode 100644 index cab49b48..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaQuery.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * The CriteriaQuery interface defines functionality that is - * specific to top-level queries. - * - * @param the type of the root entity - */ -public interface CriteriaQuery { - - /** - * Returns the query root - * - * @return from clause - */ - Root from(); - - /** - * Creates a select query - * - * @return select query - */ - EntityQuery select(); - - /** - * Creates a select function query - * - * @param functions to be computed - * @return function query - */ - FunctionQuery select(CriteriaFunction... functions); - - /** - * Creates a select expression query - * - * @param expressions to retrieve - * @return select query - */ - ExpressionQuery select(Expression... expressions); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaQueryResult.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaQueryResult.java deleted file mode 100644 index d3fa2e7c..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/CriteriaQueryResult.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * Generic interface for other query type results - * - * @param the type of the root entity - */ -public interface CriteriaQueryResult { - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/DisjunctionPredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/DisjunctionPredicate.java deleted file mode 100644 index 5b4f65dc..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/DisjunctionPredicate.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * Disjunction of {@link Predicate}s - * - * @param The Entity type whose fetching is to be be restricted - */ -public interface DisjunctionPredicate extends CompositionPredicate { - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/EntityQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/EntityQuery.java deleted file mode 100644 index 4379d167..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/EntityQuery.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import java.util.stream.Stream; - -/** - * The EntityQuery interface defines a query to fetch entities. - * - * @param the type of the root entity - */ -public interface EntityQuery extends SelectQuery, EntityQuery, Stream> { - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/EntityQueryResult.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/EntityQueryResult.java deleted file mode 100644 index cfffdb6c..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/EntityQueryResult.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import java.util.stream.Stream; - -/** - * Allows retrieving of entities from an entity query - * - * @param the type of the root entity - */ -public interface EntityQueryResult extends CriteriaQueryResult { - - /** - * Retrieves the result stream. - * - * @return the result stream - */ - Stream getEntities(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExecutableQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExecutableQuery.java deleted file mode 100644 index a54c8afc..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExecutableQuery.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * The ExecutableQuery interface defines functionality that is - * specific to executable queries. - * - * @param the type of the root entity - * @param the type of the query result - * @param the type of the actual query - * @param the type of the actual result data to feed - */ -public interface ExecutableQuery, Q extends ExecutableQuery, F> { - - /** - * Retrieves the root type. - * - * @return root type - */ - Class getType(); - - /** - * Retrieves the result. - * - * @return result - */ - R getResult(); - - /** - * Feed the results specific for this kind of query. - * - * @param results the result - * @return the same query instance - * @throws NullPointerException if the argument is null - */ - Q feed(F results); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Expression.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Expression.java deleted file mode 100644 index 0c109ffb..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Expression.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import org.eclipse.jnosql.mapping.metamodel.api.Attribute; -import java.util.Collection; - -/** - * Type for query expressions representing an Entity attribute - * - * @param the root type - * @param the entity type - * @param the type of the expression - */ -public interface Expression { - - /** - * Retrieves the path of this expression - * - * @return path - */ - Path getPath(); - - /** - * Retrieves the attribute of this expression - * - * @return attribute - */ - Attribute getAttribute(); - - /** - * Create a predicate for testing if the expression is equal to the argument - * expression - * - * @param expression the expression to check the equality against - * @return equality predicate - */ - BinaryPredicate> equal(Expression expression); - - /** - * Create a predicate for testing if the expression is equal to the argument - * value - * - * @param value the value to check the equality against - * @return equality predicate - */ - BinaryPredicate equal(T value); - - /** - * Create a predicate to test whether the expression is a member of the - * argument list. - * - * @param values values to be tested against - * @return predicate testing for membership - */ - BinaryPredicate> in(Collection values); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExpressionFunction.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExpressionFunction.java deleted file mode 100644 index a1d0fb52..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExpressionFunction.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * A function applied to an expression, to be retrieved in a function query - * - * @param the root entity type - * @param the entity type - * @param the type of the attribute the function is applied to - * @param the return type of the function - */ -public interface ExpressionFunction extends CriteriaFunction { - - /** - * Supported expression functions - * - */ - enum Function { - SUM - } - - /** - * Retrieves the expression the function must be applied to - * - * @return the expression - */ - Expression getExpression(); - - /** - * Retrieves the function to apply to the expression - * - * @return attribute - */ - Function getFunction(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExpressionQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExpressionQuery.java deleted file mode 100644 index aa548767..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExpressionQuery.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import org.eclipse.jnosql.communication.Value; - -import java.util.Collection; -import java.util.List; -import java.util.stream.Stream; - -/** - * The ExpressionQuery interface defines functionality that is - * specific to select queries retrieving only a subset of the entity fields. - * - * @param the type of the root entity - */ -public interface ExpressionQuery extends SelectQuery, ExpressionQuery, Stream>> { - - /** - * Retrieves the expressions of the fields to retrieve. - * - * @return the expressions - */ - Collection> getExpressions(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExpressionQueryResult.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExpressionQueryResult.java deleted file mode 100644 index e64612b9..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExpressionQueryResult.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import java.util.stream.Stream; - -/** - * Allows retrieving result values of an expression query - * - * @param the type of the root entity - */ -public interface ExpressionQueryResult extends CriteriaQueryResult { - - Stream> getRows(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExpressionQueryResultRow.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExpressionQueryResultRow.java deleted file mode 100644 index e98b2937..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/ExpressionQueryResultRow.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * Allows retrieving of data in a result row - * - * @param the type of the root entity - */ -public interface ExpressionQueryResultRow { - - T get(Expression expression); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/FunctionQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/FunctionQuery.java deleted file mode 100644 index 408b1a93..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/FunctionQuery.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import org.eclipse.jnosql.communication.Value; - - -import java.util.Collection; -import java.util.List; -import java.util.stream.Stream; - -/** - * The FunctionQuery interface defines functionality that is - * specific to function queries. - * - * @param the type of the root entity - */ -public interface FunctionQuery extends RestrictedQuery, FunctionQuery, Stream>> { - - /** - * Return the collection of {@link CriteriaFunction}s to retrieve. - * - * @return collection of functions - */ - Collection> getFunctions(); - - /** - * Specify the expressions that are used to form groups over - * the query results. - * Replaces the previous specified grouping expressions, if any. - * If no grouping expressions are specified, any previously - * added grouping expressions are simply removed. - * @param grouping zero or more grouping expressions - * @return the aggregated query - */ - AggregatedQuery groupBy(Expression... grouping); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/FunctionQueryResult.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/FunctionQueryResult.java deleted file mode 100644 index 56836a38..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/FunctionQueryResult.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * Allows retrieving of function query results - * - * @param the type of the root entity - */ -public interface FunctionQueryResult extends CriteriaQueryResult { - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/NegationPredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/NegationPredicate.java deleted file mode 100644 index 3d3f9e99..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/NegationPredicate.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * Negation of a {@link Predicate} - * - * @param The Entity type whose fetching is to be be restricted - */ -public interface NegationPredicate extends Predicate { - - /** - * Return the negated {@link Predicate}. - * - * @return negated predicate - */ - Predicate getPredicate(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/NumberExpression.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/NumberExpression.java deleted file mode 100644 index f30faed1..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/NumberExpression.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * Type for query expressions representing a number attribute - * - * @param the root type - * @param the entity type - * @param the number type of the expression - */ -public interface NumberExpression extends ComparableExpression { - - /** - * Return the {@link CriteriaFunction} to sum this {@link NumberExpression}. - * - * @return operator - */ - ExpressionFunction sum(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Order.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Order.java deleted file mode 100644 index 81c1bd91..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Order.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * An object that defines an ordering over the query results - * - * @param the root type - * @param the type of the defined result - */ -public interface Order { - - /** - * Whether ascending ordering is in effect - * - * @return boolean indicating whether ordering is ascending - */ - boolean isAscending(); - - /** - * Return the expression that is used for ordering - * - * @return expression used for ordering - */ - ComparableExpression getExpression(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Path.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Path.java deleted file mode 100644 index 18b9ee3c..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Path.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import org.eclipse.jnosql.mapping.metamodel.api.Attribute; -import org.eclipse.jnosql.mapping.metamodel.api.ComparableAttribute; -import org.eclipse.jnosql.mapping.metamodel.api.EntityAttribute; -import org.eclipse.jnosql.mapping.metamodel.api.NumberAttribute; -import org.eclipse.jnosql.mapping.metamodel.api.StringAttribute; -import org.eclipse.jnosql.mapping.metamodel.api.ValueAttribute; - -/** - * The Entity type representing a path from the root type in a {@link CriteriaQuery} - * - * @param the entity type referenced by the root - * @param the destination type - */ -public interface Path { - - /** - * Returns the parent path - * - * @return parent path - */ - Path getParent(); - - /** - * Returns the attribute that binds parent {@link Path} to this - * - * @return parent path - */ - Attribute getAttribute(); - - - /** - * Create a path corresponding to the referenced entity attribute - * - * @param the type of the entity attribute - * @param attribute entity attribute - * @return path corresponding to the entity attribute - */ - Path get(EntityAttribute attribute); - - /** - * Create an expression corresponding to the referenced single-valued - * attribute - * - * @param the type of the attribute - * @param attribute single-valued attribute - * @return expression corresponding to the referenced attribute - */ - Expression get(ValueAttribute attribute); - - /** - * Create an expression corresponding to the referenced single-valued string - * attribute - * - * @param attribute single-valued string attribute - * @return string expression corresponding to the referenced string - * attribute - */ - StringExpression get(StringAttribute attribute); - - /** - * Create an expression corresponding to the referenced single-valued - * comparable attribute - * - * @param the type of the comparable attribute - * @param attribute single-valued comparable attribute - * @return comparable expression corresponding to the referenced comparable - * attribute - */ - ComparableExpression get(ComparableAttribute attribute); - - /** - * Create an expression corresponding to the referenced single-valued - * number attribute - * - * @param the type of the number attribute - * @param attribute single-valued number attribute - * @return comparable expression corresponding to the referenced comparable - * attribute - */ - NumberExpression get(NumberAttribute attribute); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/PathFunction.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/PathFunction.java deleted file mode 100644 index 089c002d..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/PathFunction.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * A function to be applied to a path, to be retrieved in a function query - * - * @param the root entity type - * @param the entity type - * @param the type of the attribute the function is applied to - * @param the return type of the function - */ -public interface PathFunction extends CriteriaFunction { - - /** - * Supported path functions - * - */ - enum Function { - COUNT - } - - /** - * Retrieves the path the function must be applied to - * - * @return the path - */ - Path getPath(); - - /** - * Retrieves the function to apply to the path - * - * @return attribute - */ - Function getFunction(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Predicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Predicate.java deleted file mode 100644 index 0579329d..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Predicate.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * A predicate representing a restriction in a {@link CriteriaQuery} - * - * @param The Entity type whose fetching is to be be restricted - */ -public interface Predicate { - - /** - * Create a negation of this restriction. - * - * @return not predicate - */ - NegationPredicate not(); - - /** - * Create a conjunction of this with the argument restriction - * - * @param restriction restriction - * @return and predicate - */ - ConjunctionPredicate and(Predicate restriction); - - /** - * Create a disjunction of this with the argument restriction - * - * @param restriction restriction - * @return or predicate - */ - DisjunctionPredicate or(Predicate restriction); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/RangePredicate.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/RangePredicate.java deleted file mode 100644 index 0d826acc..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/RangePredicate.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * An {@link Predicate} to apply a range operator - * - * @param The root type - * @param The left hand side type - * @param The right hand side type - */ -public interface RangePredicate extends Predicate { - - enum Operator { - INCLUSIVE_BETWEEN, - EXCLUSIVE_BETWEEN - } - - /** - * Return the operator for this {@link Predicate}. - * - * @return negated predicate - */ - Operator getOperator(); - - /** - * Return the left hand side for this {@link Predicate}. - * - * @return negated predicate - */ - Expression getLeft(); - - /** - * Return the from value for this {@link Predicate}. - * - * @return negated predicate - */ - R getFrom(); - - /** - * Return the to value for this {@link Predicate}. - * - * @return negated predicate - */ - R getTo(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/RestrictedQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/RestrictedQuery.java deleted file mode 100644 index 7a87a389..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/RestrictedQuery.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import java.util.Collection; - -/** - * The RestrictedQuery interface defines functionality that is - * specific to restricted queries. - * - * @param the type of the root entity - * @param the type of the query result - * @param the type of the restricted query - * @param the type of data to feed the query with - */ -public interface RestrictedQuery, Q extends RestrictedQuery, F> extends ExecutableQuery { - - /** - * Modify the query to restrict the query result according to the - * conjunction of the specified restriction predicates. Replaces the - * previously added restriction(s), if any. - * - * @param restrictions zero or more restriction predicates - * @return the modified query - */ - Q where(Predicate... restrictions); - - /** - * Retrieves the restriction collection. - * - * @return the restrictions - */ - Collection> getRestrictions(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Root.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Root.java deleted file mode 100644 index 37bb775a..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/Root.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * A root type in the from clause. - * Query roots always reference entities. - * - * @param the entity type referenced by the root - */ -public interface Root extends Path { - - PathFunction count(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/SelectQuery.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/SelectQuery.java deleted file mode 100644 index 994eec19..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/SelectQuery.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -import java.util.List; - -/** - * The SelectQuery interface defines functionality that is - * specific to select queries. - * - * @param the type of the root entity - * @param the type of the query result - * @param the type of the restricted query - * @param the type of data to feed the query with - */ -public interface SelectQuery, Q extends SelectQuery, F> extends RestrictedQuery { - - /** - * Specify the ordering expressions that are used to order the query - * results. Replaces the previous ordering expressions, if any. The - * left-to-right sequence of the ordering expressions determines the - * precedence, whereby the leftmost has highest precedence. - * - * @param sortings zero or more ordering expressions - * @return the modified query - * @throws NullPointerException if the argument is null - */ - Q orderBy(Order... sortings); - - /** - * Retrieves the ordering expressions that are used to order the query - * results. Replaces the previous ordering expressions, if any. The - * left-to-right sequence of the ordering expressions determines the - * precedence, whereby the leftmost has highest precedence. - * - * @return the modified query - */ - List> getOrderBy(); - - /** - * Set the maximum number of results to retrieve. - * - * @param maxResults maximum number of results to retrieve - * @return the same query instance - * @throws IllegalArgumentException if the argument is negative - */ - Q setMaxResults(Integer maxResults); - - /** - * Retrieves the maximum number of results to retrieve. - * - * @return maximum number of results - */ - Integer getMaxResults(); - - /** - * Set the position of the first result to retrieve. - * - * @param firstResult position of the first result, numbered from 0 - * @return the same query instance - * @throws IllegalArgumentException if the argument is negative - */ - Q setFirstResult(Integer firstResult); - - /** - * Retrieves the position of the first result to retrieve. - * - * @return the position of the first result - */ - Integer getFirstResult(); - -} diff --git a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/StringExpression.java b/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/StringExpression.java deleted file mode 100644 index 18256a36..00000000 --- a/jnosql-criteria-extension/src/main/java/org/eclipse/jnosql/mapping/criteria/api/StringExpression.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria.api; - -/** - * Type for query expressions representing a string Entity attribute - * - * @param the root type - * @param the entity type - */ -public interface StringExpression extends Expression { - - /** - * Create a predicate for testing whether this expression satisfies the - * given pattern - * - * @param pattern string - * @return like predicate - */ - Predicate like(String pattern); - -} diff --git a/jnosql-criteria-extension/src/main/resources/META-INF/beans.xml b/jnosql-criteria-extension/src/main/resources/META-INF/beans.xml deleted file mode 100644 index 0340ecdb..00000000 --- a/jnosql-criteria-extension/src/main/resources/META-INF/beans.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - \ No newline at end of file diff --git a/jnosql-criteria-extension/src/test/java/org/eclipse/jnosql/mapping/criteria/DefaultCriteriaDocumentTemplateTest.java b/jnosql-criteria-extension/src/test/java/org/eclipse/jnosql/mapping/criteria/DefaultCriteriaDocumentTemplateTest.java deleted file mode 100644 index 3a7f3270..00000000 --- a/jnosql-criteria-extension/src/test/java/org/eclipse/jnosql/mapping/criteria/DefaultCriteriaDocumentTemplateTest.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Otavio Santana - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.criteria; - -import jakarta.inject.Inject; -import org.eclipse.jnosql.communication.document.Document; -import org.eclipse.jnosql.communication.document.DocumentCondition; -import org.eclipse.jnosql.communication.document.DocumentEntity; -import org.eclipse.jnosql.communication.document.DocumentManager; -import org.eclipse.jnosql.communication.document.DocumentQuery; -import org.eclipse.jnosql.mapping.core.Converters; -import org.eclipse.jnosql.mapping.criteria.api.CriteriaDocumentTemplate; -import org.eclipse.jnosql.mapping.criteria.api.CriteriaDocumentTemplateProducer; -import org.eclipse.jnosql.mapping.criteria.api.CriteriaQuery; -import org.eclipse.jnosql.mapping.criteria.api.EntityQueryResult; -import org.eclipse.jnosql.mapping.criteria.api.ExpressionQueryResult; -import org.eclipse.jnosql.mapping.criteria.api.ExpressionQueryResultRow; -import org.eclipse.jnosql.mapping.criteria.api.NumberExpression; -import org.eclipse.jnosql.mapping.criteria.api.StringExpression; -import org.eclipse.jnosql.mapping.document.DocumentEntityConverter; -import org.eclipse.jnosql.mapping.document.spi.DocumentExtension; -import org.eclipse.jnosql.mapping.reflection.Reflections; -import org.eclipse.jnosql.mapping.core.spi.EntityMetadataExtension; -import org.jboss.weld.junit5.auto.AddExtensions; -import org.jboss.weld.junit5.auto.AddPackages; -import org.jboss.weld.junit5.auto.EnableAutoWeld; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; - -import java.util.Arrays; -import java.util.Optional; -import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.mock; - -@EnableAutoWeld -@AddPackages(value = {Converters.class, - DocumentEntityConverter.class, DefaultPath.class}) -@AddPackages(Person.class) -@AddPackages(Reflections.class) -@AddExtensions({EntityMetadataExtension.class, - DocumentExtension.class}) -class DefaultCriteriaDocumentTemplateTest { - - @Inject - private DocumentEntityConverter converter; - - private DocumentManager documentManager; - - @Inject - private CriteriaDocumentTemplateProducer criteriaDocumentTemplateProducer; - - private CriteriaDocumentTemplate criteriaDocumentTemplate; - - @BeforeEach - public void setUp() { - this.documentManager = mock(DocumentManager.class); - criteriaDocumentTemplate = criteriaDocumentTemplateProducer.get(documentManager); - } - - @Test - public void shouldSelectEntitiesWithCriteria() { - - DocumentEntity documentEntity = DocumentEntity.of( - "Person", - Arrays.asList( - Document.of("_id", "Poliana"), - Document.of("age", 17) - ) - ); - - Mockito.when( - documentManager.select( - DocumentQuery.builder().from( - "Person" - ).where( - DocumentCondition.and( - new DocumentCondition[]{ - DocumentCondition.or( - DocumentCondition.eq( - "name", - "Poliana" - ), - DocumentCondition.gte( - "age", - 17 - ) - ) - } - ) - ).build() - ) - ).thenReturn( - Stream.of( - documentEntity - ) - ); - - CriteriaQuery personQuery = criteriaDocumentTemplate.createQuery(Person.class); - - EntityQueryResult executeQuery = criteriaDocumentTemplate.executeQuery( - personQuery.select().where( - personQuery.from().get( - Person_.name - ).equal( - "Poliana" - ).or( - personQuery.from().get( - Person_.age - ).greaterThanOrEqualTo(17) - ) - ) - ); - - Optional findFirst = executeQuery.getEntities().findFirst(); - - assertTrue( - findFirst.isPresent() - ); - assertEquals( - converter.toDocument( - findFirst.get() - ), - documentEntity - ); - - } - - @Test - public void shouldSelectProjectionsWithCriteria() { - - DocumentEntity documentEntity = DocumentEntity.of( - "Person", - Arrays.asList( - Document.of("_id", "Poliana"), - Document.of("age", 17) - ) - ); - - Mockito.when( - documentManager.select( - DocumentQuery.builder( - "name", - "age" - ).from( - "Person" - ).where( - DocumentCondition.and( - new DocumentCondition[]{ - DocumentCondition.or( - DocumentCondition.eq( - "name", - "Poliana" - ), - DocumentCondition.gte( - "age", - 17 - ) - ) - } - ) - ).build() - ) - ).thenReturn( - Stream.of( - documentEntity - ) - ); - - CriteriaQuery personQuery = criteriaDocumentTemplate.createQuery(Person.class); - - StringExpression nameExpression = personQuery.from().get( - Person_.name - ); - NumberExpression ageExpression = personQuery.from().get( - Person_.age - ); - - ExpressionQueryResult executeQuery = criteriaDocumentTemplate.executeQuery( - personQuery.select( - nameExpression, - ageExpression - ).where( - nameExpression.equal( - "Poliana" - ).or( - ageExpression.greaterThanOrEqualTo(17) - ) - ) - ); - - Optional> findFirst = executeQuery.getRows().findFirst(); - - assertTrue( - findFirst.isPresent() - ); - assertEquals( - findFirst.get().get( - nameExpression - ), - "Poliana" - ); - assertEquals( - findFirst.get().get( - ageExpression - ), - 17 - ); - - } - -} diff --git a/jnosql-criteria-extension/src/test/java/org/eclipse/jnosql/mapping/criteria/Person.java b/jnosql-criteria-extension/src/test/java/org/eclipse/jnosql/mapping/criteria/Person.java deleted file mode 100644 index e5539438..00000000 --- a/jnosql-criteria-extension/src/test/java/org/eclipse/jnosql/mapping/criteria/Person.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Otavio Santana - */ -package org.eclipse.jnosql.mapping.criteria; - - -import jakarta.nosql.Column; -import jakarta.nosql.Entity; -import jakarta.nosql.Id; - -import java.util.Objects; - -@Entity -public class Person { - - @Id - private String name; - - @Column - private Integer age; - - - public String getName() { - return name; - } - - public Integer getAge() { - return age; - } - - public Person(String name, Integer age) { - this.name = name; - this.age = age; - } - - public Person() { - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Person person = (Person) o; - return Objects.equals(name, person.name) && - Objects.equals(age, person.age); - } - - @Override - public int hashCode() { - return Objects.hash(name, age); - } - - @Override - public String toString() { - String sb = "Person{" + "name='" + name + '\'' + - ", age=" + age + - '}'; - return sb; - } -} \ No newline at end of file diff --git a/jnosql-criteria-extension/src/test/resources/META-INF/beans.xml b/jnosql-criteria-extension/src/test/resources/META-INF/beans.xml deleted file mode 100644 index 0340ecdb..00000000 --- a/jnosql-criteria-extension/src/test/resources/META-INF/beans.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - \ No newline at end of file diff --git a/jnosql-mapping-validation/src/test/java/org/eclipse/jnosql/mapping/validation/ColumnTemplateValidationTest.java b/jnosql-mapping-validation/src/test/java/org/eclipse/jnosql/mapping/validation/ColumnTemplateValidationTest.java index 210f88e8..e9af5472 100644 --- a/jnosql-mapping-validation/src/test/java/org/eclipse/jnosql/mapping/validation/ColumnTemplateValidationTest.java +++ b/jnosql-mapping-validation/src/test/java/org/eclipse/jnosql/mapping/validation/ColumnTemplateValidationTest.java @@ -15,14 +15,14 @@ package org.eclipse.jnosql.mapping.validation; import jakarta.inject.Inject; -import jakarta.nosql.column.ColumnTemplate; import jakarta.validation.ConstraintViolation; import jakarta.validation.ConstraintViolationException; +import org.eclipse.jnosql.mapping.column.ColumnTemplate; import org.eclipse.jnosql.mapping.core.Converters; -import org.eclipse.jnosql.mapping.column.ColumnEntityConverter; import org.eclipse.jnosql.mapping.column.spi.ColumnExtension; import org.eclipse.jnosql.mapping.reflection.Reflections; import org.eclipse.jnosql.mapping.core.spi.EntityMetadataExtension; +import org.eclipse.jnosql.mapping.semistructured.EntityConverter; import org.jboss.weld.junit5.auto.AddExtensions; import org.jboss.weld.junit5.auto.AddPackages; import org.jboss.weld.junit5.auto.EnableAutoWeld; @@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @EnableAutoWeld -@AddPackages(value = {Converters.class, ColumnEntityConverter.class, EntityObserver.class}) +@AddPackages(value = {Converters.class, EntityConverter.class, EntityObserver.class}) @AddPackages(Person.class) @AddPackages(Reflections.class) @AddExtensions({EntityMetadataExtension.class, ColumnExtension.class}) diff --git a/jnosql-metamodel-extension/.gitignore b/jnosql-metamodel-extension/.gitignore deleted file mode 100644 index b43ed933..00000000 --- a/jnosql-metamodel-extension/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -target/ -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next -test-output/ -/doc -*.iml -*.idea -*.log -.classpath --project -/.resourceCache -/.project -/.idea -.settings/ diff --git a/jnosql-metamodel-extension/README.adoc b/jnosql-metamodel-extension/README.adoc deleted file mode 100644 index 192a8269..00000000 --- a/jnosql-metamodel-extension/README.adoc +++ /dev/null @@ -1,27 +0,0 @@ -= Metamodel Layer - -This extension contains Metamodel class definitions, used to describe a type annotated with JNoSql annotations such as Entity, MappedSupertype or Embeddable. -These classes are not meant to be used directly, metamodel-processor will do that for you. - -Anyway, if you want, you can manually describe the following example class : - -[source,java] ----- -@Entity -public class Person { - - @Id - private String name; - - @Column - private Integer age; - -} ----- - -By doing this : - -[source,java] ----- -StringAttribute name = new DefaultStringAttribute(Person.class, "name"); -NumberAttribute age = new DefaultNumberAttribute(Person.class, Integer.class, "age"); diff --git a/jnosql-metamodel-extension/pom.xml b/jnosql-metamodel-extension/pom.xml deleted file mode 100644 index ce338811..00000000 --- a/jnosql-metamodel-extension/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - 4.0.0 - - - org.eclipse.jnosql.mapping - jnosql-mapping-extensions - 1.1.1-SNAPSHOT - - - jnosql-metamodel-extension - Eclipse JNoSQL mapping metamodel layer - - - - diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/AbstractGenericType.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/AbstractGenericType.java deleted file mode 100644 index 8f18a6a0..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/AbstractGenericType.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping; - -/** - * Utility generic abstract base class storing the generic type - * @param generic type - */ -public abstract class AbstractGenericType { - - private final Class type; - - protected AbstractGenericType(Class type) { - this.type = type; - } - - public Class getType() { - return type; - } - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultAttribute.java deleted file mode 100644 index 0b250fe9..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultAttribute.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel; - -import org.eclipse.jnosql.mapping.metamodel.api.Attribute; -import org.eclipse.jnosql.mapping.AbstractGenericType; - -/** - * Default metamodel attribute implementation - * @param The Entity type the attribute belongs to - * @param The attribute type - */ -public abstract class DefaultAttribute extends AbstractGenericType implements Attribute { - - private final Class attributeType; - private final String name; - - public DefaultAttribute(Class type, Class attributeType, String name) { - super(type); - this.attributeType = attributeType; - this.name = name; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public Class getAttributeType() { - return attributeType; - } - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultComparableAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultComparableAttribute.java deleted file mode 100644 index bdbb6293..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultComparableAttribute.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel; - -import org.eclipse.jnosql.mapping.metamodel.api.ComparableAttribute; - -/** - * Default metamodel comparable attribute implementation - * @param The Entity type the attribute belongs to - * @param The comparable attribute type - */ -public class DefaultComparableAttribute extends DefaultValueAttribute implements ComparableAttribute { - - public DefaultComparableAttribute(Class type, Class attributeType, String name) { - super(type, attributeType, name); - } - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultEntityAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultEntityAttribute.java deleted file mode 100644 index 39cbb28d..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultEntityAttribute.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel; - -import org.eclipse.jnosql.mapping.metamodel.api.EntityAttribute; - -/** - * Default metamodel entity attribute implementation - * @param The Entity type the attribute belongs to - * @param The entity attribute type (could be an embed or nested entity) - */ -public class DefaultEntityAttribute extends DefaultSingularAttribute implements EntityAttribute{ - - public DefaultEntityAttribute(Class type, Class attributeType, String name) { - super(type, attributeType, name); - } - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultNumberAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultNumberAttribute.java deleted file mode 100644 index 51a12497..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultNumberAttribute.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel; - -import org.eclipse.jnosql.mapping.metamodel.api.NumberAttribute; - -/** - * Default metamodel numeric attribute implementation - * @param The Entity type the attribute belongs to - * @param The numeric attribute type - */ -public class DefaultNumberAttribute extends DefaultComparableAttribute implements NumberAttribute { - - public DefaultNumberAttribute(Class type, Class attributeType, String name) { - super(type, attributeType, name); - } - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultPluralAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultPluralAttribute.java deleted file mode 100644 index 094fe172..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultPluralAttribute.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel; - -import org.eclipse.jnosql.mapping.metamodel.api.PluralAttribute; -/** - * Default metamodel plural attribute implementation - * @param The Entity type the attribute belongs to - * @param The plural attribute type - */ -public class DefaultPluralAttribute extends DefaultAttribute implements PluralAttribute { - - public DefaultPluralAttribute(Class type, Class attributeType, String name) { - super(type, attributeType, name); - } - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultSingularAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultSingularAttribute.java deleted file mode 100644 index 190dc8c5..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultSingularAttribute.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel; - -import org.eclipse.jnosql.mapping.metamodel.api.SingularAttribute; - -/** - * Default metamodel singular attribute implementation - * @param The Entity type the attribute belongs to - * @param The singular attribute type - */ -public abstract class DefaultSingularAttribute extends DefaultAttribute implements SingularAttribute { - - public DefaultSingularAttribute(Class type, Class attributeType, String name) { - super(type, attributeType, name); - } - -} - - diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultStringAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultStringAttribute.java deleted file mode 100644 index 4a81ad6e..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultStringAttribute.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel; - -import org.eclipse.jnosql.mapping.metamodel.api.StringAttribute; - -/** - * Default metamodel string attribute implementation - * @param The Entity type the attribute belongs to - */ -public class DefaultStringAttribute extends DefaultValueAttribute implements StringAttribute{ - - public DefaultStringAttribute(Class type, String name) { - super(type, String.class, name); - } - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultValueAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultValueAttribute.java deleted file mode 100644 index 1c5f7353..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/DefaultValueAttribute.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel; - -import org.eclipse.jnosql.mapping.metamodel.api.ValueAttribute; - -/** - * Default metamodel value attribute implementation - * @param The Entity type the attribute belongs to - * @param The value attribute type (cannot be an entity) - */ -public class DefaultValueAttribute extends DefaultSingularAttribute implements ValueAttribute{ - - public DefaultValueAttribute(Class type, Class attributeType, String name) { - super(type, attributeType, name); - } - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/Attribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/Attribute.java deleted file mode 100644 index 6a2c4dfc..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/Attribute.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.api; - -/** - * Represents an attribute of a JNoSql Entity type - * @param The Entity type the attribute belongs to - * @param The attribute type - */ -public interface Attribute { - - /** - * Return the class type - * @return class type - */ - Class getType(); - - /** - * Return the attribute type - * @return attribute type - */ - Class getAttributeType(); - - /** - * Return the name of the attribute - * @return the name of the attribute - */ - String getName(); - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/ComparableAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/ComparableAttribute.java deleted file mode 100644 index 90133e18..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/ComparableAttribute.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.api; - -/** - * Represents a comparable value attribute of a JNoSql Entity type - * @param The Entity type the comparable attribute belongs to - * @param The attribute type -*/ -public interface ComparableAttribute extends ValueAttribute { - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/EntityAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/EntityAttribute.java deleted file mode 100644 index d85a0007..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/EntityAttribute.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.api; - -/** - * Represents a singular entity attribute of a JNoSql Entity type - * @param The Entity type the string attribute belongs to - * @param The attribute Entity type -*/ -public interface EntityAttribute extends SingularAttribute { - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/NumberAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/NumberAttribute.java deleted file mode 100644 index 8d6ae131..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/NumberAttribute.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.api; - -public interface NumberAttribute extends ComparableAttribute { - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/PluralAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/PluralAttribute.java deleted file mode 100644 index 794939de..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/PluralAttribute.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.api; - -/** - * Represents a plural attribute of a JNoSql Entity type - * @param The Entity type the plural attribute belongs to - * @param The attribute type -*/ -public interface PluralAttribute extends Attribute { - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/SingularAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/SingularAttribute.java deleted file mode 100644 index 2ddac5e7..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/SingularAttribute.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.api; - -/** - * Represents a singular attribute of a JNoSql Entity type - * - * @param The Entity type the singular attribute belongs to - * @param The attribute type - */ -public interface SingularAttribute extends Attribute { - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/StringAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/StringAttribute.java deleted file mode 100644 index bb964c1c..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/StringAttribute.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.api; - -/** - * Represents a string value attribute of a JNoSql Entity type - * @param The Entity type the string attribute belongs to -*/ -public interface StringAttribute extends ValueAttribute { - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/ValueAttribute.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/ValueAttribute.java deleted file mode 100644 index ce1d58a1..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/api/ValueAttribute.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.api; - -/** - * Represents a singular value attribute of a JNoSql Entity type - * - * @param The Entity type the singular attribute belongs to - * @param The attribute type - */ -public interface ValueAttribute extends SingularAttribute { - -} diff --git a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/package-info.java b/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/package-info.java deleted file mode 100644 index 4484ba9a..00000000 --- a/jnosql-metamodel-extension/src/main/java/org/eclipse/jnosql/mapping/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ - -/** - * Metamodel is what describes a model, a Java class, enumerating its attributes in a stronly typed manner. - * This metamodel can be used for operations needing to programmatically access such attributes, - * for example a stronly typed query builder. - */ -package org.eclipse.jnosql.mapping.metamodel; \ No newline at end of file diff --git a/jnosql-metamodel-processor-extension/.gitignore b/jnosql-metamodel-processor-extension/.gitignore deleted file mode 100644 index b43ed933..00000000 --- a/jnosql-metamodel-processor-extension/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -target/ -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next -test-output/ -/doc -*.iml -*.idea -*.log -.classpath --project -/.resourceCache -/.project -/.idea -.settings/ diff --git a/jnosql-metamodel-processor-extension/README.adoc b/jnosql-metamodel-processor-extension/README.adoc deleted file mode 100644 index 0ee50412..00000000 --- a/jnosql-metamodel-processor-extension/README.adoc +++ /dev/null @@ -1,31 +0,0 @@ -= Metamodel Processor - -This extension contains the Metamodel processor which, using the Metamodel layer, is able to automatically create description of a type annotated with JNoSql annotations such as Entity, MappedSupertype or Embeddable. -Include this library as an optional dependency to automatically activate the metamodel generation at compile time. - -So, for example : - -[source,java] ----- -@Entity -public class Person { - - @Id - private String name; - - @Column - private Integer age; - -} ----- - -Will produce this Metamodel : - -[source,java] ----- -public class Person_ { - - public static volatile StringAttribute name = new DefaultStringAttribute(org.eclipse.jnosql.mapping.metamodel.processor.Person.class, "name"); - public static volatile NumberAttribute age = new DefaultNumberAttribute(org.eclipse.jnosql.mapping.metamodel.processor.Person.class, Integer.class, "age"); - -} \ No newline at end of file diff --git a/jnosql-metamodel-processor-extension/pom.xml b/jnosql-metamodel-processor-extension/pom.xml deleted file mode 100644 index b75ce533..00000000 --- a/jnosql-metamodel-processor-extension/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - 4.0.0 - - - org.eclipse.jnosql.mapping - jnosql-mapping-extensions - 1.1.1-SNAPSHOT - - - jnosql-metamodel-processor-extension - Eclipse JNoSQL mapping metamodel layer processor - - - - ${project.groupId} - jnosql-metamodel-extension - ${project.version} - - - org.eclipse.jnosql.mapping - jnosql-mapping-document - - - com.google.auto.service - auto-service - 1.1.1 - true - - - com.sun.codemodel - codemodel - 2.6 - compile - - - diff --git a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/AbstractFieldBuilder.java b/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/AbstractFieldBuilder.java deleted file mode 100644 index 849a7848..00000000 --- a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/AbstractFieldBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - -import com.sun.codemodel.JClass; -import com.sun.codemodel.JDefinedClass; -import com.sun.codemodel.JExpr; -import com.sun.codemodel.JExpression; -import com.sun.codemodel.JInvocation; -import com.sun.codemodel.JMod; -import java.util.List; -import javax.lang.model.element.Element; - -/** - * Utility class to extend for field builders. - */ -public abstract class AbstractFieldBuilder { - - protected JInvocation buildInvocation( - JClass jClass, - List arguments - ) { - JInvocation invocation = JExpr._new( - jClass - ); - for (JExpression argument : arguments) { - invocation.arg(argument); - } - return invocation; - } - - protected void buildField(JDefinedClass jClass, Element element, JClass type, JInvocation value) { - jClass.field( - JMod.PUBLIC | JMod.STATIC | JMod.VOLATILE, - type, - element.getSimpleName().toString(), - value - ); - } - -} diff --git a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/AbstractSimpleFieldBuilder.java b/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/AbstractSimpleFieldBuilder.java deleted file mode 100644 index 3dbde103..00000000 --- a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/AbstractSimpleFieldBuilder.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - -import com.sun.codemodel.JCodeModel; -import com.sun.codemodel.JDefinedClass; -import com.sun.codemodel.JExpr; -import org.eclipse.jnosql.mapping.metamodel.api.Attribute; -import java.util.Arrays; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import org.eclipse.jnosql.mapping.metamodel.DefaultAttribute; - -/** - * Utility class to extend for simple field builders. - * @param attribute interface - * @param attribute implementation - */ -public abstract class AbstractSimpleFieldBuilder extends AbstractFieldBuilder { - - public abstract void buildField(JCodeModel codeModel, JDefinedClass jClass, TypeElement typeElement, Element element); - - protected void buildField(JCodeModel codeModel, JDefinedClass jClass, TypeElement typeElement, Element element, Class attributeInterface, Class attributeClass) { - super.buildField(jClass, - element, - codeModel.ref( - attributeInterface - ).narrow( - codeModel.ref(typeElement.getQualifiedName().toString()) - ), - buildInvocation( - codeModel.ref( - attributeClass - ), - Arrays.asList( - codeModel.ref(typeElement.getQualifiedName().toString()).dotclass(), - JExpr.lit(element.getSimpleName().toString()) - ) - ) - ); - } - -} diff --git a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/AbstractValueFieldBuilder.java b/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/AbstractValueFieldBuilder.java deleted file mode 100644 index ccc4805e..00000000 --- a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/AbstractValueFieldBuilder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - -import com.sun.codemodel.JCodeModel; -import com.sun.codemodel.JDefinedClass; -import com.sun.codemodel.JExpr; -import org.eclipse.jnosql.mapping.metamodel.api.Attribute; -import java.util.Arrays; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import org.eclipse.jnosql.mapping.metamodel.DefaultAttribute; - -/** - * Field builder for value attributes. - * @param attribute interface - * @param attribute implementation - */ -public abstract class AbstractValueFieldBuilder extends AbstractFieldBuilder { - - public abstract void buildField(JCodeModel codeModel, JDefinedClass jClass, TypeElement typeElement, Element element, Class forName); - - public void buildField( - JCodeModel codeModel, - JDefinedClass jClass, - TypeElement typeElement, - Element element, - Class forName, - Class attributeInterface, - Class attributeClass - ) { - super.buildField( - jClass, - element, - codeModel.ref( - attributeInterface - ).narrow( - Arrays.asList( - codeModel.ref(typeElement.getQualifiedName().toString()), - codeModel.ref(forName) - ) - ), - buildInvocation( - codeModel.ref( - attributeClass - ), - Arrays.asList( - codeModel.ref(typeElement.getQualifiedName().toString()).dotclass(), - codeModel.ref(forName).dotclass(), - JExpr.lit(element.getSimpleName().toString()) - ) - ) - ); - } - -} diff --git a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/ComparableFieldBuilder.java b/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/ComparableFieldBuilder.java deleted file mode 100644 index a6562805..00000000 --- a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/ComparableFieldBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - -import com.sun.codemodel.JCodeModel; -import com.sun.codemodel.JDefinedClass; -import org.eclipse.jnosql.mapping.metamodel.api.ComparableAttribute; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import org.eclipse.jnosql.mapping.metamodel.DefaultComparableAttribute; - -/** - * Field builder for comparable attributes. - */ -public class ComparableFieldBuilder extends AbstractSimpleFieldBuilder { - - @Override - public void buildField(JCodeModel codeModel, JDefinedClass jClass, TypeElement typeElement, Element element) { - super.buildField(codeModel, jClass, typeElement, element, ComparableAttribute.class, DefaultComparableAttribute.class); - } - -} diff --git a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/EntityFieldBuilder.java b/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/EntityFieldBuilder.java deleted file mode 100644 index 0853a3c3..00000000 --- a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/EntityFieldBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - -import com.sun.codemodel.JCodeModel; -import com.sun.codemodel.JDefinedClass; -import com.sun.codemodel.JExpr; -import org.eclipse.jnosql.mapping.metamodel.api.EntityAttribute; -import java.util.Arrays; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import org.eclipse.jnosql.mapping.metamodel.DefaultEntityAttribute; - -/** - * Field builder for comparable attributes. - */ -public class EntityFieldBuilder extends AbstractFieldBuilder { - - public void buildField(JCodeModel codeModel, JDefinedClass jClass, TypeElement typeElement, Element element, String toString) { - super.buildField( - jClass, - element, - codeModel.ref( - EntityAttribute.class - ).narrow( - Arrays.asList( - codeModel.ref(typeElement.getQualifiedName().toString()), - codeModel.ref(toString) - ) - ), - buildInvocation( - codeModel.ref( - DefaultEntityAttribute.class - ), - Arrays.asList( - codeModel.ref(typeElement.getQualifiedName().toString()).dotclass(), - codeModel.ref(toString).dotclass(), - JExpr.lit(element.getSimpleName().toString()) - ) - ) - ); - } - -} diff --git a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/MetamodelProcessor.java b/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/MetamodelProcessor.java deleted file mode 100644 index bf5651d0..00000000 --- a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/MetamodelProcessor.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - -import com.google.auto.service.AutoService; -import com.sun.codemodel.JClassAlreadyExistsException; -import com.sun.codemodel.JCodeModel; -import com.sun.codemodel.JDefinedClass; -import jakarta.nosql.Column; -import jakarta.nosql.Entity; -import jakarta.nosql.Id; -import org.eclipse.jnosql.mapping.Embeddable; -import org.eclipse.jnosql.mapping.MappedSuperclass; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.Processor; -import javax.annotation.processing.RoundEnvironment; -import javax.annotation.processing.SupportedSourceVersion; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.TypeElement; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.PrimitiveType; -import javax.lang.model.type.TypeMirror; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; -import java.util.function.Predicate; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.stream.Collectors; - -/** - * Metamodel processor to automagically generate metamodel attributes for JNoSql - * entities. - */ -@AutoService(Processor.class) -@SupportedSourceVersion(SourceVersion.RELEASE_8) -public class MetamodelProcessor extends AbstractProcessor { - - private final Predicate isField = element -> ElementKind.FIELD.equals(element.getKind()); - private final Predicate isId = element -> Objects.nonNull(element.getAnnotation(Id.class)); - private final Predicate isColumn = element -> Objects.nonNull(element.getAnnotation(Column.class)); - - private final AbstractSimpleFieldBuilder stringFieldBuilder = new StringFieldBuilder(); - private final AbstractValueFieldBuilder numberFieldBuilder = new NumberFieldBuilder(); - private final AbstractSimpleFieldBuilder comparableFieldBuilder = new ComparableFieldBuilder(); - private final AbstractSimpleFieldBuilder pluralFieldBuilder = new PluralFieldBuilder(); - private final AbstractValueFieldBuilder valueFieldBuilder = new ValueFieldBuilder(); - private final EntityFieldBuilder entityFieldBuilder = new EntityFieldBuilder(); - - @Override - public Set getSupportedAnnotationTypes() { - return new HashSet<>( - Arrays.asList( - Entity.class, - Embeddable.class, - MappedSuperclass.class - ).stream().map( - Class::getName - ).collect( - Collectors.toList() - ) - ); - } - - private void buildField(JCodeModel codeModel, JDefinedClass jClass, TypeElement typeElement, Element element) { - TypeMirror asType = element.asType(); - TypeElement fieldType = null; - if (asType instanceof DeclaredType) { - Element asElement = this.processingEnv.getTypeUtils().asElement(asType); - if (asElement instanceof TypeElement) { - fieldType = TypeElement.class.cast(asElement); - } - } else if (asType instanceof PrimitiveType) { - fieldType = this.processingEnv.getTypeUtils().boxedClass( - PrimitiveType.class.cast(asType) - ); - } - if (Objects.nonNull(typeElement)) { - String toString = fieldType.toString(); - try { - Class forName = Class.forName( - toString - ); - if (String.class.isAssignableFrom(forName)) { - stringFieldBuilder.buildField(codeModel, jClass, typeElement, element); - } else if (Number.class.isAssignableFrom(forName)) { - numberFieldBuilder.buildField(codeModel, jClass, typeElement, element, forName); - } else if (Comparable.class.isAssignableFrom(forName)) { - comparableFieldBuilder.buildField(codeModel, jClass, typeElement, element); - } else if (Collection.class.isAssignableFrom(forName)) { - pluralFieldBuilder.buildField(codeModel, jClass, typeElement, element); - } else { - valueFieldBuilder.buildField(codeModel, jClass, typeElement, element, forName); - } - } catch (ClassNotFoundException exception) { - entityFieldBuilder.buildField(codeModel, jClass, typeElement, element, toString); - } - } - } - - @Override - public boolean process(Set set, RoundEnvironment re) { - for (TypeElement annotationElement : set) { - for (Element element : re.getElementsAnnotatedWith(annotationElement)) { - if (element instanceof TypeElement) { - TypeElement typeElement = TypeElement.class.cast(element); - - String name = typeElement.getQualifiedName() + "_"; - - JCodeModel codeModel = new JCodeModel(); - - try { - - JDefinedClass definedClass = codeModel._class(name); - - element.getEnclosedElements().stream().filter( - isId.or(isColumn).and(isField) - ).forEach(enclosedElement - -> MetamodelProcessor.this.buildField( - codeModel, - definedClass, - typeElement, - enclosedElement - ) - ); - - codeModel.build( - new OutputStreamCodeWriter( - processingEnv.getFiler().createSourceFile( - name - ).openOutputStream() - ) - ); - } catch (JClassAlreadyExistsException | IOException ex) { - Logger.getLogger(MetamodelProcessor.class.getName()).log(Level.SEVERE, null, ex); - } - - } - } - } - - return true; - } - -} diff --git a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/NumberFieldBuilder.java b/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/NumberFieldBuilder.java deleted file mode 100644 index caa30020..00000000 --- a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/NumberFieldBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - -import com.sun.codemodel.JCodeModel; -import com.sun.codemodel.JDefinedClass; -import org.eclipse.jnosql.mapping.metamodel.api.NumberAttribute; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import org.eclipse.jnosql.mapping.metamodel.DefaultNumberAttribute; - -/** - * Field builder for numerical attributes. - */ -public class NumberFieldBuilder extends AbstractValueFieldBuilder { - - @Override - public void buildField(JCodeModel codeModel, JDefinedClass jClass, TypeElement typeElement, Element element, Class forName) { - super.buildField(codeModel, jClass, typeElement, element, forName, NumberAttribute.class, DefaultNumberAttribute.class); - } - -} diff --git a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/OutputStreamCodeWriter.java b/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/OutputStreamCodeWriter.java deleted file mode 100644 index ee35d7d0..00000000 --- a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/OutputStreamCodeWriter.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - -import com.sun.codemodel.CodeWriter; -import com.sun.codemodel.JPackage; -import java.io.IOException; -import java.io.OutputStream; - -/** - * CodeWriter based on an output stream. - * This is used to write the metamodel source files. - */ -public class OutputStreamCodeWriter extends CodeWriter { - - private final OutputStream outputStream; - - public OutputStreamCodeWriter(OutputStream outputStream) { - this.outputStream = outputStream; - } - - @Override - public OutputStream openBinary(JPackage jp, String string) throws IOException { - return this.outputStream; - } - - @Override - public void close() throws IOException { - this.outputStream.close(); - } - -} diff --git a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/PluralFieldBuilder.java b/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/PluralFieldBuilder.java deleted file mode 100644 index 6a2d2f70..00000000 --- a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/PluralFieldBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - -import com.sun.codemodel.JCodeModel; -import com.sun.codemodel.JDefinedClass; -import org.eclipse.jnosql.mapping.metamodel.api.PluralAttribute; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import org.eclipse.jnosql.mapping.metamodel.DefaultPluralAttribute; - -/** - * Field builder for plural attributes. - */ -public class PluralFieldBuilder extends AbstractSimpleFieldBuilder { - - @Override - public void buildField(JCodeModel codeModel, JDefinedClass jClass, TypeElement typeElement, Element element) { - super.buildField(codeModel, jClass, typeElement, element, PluralAttribute.class, DefaultPluralAttribute.class); - } - -} diff --git a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/StringFieldBuilder.java b/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/StringFieldBuilder.java deleted file mode 100644 index 47749933..00000000 --- a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/StringFieldBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - -import com.sun.codemodel.JCodeModel; -import com.sun.codemodel.JDefinedClass; -import org.eclipse.jnosql.mapping.metamodel.api.StringAttribute; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import org.eclipse.jnosql.mapping.metamodel.DefaultStringAttribute; - -/** - * Field builder for string attributes. - */ -public class StringFieldBuilder extends AbstractSimpleFieldBuilder { - - @Override - public void buildField(JCodeModel codeModel, JDefinedClass jClass, TypeElement typeElement, Element element) { - super.buildField(codeModel, jClass, typeElement, element, StringAttribute.class, DefaultStringAttribute.class); - } - -} diff --git a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/ValueFieldBuilder.java b/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/ValueFieldBuilder.java deleted file mode 100644 index 3d8e47e0..00000000 --- a/jnosql-metamodel-processor-extension/src/main/java/org/eclipse/jnosql/mapping/metamodel/processor/ValueFieldBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - -import com.sun.codemodel.JCodeModel; -import com.sun.codemodel.JDefinedClass; -import org.eclipse.jnosql.mapping.metamodel.api.ValueAttribute; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import org.eclipse.jnosql.mapping.metamodel.DefaultValueAttribute; - -/** - * Field builder for value attributes. - */ -public class ValueFieldBuilder extends AbstractValueFieldBuilder { - - @Override - public void buildField(JCodeModel codeModel, JDefinedClass jClass, TypeElement typeElement, Element element, Class forName) { - super.buildField(codeModel, jClass, typeElement, element, forName, ValueAttribute.class, DefaultValueAttribute.class); - } - -} diff --git a/jnosql-metamodel-processor-extension/src/test/java/org/eclipse/jnosql/mapping/metamodel/processor/MetamodelTest.java b/jnosql-metamodel-processor-extension/src/test/java/org/eclipse/jnosql/mapping/metamodel/processor/MetamodelTest.java deleted file mode 100644 index ff53ed99..00000000 --- a/jnosql-metamodel-processor-extension/src/test/java/org/eclipse/jnosql/mapping/metamodel/processor/MetamodelTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Alessandro Moscatelli - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - -import org.eclipse.jnosql.mapping.metamodel.api.NumberAttribute; -import org.eclipse.jnosql.mapping.metamodel.api.StringAttribute; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -class MetamodelTest { - - @Test - public void shouldGenerateMetamodel() { - - assertTrue( - Person_.name instanceof StringAttribute - ); - assertTrue( - Person_.age instanceof NumberAttribute - ); - assertTrue( - Music_.id instanceof StringAttribute - ); - assertTrue( - Music_.name instanceof StringAttribute - ); - assertTrue( - Music_.year instanceof NumberAttribute - ); - - } - -} diff --git a/jnosql-metamodel-processor-extension/src/test/java/org/eclipse/jnosql/mapping/metamodel/processor/Music.java b/jnosql-metamodel-processor-extension/src/test/java/org/eclipse/jnosql/mapping/metamodel/processor/Music.java deleted file mode 100644 index 638a5a45..00000000 --- a/jnosql-metamodel-processor-extension/src/test/java/org/eclipse/jnosql/mapping/metamodel/processor/Music.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Otavio Santana - */ - -package org.eclipse.jnosql.mapping.metamodel.processor; - - -import jakarta.nosql.Column; -import jakarta.nosql.Entity; -import jakarta.nosql.Id; - -@Entity -public class Music { - - @Id - private String id; - - @Column - private String name; - - @Column - private int year; - - Music() { - } - - - Music(String id, String name, int year) { - this.id = id; - this.name = name; - this.year = year; - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public int getYear() { - return year; - } - - @Override - public String toString() { - return "Music{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", year=" + year + - '}'; - } -} diff --git a/jnosql-metamodel-processor-extension/src/test/java/org/eclipse/jnosql/mapping/metamodel/processor/Person.java b/jnosql-metamodel-processor-extension/src/test/java/org/eclipse/jnosql/mapping/metamodel/processor/Person.java deleted file mode 100644 index 6659eadf..00000000 --- a/jnosql-metamodel-processor-extension/src/test/java/org/eclipse/jnosql/mapping/metamodel/processor/Person.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Apache License v2.0 which accompanies this distribution. - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. - * - * You may elect to redistribute this code under either of these licenses. - * - * Contributors: - * - * Otavio Santana - */ -package org.eclipse.jnosql.mapping.metamodel.processor; - - -import jakarta.nosql.Column; -import jakarta.nosql.Entity; -import jakarta.nosql.Id; - -import java.util.Objects; - -@Entity -public class Person { - - @Id - private String name; - - @Column - private Integer age; - - - public String getName() { - return name; - } - - public Integer getAge() { - return age; - } - - public Person(String name, Integer age) { - this.name = name; - this.age = age; - } - - public Person() { - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Person person = (Person) o; - return Objects.equals(name, person.name) && - Objects.equals(age, person.age); - } - - @Override - public int hashCode() { - return Objects.hash(name, age); - } - - @Override - public String toString() { - String sb = "Person{" + "name='" + name + '\'' + - ", age=" + age + - '}'; - return sb; - } -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index affaa4aa..7c229371 100644 --- a/pom.xml +++ b/pom.xml @@ -43,10 +43,7 @@ jnosql-lite - jnosql-metamodel-extension - jnosql-metamodel-processor-extension jnosql-graph-connections - jnosql-criteria-extension jnosql-mapping-validation