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


Java Expression类代码示例

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


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

示例1: buildOrderPropertyPathFrom

import com.mysema.query.types.Expression; //导入依赖的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: evaluate

import com.mysema.query.types.Expression; //导入依赖的package包/类
public void evaluate(String expression, QueryDslContext context, ParserConfig config) {
    List<Node> nodeList = Evaluator.parse(expression, config);
    for (Node node : nodeList) {
        if (node instanceof LogicalNode) {
            Predicate filter = node.accept(visitor, context);
            if (node instanceof OrNode) {
                context.addOr(filter);
            } else {
                context.addAnd(filter);
            }
        } else if (node instanceof FilterNode) {
            Predicate filterNode = node.accept(visitor, context);
            context.addAnd(filterNode);
        } else if (node instanceof OrderNode) {
            LinkedList order = (LinkedList<OrderSpecifier>) node.accept(visitor, context);
            context.setOrderSpecifiers(order);
        } else if (node instanceof LimitNode) {
            QueryModifiers modifiers = (QueryModifiers) (Object) node.accept(visitor, context);
            context.setQueryModifiers(modifiers);
        } else if (node instanceof ProjectionNode) {
            Expression projection = (QBean) node.accept(visitor, context);
            context.setProjection(projection);
        }
    }
}
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:26,代码来源:QueryDslEvaluator.java

示例3: downloadMain

import com.mysema.query.types.Expression; //导入依赖的package包/类
private long downloadMain(QueryConfigurer commonClause, QueryConfigurer orderByClause, Consumer consumer,
		Limiter limiter, Expression<?>... expressions) throws LimiterException, IOException {

	ResultSetExtractor<Long> extractor = new ExtractorResultSetExtractor(consumer, limiter);

	limiter.start();
	try {

		SQLQuery query = queryDslJdbcOperations.newSqlQuery();
		query = commonClause.configure(query);
		query = orderByClause.configure(query);

		return queryDslJdbcOperations.queryForObject(query, extractor, expressions);
	} catch (IllegalStateException ex) {
		throw (IOException) ex.getCause();
	} finally {
		limiter.stop();
	}
}
 
开发者ID:agwlvssainokuni,项目名称:sqlapp,代码行数:20,代码来源:QueryDslSupportImpl.java

示例4: downloadXls

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Transactional
@Override
public void downloadXls(HttpServletResponse response, String filename, LocalDateTime timestamp,
		final List<String> header, final QueryConfigurer commonClause, final QueryConfigurer orderByClause,
		final Expression<?>... expressions) throws IOException {
	downloadOperation.download(response, excelType, null, filename, timestamp, new DownloadAction() {
		@Override
		public long doDownload(OutputStream stream) throws IOException {
			try (Workbook workbook = ExcelFactory.createBlankXls(); ExcelWriter writer = new ExcelWriter(workbook)) {
				Consumer consumer = createExcelConsumer(writer, header);
				long count = queryDslSupport.download(commonClause, orderByClause, consumer, expressions);
				workbook.write(stream);
				return count;
			}
		}
	});
}
 
开发者ID:agwlvssainokuni,项目名称:sqlapp,代码行数:18,代码来源:TableDownloadTemplate.java

示例5: downloadXlsx

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Transactional
@Override
public void downloadXlsx(HttpServletResponse response, String filename, LocalDateTime timestamp,
		final List<String> header, final QueryConfigurer commonClause, final QueryConfigurer orderByClause,
		final Expression<?>... expressions) throws IOException {
	downloadOperation.download(response, excelType, null, filename, timestamp, new DownloadAction() {
		@Override
		public long doDownload(OutputStream stream) throws IOException {
			try (Workbook workbook = ExcelFactory.createBlankXlsx(); ExcelWriter writer = new ExcelWriter(workbook)) {
				Consumer consumer = createExcelConsumer(writer, header);
				long count = queryDslSupport.download(commonClause, orderByClause, consumer, expressions);
				workbook.write(stream);
				return count;
			}
		}
	});
}
 
开发者ID:agwlvssainokuni,项目名称:sqlapp,代码行数:18,代码来源:TableDownloadTemplate.java

示例6: QAuthor

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Test
public void sec020201_定数値をカラムとして照会する() {

	Expression<Integer> const1 = Expressions.constant(1);
	Expression<String> const2 = Expressions.constant("string");

	QAuthor a = new QAuthor("a");
	SQLQuery query = queryDslJdbcOperations.newSqlQuery();
	query.from(a);
	List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.id,
			const1, const2));

	for (Tuple tuple : list) {
		Long valId = tuple.get(a.id);
		Integer valConst1 = tuple.get(const1);
		String valConst2 = tuple.get(const2);
		out.println(format("{0}: const1={1}, const2={2}", valId, valConst1,
				valConst2));
	}
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:21,代码来源:SelectClauseTest.java

示例7: testNamedSetExpression

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Test
public void testNamedSetExpression() {
	Expression<Set<String>> expr = DatabaseUtils.namedExpression("test");		
	QTuple q = new QTuple(expr);
	
	Tuple t = q.newInstance(Collections.singleton("Hello, world!"));		
	assertNotNull(t);
	
	Set<String> result = t.get(expr);
	assertNotNull(result);
	
	Iterator<String> itr = result.iterator();
	assertTrue(itr.hasNext());
	assertEquals("Hello, world!", itr.next());
	assertFalse(itr.hasNext());
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:17,代码来源:DatabaseUtilsTest.java

示例8: QTodo

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Test
public void sec020501_CASE式を指定する_単純CASE式() {

	/* 抽出条件を組み立てる。 */
	QTodo a = new QTodo("a");
	SQLQuery query = queryDslJdbcOperations.newSqlQuery();
	query.from(a);

	/* CASE式を組立てる。 */
	Expression<String> doneDesc = a.doneFlg.when(0).then("未実施").when(1)
			.then("実施済").otherwise("不定");

	/* 取出すカラムとデータの取出し方を指定してクエリを発行する。 */
	List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.id,
			a.doneFlg, doneDesc));

	/* クエリの結果を表示する。 */
	for (Tuple tuple : list) {
		Long valId = tuple.get(a.id);
		Integer valDoneFlg = tuple.get(a.doneFlg);
		String valDoneDesc = tuple.get(doneDesc);
		out.println(format("{0}: doneFlg={1}, doneDesc(CASE)={2}", valId,
				valDoneFlg, valDoneDesc));
	}
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:26,代码来源:SelectClauseTest.java

示例9: testDetectedWrongOrder

import com.mysema.query.types.Expression; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test(expected=IllegalArgumentException.class)
public void testDetectedWrongOrder() {
	Expression<Integer> idExpr = mock(Expression.class);
	Expression<String> valueExpr = mock(Expression.class);
	
	List<Tuple> tuples = new ArrayList<Tuple>();
	
	Random r = new Random(0);
	for(int i = 0; i < 10; i++) {
		Tuple a = mock(Tuple.class);
		when(a.get(idExpr)).thenReturn(r.nextInt());
		when(a.get(valueExpr)).thenReturn("" + i + "a");
		
		Tuple b = mock(Tuple.class);
		when(b.get(idExpr)).thenReturn(i);
		when(b.get(valueExpr)).thenReturn("" + i + "b");
		
		tuples.add(a);
		tuples.add(b);
	}		
		
	ListIterator<Tuple> itr = tuples.listIterator();
	DatabaseUtils.consumeList(itr, 42, idExpr, t -> t.get(valueExpr));
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:26,代码来源:DatabaseUtilsTest.java

示例10: afterPropertiesSet

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Override
public void afterPropertiesSet() {

	QSqlClause c = new QSqlClause("c");
	QSqlStatement s = new QSqlStatement("s");
	QSqlLoad l = new QSqlLoad("l");

	StringExpression databaseName = cases() //
			.when(m.sqlType.eq(SqlType.CLAUSE.code())) //
			.then(new SQLSubQuery().from(c).where(c.id.eq(m.id)).unique(c.databaseName)) //
			.when(m.sqlType.eq(SqlType.STATEMENT.code())) //
			.then(new SQLSubQuery().from(s).where(s.id.eq(m.id)).unique(s.databaseName)) //
			.when(m.sqlType.eq(SqlType.LOAD.code())) //
			.then(new SQLSubQuery().from(l).where(l.id.eq(m.id)).unique(l.databaseName)) //
			.otherwise(StringUtils.EMPTY).as(getColumnMetadata(c.databaseName).getName());

	List<Expression<?>> list = new ArrayList<>(m.all().length + 1);
	for (Path<?> e : m.all()) {
		list.add(e);
	}
	list.add(databaseName);

	expressions = list.toArray(new Expression<?>[list.size()]);
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:25,代码来源:SearchServiceImpl.java

示例11: downloadMain

import com.mysema.query.types.Expression; //导入依赖的package包/类
private long downloadMain(QueryConfigurer commonClause, QueryConfigurer orderByClause, Consumer consumer,
		Limiter limiter, Expression<?>... expressions) throws LimiterException, IOException {

	limiter.start();
	try {

		SQLQuery query = commonClause.configure(queryFactory.query());
		query = orderByClause.configure(query);

		ResultSetExtractor<Long> extractor = new ExtractorResultSetExtractor(consumer, limiter);
		return getResults("download", query, extractor, expressions);

	} catch (IllegalStateException ex) {
		throw (IOException) ex.getCause();
	} finally {
		limiter.stop();
	}
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:19,代码来源:QueryDslSupportImpl.java

示例12: join

import com.mysema.query.types.Expression; //导入依赖的package包/类
/**
 * Performs an inner join on provided streams. 
 * 
 * Consider using {@link #join(Collection, Collection, Expression, Expression...)} for streams
 * obtained from a {@link Collection}.  
 * 
 * @param left left stream.
 * @param right right stream.
 * @param firstExpr first join condition.
 * @param otherExprs additional join conditions.
 * @return the join result.
 */
@SafeVarargs
public static <T extends Comparable<? super T>> Stream<Tuple> join(Stream<Tuple> left, Stream<Tuple> right, Expression<? extends T> firstExpr, Expression<? extends T>... otherExprs) {
	return StreamUtils
		.mergeJoin(
			left, 
			right, 
			comparing(firstExpr, otherExprs)::compare,
			Collectors.toList(),
			Collectors.toList(),
			(leftResult, rightResult) -> 
				// generate a JoinedTuple for every combination of leftResult and rightResult.
				leftResult.stream()
					.<Tuple>flatMap(leftItem ->
						rightResult.stream()
							.<Tuple>map(rightItem -> (Tuple)new JoinedTuple(leftItem, rightItem))))
		.flatMap(Function.identity()); // convert Stream<Stream<Tuple>> into Stream<Tuple>.
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:30,代码来源:DatabaseUtils.java

示例13: createSuperTuple

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Before
@SuppressWarnings("unchecked")
public void createSuperTuple() {
	id = (Expression<Integer>)mock(Expression.class);
	stringValue = (Expression<String>)mock(Expression.class);
	doubleValue = (Expression<Double>)mock(Expression.class);
			
	Tuple parentTuple = mock(Tuple.class);
	when(parentTuple.size()).thenReturn(2);
	when(parentTuple.toArray()).thenReturn(new Object[]{0, "Hello, world!"});
	when(parentTuple.get(id)).thenReturn(0);
	when(parentTuple.get(stringValue)).thenReturn("Hello, world!");		
	when(parentTuple.get(0, Integer.class)).thenReturn(0);
	when(parentTuple.get(1, String.class)).thenReturn("Hello, world!");
	
	Tuple tuple = mock(Tuple.class);
	when(tuple.size()).thenReturn(2);
	when(tuple.toArray()).thenReturn(new Object[]{0, 42.0});
	when(tuple.get(id)).thenReturn(0);
	when(tuple.get(doubleValue)).thenReturn(42.0);
	when(tuple.get(0, Integer.class)).thenReturn(0);
	when(tuple.get(1, Double.class)).thenReturn(42.0);
	
	superTuple = new JoinedTuple(parentTuple, tuple);
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:26,代码来源:SuperTupleTest.java

示例14: downloadXlsx

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Transactional
@Override
public void downloadXlsx(HttpServletResponse response, String filename, LocalDateTime timestamp,
		final List<String> header, final QueryConfigurer commonClause, final QueryConfigurer orderByClause,
		final Expression<?>... expressions) {
	downloadOperation.download(response, excelType, null, filename, timestamp, new DownloadAction() {
		@Override
		public long doDownload(OutputStream stream) throws IOException {
			try (Workbook workbook = ExcelFactory.createBlankXlsx(); ExcelWriter writer = new ExcelWriter(workbook)) {
				Consumer consumer = createExcelConsumer(writer, header);
				long count = queryDslSupport.download(commonClause, orderByClause, consumer, expressions);
				workbook.write(stream);
				return count;
			}
		}
	});
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:18,代码来源:TableDownloadTemplate.java

示例15: tupleToMap

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Test
public void tupleToMap() {
	Expression<String> string = constant("string");
	Expression<String> stringWithName = as(string, "aaa");
	List<Tuple> list = queryFactory.query().list(string, stringWithName);

	PagedList<Tuple> pagedList = new PagedList<>();
	pagedList.setPageSet(new PageSet());
	pagedList.setList(list);

	PagedList<Map<String, ?>> plist = QueryDslUtil.tupleToMap(pagedList, string, stringWithName);
	assertEquals(pagedList.getPageSet(), plist.getPageSet());
	assertEquals(1, plist.getList().size());
	assertEquals(1, plist.getList().get(0).entrySet().size());
	assertEquals("string", plist.getList().get(0).get("aaa"));
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:17,代码来源:QueryDslUtilTest.java


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