项目:oma-riista-web
文件:CriteriaUtils.java
@SuppressWarnings("unchecked")
@Nonnull
public static <T,U> Join<T,U> join(
@Nonnull final From<?,T> from,@Nonnull final PluralAttribute<? super T,?,U> attribute) {
Objects.requireNonNull(from,"from is null");
Objects.requireNonNull(attribute,"attribute is null");
if (attribute instanceof CollectionAttribute) {
return from.join((CollectionAttribute<T,U>) attribute);
}
if (attribute instanceof SetAttribute) {
return from.join((SetAttribute<T,U>) attribute);
}
if (attribute instanceof ListAttribute) {
return from.join((ListAttribute<T,U>) attribute);
}
if (attribute instanceof MapAttribute) {
return from.join((MapAttribute<T,U>) attribute);
}
// Should never end up here.
throw new IllegalArgumentException();
}
项目:darceo
文件:DataFileFormatDaoBean.java
/**
* Return active file formats for the given DigitalObject type,filtered by the given migration attribute (only
* those objects for which the given migration attribute returns an empty result will be checked for formats).
*
* A format is considered active if it is used by a file belonging to the current version of a digital object that
* has not been migrated from.
*
* @param <T>
* type of the digital object
* @param clazz
* class of the digital object
* @param excludedMigration
* migration attribute to check
* @return list of active file formats
*/
private <T extends DigitalObject> List<DataFileFormat> findActive(Class<T> clazz,ListAttribute<? super T,? extends Migration<?,?>> excludedMigration) {
CriteriaQuery<DataFileFormat> query = criteriaBuilder.createquery(DataFileFormat.class);
Root<T> root = query.from(clazz);
query.where(criteriaBuilder.isEmpty(root.<List<?>> get(excludedMigration.getName())));
Join<T,ContentVersion> joinVersion = root.join(DigitalObject_.currentVersion);
Join<ContentVersion,DataFiLeversion> joinFiLeversions = joinVersion.join(ContentVersion_.files);
Join<DataFiLeversion,DataFile> joinFiles = joinFiLeversions.join(DataFiLeversion_.dataFile);
query.select(joinFiles.get(DataFile_.format));
return entityManager.createquery(query).getResultList();
}
项目:VaadinUtils
文件:JoinBuilder.java
@SuppressWarnings("unchecked")
private <V> Expression<?> castGet(final Attribute<K,V> attribute,Join<E,K> join)
{
if (attribute instanceof Singularattribute)
{
return join.get((Singularattribute<K,V>) attribute);
}
else if (attribute instanceof ListAttribute)
{
return join.get((ListAttribute<K,V>) attribute);
}
else if (attribute instanceof SetAttribute)
{
return join.get((SetAttribute<K,V>) attribute);
}
else
{
return null;
}
}
/**
* @return last possibly used alias
*/
private int copyJoins(From<?,?> from,From<?,?> to,int counter) {
for (Join<?,?> join : sort(comparator,from.getJoins())) {
Attribute<?,?> attr = join.getAttribute();
// Hibern fails with String-bases api; Join.join(String,JoinType)
@SuppressWarnings({ "rawtypes","unchecked" })
Join<Object,Object> j = attr instanceof Singularattribute ? to.join((Singularattribute) join.getAttribute(),join.getJoinType()) :
attr instanceof CollectionAttribute ? to.join((CollectionAttribute) join.getAttribute(),join.getJoinType()) :
attr instanceof SetAttribute ? to.join((SetAttribute) join.getAttribute(),join.getJoinType()) :
attr instanceof ListAttribute ? to.join((ListAttribute) join.getAttribute(),join.getJoinType()) :
attr instanceof MapAttribute ? to.join((MapAttribute) join.getAttribute(),join.getJoinType()) :
to.join((CollectionAttribute) join.getAttribute(),join.getJoinType());
copyAlias(join,j,++counter);
counter = copyJoins(join,++counter);
}
copyFetches(from,to);
return counter;
}
项目:darceo
文件:IdentifierDaoBean.java
/**
* Returns the identifiers of digital objects of the given type,whose current version contains at least one data
* file in a format with the given puid,filtered by the given migration attribute (only those objects for which the
* given migration attribute returns an empty result will be returned) and optionally filtered by the object owner
* and the object database id.
*
* @param <T>
* type of the digital object
* @param clazz
* class of the digital object
* @param excludedMigration
* migration attribute to check
* @param puid
* data file format puid to look for
* @param ownerId
* digital object owner id; can be <code>null</code>
* @param objectIds
* digital object database identifiers; can be <code>null</code>
* @return list of digital object identifiers
*/
private <T extends DigitalObject> List<String> findIdentifiers(Class<T> clazz,?>> excludedMigration,String puid,Long ownerId,Collection<Long> objectIds) {
if (objectIds != null && objectIds.isEmpty()) {
return Collections.emptyList();
}
CriteriaQuery<String> query = criteriaBuilder.createquery(String.class);
Root<T> root = query.from(clazz);
Join<T,Identifier> joinIdentifier = root.join(DigitalObject_.defaultIdentifier);
Join<T,DataFile> joinFiles = joinFiLeversions.join(DataFiLeversion_.dataFile);
Join<DataFile,DataFileFormat> jo@R_641_4045@ = joinFiles.join(DataFile_.format);
Predicate where = criteriaBuilder.and(criteriaBuilder.equal(jo@R_641_404[email protected](DataFileFormat_.puid),puid),criteriaBuilder.isEmpty(root.<List<?>> get(excludedMigration.getName())));
if (ownerId != null) {
where = criteriaBuilder.and(where,criteriaBuilder.equal(root.get(DigitalObject_.ownerId),ownerId));
}
if (objectIds != null) {
where = criteriaBuilder.and(where,root.get(DigitalObject_.id).in(objectIds));
}
query.select(joinIdentifier.get(Identifier_.identifier));
query.distinct(true);
query.where(where);
return entityManager.createquery(query).getResultList();
}
项目:hibernate-semantic-query
文件:AbstractFromImpl.java
项目:hibernate-semantic-query
文件:AbstractFromImpl.java
@Override
@SuppressWarnings({"unchecked"})
public <X,Y> JpaAttributeJoin<X,Y> join(String attributeName,JoinType jt) {
if ( !canBeJoinSource() ) {
throw illegalJoin();
}
if ( jt.equals( JoinType.RIGHT ) ) {
throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
}
final Attribute<X,?> attribute = (Attribute<X,?>) locateAttribute( attributeName );
if ( attribute.isCollection() ) {
final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
if ( PluralAttribute.CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
return (JpaAttributeJoin<X,Y>) join( (CollectionAttribute) attribute,jt );
}
else if ( PluralAttribute.CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
return (JpaAttributeJoin<X,Y>) join( (ListAttribute) attribute,jt );
}
else if ( PluralAttribute.CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
return (JpaAttributeJoin<X,Y>) join( (SetAttribute) attribute,jt );
}
else {
return (JpaAttributeJoin<X,Y>) join( (MapAttribute) attribute,jt );
}
}
else {
return (JpaAttributeJoin<X,Y>) join( (Singularattribute) attribute,jt );
}
}
项目:hibernate-semantic-query
文件:AbstractFromImpl.java
@Override
@SuppressWarnings({"unchecked"})
public <X,Y> JpaListJoin<X,Y> joinList(String attributeName,JoinType jt) {
final Attribute<X,?>) locateAttribute( attributeName );
if ( !attribute.isCollection() ) {
throw new IllegalArgumentException( "Requested attribute was not a list" );
}
final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
if ( !PluralAttribute.CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
throw new IllegalArgumentException( "Requested attribute was not a list" );
}
return (JpaListJoin<X,jt );
}
项目:VaadinUtils
文件:JpaDslAbstract.java
public <J,V> Condition<E> eq(final JoinBuilder<E,J> join,final ListAttribute<J,V> field,final V value)
{
return new AbstractCondition<E>()
{
@Override
public Predicate getPredicates()
{
return builder.equal(getJoin(join).get(field),value);
}
};
}
项目:VaadinUtils
文件:JpaDslAbstract.java
public <J,V> Condition<E> equal(final ListAttribute<? super E,J> joinAttribute,final JoinType joinType,final Singularattribute<J,final V value)
{
return new AbstractCondition<E>()
{
@Override
public Predicate getPredicates()
{
Join<E,J> join = getJoin(joinAttribute,joinType);
return builder.equal(join.get(field),value);
}
};
}
项目:VaadinUtils
文件:JpaDslAbstract.java
public <L> Condition<E> equal(final ListAttribute<E,L> field,final L value)
{
return new AbstractCondition<E>()
{
@Override
public Predicate getPredicates()
{
return builder.equal(root.get(field),V extends Comparable<? super V>> Condition<E> greaterThanorEqualTo(
final ListAttribute<? super E,joinType);
return builder.greaterThanorEqualTo(join.get(field),V extends Comparable<? super V>> Condition<E> greaterThan(
final ListAttribute<? super E,final Singularattribute<E,V> value)
{
return new AbstractCondition<E>()
{
@Override
public Predicate getPredicates()
{
Join<E,joinType);
return builder.greaterThan(join.get(field),root.get(value));
}
};
}
项目:VaadinUtils
文件:JpaDslAbstract.java
public <J,root.get(value));
}
};
}
项目:VaadinUtils
文件:JpaDslAbstract.java
public <V,K> Condition<E> in(final JoinBuilder<E,V> join,final ListAttribute<V,K> attribute,final Collection<K> values)
{
return new AbstractCondition<E>()
{
@Override
public Predicate getPredicates()
{
return getJoin(join).get(attribute).in(values);
}
};
}
项目:VaadinUtils
文件:JpaDslAbstract.java
项目:VaadinUtils
文件:JoinBuilder.java
@SuppressWarnings(
{ "unchecked","rawtypes" })
public JoinBuilder(final ListAttribute<? super E,final JoinType type,final boolean fetch)
{
joins.add(new JoinMetaDataList(attribute,type,fetch));
}
项目:VaadinUtils
文件:JoinBuilder.java
@SuppressWarnings(
{ "unchecked","rawtypes" })
private <T> JoinBuilder<E,T> join(final ListAttribute<K,T> attribute,final boolean fetch)
{
final JoinBuilder<E,T> jb = new JoinBuilder<E,T>();
jb.joins.addAll(joins);
jb.joins.add(new JoinMetaDataList(attribute,fetch));
return jb;
}
项目:query-utils
文件:ProjectionResultUtil.java
static Object postProcessResult(Class<?> constructorParameterType,Attribute<?,?> attr,List<Object> val) {
logger.debug("postProcessResult({},{},{})",new Object[] {constructorParameterType,attr,val});
Object ret;
if (attr instanceof Singularattribute) {
if (!isrequiredByQueryAttribute(attr) && val.isEmpty()) {
logger.debug("Optional Singularattribute and empty resultList,returning null to be later replaced by None()");
ret = null;
} else {
if (val.size() != 1) {
throw new IllegalArgumentException("Collection expected to be of size " + 1 + " but was: " + val + " for: " + attr.getName());
}
ret = head(val);
}
} else {
if (constructorParameterType.equals(ArrayList.class)) {
logger.debug("Constructor expecting an ArrayList: {}",constructorParameterType.getName());
ret = val instanceof ArrayList ? val : new ArrayList<Object>(val);
} else if (constructorParameterType.equals(List.class) || constructorParameterType.equals(Object.class) && attr instanceof ListAttribute) {
logger.debug("Constructor expecting a List: {}",constructorParameterType.getName());
ret = val;
} else if (constructorParameterType.equals(Collection.class) || constructorParameterType.equals(Object.class) && attr instanceof CollectionAttribute) {
logger.debug("Constructor expecting a Collection: {}",constructorParameterType.getName());
ret = val;
} else if (constructorParameterType.equals(SortedSet.class) || constructorParameterType.equals(TreeSet.class)) {
logger.debug("Constructor expecting a SortedSet: {}",constructorParameterType.getName());
ret = new TreeSet<Object>(val);
} else if (constructorParameterType.equals(Set.class) || constructorParameterType.equals(Object.class) && attr instanceof SetAttribute) {
logger.debug("Constructor expecting a Set: {}",constructorParameterType.getName());
ret = newSet(val);
} else {
ret = val;
}
if (((Collection<?>)ret).size() != val.size()) {
logger.info("size of a Set/SortedSet was different from the size of the originating data! Have you maybe suboptimally implemented equals/compareto? Enable debug logging for stack trace. Attribute: {},List: {},Set: {}",val,ret);
logger.debug("size of a Set/SortedSet... stack: ",new Exception());
}
}
logger.debug("postProcessResult -> {}",ret);
return ret;
}
项目:query-utils
文件:ProjectionHelper.java
private void setListAttributeOrderings(Attribute<?,?> target,CriteriaQuery<Object[]> query,Map<Attribute<?,?>,?>> actualJoins) {
if (target instanceof JoiningAttribute) {
logger.debug("Adding orderings based on ListAttributes");
for (Attribute<?,?> a: ((JoiningAttribute) target).getAttributes()) {
setListAttributeOrderings(a,query,actualJoins);
}
} else if (target instanceof ListAttribute) {
addListAttributeOrdering(query,actualJoins.get(target),resolveOrderColumn((ListAttribute<?,?>)target),em.apply().getCriteriaBuilder());
}
}
项目:query-utils
文件:QueryUtils.java
public static Expression<?> get(Path<?> path,?> attr) {
@SuppressWarnings({ "rawtypes","unchecked" })
Expression<?> ret = attr instanceof Singularattribute ? path.get((Singularattribute) attr) :
attr instanceof CollectionAttribute ? path.get((CollectionAttribute) attr) :
attr instanceof SetAttribute ? path.get((SetAttribute) attr) :
attr instanceof ListAttribute ? path.get((ListAttribute) attr) :
attr instanceof MapAttribute ? path.get((PluralAttribute) attr) :
path.get((CollectionAttribute) attr);
return ret;
}
public void copyCriteriaWithoutSelect(CriteriaQuery<?> from,CriteriaQuery<?> to,CriteriaBuilder cb) {
int counter = findLatestCustomAlias(from).getorElse(0);
for (Root<?> root : sort(comparator,from.getRoots())) {
Root<?> r = to.from(root.getJavaType());
copyAlias(root,r,++counter);
counter = copyJoins(root,++counter);
}
to.distinct(from.isdistinct());
if (from.getGroupList() != null) {
to.groupBy(from.getGroupList());
}
if (from.getGroupRestriction() != null) {
to.having(from.getGroupRestriction());
}
if (from.getRestriction() != null) {
to.where(from.getRestriction());
}
if (from.getorderList() != null && !from.getorderList().isEmpty()) {
to.orderBy(from.getorderList());
} else {
Selection<?> selection = QueryUtils.resolveSelection(from,to);
if (selection.isCompoundSelection()) {
for (Selection<?> s: selection.getCompoundSelectionItems()) {
if (s instanceof Path<?> && ((Path<?>)s).getModel() instanceof ListAttribute) {
addListAttributeOrdering(to,(Expression<?>) s,?>)((Path<?>)s).getModel()),cb);
}
}
} else if (selection instanceof Path<?> && ((Path<?>)selection).getModel() instanceof ListAttribute) {
addListAttributeOrdering(to,(Expression<?>) selection,?>)((Path<?>)selection).getModel()),cb);
}
}
}
private static void copyFetches(FetchParent<?,FetchParent<?,?> to) {
for (Fetch<?,?> fetch : sort(fetchComparator,from.getFetches())) {
Attribute<?,?> attr = fetch.getAttribute();
@SuppressWarnings({ "rawtypes","unchecked" })
Fetch<?,?> f = attr instanceof Singularattribute ? to.fetch((Singularattribute) fetch.getAttribute(),fetch.getJoinType()) :
attr instanceof CollectionAttribute ? to.fetch((CollectionAttribute) fetch.getAttribute(),fetch.getJoinType()) :
attr instanceof SetAttribute ? to.fetch((SetAttribute) fetch.getAttribute(),fetch.getJoinType()) :
attr instanceof ListAttribute ? to.fetch((ListAttribute) fetch.getAttribute(),fetch.getJoinType()) :
attr instanceof MapAttribute ? to.fetch((MapAttribute) fetch.getAttribute(),fetch.getJoinType()) :
to.fetch((CollectionAttribute) fetch.getAttribute(),fetch.getJoinType());
copyFetches(fetch,f);
}
}
项目:tap17-muggl-javaee
文件:MugglFrom.java
@Override
public <Y> ListJoin<X,Y> list) {
// Todo Auto-generated method stub
return null;
}
项目:tap17-muggl-javaee
文件:MugglFrom.java
@Override
public <Y> ListJoin<X,JoinType jt) {
// Todo Auto-generated method stub
return null;
}
项目:hibernate-semantic-query
文件:JpaFrom.java
@Override
<Y> JpaListJoin<X,Y> list);
项目:hibernate-semantic-query
文件:JpaFrom.java
@Override
<Y> JpaListJoin<X,JoinType jt);
项目:hibernate-semantic-query
文件:AbstractFromImpl.java
@Override
public <Y> JpaListJoin<X,Y> list) {
return join( list,DEFAULT_JOIN_TYPE );
}
项目:olingo-odata2
文件:JPAEntityTypeMock.java
@Override
public ListAttribute<X,?> getDeclaredList(final String arg0) {
return null;
}
项目:olingo-odata2
文件:JPAEntityTypeMock.java
@Override
public <E> ListAttribute<X,E> getDeclaredList(final String arg0,final Class<E> arg1) {
return null;
}
项目:olingo-odata2
文件:JPAEntityTypeMock.java
@Override
public ListAttribute<? super X,?> getList(final String arg0) {
return null;
}
项目:olingo-odata2
文件:JPAEntityTypeMock.java
@Override
public <E> ListAttribute<? super X,E> getList(final String arg0,final Class<E> arg1) {
return null;
}
项目:olingo-odata2
文件:JPAManagedTypeMock.java
@Override
public ListAttribute<X,?> getDeclaredList(final String arg0) {
return null;
}
项目:olingo-odata2
文件:JPAManagedTypeMock.java
@Override
public <E> ListAttribute<X,final Class<E> arg1) {
return null;
}
项目:olingo-odata2
文件:JPAManagedTypeMock.java
@Override
public ListAttribute<? super X,?> getList(final String arg0) {
return null;
}
项目:olingo-odata2
文件:JPAManagedTypeMock.java
@Override
public <E> ListAttribute<? super X,final Class<E> arg1) {
return null;
}
@Override
public ListAttribute<X,?> getDeclaredList(final String arg0) {
return null;
}
@Override
public <E> ListAttribute<X,final Class<E> arg1) {
return null;
}
@Override
public ListAttribute<? super X,?> getList(final String arg0) {
return null;
}
@Override
public <E> ListAttribute<? super X,final Class<E> arg1) {
return null;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。