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


Java Tuple类代码示例

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


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

示例1: addToQuery

import com.querydsl.core.Tuple; //导入依赖的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

示例2: visit

import com.querydsl.core.Tuple; //导入依赖的package包/类
@Override
public void visit(EntityPathElement element) {
    sqlQuery.limit(2);
    List<Tuple> results = sqlQuery.fetch();
    if (results.size() > 1) {
        throw new IllegalStateException("Expecting an element, yet more than 1 result. Got " + results.size() + " results.");
    }
    if (results.isEmpty()) {
        return;
    }

    PropertyHelper.entityFromTupleFactory<? extends Entity> factory = PropertyHelper.getFactoryFor(element.getEntityType().getImplementingClass());
    Entity entity = factory.create(results.get(0), query, new DataSize());

    if (entity == null) {
        throw new IllegalStateException("Failed to create an entity from result set.");
    }
    expandEntity(entity, query);
    resultObject = entity;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:21,代码来源:EntityCreator.java

示例3: createSetFromTuples

import com.querydsl.core.Tuple; //导入依赖的package包/类
public static <T extends Entity> EntitySet<T> createSetFromTuples(entityFromTupleFactory<T> factory, CloseableIterator<Tuple> tuples, Query query, long maxDataSize) {
    EntitySet<T> entitySet = new EntitySetImpl<>(factory.getEntityType());
    int count = 0;
    DataSize size = new DataSize();
    int top = query.getTopOrDefault();
    while (tuples.hasNext()) {
        Tuple tuple = tuples.next();
        entitySet.add(factory.create(tuple, query, size));
        count++;
        if (count >= top) {
            return entitySet;
        }
        if (size.getDataSize() > maxDataSize) {
            LOGGER.debug("Size limit reached: {} > {}.", size.getDataSize(), maxDataSize);
            return entitySet;
        }
    }
    return entitySet;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:20,代码来源:PropertyHelper.java

示例4: create

import com.querydsl.core.Tuple; //导入依赖的package包/类
@Override
public Thing create(Tuple tuple, Query query, DataSize dataSize) {
    Set<Property> select = query == null ? Collections.emptySet() : query.getSelect();

    Thing entity = new Thing();
    entity.setName(tuple.get(qInstance.name));
    entity.setDescription(tuple.get(qInstance.description));

    UUID id = tuple.get(qInstance.id);
    if (id != null) {
        entity.setId(new UuidId(tuple.get(qInstance.id)));
    }

    if (select.isEmpty() || select.contains(EntityProperty.Properties)) {
        String props = tuple.get(qInstance.properties);
        dataSize.increase(props == null ? 0 : props.length());
        entity.setProperties(jsonToObject(props, Map.class));
    }

    return entity;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:22,代码来源:PropertyHelper.java

示例5: create

import com.querydsl.core.Tuple; //导入依赖的package包/类
@Override
public Thing create(Tuple tuple, Query query, DataSize dataSize) {
    Set<Property> select = query == null ? Collections.emptySet() : query.getSelect();

    Thing entity = new Thing();
    entity.setName(tuple.get(qInstance.name));
    entity.setDescription(tuple.get(qInstance.description));

    Long id = tuple.get(qInstance.id);
    if (id != null) {
        entity.setId(new LongId(tuple.get(qInstance.id)));
    }

    if (select.isEmpty() || select.contains(EntityProperty.Properties)) {
        String props = tuple.get(qInstance.properties);
        dataSize.increase(props == null ? 0 : props.length());
        entity.setProperties(jsonToObject(props, Map.class));
    }

    return entity;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:22,代码来源:PropertyHelper.java

示例6: addOrderbyToQuery

import com.querydsl.core.Tuple; //导入依赖的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

示例7: create

import com.querydsl.core.Tuple; //导入依赖的package包/类
@Override
public Thing create(Tuple tuple, Query query, DataSize dataSize) {
    Set<Property> select = query == null ? Collections.emptySet() : query.getSelect();

    Thing entity = new Thing();
    entity.setName(tuple.get(qInstance.name));
    entity.setDescription(tuple.get(qInstance.description));

    String id = tuple.get(qInstance.id);
    if (id != null) {
        entity.setId(new StringId(tuple.get(qInstance.id)));
    }

    if (select.isEmpty() || select.contains(EntityProperty.Properties)) {
        String props = tuple.get(qInstance.properties);
        dataSize.increase(props == null ? 0 : props.length());
        entity.setProperties(jsonToObject(props, Map.class));
    }

    return entity;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:22,代码来源:PropertyHelper.java

示例8: resolveProjectKeyIdMap

import com.querydsl.core.Tuple; //导入依赖的package包/类
private Map<String, Long> resolveProjectKeyIdMap(final Set<String> projectKeys) {
  Map<String, Long> result = querydslSupport.execute((connection, configuration) -> {
    List<Tuple> resultSet = new SQLQuery<>(connection, configuration)
        .select(QProject.project.pkey, QProject.project.id)
        .from(QProject.project)
        .where(QProject.project.pkey.in(projectKeys)).fetch();

    Map<String, Long> localResult = new HashMap<>();
    for (Tuple tuple : resultSet) {
      localResult.put(tuple.get(QProject.project.pkey), tuple.get(QProject.project.id));
    }
    return localResult;
  });

  checkNoProjectKeyMissing(projectKeys, result.keySet());
  return result;
}
 
开发者ID:everit-org,项目名称:jira-hr-admin,代码行数:18,代码来源:SpecialIssuesServlet.java

示例9: map

import com.querydsl.core.Tuple; //导入依赖的package包/类
@Override
protected Facility map(Tuple row) {
    Facility facility = mapFacility(row, new Facility());
    facility.contacts = new FacilityContacts(
            row.get(qFacility.emergencyContactId),
            row.get(qFacility.operatorContactId),
            row.get(qFacility.serviceContactId)
    );
    facility.paymentInfo.detail = paymentInfoDetailMapping.map(row);
    facility.paymentInfo.url = paymentInfoUrlMapping.map(row);

    facility.openingHours.info = openingHoursInfoMapping.map(row);
    facility.openingHours.url = openingHoursUrlMapping.map(row);

    return facility;
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:17,代码来源:FacilityDao.java

示例10: map

import com.querydsl.core.Tuple; //导入依赖的package包/类
@Override
protected Contact map(Tuple row) {
    Long id = row.get(qContact.id);
    if (id == null) {
        return null;
    }
    Contact contact = new Contact();
    contact.id = id;
    contact.operatorId = row.get(qContact.operatorId);
    contact.email = row.get(qContact.email);
    contact.phone = row.get(qContact.phone);
    contact.name = nameMapping.map(row);
    contact.address = addressMapping.map(row);
    contact.openingHours = openingHoursMapping.map(row);
    contact.info = infoMapping.map(row);
    return contact;
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:18,代码来源:ContactDao.java

示例11: setEndDateForPreviousStateHistoryEntry

import com.querydsl.core.Tuple; //导入依赖的package包/类
private void setEndDateForPreviousStateHistoryEntry(long facilityId, DateTime currentDate) {
    final Tuple lastHistoryEntry = queryFactory.query()
            .select(qFacilityStatusHistory.id, qFacilityStatusHistory.startTs)
            .from(qFacilityStatusHistory)
            .where(qFacilityStatusHistory.facilityId.eq(facilityId))
            .orderBy(qFacilityStatusHistory.endTs.desc().nullsFirst())
            .fetchFirst();

    if (lastHistoryEntry != null) {
        Long lastHistoryEntryId = lastHistoryEntry.get(qFacilityStatusHistory.id);
        final DateTime lastEntryStartTs = lastHistoryEntry.get(qFacilityStatusHistory.startTs);
        validateTimestamp(facilityId, currentDate, lastEntryStartTs, lastHistoryEntryId);
        queryFactory.update(qFacilityStatusHistory)
                .set(qFacilityStatusHistory.endTs, currentDate)
                .where(qFacilityStatusHistory.id.eq(lastHistoryEntryId))
                .execute();
    }
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:19,代码来源:FacilityHistoryDao.java

示例12: setEndDateForPreviousCapacityHistoryEntry

import com.querydsl.core.Tuple; //导入依赖的package包/类
private void setEndDateForPreviousCapacityHistoryEntry(long facilityId, DateTime currentDate) {
    final Tuple lastHistoryEntry = queryFactory.query()
            .select(qFacilityCapacityHistory.id, qFacilityCapacityHistory.startTs)
            .from(qFacilityCapacityHistory)
            .where(qFacilityCapacityHistory.facilityId.eq(facilityId))
            .orderBy(qFacilityCapacityHistory.endTs.desc().nullsFirst())
            .fetchFirst();

    if (lastHistoryEntry != null) {
        Long lastHistoryEntryId = lastHistoryEntry.get(qFacilityCapacityHistory.id);
        final DateTime lastEntryStartTs = lastHistoryEntry.get(qFacilityCapacityHistory.startTs);
        validateTimestamp(facilityId, currentDate, lastEntryStartTs, lastHistoryEntryId);
        queryFactory.update(qFacilityCapacityHistory)
                .set(qFacilityCapacityHistory.endTs, currentDate)
                .where(qFacilityCapacityHistory.id.eq(lastHistoryEntryId))
                .execute();
    }
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:19,代码来源:FacilityHistoryDao.java

示例13: predictionMapping

import com.querydsl.core.Tuple; //导入依赖的package包/类
private static MappingProjection<PredictionBatch> predictionMapping(DateTime timeWithFullPrecision) {
    DateTime time = toPredictionResolution(timeWithFullPrecision);
    Path<Integer> spacesAvailableColumn = spacesAvailableAt(time);
    return new MappingProjection<PredictionBatch>(PredictionBatch.class,
            qPrediction.facilityId,
            qPrediction.capacityType,
            qPrediction.usage,
            qPrediction.start,
            spacesAvailableColumn) {
        @Override
        protected PredictionBatch map(Tuple row) {
            PredictionBatch pb = new PredictionBatch();
            pb.utilizationKey = new UtilizationKey(
                    row.get(qPrediction.facilityId),
                    row.get(qPrediction.capacityType),
                    row.get(qPrediction.usage)
            );
            pb.sourceTimestamp = row.get(qPrediction.start);
            Integer spacesAvailable = row.get(spacesAvailableColumn);
            if (spacesAvailable != null) {
                pb.predictions.add(new Prediction(time, spacesAvailable));
            }
            return pb;
        }
    };
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:27,代码来源:PredictionDao.java

示例14: fetch

import com.querydsl.core.Tuple; //导入依赖的package包/类
protected FetchResults<Id, M> fetch(List<Group> versionsAndParents, boolean optimized, BooleanExpression predicate) {
    if (versionsAndParents.isEmpty()) {
        return noResults;
    }

    Map<Revision, List<Tuple>> properties = fetchProperties(optimized, predicate);
    ListMultimap<Id, ObjectVersion<M>> results = ArrayListMultimap.create();
    Revision latestRevision = null;

    for (Group versionAndParents : versionsAndParents) {
        Id id = versionAndParents.getOne(options.version.docId);
        latestRevision = versionAndParents.getOne(options.version.revision);
        Map<PropertyPath, Object> changeset = toChangeSet(properties.get(latestRevision));

        results.put(id, buildVersion(latestRevision, versionAndParents, changeset));
    }
    return new FetchResults<>(results, latestRevision);
}
 
开发者ID:ssaarela,项目名称:javersion,代码行数:19,代码来源:AbstractVersionStoreJdbc.java

示例15: fetchProperties

import com.querydsl.core.Tuple; //导入依赖的package包/类
protected Map<Revision, List<Tuple>> fetchProperties(boolean optimized, BooleanExpression predicate) {
    SQLQuery<?> qry = options.queryFactory
            .from(options.property)
            .where(predicate);

    if (optimized) {
        qry.innerJoin(options.version).on(
                options.version.revision.eq(options.property.revision),
                options.version.status.goe(ACTIVE));
        qry.where(options.property.status.goe(ACTIVE));
    } else {
        qry.innerJoin(options.version).on(options.version.revision.eq(options.property.revision));
        qry.where(options.property.status.loe(ACTIVE));
    }
    return qry.transform(properties);
}
 
开发者ID:ssaarela,项目名称:javersion,代码行数:17,代码来源:AbstractVersionStoreJdbc.java


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