当前位置: 首页>>代码示例>>Java>>正文


Java Path类代码示例

本文整理汇总了Java中com.mysema.query.types.Path的典型用法代码示例。如果您正苦于以下问题:Java Path类的具体用法?Java Path怎么用?Java Path使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Path类属于com.mysema.query.types包,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildOrderPropertyPathFrom

import com.mysema.query.types.Path; //导入依赖的package包/类
private Expression<?> buildOrderPropertyPathFrom(JoinerQuery<?, ?> joinerQuery, Sort.Order order) {
    PathBuilder<?> builder = new PathBuilder<Object>(joinerQuery.getFrom().getType(), joinerQuery.getFrom().toString());

    PropertyPath path = PropertyPath.from(order.getProperty(), builder.getType());
    Expression<?> sortPropertyExpression = builder;

    while (path != null) {

        if (!path.hasNext() && order.isIgnoreCase()) {
            // if order is ignore-case we have to treat the last path segment as a String.
            sortPropertyExpression = Expressions.stringPath((Path<?>) sortPropertyExpression, path.getSegment()).lower();
        } else {
            sortPropertyExpression = Expressions.path(path.getType(), (Path<?>) sortPropertyExpression, path.getSegment());
        }

        path = path.next();
    }

    return sortPropertyExpression;
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:21,代码来源:PageableFeature.java

示例2: createExampleByPk

import com.mysema.query.types.Path; //导入依赖的package包/类
/**
 * 根据主键创建查询条件
 *
 * @param pathBase Querydsl query type
 * @param pk       主键
 * @return 查询条件
 */
public static QueryExample createExampleByPk(RelationalPathBase<?> pathBase, Object pk) {
    int numOfPk = pathBase.getPrimaryKey().getLocalColumns().size();
    Validate.isTrue(numOfPk > 0, "primaryKey not exists");
    QueryExample example = QueryExample.newInstance();
    if (numOfPk == 1) {
        example.equalsTo(pathBase.getPrimaryKey().getLocalColumns()
                .get(0).getMetadata().getName(), pk);
    } else {
        SqlParameterSource source = new BeanPropertySqlParameterSource(pk);
        for (Path<?> path : pathBase.getPrimaryKey().getLocalColumns()) {
            String name = path.getMetadata().getName();
            String humpName = humpName(name);
            example.equalsTo(humpName, source.getValue(name));
        }
    }
    return example;
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:25,代码来源:QueryExampleHelper.java

示例3: applyPredicates

import com.mysema.query.types.Path; //导入依赖的package包/类
/**
 * Apply "where", "groupBy" and "having"
 *
 * @param request
 * @param query
 * @param usedAliases
 * @param joins
 * @param <T>
 * @param <R>
 */
private <T, R> void applyPredicates(JoinerQuery<T, R> request, JPAQuery query, Set<Path<?>> usedAliases, List<JoinDescription> joins) {
    if (request.getWhere() != null) {
        Predicate where = predicateAliasResolver.resolvePredicate(request.getWhere(), joins, usedAliases);
        checkAliasesArePresent(where, usedAliases);
        query.where(where);
    }
    if (request.getGroupBy() != null) {
        Map<AnnotatedElement, List<JoinDescription>> grouped = joins.stream()
                .collect(Collectors.groupingBy(j -> j.getOriginalAlias().getAnnotatedElement()));
        Path<?> grouping = predicateAliasResolver.resolvePath(request.getGroupBy(), grouped, usedAliases);
        checkAliasesArePresent(grouping, usedAliases);
        query.groupBy(grouping);
    }
    if (request.getHaving() != null) {
        Predicate having = predicateAliasResolver.resolvePredicate(request.getHaving(), joins, usedAliases);
        checkAliasesArePresent(having, usedAliases);
        query.having(having);
    }
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:30,代码来源:Joiner.java

示例4: PerformInsertBatch

import com.mysema.query.types.Path; //导入依赖的package包/类
public PerformInsertBatch(Path<?>[] columns, Expression<?>[] values, Optional<SubQueryExpression<?>> optionalSubQuery) {
	Objects.requireNonNull(columns);
	Objects.requireNonNull(values);
	
	int valueCount = 
		optionalSubQuery
			.map(subQuery -> subQuery.getMetadata().getProjection().size())
			.orElse(values.length);
	
	if(columns.length != valueCount) {
		throw new IllegalArgumentException("columns length (" + columns.length + ") and values length (" + valueCount + ") mismatch");
	}
	
	this.columns = columns;
	this.values = values;
	this.subQuery = optionalSubQuery.orElse(null);
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:18,代码来源:PerformInsertBatch.java

示例5: getOrderSpecs

import com.mysema.query.types.Path; //导入依赖的package包/类
public static final List<OrderSpecifier<?>> getOrderSpecs(RelationalPathBase<?> pathBase, QueryExample example) {
    List<OrderSpecifier<?>> specifiers = new ArrayList<OrderSpecifier<?>>();
    List<Path<?>> columns = pathBase.getColumns();
    List<OrderBy> orderBies = example.getOrderBies();
    for (OrderBy orderBy : orderBies) {
        for (Path<?> path : columns) {
            if (checkColumn(path, orderBy.getField())) {
                if (path instanceof ComparableExpressionBase
                        && Comparable.class
                        .isAssignableFrom(path.getType())) {
                    specifiers.add(caseOrderBy(orderBy, (ComparableExpressionBase<? extends Comparable>) path));
                }
            }
        }
    }
    return specifiers;
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:18,代码来源:QueryExampleHelper.java

示例6: collectPredicatePathsInternal

import com.mysema.query.types.Path; //导入依赖的package包/类
private static void collectPredicatePathsInternal(Expression<?> expression, List<Path<?>> paths) {
    if (expression instanceof Path) {
        paths.add((Path<?>) expression);
    } else if (expression instanceof Operation) {
        for (Expression exp : ((Operation<?>) expression).getArgs()) {
            collectPredicatePathsInternal(exp, paths);
        }
    }
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:10,代码来源:JoinerUtils.java

示例7: resolveJoinAlias

import com.mysema.query.types.Path; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void resolveJoinAlias(JoinDescription join, EntityPath<?> root) {
    Path<?> parent = join.getParent() != null ? join.getParent().getAlias() : root;

    Path<?> fieldOnParent = findPathOnParent(parent, join.getAlias().getType(), join);
    if (fieldOnParent instanceof CollectionPathBase) {
        join.collectionPath((CollectionPathBase<?, ?, ?>) fieldOnParent);
    } else if (fieldOnParent instanceof EntityPath) {
        join.singlePath((EntityPath<?>) fieldOnParent);
    } else {
        throw new JoinerException("Target field not found for join " + join);
    }
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:15,代码来源:DefaultAliasResolver.java

示例8: findPathOnParent

import com.mysema.query.types.Path; //导入依赖的package包/类
private Path<?> findPathOnParent(Path<?> parent, Class<?> targetType, JoinDescription joinDescription) {
    String cacheKey = joinDescription.getOriginalAlias().toString() + parent.toString() + parent.getClass().getSimpleName() + targetType.getSimpleName();
    if (aliasCache.containsKey(cacheKey)) {
        return aliasCache.get(cacheKey);
    }

    Path<?> result = doFindPathOnParent(parent, targetType, joinDescription);
    aliasCache.put(cacheKey, result);
    return result;
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:11,代码来源:DefaultAliasResolver.java

示例9: doFindPathOnParent

import com.mysema.query.types.Path; //导入依赖的package包/类
/**
 * @param parent          parent join or "from" element
 * @param targetType      type of joined attribute
 * @param joinDescription join description
 * @return path on parent Q class
 */
protected Path<?> doFindPathOnParent(Path<?> parent, Class<?> targetType, JoinDescription joinDescription) {
    List<Path<?>> candidatePaths = new ArrayList<>();

    for (Field field : parent.getClass().getFields()) {
        testAliasCandidate(targetType, candidatePaths, getField(field, parent));
    }

    if (candidatePaths.isEmpty()) {
        findPathOnParentSubclasses(parent, targetType, candidatePaths);
    }

    if (candidatePaths.isEmpty()) {
        J.unrollChildrenJoins(Collections.singletonList(joinDescription)).forEach(j -> j.fetch(false));
        return nullPath;
    } else if (candidatePaths.size() == 1) {
        return candidatePaths.get(0);
    } else {
        // Multiple associations on parent, try find by specified alias
        String targetFieldName = joinDescription.getOriginalAlias().toString();
        for (Path<?> candidatePath : candidatePaths) {
            if (targetFieldName.equals(candidatePath.getMetadata().getElement())) {
                return candidatePath;
            }
        }
        throw new JoinerException("Join with ambiguous alias : " + joinDescription + ". Multiple mappings found: " + candidatePaths);
    }
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:34,代码来源:DefaultAliasResolver.java

示例10: findPathOnParentSubclasses

import com.mysema.query.types.Path; //导入依赖的package包/类
/**
 * Try to find attribute on a subclass of parent (for instance in test domain when looking for <code>Key</code> on <code>User</code>)
 *
 * @param parent         parent join or "from" element
 * @param targetType     type of joined attribute
 * @param candidatePaths container for found paths
 */
private void findPathOnParentSubclasses(Path<?> parent, Class<?> targetType, List<Path<?>> candidatePaths) {
    for (Class child : ReflectionUtils.getSubclasses(parent.getType(), entityManager)) {
        try {
            Class clazz = Class.forName(child.getPackage().getName() + ".Q" + child.getSimpleName());
            Object childInstance = ReflectionUtils.instantiate(clazz, (String) parent.getMetadata().getElement());
            for (Field field : clazz.getFields()) {
                testAliasCandidate(targetType, candidatePaths, getField(field, childInstance));
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:21,代码来源:DefaultAliasResolver.java

示例11: testAliasCandidate

import com.mysema.query.types.Path; //导入依赖的package包/类
private void testAliasCandidate(Class<?> targetType, List<Path<?>> candidatePaths, Object candidate) {
    if (candidate instanceof CollectionPathBase) {
        Field elementTypeField = ReflectionUtils.findField(candidate.getClass(), "elementType");
        Class<?> elementType = (Class<?>) getField(elementTypeField, candidate);

        if (elementType.isAssignableFrom(targetType)) {
            candidatePaths.add((Path<?>) candidate);
        }
    } else if (candidate instanceof EntityPathBase) {
        Class<?> type = ((EntityPathBase) candidate).getType();
        if (type.isAssignableFrom(targetType)) {
            candidatePaths.add((Path<?>) candidate);
        }
    }
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:16,代码来源:DefaultAliasResolver.java

示例12: checkAliasesArePresent

import com.mysema.query.types.Path; //导入依赖的package包/类
private void checkAliasesArePresent(Expression<?> expression, Set<Path<?>> usedAliases) {
    for (Path<?> path : JoinerUtils.collectPredicatePaths(expression)) {
        Path predicatePath = path.getRoot();
        if (!predicatePath.toString().startsWith("any(")) {
            if (!usedAliases.contains(predicatePath)) {
                throw new AliasMissingException("Alias " + predicatePath + " is not present in joins!");
            }
        }
    }
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:11,代码来源:Joiner.java

示例13: testOperationResolved

import com.mysema.query.types.Path; //导入依赖的package包/类
@Test
public void testOperationResolved() {
    Map<AnnotatedElement, List<JoinDescription>> grouped = Stream.of(J.left(testStatus))
            .collect(Collectors.groupingBy(j -> j.getOriginalAlias().getAnnotatedElement()));
    Path<String> resolved = resolver.resolvePath(QStatus.status.name, grouped, Collections.emptySet());
    Assert.assertEquals(testStatus.name, resolved);
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:8,代码来源:PredicateResolverTest.java

示例14: PerformInsert

import com.mysema.query.types.Path; //导入依赖的package包/类
public PerformInsert(RelationalPath<?> entity, List<PerformInsertBatch> batches, Optional<Path<?>> key) {
	Objects.requireNonNull(entity);
	
	if(batches.isEmpty()) {
		throw new IllegalArgumentException("batches list is empty");
	}
	
	this.entity = entity;
	this.batches = batches;
	this.key = key.orElse(null);
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:12,代码来源:PerformInsert.java

示例15: set

import com.mysema.query.types.Path; //导入依赖的package包/类
@Override
public AsyncSQLUpdateClause set(List<? extends Path<?>> paths, List<?> values) {
    for (int i = 0; i < paths.size(); i++) {
    	this.columns.add(paths.get(i));
    	
        if (values.get(i) instanceof Expression) {            	
        	this.values.add((Expression<?>)values.get(i));                
        } else if (values.get(i) != null) {            	
        	this.values.add(ConstantImpl.create(values.get(i)));                
        } else {
        	this.values.add(Null.CONSTANT);                
        }
    }
    return this;
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:16,代码来源:AsyncSQLUpdateClause.java


注:本文中的com.mysema.query.types.Path类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。