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


Java Expression类代码示例

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


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

示例1: countHarvest

import com.querydsl.core.types.Expression; //导入依赖的package包/类
private Map<Long, Integer> countHarvest(final int huntingYear,
                                        final Collection<Long> includedGameSpeciesIds) {
    final SQHarvest harvest = SQHarvest.harvest;

    final Expression<Long> keyColumn = harvest.gameSpeciesId;
    final Expression<Integer> valueColumn = harvest.amount.sum();

    return sqlQueryFactory
            .select(keyColumn, valueColumn)
            .from(harvest)
            .where(sqlDateTimeInsideHuntingYear(harvest.pointOfTime, huntingYear),
                    harvest.gameSpeciesId.in(includedGameSpeciesIds),
                    harvest.groupHuntingDayId.isNotNull(),
                    harvest.groupHuntingDayId.notIn(
                            huntingDaysOfModeratedGroups(includedGameSpeciesIds, huntingYear)))
            .groupBy(keyColumn)
            .transform(GroupBy.groupBy(keyColumn).as(valueColumn));
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:19,代码来源:AdminMooselikeHuntingMetricsService.java

示例2: addToQuery

import com.querydsl.core.types.Expression; //导入依赖的package包/类
public void addToQuery(OrderBy orderBy, Expression<?> sqlExpression, SQLQuery<Tuple> sqlQuery) {
    if (sqlExpression instanceof ComparableExpressionBase) {
        ComparableExpressionBase comparable = (ComparableExpressionBase) sqlExpression;
        Expression<?> projection = sqlQuery.getMetadata().getProjection();
        if (projection instanceof QTuple) {
            QTuple qTuple = (QTuple) projection;
            List<Expression<?>> args = new ArrayList<>(qTuple.getArgs());
            args.add(comparable);
            sqlQuery.select(args.toArray(new Expression[args.size()]));
        }

        if (orderBy.getType() == OrderBy.OrderType.Ascending) {
            sqlQuery.orderBy(comparable.asc());
        } else {
            sqlQuery.orderBy(comparable.desc());
        }
    }
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:19,代码来源:PgExpressionHandler.java

示例3: serialize

import com.querydsl.core.types.Expression; //导入依赖的package包/类
@Override
protected JPQLSerializer serialize(boolean forCountRow) {

	// query target
	if (getMetadata().getJoins() != null && !getMetadata().getJoins().isEmpty()) {
		JoinExpression join = getMetadata().getJoins().get(0);
		Expression<?> je = join.getTarget();
		if (je != null && EntityPath.class.isAssignableFrom(je.getClass())) {
			getQueryDefinition().setTarget(QueryDslTarget.of((EntityPath<?>) je));
		}
	}

	QueryDSLUtils.configureQueryFromDefinition(this, getQueryDefinition(), null);

	return super.serialize(forCountRow);
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa-querydsl,代码行数:17,代码来源:JpaQuery.java

示例4: addOrderbyToQuery

import com.querydsl.core.types.Expression; //导入依赖的package包/类
public void addOrderbyToQuery(OrderBy orderBy, SQLQuery<Tuple> sqlQuery) {
    Expression<?> resultExpression = orderBy.getExpression().accept(this);
    if (resultExpression instanceof TimeIntervalExpression) {
        TimeIntervalExpression ti = (TimeIntervalExpression) resultExpression;
        addToQuery(orderBy, ti.getStart(), sqlQuery);
        addToQuery(orderBy, ti.getEnd(), sqlQuery);
    }
    if (resultExpression instanceof ConstantDurationExpression) {
        ConstantDurationExpression duration = (ConstantDurationExpression) resultExpression;
        addToQuery(orderBy, duration.getDuration(), sqlQuery);
    }
    if (resultExpression instanceof ListExpression) {
        for (Expression<?> sqlExpression : ((ListExpression) resultExpression).getExpressionsForOrder().values()) {
            addToQuery(orderBy, sqlExpression, sqlQuery);
        }
    } else {
        addToQuery(orderBy, resultExpression, sqlQuery);
    }
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:20,代码来源:PgExpressionHandler.java

示例5: getSubExpression

import com.querydsl.core.types.Expression; //导入依赖的package包/类
private Expression<?> getSubExpression(List<Property> elements, int curIdx, Map<String, Expression<?>> pathExpressions) {
    int nextIdx = curIdx + 1;
    if (elements.size() > nextIdx) {
        Property subProperty = elements.get(nextIdx);
        // If the subProperty is unknown, and the expression can be of type JSON,
        // then we assume JSON.
        if (!pathExpressions.containsKey(subProperty.getName()) && pathExpressions.containsKey("j")) {
            return pathExpressions.get("j");
        }
        // We can not accept json, so the subProperty must a known name.
        // We consume the subProperty. If the pathExpressions contains the property, there is no need to look further.
        elements.remove(nextIdx);
        return pathExpressions.get(subProperty.getName());
    } else {
        if (pathExpressions.containsKey(KEY_TIME_INTERVAL_START)
                && pathExpressions.containsKey(KEY_TIME_INTERVAL_END)) {
            return new TimeIntervalExpression(pathExpressions);
        }
        return new ListExpression(pathExpressions);
    }
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:22,代码来源:PgExpressionHandler.java

示例6: visit

import com.querydsl.core.types.Expression; //导入依赖的package包/类
@Override
public Expression<?> visit(After node) {
    List<de.fraunhofer.iosb.ilt.sta.query.expression.Expression> params = node.getParameters();
    Expression<?> p1 = params.get(0).accept(this);
    Expression<?> p2 = params.get(1).accept(this);
    if (p1 instanceof TimeIntervalExpression) {
        TimeIntervalExpression ti1 = (TimeIntervalExpression) p1;
        return ti1.after(p2);
    }
    if (p2 instanceof TimeIntervalExpression) {
        TimeIntervalExpression ti2 = (TimeIntervalExpression) p2;
        return ti2.before(p1);
    }
    DateTimeExpression d1 = getSingleOfType(DateTimeExpression.class, p1);
    DateTimeExpression d2 = getSingleOfType(DateTimeExpression.class, p2);
    return d1.after(d2);
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:18,代码来源:PgExpressionHandler.java

示例7: expressionsForProperty

import com.querydsl.core.types.Expression; //导入依赖的package包/类
/**
 * Get a Map of expressions for the given property and path. Add it to the
 * given Map, or a new Map.
 *
 * @param property The property to get expressions for.
 * @param qPath The path to get expressions for.
 * @param target The Map to add to. If null a new Map will be created.
 * @return The target Map, or a new Map if target was null.
 */
public static Map<String, Expression<?>> expressionsForProperty(EntityProperty property, Path<?> qPath, Map<String, Expression<?>> target) {
    Map<Class, Map<String, ExpressionFactory>> innerMap = EP_MAP_MULTI.get(property);
    if (innerMap == null) {
        throw new IllegalArgumentException("We do not know any property called " + property.toString());
    }
    Map<String, ExpressionFactory> coreMap = innerMap.get(qPath.getClass());
    if (coreMap == null) {
        throw new IllegalArgumentException("No property called " + property.toString() + " for " + qPath.getClass());
    }
    if (target == null) {
        target = new LinkedHashMap<>();
    }
    for (Map.Entry<String, ExpressionFactory> es : coreMap.entrySet()) {
        target.put(es.getKey(), es.getValue().get(qPath));
    }
    return target;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:27,代码来源:PropertyResolver.java

示例8: expectedWorkAmount

import com.querydsl.core.types.Expression; //导入依赖的package包/类
/**
 * Getting the expected work amount for a date period. The calculation for each day in the range
 * is done in the following order:
 * <ol>
 * <li>if there is an exact work day specified for a specific date, that is used. Otherwise</li>
 * <li>if there is a replacement day of a public holiday and there is a weekday specified for the
 * replaced holiday, that is used. Otherwise</li>
 * <li>If there is a non holiday weekday, that is used. Otherwise</li>
 * <li>zero is used.</li>
 * </ol>
 *
 * @param userId
 *          The id of the user who should have done the work.
 * @param startDate
 *          The date when we start calculating the work that should be done from.
 * @param endDateExcluded
 *          The date until we calculate the work that should be done (excluded).
 * @return The amount of work that should be done by the specified user in the specific time
 *         period.
 */
public static SQLQuery<Long> expectedWorkAmount(final Expression<Long> userId,
    final Expression<Date> startDate, final Expression<Date> endDateExcluded) {

  QDateSequence qDates = new QDateSequence("exp_work_dates");
  QDateRange qDateRange = new QDateRange("exp_work_date_range");
  QUserWorkScheme qUserWorkScheme = new QUserWorkScheme("exp_work_user_work_scheme");

  SQLQuery<Long> query = new SQLQuery<>();
  query.select(
      new Coalesce<Long>(Long.class,
          exactWorkSubSelect(qUserWorkScheme.workSchemeId, qDates.date),
          replacementWeekdaySubSelect(qUserWorkScheme.workSchemeId, userId, qDates.date),
          nonHolidayWeekdaySubSelect(qUserWorkScheme.workSchemeId, userId, qDates.date),
          Expressions.ZERO)
              .asNumber().sum());
  query
      .from(qDates)
      .innerJoin(qDateRange)
      .on(qDateRange.startDate.loe(qDates.date).and(qDateRange.endDateExcluded.gt(qDates.date)))
      .innerJoin(qUserWorkScheme).on(qUserWorkScheme.dateRangeId.eq(qDateRange.dateRangeId))
      .where(qDates.date.goe(startDate).and(qDates.date.lt(endDateExcluded))
          .and(qUserWorkScheme.userId.eq(userId)));

  return query;
}
 
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:46,代码来源:QueryUtil.java

示例9: doJoin

import com.querydsl.core.types.Expression; //导入依赖的package包/类
@Override
public Expression<?> doJoin(MetaAttribute targetAttr, JoinType joinType, Expression<?> parent) {
	if (targetAttr instanceof MetaComputedAttribute) {

		MetaComputedAttribute computedAttr = (MetaComputedAttribute) targetAttr;
		QuerydslExpressionFactory expressionFactory = (QuerydslExpressionFactory<?>) queryImpl.getComputedAttrs()
				.get(computedAttr);

		return expressionFactory.getExpression(parent, getQuery());
	}
	else {
		Expression<Object> expression = QuerydslUtils.get(parent, targetAttr.getName());
		querydslQuery.getMetadata().addJoin(QuerydslUtils.convertJoinType(joinType), expression);
		return expression;
	}
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:17,代码来源:QuerydslQueryBackend.java

示例10: noHolidayExistsSubSelect

import com.querydsl.core.types.Expression; //导入依赖的package包/类
private static Predicate noHolidayExistsSubSelect(final Expression<Long> userId,
    final DatePath<Date> date) {
  QPublicHoliday qPublicHoliday = new QPublicHoliday("exp_work_nh_ph");
  QUserHolidayScheme qUserHolidayScheme = new QUserHolidayScheme("exp_work_nh_uhsch");
  QDateRange qDateRange = new QDateRange("exp_work_nh_data_range");

  return new SQLQuery<>().select(qPublicHoliday.publicHolidayId).from(qPublicHoliday)
      .innerJoin(qUserHolidayScheme)
      .on(qUserHolidayScheme.holidaySchemeId.eq(qPublicHoliday.holidaySchemeId))
      .innerJoin(qDateRange).on(qDateRange.dateRangeId.eq(qUserHolidayScheme.dateRangeId))
      .where(qUserHolidayScheme.userId.eq(userId)
          .and(qDateRange.startDate.loe(date))
          .and(qDateRange.endDateExcluded.gt(date))
          .and(qPublicHoliday.date.eq(date)))
      .notExists();
}
 
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:17,代码来源:QueryUtil.java

示例11: select

import com.querydsl.core.types.Expression; //导入依赖的package包/类
/**
 * Change the projection of this query
 * @param <U> Results type
 * @param expr new projection
 * @return the current object
 */
@Override
public <U> JpaQuery<U> select(Expression<U> expr) {
	queryMixin.setProjection(expr);
	@SuppressWarnings("unchecked") // This is the new type
	JpaQuery<U> newType = (JpaQuery<U>) this;
	return newType;
}
 
开发者ID:holon-platform,项目名称:holon-datastore-jpa-querydsl,代码行数:14,代码来源:JpaQuery.java

示例12: get

import com.querydsl.core.types.Expression; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> Expression<T> get(Expression<?> path, String name) {
	try {
		Class<?> clazz = path.getClass();
		Field field = clazz.getField(name);
		return (Expression<T>) field.get(path);
	} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
		throw new IllegalStateException("failed get field " + path + "." + name, e);
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:11,代码来源:QuerydslUtils.java

示例13: setup

import com.querydsl.core.types.Expression; //导入依赖的package包/类
@Before
public void setup() {

	expression = Mockito.mock(Expression.class);
	Tuple tuple = Mockito.mock(Tuple.class);
	Mockito.when(tuple.size()).thenReturn(2);
	Mockito.when(tuple.get(expression)).thenReturn("test");
	Mockito.when(tuple.toArray()).thenReturn(new Object[]{"0", "1"});
	Mockito.when(tuple.get(0, String.class)).thenReturn("0");
	Mockito.when(tuple.get(1, String.class)).thenReturn("1");

	Mockito.when(tuple.size()).thenReturn(2);
	Map<String, Integer> selectionBindings = new HashMap<>();
	impl = new QuerydslTupleImpl(tuple, selectionBindings);
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:16,代码来源:QueryDslTupleImplTest.java

示例14: createQueryFactory

import com.querydsl.core.types.Expression; //导入依赖的package包/类
@Override
protected JpaQueryFactory createQueryFactory(EntityManager em) {
	QuerydslQueryFactory factory = QuerydslQueryFactory.newInstance();

	factory.registerComputedAttribute(TestEntity.class, ATTR_VIRTUAL_VALUE, String.class,
			new QuerydslExpressionFactory<QTestEntity>() {

				@Override
				public Expression<?> getExpression(QTestEntity test, JPAQuery<?> query) {
					return test.stringValue.toUpperCase();
				}
			});

	return factory;
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:16,代码来源:ComputedAttributeQuerydslTest.java

示例15: expressionForProperty

import com.querydsl.core.types.Expression; //导入依赖的package包/类
public static Expression<?> expressionForProperty(EntityProperty property, Path<?> qPath) {
    Map<Class, ExpressionFactory> innerMap = epMapSingle.get(property);
    if (innerMap == null) {
        throw new IllegalArgumentException("ObservedProperty has no property called " + property.toString());
    }
    return innerMap.get(qPath.getClass()).get(qPath);
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:8,代码来源:PropertyResolver.java


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