@Override public SelectSelectStep<Record1<Integer>> selectOne() { SelectSelectStep<Record1<Integer>> result = DSL.selectOne(); result.attach(configuration); return result; }
select(aliasedFields(map.values().toArray(EMPTY_FIELD), aliases)) .whereNotExists( selectOne() .from(table) .where(matchByConflictingKeys(configuration, map))
private Condition noSuccessfulHandlers(Field<UUID> parentInstanceId, ProcessKind kind) { return notExists(selectOne().from(PROCESS_QUEUE) .where(PROCESS_QUEUE.PARENT_INSTANCE_ID.eq(parentInstanceId) .and(PROCESS_QUEUE.PROCESS_KIND.eq(kind.toString())) .and(PROCESS_QUEUE.CURRENT_STATUS.eq(ProcessStatus.FINISHED.toString())))); }
private Condition noRunningHandlers(Field<UUID> parentInstanceId) { return notExists(selectOne().from(PROCESS_QUEUE) .where(PROCESS_QUEUE.PARENT_INSTANCE_ID.eq(parentInstanceId) .and(PROCESS_QUEUE.CURRENT_STATUS.in(Utils.toString(ACTIVE_PROCESS_STATUSES))) .and(PROCESS_QUEUE.PROCESS_KIND.in(Utils.toString(SPECIAL_HANDLERS))))); }
.get(0, Boolean.class); if (!identity && !create().fetchExists(selectOne().from("{0}", DSL.name(getName())))) identity = create() .select(SQLiteMaster.SQL)
public List<SecretEntry> list(UUID orgId, UUID currentUserId, Field<?> sortField, boolean asc) { SelectConditionStep<Record1<UUID>> teamIds = select(TEAMS.TEAM_ID) .from(TEAMS) .where(TEAMS.ORG_ID.eq(orgId)); Condition filterByTeamMember = exists(selectOne().from(USER_TEAMS) .where(USER_TEAMS.USER_ID.eq(currentUserId) .and(USER_TEAMS.TEAM_ID.in(teamIds)))); try (DSLContext tx = DSL.using(cfg)) { SelectJoinStep<Record12<UUID, String, UUID, String, UUID, String, UUID, String, String, String, String, String>> query = selectEntry(tx); if (currentUserId != null) { query.where(or(SECRETS.VISIBILITY.eq(SecretVisibility.PUBLIC.toString()), filterByTeamMember)); } if (orgId != null) { query.where(SECRETS.ORG_ID.eq(orgId)); } if (sortField != null) { query.orderBy(asc ? sortField.asc() : sortField.desc()); } return query.fetch(SecretDao::toEntry); } }
private List<LandingEntry> list(DSLContext tx, UUID orgId, UUID currentUserId) { LandingPage lp = LANDING_PAGE.as("lp"); Projects p = PROJECTS.as("p"); Repositories r = REPOSITORIES.as("r"); Field<String> orgNameField = select(ORGANIZATIONS.ORG_NAME).from(ORGANIZATIONS).where(ORGANIZATIONS.ORG_ID.eq(p.ORG_ID)).asField(); SelectConditionStep<Record1<UUID>> teamIds = select(TEAMS.TEAM_ID) .from(TEAMS) .where(TEAMS.ORG_ID.eq(orgId)); Condition filterByTeamMember = exists(selectOne().from(USER_TEAMS) .where(USER_TEAMS.USER_ID.eq(currentUserId) .and(USER_TEAMS.TEAM_ID.in(teamIds)))); SelectJoinStep<Record9<UUID, UUID, String, UUID, String, String, String, String, byte[]>> q = tx.select(lp.LANDING_PAGE_ID, p.ORG_ID, orgNameField, lp.PROJECT_ID, p.PROJECT_NAME, r.REPO_NAME, lp.NAME, lp.DESCRIPTION, lp.ICON) .from(lp) .innerJoin(p).on(p.PROJECT_ID.eq(lp.PROJECT_ID)) .innerJoin(r).on(r.REPO_ID.eq(lp.REPO_ID)); if (currentUserId != null) { q.where(or(p.VISIBILITY.eq(ProjectVisibility.PUBLIC.toString()), filterByTeamMember)); } return q.orderBy(lp.NAME) .fetch(LandingDao::toEntity); }
.where(TEAMS.ORG_ID.eq(orgId)); Condition filterByTeamMember = exists(selectOne().from(USER_TEAMS) .where(USER_TEAMS.USER_ID.eq(currentUserId) .and(USER_TEAMS.TEAM_ID.in(teamIds))));