Java 类org.jooq.RecordMapper 实例源码

项目:tiny-rxjava-jdbc    文件:InsertReturning.java   
private InsertReturning(
  Connection connection,
  InsertReturningQueryBuilder<? extends InsertResultStep<? extends R>> queryBuilder,
  RecordMapper<? super R, ? extends T> recordMapper
) {
  super(
    subscriber -> {
      try (InsertResultStep<? extends R> query = queryBuilder.build(connection)) {
        Iterable<? extends R> result = query.fetch();
        setupUnsubscription(subscriber, query);
        log.debug("InsertReturning setProducer for {}", query);
        subscriber.setProducer(
          new InsertReturningProducer<>(
            subscriber,
            query,
            result,
            recordMapper
          )
        );
      } catch (Throwable t) {
        handleException(t, subscriber);
      }
    }
  );
}
项目:tiny-rxjava-jdbc    文件:Select.java   
private Select(
  Connection connection,
  QueryBuilder<ResultQuery<? extends R>> queryBuilder,
  RecordMapper<? super R, ? extends T> recordMapper
) {
  super(
    subscriber -> {
      try (ResultQuery<? extends R> query = queryBuilder.build(connection)) {
        Cursor<? extends R> cursor = query.fetchLazy();
        setupUnsubscription(subscriber, query, cursor);
        log.debug("Select setProducer for  {}", query);
        subscriber.setProducer(new SelectProducer<>(
          subscriber,
          query,
          cursor,
          recordMapper
        ));
      } catch (Throwable t) {
        handleException(t, subscriber);
      }
    }
  );
}
项目:breakout-groep23    文件:Database.java   
public Level getLevel(int id) {
    Level level = create.select().from(LEVELS).where(LEVELS.ID.eq(id)).fetchOne().into(Level.class);
    List<EntityBlock> blocks = create.select().from(LEVEL_MAP).where(LEVEL_MAP.ID.eq(level.getId())).fetch().map(new RecordMapper<Record, EntityBlock>() {
        @Override
        public EntityBlock map(Record record) {
            return new EntityBlock(record.getValue(LEVEL_MAP.X).intValue(),
                    record.getValue(LEVEL_MAP.Y).intValue(),
                    record.getValue(LEVEL_MAP.WIDTH).intValue(),
                    record.getValue(LEVEL_MAP.HEIGHT).intValue(),
                    getPowerUp(record.getValue(LEVEL_MAP.POWERUPTYPE).intValue()));
        }
    });
    level.setBlockList(blocks);
    System.out.println(blocks);
    return level;
}
项目:breakout-groep23    文件:Database.java   
public List<Level> getLevels() {
    List<Level> levels = create.select().from(LEVELS).fetch().into(Level.class);
    for (Level level : levels) {
        List<EntityBlock> blocks = create.select().from(LEVEL_MAP).where(LEVEL_MAP.ID.eq(level.getId())).fetch().map(new RecordMapper<Record, EntityBlock>() {
            @Override
            public EntityBlock map(Record record) {
                return new EntityBlock(record.getValue(LEVEL_MAP.X).intValue(),
                        record.getValue(LEVEL_MAP.Y).intValue(),
                        record.getValue(LEVEL_MAP.WIDTH).intValue(),
                        record.getValue(LEVEL_MAP.HEIGHT).intValue(),
                        getPowerUp(record.getValue(LEVEL_MAP.POWERUPTYPE).intValue()));
            }
        });
        level.setBlockList(blocks);
    }
    return levels;
}
项目:breakout-groep23    文件:Database.java   
public List<MPGame> getMPHightScores() {
    List<MPGame> games = create.select().from(MPGAMES).fetch().map(new RecordMapper<Record, MPGame>() {
        @Override
        public MPGame map(Record record) {
            MpgamesRecord mpgamesRecord = (MpgamesRecord) record;
            return new MPGame(getMPPlayer(mpgamesRecord.getPlayer1()), getMPPlayer(mpgamesRecord.getPlayer2()));
        }
    });

    Collections.sort(games, new Comparator<MPGame>() {
        @Override
        public int compare(MPGame game1, MPGame game2) {
            return game2.getTotalScore() - game1.getTotalScore();
        }
    });
    return games;
}
项目:adjule    文件:JooqQuestionsDao.java   
private RecordMapper<Record, QuestionView> getQuestionMapper(final QuestionContent questionContent) {
    return record -> {
        final QuestionView questionView = new QuestionView();
        questionView.setQuestionId(record.getValue(QUESTIONS.QUESTION_ID));
        questionView.setCreated(record.getValue(QUESTIONS.CREATED).toLocalDateTime());
        questionView.setUser(
                new UserView(record.getValue(USERS.LOGIN),
                             record.getValue(PROFILES.FIRST_NAME),
                             record.getValue(PROFILES.LAST_NAME),
                             record.getValue(PROFILES.NICKNAME))
        );
        questionView.setGroupCode(record.getValue(CONTESTS.CODE));
        questionView.setProblemCode(record.getValue(TASKS.CODE));
        questionView.setStatus(record.getValue(QUESTIONS.STATUS));
        questionView.setType();
        if (QuestionContent.WITH_CONTENT.equals(questionContent)) {
            questionView.setContent(record.getValue(QUESTIONS.QUESTION));
        }
        questionView.setPrivateQuestion(record.getValue(QUESTIONS.PRIVATE));
        questionView.setAnswersCount(record.getValue("answersCount", Integer.class));
        if (record.field("hasNotification") != null) {
            questionView.setHasNotification(record.getValue("hasNotification", Boolean.class));
        }
        return questionView;
    };
}
项目:tiny-rxjava-jdbc    文件:InsertReturning.java   
public static <R extends Record, T> InsertReturning<R, T> using(
  Connection connection,
  InsertReturningQueryBuilder<? extends InsertResultStep<? extends R>> queryBuilder,
  RecordMapper<? super R, ? extends T> recordMapper
) {
  return new InsertReturning<>(connection, queryBuilder, recordMapper);
}
项目:tiny-rxjava-jdbc    文件:SelectProducer.java   
public SelectProducer(
  Subscriber<? super T> subscriber,
  ResultQuery<? extends R> query,
  Cursor<? extends R> cursor,
  RecordMapper<? super R, ? extends T> recordMapper
) {
  this.subscriber = subscriber;
  this.query = query;
  this.cursor = cursor;
  this.recordMapper = recordMapper;
}
项目:tiny-rxjava-jdbc    文件:InsertReturningProducer.java   
public InsertReturningProducer(
  Subscriber<? super T> subscriber,
  Query query,
  Iterable<? extends R> result,
  RecordMapper<? super R, ? extends T> recordMapper
) {
  this.subscriber = subscriber;
  this.query = query;
  this.result = result.iterator();
  this.recordMapper = recordMapper;
}
项目:gradle-jooq-plugin    文件:JooqTest.java   
@BeforeClass
public void beforeClass() {
  recordMapper = new RecordMapper<Record, User>() {
    @Override public User map(Record record) {
      return mapper.map(record, User.class);
    }
  };
}
项目:tiny-rxjava-jdbc    文件:Select.java   
public static <R extends Record, T> Select<R, T> using(Connection connection,
                                                       QueryBuilder<ResultQuery<? extends R>> queryBuilder,
                                                       RecordMapper<? super R, ? extends T> recordMapper) {
  return new Select<>(connection, queryBuilder, recordMapper);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JooqAutoConfigurationTests.java   
@Override
public <R extends Record, E> RecordMapper<R, E> provide(RecordType<R> recordType,
        Class<? extends E> aClass) {
    return null;
}
项目:spring-boot-concourse    文件:JooqAutoConfigurationTests.java   
@Override
public <R extends Record, E> RecordMapper<R, E> provide(RecordType<R> recordType,
        Class<? extends E> aClass) {
    return null;
}
项目:contestparser    文件:JooqAutoConfigurationTests.java   
@Override
public <R extends Record, E> RecordMapper<R, E> provide(RecordType<R> recordType,
        Class<? extends E> aClass) {
    return null;
}
项目:adjule    文件:JooqProblemDetailDao.java   
private RecordMapper<Record, ProblemDetailView> getProblemDetailMapper(final boolean extendInfo) {
    return record -> {
        ProblemDetailView p = new ProblemDetailView();
        p.setId(record.getValue(TASKS.TASK_ID));
        p.setCode(record.getValue(TASKS.CODE));
        p.setName(record.getValue(TASKS.NAME));
        Optional.ofNullable(record.getValue(TASKS.CONTENT)).ifPresent(p::setContent);
        if (!extendInfo && record.field(TRANSLATIONS.TRANSLATION) != null) {
            Optional.ofNullable(record.getValue(TRANSLATIONS.TRANSLATION)).ifPresent(p::setContent);
        }
        p.setHasAttachment(!StringUtils.isEmpty(record.getValue(TASKS.FILETYPE)));

        if (extendInfo) {
            p.setCheckerSource(record.getValue(TASKS.CHECKSRC));
            p.setDefaultTimeLimit(record.getValue(TASKS.DEFAULT_TIME_LIMIT));
            p.setDefaultMemoryLimit(record.getValue(TASKS.DEFAULT_MEMORY_LIMIT));
            p.setAuthor(record.getValue(TASKS.AUTHOR));
        }

        if (record.field(submissionsCountField) != null) {
            final Optional<Integer> totalCount =
                    Optional.ofNullable(record.getValue(submissionsCountField));

            totalCount.ifPresent(p::setSubmissionsCount);
        }

        if (record.field("acceptRatio") != null) {
            final Optional<Float> acceptRatio =
                    Optional.ofNullable(record.getValue("acceptRatio", Float.class));
            acceptRatio.ifPresent(p::setAcceptRatio);
        }

        if (record.field(submissionsCountLastWeekField) != null) {
            final Optional<Integer> totalLastWeekCount =
                    Optional.ofNullable(record.getValue(submissionsCountLastWeekField));
            totalLastWeekCount.ifPresent(p::setSubmissionsCount);
        }

        return p;
    };
}
项目:adjule    文件:JooqUsersDao.java   
private void getUserGroups(final UserDetailView userDetailView,
                           final String login) {

    UserGroupsView userGroupsView = new UserGroupsView();
    userDetailView.setGroups(userGroupsView);

    final List<UserGroupView> finalised = new LinkedList<>();
    final List<UserGroupView> current = new LinkedList<>();
    final List<UserGroupView> future = new LinkedList<>();

    userGroupsView.setFinalised(finalised);
    userGroupsView.setCurrent(current);
    userGroupsView.setFuture(future);

    final Field<Timestamp> currentTimestamp = DSL.currentTimestamp();

    jooq.select(TEAMS.CODE,
                TEAMS.NAME,
                TEAMS_CONTESTS.STATUS,
                CONTESTS.CODE,
                CONTESTS.NAME,
                CONTESTS.CONTEST_START,
                CONTESTS.CONTEST_END,
                currentTimestamp)
        .from(TEAMS, TEAMS_CONTESTS, CONTESTS)
        .where(TEAMS_CONTESTS.TEAM_ID.in(DSL.select(USERS.TEAM_ID)
                                            .from(USERS)
                                            .where(USERS.LOGIN
                                                           .eq(login))))
        .and(TEAMS_CONTESTS.CONTEST_ID.eq(CONTESTS.CONTEST_ID))
        .and(TEAMS_CONTESTS.TEAM_ID.eq(TEAMS.TEAM_ID))
        .orderBy(CONTESTS.NAME)
        .fetch()
        .map(new RecordMapper<Record, UserGroupView>() {
            @Override
            public UserGroupView map(final Record record) {
                UserGroupView userGroupView = new UserGroupView();
                userGroupView.setCode(record.getValue(CONTESTS.CODE));
                userGroupView.setName(record.getValue(CONTESTS.NAME));

                final Timestamp currentTime = record.getValue(currentTimestamp);
                final Timestamp contestStart = record.getValue(CONTESTS.CONTEST_START);
                final Timestamp contestEnd = record.getValue(CONTESTS.CONTEST_END);

                if (contestEnd == null || (contestEnd.after(currentTime) && contestStart != null && contestStart.before(currentTime))) {
                    current.add(userGroupView);
                } else if (contestEnd.before(currentTime)) {
                    finalised.add(userGroupView);
                } else {
                    future.add(userGroupView);
                }

                return userGroupView;
            }
        });
}
项目:daguerreo    文件:BasicJooqRepository.java   
/**
 * Returns the {@link RecordMapper}.
 * <p>
 * Subclasses may override this method to provide custom implementations.
 * </p>
 *
 * @return the record mapper
 */
protected RecordMapper<R, E> mapper() {
    return mapper;
}