本文整理汇总了Java中com.mysema.query.support.Expressions类的典型用法代码示例。如果您正苦于以下问题:Java Expressions类的具体用法?Java Expressions怎么用?Java Expressions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Expressions类属于com.mysema.query.support包,在下文中一共展示了Expressions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildOrderPropertyPathFrom
import com.mysema.query.support.Expressions; //导入依赖的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;
}
示例2: getOmCounts
import com.mysema.query.support.Expressions; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public OptionalHashMap<String, Long> getOmCounts(MinSupportCountSettings minSupportCountSettings) {
Expression<String> caseBuilder = new CaseBuilder()
.when(InitiativeDaoSearchExpressions.INITIATIVE_IS_WAITING).then(new ConstantImpl<>(Show.waiting.name()))
.when(InitiativeDaoSearchExpressions.INITIATIVE_IS_RUNNING(minSupportCountSettings)).then(new ConstantImpl<>(Show.running.name()))
.when(InitiativeDaoSearchExpressions.INITIATIVE_IS_PREPARATION).then(new ConstantImpl<>(Show.preparation.name()))
.when(InitiativeDaoSearchExpressions.INITIATIVE_IS_REVIEW).then(new ConstantImpl<>(Show.review.name()))
.when(InitiativeDaoSearchExpressions.INITIATIVE_IS_OM_CANCELED).then(new ConstantImpl<>(Show.canceled.name()))
.when(InitiativeDaoSearchExpressions.INITIATIVE_IS_SENT_TO_PARLIAMENT).then(new ConstantImpl<>(Show.sentToParliament.name()))
.otherwise(Show.ended.name());
SimpleExpression<String> simpleExpression = Expressions.as(caseBuilder, "showCategory");
Map<String, Long> map = queryFactory
.from(qInitiative)
.groupBy(simpleExpression)
.map(simpleExpression, qInitiative.count());
return new OptionalHashMap<>(map);
}
示例3: getPublicCounts
import com.mysema.query.support.Expressions; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public OptionalHashMap<String, Long> getPublicCounts(MinSupportCountSettings minSupportCountSettings) {
Expression<String> caseBuilder = new CaseBuilder()
.when(InitiativeDaoSearchExpressions.INITIATIVE_IS_WAITING).then(new ConstantImpl<>(Show.waiting.name()))
.when(InitiativeDaoSearchExpressions.INITIATIVE_IS_RUNNING(minSupportCountSettings)).then(new ConstantImpl<>(Show.running.name()))
.when(InitiativeDaoSearchExpressions.INITIATIVE_IS_CANCELED).then(new ConstantImpl<>(Show.canceled.name()))
.when(InitiativeDaoSearchExpressions.INITIATIVE_IS_SENT_TO_PARLIAMENT).then(new ConstantImpl<>(Show.sentToParliament.name()))
.otherwise(Show.ended.name());
SimpleExpression<String> simpleExpression = Expressions.as(caseBuilder, "showCategory");
Map<String, Long> map = queryFactory
.from(qInitiative)
.where(InitiativeDaoSearchExpressions.INITIATIVE_PUBLIC_ALL())
.groupBy(simpleExpression)
.map(simpleExpression, qInitiative.count());
return new OptionalHashMap<>(map);
}
示例4: QAuthor
import com.mysema.query.support.Expressions; //导入依赖的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));
}
}
示例5: handleListStylesWithQuery
import com.mysema.query.support.Expressions; //导入依赖的package包/类
private CompletableFuture<Page<Style>> handleListStylesWithQuery (final ListStyles listStyles) {
final BooleanExpression styleInUse = new SQLSubQuery ()
.from (layerStyle)
.where (layerStyle.styleId.eq (style.id))
.exists ();
final AsyncSQLQuery baseQuery = db
.query()
.from(style)
.orderBy (style.name.asc ());
if (listStyles.getQuery () != null) {
baseQuery.where (style.name.containsIgnoreCase (listStyles.getQuery ()));
}
if (listStyles.getStyleType() != null) {
baseQuery.where (style.styleType.eq(listStyles.getStyleType()));
}
final AsyncSQLQuery listQuery = baseQuery.clone ();
singlePage (listQuery, listStyles.getPage ());
return baseQuery
.count ()
.thenCompose ((count) -> {
final Page.Builder<Style> builder = new Page.Builder<> ();
addPageInfo (builder, listStyles.getPage (), count);
return listQuery
.list (new QStyle (style.identification, style.name, style.styleSchemeType, Expressions.constant(""), style.styleType, styleInUse))
.thenApply ((styles) -> {
builder.addAll (styles.list ());
return builder.build ();
});
});
}
示例6: visitGenericQueryDslMethod
import com.mysema.query.support.Expressions; //导入依赖的package包/类
protected void visitGenericQueryDslMethod(Node node, String queryDslMethod) {
final Node leftNode = node.getLeft();
final boolean leftNodeIsLiteral = leftNode instanceof LiteralNode;
if (leftNodeIsLiteral) {
// Must transform this left node literal to an expression in order to use QueryDSL expression syntax for operation and right node
queryDslCode.append(useClass(Expressions.class)).append(".");
if (leftNode instanceof TemporalLiteralNode) {
queryDslCode.append("comparableTemplate(").append(useClass(Date.class)).append(".class, \"{0}\", ");
} else if (leftNode instanceof StringLiteralNode) {
queryDslCode.append("stringTemplate(\"{0}\", ");
} else if (leftNode instanceof FloatLiteralNode) {
queryDslCode.append("numberTemplate(").append(useClass(Float.class)).append(".class, \"{0}\", ");
} else if (leftNode instanceof LongLiteralNode) {
queryDslCode.append("numberTemplate(").append(useClass(Long.class)).append(".class, \"{0}\", ");
} else if (leftNode instanceof DoubleLiteralNode) {
queryDslCode.append("numberTemplate(").append(useClass(Double.class)).append(".class, \"{0}\", ");
} else if (leftNode instanceof IntegerLiteralNode) {
queryDslCode.append("numberTemplate(").append(useClass(Integer.class)).append(".class, \"{0}\", ");
} else if (leftNode instanceof BooleanLiteralNode) {
queryDslCode.append("booleanTemplate(\"{0}\", ");
}
}
visitInspectInstance(leftNode);
if (leftNodeIsLiteral) {
queryDslCode.append(")");
}
queryDslCode.append("." + queryDslMethod + "(");
visitInspectInstance(node.getRight());
queryDslCode.append(")");
}
示例7: QTodo
import com.mysema.query.support.Expressions; //导入依赖的package包/类
@Test
public void sec020502_CASE式を指定する_検索CASE式() {
/* 抽出条件を組み立てる。 */
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
/* CASE式を組立てる。 */
Expression<String> doneDesc = Expressions.cases().when(a.doneFlg.eq(1))
.then("実施済").when(a.dueDt.lt(new LocalDate(2015, 2, 1)))
.then("未実施(期限内)").otherwise("未実施(期限切)");
/* 取出すカラムとデータの取出し方を指定してクエリを発行する。 */
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.id,
a.dueDt, a.doneFlg, doneDesc));
/* クエリの結果を表示する。 */
for (Tuple tuple : list) {
Long valId = tuple.get(a.id);
LocalDate valDueDt = tuple.get(a.dueDt);
Integer valDoneFlg = tuple.get(a.doneFlg);
String valDoneDesc = tuple.get(doneDesc);
out.println(format(
"{0}: dueDt={1}, doneFlg={2}, doneDesc(CASE)={3}", valId,
valDueDt, valDoneFlg, valDoneDesc));
}
}
示例8: executeGetDatasetStatus
import com.mysema.query.support.Expressions; //导入依赖的package包/类
private Object executeGetDatasetStatus(GetDatasetStatus query) {
SQLQuery baseQuery = query().from(datasetStatus)
.join(dataset).on(dataset.id.eq(datasetStatus.id));
Expression<DatasetStatusInfo> expression =
new QDatasetStatusInfo(
dataset.identification,
datasetStatus.columnsChanged,
datasetStatus.filterConditionChanged,
datasetStatus.sourceDatasetChanged,
datasetStatus.imported,
Expressions.constant(false),
datasetStatus.sourceDatasetColumnsChanged,
datasetStatus.sourceDatasetRevisionChanged);
String datasourceId = query.getDatasetId();
if(datasourceId == null) {
return new TypedList<>(
DatasetStatusInfo.class,
baseQuery.list(expression));
} else {
return
baseQuery.where(dataset.identification.eq(datasourceId))
.singleResult(expression);
}
}
示例9: constExpression
import com.mysema.query.support.Expressions; //导入依赖的package包/类
private <T> Expression<T> constExpression(T value) {
if(value instanceof Serializable) {
return Expressions.constant(value);
} else {
throw new IllegalArgumentException("value is not serializable");
}
}
示例10: asExpressions
import com.mysema.query.support.Expressions; //导入依赖的package包/类
private Expression<?>[] asExpressions(Object... args) {
Expression<?>[] exprArgs = new Expression<?>[args.length];
int i = 0;
for(Object arg : args) {
if(arg instanceof Expression) {
exprArgs[i++] = (Expression<?>)arg;
} else {
exprArgs[i++] = Expressions.constant(arg);
}
}
return exprArgs;
}
示例11: isConfidential
import com.mysema.query.support.Expressions; //导入依赖的package包/类
private BooleanExpression isConfidential () {
final QLeafLayer leafLayer = new QLeafLayer ("leaf_layer2");
return new SQLSubQuery ()
.from (groupStructure)
.join (leafLayer).on (groupStructure.childLayerId.eq (leafLayer.genericLayerId))
.join (dataset).on (leafLayer.datasetId.eq (dataset.id))
.join (sourceDataset).on (dataset.sourceDatasetId.eq (sourceDataset.id))
.where (groupStructure.groupLayerIdentification.eq (genericLayer.identification))
.where (Expressions.booleanOperation (Ops.EQ, Expressions.constant (true), new SQLSubQuery ().from (sourceDatasetVersion).where (sourceDatasetVersion.sourceDatasetId.eq (sourceDataset.id)).orderBy (sourceDatasetVersion.createTime.desc ()).limit (1).list (sourceDatasetVersion.confidential)))
.exists ();
}
示例12: isWmsOnly
import com.mysema.query.support.Expressions; //导入依赖的package包/类
private BooleanExpression isWmsOnly () {
final QLeafLayer leafLayer = new QLeafLayer ("leaf_layer2");
return new SQLSubQuery ()
.from (groupStructure)
.join (leafLayer).on (groupStructure.childLayerId.eq (leafLayer.genericLayerId))
.join (dataset).on (leafLayer.datasetId.eq (dataset.id))
.join (sourceDataset).on (dataset.sourceDatasetId.eq (sourceDataset.id))
.where (groupStructure.groupLayerIdentification.eq (genericLayer.identification))
.where (Expressions.booleanOperation (Ops.EQ, Expressions.constant (true), new SQLSubQuery ().from (sourceDatasetVersion).where (sourceDatasetVersion.sourceDatasetId.eq (sourceDataset.id)).orderBy (sourceDatasetVersion.createTime.desc ()).limit (1).list (sourceDatasetVersion.wmsOnly)))
.exists ();
}
示例13: isConfidential
import com.mysema.query.support.Expressions; //导入依赖的package包/类
private BooleanExpression isConfidential () {
return new SQLSubQuery ()
.from (serviceStructure)
.join (leafLayer).on (serviceStructure.childLayerId.eq (leafLayer.genericLayerId))
.join (dataset).on (leafLayer.datasetId.eq (dataset.id))
.join (sourceDataset).on (dataset.sourceDatasetId.eq (sourceDataset.id))
.where (serviceStructure.serviceIdentification.eq (genericLayer.identification))
.where (Expressions.booleanOperation (Ops.EQ, Expressions.constant (true), new SQLSubQuery ().from (sourceDatasetVersion).where (sourceDatasetVersion.sourceDatasetId.eq (sourceDataset.id)).orderBy (sourceDatasetVersion.createTime.desc ()).limit (1).list (sourceDatasetVersion.confidential)))
.exists ();
}
示例14: isWmsOnly
import com.mysema.query.support.Expressions; //导入依赖的package包/类
private BooleanExpression isWmsOnly () {
return new SQLSubQuery ()
.from (serviceStructure)
.join (leafLayer).on (serviceStructure.childLayerId.eq (leafLayer.genericLayerId))
.join (dataset).on (leafLayer.datasetId.eq (dataset.id))
.join (sourceDataset).on (dataset.sourceDatasetId.eq (sourceDataset.id))
.where (serviceStructure.serviceIdentification.eq (genericLayer.identification))
.where (Expressions.booleanOperation (Ops.EQ, Expressions.constant (true), new SQLSubQuery ().from (sourceDatasetVersion).where (sourceDatasetVersion.sourceDatasetId.eq (sourceDataset.id)).orderBy (sourceDatasetVersion.createTime.desc ()).limit (1).list (sourceDatasetVersion.wmsOnly)))
.exists ();
}
示例15: with
import com.mysema.query.support.Expressions; //导入依赖的package包/类
@Override
public WithBuilder<Q> with(Path<?> alias, Path<?>... columns) {
Expression<?> columnsCombined = ExpressionUtils.list(Object.class, columns);
Expression<?> aliasCombined = Expressions.operation(alias.getType(), SQLOps.WITH_COLUMNS, alias, columnsCombined);
return new WithBuilder<Q>(queryMixin, aliasCombined);
}