Java Code Examples for org.jooq.lambda.tuple.Tuple#tuple()

The following examples show how to use org.jooq.lambda.tuple.Tuple#tuple() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChangeReporter.java    From waltz with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    ApplicationIdSelectorFactory selectorFactory = new ApplicationIdSelectorFactory();

    LocalDateTime exerciseStart = LocalDateTime.of(2018, 06, 04, 0, 1).truncatedTo(ChronoUnit.DAYS);
    LocalDateTime dayBeforeYesterday = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(1);
    LocalDateTime yesterday = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);

    EntityReference appGroupRef = EntityReference.mkRef(EntityKind.APP_GROUP, 10862); // BCBS239
    Select<Record1<Long>> appSelector = mkSelector(selectorFactory, appGroupRef);

    Tuple3<String, LocalDateTime, LocalDateTime> dayPeriod = Tuple.tuple("day", dayBeforeYesterday, yesterday);
    Tuple3<String, LocalDateTime, LocalDateTime> cumulativePeriod = Tuple.tuple("cumulative", exerciseStart, yesterday);

    dumpReport(dsl, dayPeriod, appGroupRef, appSelector);
    dumpReport(dsl, cumulativePeriod, appGroupRef, appSelector);
}
 
Example 2
Source File: MeasurableRatingPlannedDecommissionDao.java    From waltz with Apache License 2.0 6 votes vote down vote up
public Tuple2<Operation, Boolean> save(EntityReference entityReference, long measurableId, DateFieldChange dateChange, String userName) {
    MeasurableRatingPlannedDecommissionRecord existingRecord = dsl
            .selectFrom(MEASURABLE_RATING_PLANNED_DECOMMISSION)
            .where(mkRefCondition(entityReference)
                    .and(MEASURABLE_RATING_PLANNED_DECOMMISSION.MEASURABLE_ID.eq(measurableId)))
            .fetchOne();

    if (existingRecord != null) {
        updateDecommDateOnRecord(existingRecord, dateChange, userName);
        boolean updatedRecord = existingRecord.update() == 1;

        return Tuple.tuple(Operation.UPDATE, updatedRecord);
    } else {
        MeasurableRatingPlannedDecommissionRecord record = dsl.newRecord(MEASURABLE_RATING_PLANNED_DECOMMISSION);
        updateDecommDateOnRecord(record, dateChange, userName);
        record.setCreatedAt(DateTimeUtilities.nowUtcTimestamp());
        record.setCreatedBy(userName);
        record.setEntityId(entityReference.id());
        record.setEntityKind(entityReference.kind().name());
        record.setMeasurableId(measurableId);
        boolean recordsInserted = record.insert() == 1;

        return Tuple.tuple(Operation.ADD, recordsInserted);
    }
}
 
Example 3
Source File: SortedNeighborhoodPairGenerator.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private Tuple2<T, Collection<T>> generatePairs(T leftValue) {
	Collection<T> window = StreamUtils.seq(upperWindow)
		.concat(getCurrent())
		.concat(lowerWindow)
		.map(ValueWrapper::getValue)
		.toList();
	return Tuple.tuple(leftValue, window);
}
 
Example 4
Source File: AllocationHarness.java    From waltz with Apache License 2.0 5 votes vote down vote up
private static Tuple4<Application, MeasurableCategory, List<Measurable>, AllocationScheme> setup(DSLContext dsl,
                                                                                                 AllocationSchemeService schemesService,
                                                                                                 MeasurableService measurableService,
                                                                                                 MeasurableCategoryDao categoryDao,
                                                                                                 ApplicationService applicationService) {
    deleteAll(dsl);
    Application app = mkApp(dsl, applicationService);
    MeasurableCategory category = mkCategory(dsl, categoryDao);
    List<Measurable> measurables = mkMeasurables(measurableService, category);
    AllocationScheme scheme = mkScheme(schemesService, category);

    return Tuple.tuple(app,category,measurables,scheme);
}
 
Example 5
Source File: EntityRelationshipUtilities.java    From waltz with Apache License 2.0 5 votes vote down vote up
public static Optional<EntityRelationshipKey> mkEntityRelationshipKey(EntityReference entityA,
                                                                      EntityReference entityB,
                                                                      RelationshipKind relationshipKind,
                                                                      boolean validate) {
    checkNotNull(relationshipKind, "relationshipKind cannot be null");
    checkNotNull(entityA, "entityA cannot be null");
    checkNotNull(entityB, "entityB cannot be null");

    if (! validate) {
        return Optional.of(ImmutableEntityRelationshipKey.builder()
                .a(entityA)
                .b(entityB)
                .relationshipKind(relationshipKind.name())
                .build());
    }

    // given A, B and a relationship kind -> return the valid entity relationship
    Set<Tuple2<EntityKind, EntityKind>> allowedEntityKinds = relationshipKind.getAllowedEntityKinds();

    Tuple2<EntityKind, EntityKind> exact = Tuple.tuple(entityA.kind(), entityB.kind());
    Tuple2<EntityKind, EntityKind> opposite = Tuple.tuple(entityB.kind(), entityA.kind());

    if (allowedEntityKinds.contains(exact)) {
        return Optional.of(ImmutableEntityRelationshipKey.builder()
                .a(entityA)
                .b(entityB)
                .relationshipKind(relationshipKind.name())
                .build());
    } else if (allowedEntityKinds.contains(opposite)){
        return Optional.of(ImmutableEntityRelationshipKey.builder()
                .a(entityB)
                .b(entityA)
                .relationshipKind(relationshipKind.name())
                .build());
    } else {
        return Optional.empty();
    }
}
 
Example 6
Source File: Tuple2id.java    From RankSys with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Converts the tuple into a jOOL tuple.
 *
 * @return jOOL tuple
 */
public Tuple2<Integer, Double> asTuple() {
    return Tuple.tuple(v1, v2);
}
 
Example 7
Source File: Tuple2io.java    From RankSys with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Converts the tuple into a jOOL tuple.
 *
 * @return jOOL tuple
 */
public Tuple2<Integer, T2> asTuple() {
    return Tuple.tuple(v1, v2);
}
 
Example 8
Source File: Tuple2od.java    From RankSys with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Converts the tuple into a jOOL tuple.
 *
 * @return jOOL tuple
 */
public Tuple2<T1, Double> asTuple() {
    return Tuple.tuple(v1, v2);
}
 
Example 9
Source File: FastFeatureIndex.java    From RankSys with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Applies FastFeatureIndex::fidx2feature to the first element of the tuple.
 *
 * @param <V> type of value
 * @param tuple fidx-value tuple
 * @return feature-value tuple
 */
default <V> Tuple2<F, V> fidx2feature(Tuple2io<V> tuple) {
    return Tuple.tuple(fidx2feature(tuple.v1), tuple.v2);
}
 
Example 10
Source File: FastUserIndex.java    From RankSys with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Applies FastUserIndex::uidx2user to the first element of the tuple.
 *
 * @param <V> type of value
 * @param tuple uidx-value tuple
 * @return user-value tuple
 */
default <V> Tuple2<U, V> uidx2user(Tuple2io<V> tuple) {
    return Tuple.tuple(uidx2user(tuple.v1), tuple.v2);
}
 
Example 11
Source File: FastItemIndex.java    From RankSys with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Applies FastItemIndex::iidx2item to the first element of the tuple.
 *
 * @param <V> type of value
 * @param tuple iidx-value tuple
 * @return item-value tuple
 */
default <V> Tuple2<I, V> iidx2item(Tuple2io<V> tuple) {
    return Tuple.tuple(iidx2item(tuple.v1), tuple.v2);
}