, QueryDslSupport {
11 | }
12 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/criteria/processor/QueryProcessor.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.criteria.processor;
2 |
3 | import javax.persistence.criteria.CriteriaBuilder;
4 | import javax.persistence.criteria.CriteriaQuery;
5 | import javax.persistence.criteria.Path;
6 |
7 | public interface QueryProcessor {
8 |
9 | void process(CriteriaQuery query, CriteriaBuilder builder, Path path);
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/impl/src/test/java/com/ctp/cdi/query/test/domain/EmbeddedSimple.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.test.domain;
2 |
3 | import javax.persistence.Embeddable;
4 |
5 | @Embeddable
6 | public class EmbeddedSimple {
7 |
8 | private String embedd;
9 |
10 | public String getEmbedd() {
11 | return embedd;
12 | }
13 |
14 | public void setEmbedd(String embedd) {
15 | this.embedd = embedd;
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/criteria/predicate/NoValueBuilder.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.criteria.predicate;
2 |
3 | import javax.persistence.metamodel.SingularAttribute;
4 |
5 | abstract class NoValueBuilder implements PredicateBuilder {
6 |
7 | final SingularAttribute super E, V> att;
8 |
9 | NoValueBuilder(SingularAttribute super E, V> att) {
10 | this.att = att;
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/criteria/predicate/PredicateBuilder.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.criteria.predicate;
2 |
3 | import java.util.List;
4 |
5 | import javax.persistence.criteria.CriteriaBuilder;
6 | import javax.persistence.criteria.Path;
7 | import javax.persistence.criteria.Predicate;
8 |
9 | public interface PredicateBuilder {
10 |
11 | List build(CriteriaBuilder builder, Path path);
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/util/jpa/ProviderSpecific.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.util.jpa;
2 |
3 | import static java.lang.annotation.ElementType.TYPE;
4 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
5 |
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.Target;
8 |
9 | @Target({ TYPE })
10 | @Retention(RUNTIME)
11 | public @interface ProviderSpecific {
12 |
13 | String value();
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/impl/src/test/java/com/ctp/cdi/query/test/service/SimpleEntityManagerDao.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.test.service;
2 |
3 | import java.util.List;
4 |
5 | import javax.persistence.EntityManager;
6 |
7 | import com.ctp.cdi.query.Dao;
8 | import com.ctp.cdi.query.test.domain.Simple3;
9 |
10 | @Dao(Simple3.class)
11 | public interface SimpleEntityManagerDao extends EntityManager {
12 |
13 | List findByName(String name);
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/builder/part/ConnectingQueryPart.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.builder.part;
2 |
3 | /**
4 | *
5 | * @author thomashug
6 | */
7 | abstract class ConnectingQueryPart extends QueryPart {
8 |
9 | protected final boolean first;
10 |
11 | public ConnectingQueryPart(boolean first) {
12 | this.first = first;
13 | }
14 |
15 | public boolean isFirst() {
16 | return first;
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/util/jpa/OpenJpaQueryStringExtractor.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.util.jpa;
2 |
3 | import javax.persistence.Query;
4 |
5 | @ProviderSpecific("org.apache.openjpa.persistence.OpenJPAQuery")
6 | public class OpenJpaQueryStringExtractor extends BaseQueryStringExtractor {
7 |
8 | @Override
9 | public String extractFrom(Query query) {
10 | return (String) invoke("getQueryString", query);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/impl/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/criteria/predicate/SingleValueBuilder.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.criteria.predicate;
2 |
3 | import javax.persistence.metamodel.SingularAttribute;
4 |
5 |
6 | abstract class SingleValueBuilder extends NoValueBuilder {
7 |
8 | final V value;
9 |
10 | SingleValueBuilder(SingularAttribute super E, V> att, V value) {
11 | super(att);
12 | this.value = value;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/api/src/main/java/com/ctp/cdi/query/criteria/QuerySelection.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.criteria;
2 |
3 | import javax.persistence.criteria.CriteriaBuilder;
4 | import javax.persistence.criteria.CriteriaQuery;
5 | import javax.persistence.criteria.Path;
6 | import javax.persistence.criteria.Selection;
7 |
8 | public interface QuerySelection {
9 |
10 | Selection toSelection(CriteriaQuery query, CriteriaBuilder builder, Path extends P> path);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/builder/OrderDirection.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.builder;
2 |
3 | public enum OrderDirection {
4 |
5 | ASC {
6 | @Override
7 | public OrderDirection change() {
8 | return DESC;
9 | }
10 | },
11 | DESC {
12 | @Override
13 | public OrderDirection change() {
14 | return ASC;
15 | }
16 | };
17 |
18 | public abstract OrderDirection change();
19 | }
20 |
--------------------------------------------------------------------------------
/dist/src/main/assembly/notice.txt:
--------------------------------------------------------------------------------
1 | ===================================================================================
2 | == NOTICE file corresponding to section 4d of the Apache License, Version 2.0, ==
3 | == in this case for the CDI Query distribution. ==
4 | ===================================================================================
5 |
6 | CDI Query
7 | Copyright 2011 Cambridge Technology Partners, and individual contributors by the @authors tag
8 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/meta/verifier/EntityVerifier.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.meta.verifier;
2 |
3 | import javax.persistence.Entity;
4 |
5 | import com.ctp.cdi.query.meta.unit.PersistenceUnits;
6 |
7 | public class EntityVerifier implements Verifier> {
8 |
9 | @Override
10 | public boolean verify(Class> entity) {
11 | return entity.isAnnotationPresent(Entity.class) || PersistenceUnits.instance().isEntity(entity);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/home/DefaultConversationProvider.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.home;
2 |
3 | public class DefaultConversationProvider implements ConversationProvider {
4 |
5 | private static final long serialVersionUID = 1L;
6 |
7 | @Override
8 | public void begin() {
9 | }
10 |
11 | @Override
12 | public void end() {
13 | }
14 |
15 | @Override
16 | public boolean isTransient() {
17 | return true;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/api/src/main/java/com/ctp/cdi/query/audit/ModifiedBy.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.audit;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Marks a property which should keep track on the last changing user.
10 | */
11 | @Retention(RetentionPolicy.RUNTIME)
12 | @Target({ElementType.FIELD, ElementType.METHOD})
13 | public @interface ModifiedBy {
14 | }
15 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/meta/extractor/MetadataExtractor.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.meta.extractor;
2 |
3 | import com.ctp.cdi.query.meta.DaoEntity;
4 |
5 | public interface MetadataExtractor {
6 |
7 | /**
8 | * Read entity meta data for a class.
9 | * @return Meta data packed in a {@link DaoEntity}, or {@code null}
10 | * if the extractor was not able to find data.
11 | */
12 | DaoEntity extract(Class> daoClass);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/api/src/main/java/com/ctp/cdi/query/FirstResult.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Use paging for the query. Must be applied to an Integer parameter.
10 | * @author thomashug
11 | */
12 | @Retention(RetentionPolicy.RUNTIME)
13 | @Target(ElementType.PARAMETER)
14 | public @interface FirstResult {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/api/src/main/java/com/ctp/cdi/query/MaxResults.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Limit the size of the result set. Must be applied to an Integer parameter.
10 | * @author thomashug
11 | */
12 | @Retention(RetentionPolicy.RUNTIME)
13 | @Target(ElementType.PARAMETER)
14 | public @interface MaxResults {
15 | }
16 |
--------------------------------------------------------------------------------
/api/src/main/java/com/ctp/cdi/query/audit/CreatedOn.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.audit;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Marks a property which should be updated with a timestamp when the entity gets persisted.
10 | */
11 | @Retention(RetentionPolicy.RUNTIME)
12 | @Target({ElementType.FIELD, ElementType.METHOD})
13 | public @interface CreatedOn {
14 | }
15 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/param/Parameter.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.param;
2 |
3 | import javax.persistence.Query;
4 |
5 | /**
6 | * Base class for parameters.
7 | * @author thomashug
8 | */
9 | public abstract class Parameter {
10 |
11 | final Object value;
12 | final int argIndex;
13 |
14 | public Parameter(Object value, int argIndex) {
15 | this.value = value;
16 | this.argIndex = argIndex;
17 | }
18 |
19 | public abstract void apply(Query query);
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/faces/src/main/java/com/ctp/cdi/query/home/FacesHome.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.home;
2 |
3 | import static java.lang.annotation.ElementType.TYPE;
4 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
5 |
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.Target;
8 |
9 | import javax.enterprise.inject.Alternative;
10 | import javax.enterprise.inject.Stereotype;
11 |
12 | @Alternative
13 | @Stereotype
14 | @Target({ TYPE })
15 | @Retention(RUNTIME)
16 | public @interface FacesHome {
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/impl/src/main/java/com/ctp/cdi/query/audit/AuditProvider.java:
--------------------------------------------------------------------------------
1 | package com.ctp.cdi.query.audit;
2 |
3 | import org.jboss.solder.logging.Logger;
4 | import org.jboss.solder.properties.Property;
5 |
6 | abstract class AuditProvider implements PrePersistAuditListener, PreUpdateAuditListener {
7 |
8 | final Logger log = Logger.getLogger(getClass());
9 |
10 | String propertyName(Object entity, Property