Java Code Examples for org.jooq.Result#isEmpty()
The following examples show how to use
org.jooq.Result#isEmpty() .
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: ResultBuilder.java From FROST-Server with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void visit(PathElementEntity element) { Result<Record> 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; } EntityFactory factory; factory = pm.getEntityFactories().getFactoryFor(element.getEntityType()); Entity entity = factory.create(results.get(0), staQuery, new DataSize()); if (entity == null) { throw new IllegalStateException("Failed to create an entity from result set."); } expandEntity(entity, staQuery); resultObject = entity; }
Example 2
Source File: DBRequestRuleStore.java From LoboBrowser with MIT License | 6 votes |
public void storePermissions(final String frameHost, final String requestHost, final Optional<RequestKind> kindOpt, final PermissionSystem.Permission permission) { final Result<PermissionsRecord> permissionRecords = AccessController.doPrivileged((PrivilegedAction<Result<PermissionsRecord>>) () -> { return userDB.fetch(Permissions.PERMISSIONS, matchHostsCondition(frameHost, requestHost)); }); final Integer permissionMask = makeBitSetMask(kindOpt, permission); if (permissionRecords.isEmpty()) { final PermissionsRecord newPermissionRecord = new PermissionsRecord(frameHost, requestHost, permissionMask); newPermissionRecord.attach(userDB.configuration()); newPermissionRecord.store(); } else { final PermissionsRecord existingRecord = permissionRecords.get(0); final Integer existingPermissions = existingRecord.getPermissions(); final int newPermissions = (existingPermissions & makeBitBlockMask(kindOpt)) | permissionMask; existingRecord.setPermissions(newPermissions); existingRecord.store(); } }
Example 3
Source File: DBRequestRuleStore.java From LoboBrowser with MIT License | 5 votes |
public Pair<PermissionSystem.Permission, PermissionSystem.Permission[]> getPermissions(final String frameHostPattern, final String requestHost) { final Result<PermissionsRecord> permissionRecords = AccessController.doPrivileged((PrivilegedAction<Result<PermissionsRecord>>) () -> { return userDB.fetch(Permissions.PERMISSIONS, matchHostsCondition(frameHostPattern, requestHost)); }); if (permissionRecords.isEmpty()) { return defaultPermissionPair; } else { final PermissionsRecord existingRecord = permissionRecords.get(0); final Integer existingPermissions = existingRecord.getPermissions(); final Pair<PermissionSystem.Permission, PermissionSystem.Permission[]> permissions = decodeBitMask(existingPermissions); return permissions; } }
Example 4
Source File: BackfillRowHmacResource.java From keywhiz with Apache License 2.0 | 4 votes |
/** * Backfill row_hmac for this secret. */ @Timed @ExceptionMetered @Path("backfill-secrets/{cursor_start}/{max_rows}") @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) public void backfillSecretsRowHmac(@PathParam("cursor_start") Long cursorStart, @PathParam("max_rows") Long maxRows) { logger.info("backfill-secrets: processing secrets"); long cursor; if (cursorStart != 0) { cursor = cursorStart; } else { cursor = jooq.select(min(SECRETS.ID)) .from(SECRETS) .fetch().get(0).value1() - 1; } long processedRows = 0; while (processedRows < maxRows) { Result<SecretsRecord> rows = jooq.selectFrom(SECRETS) .where(SECRETS.ID.greaterThan(cursor)) .orderBy(SECRETS.ID) .limit(1000) .fetchInto(SECRETS); if (rows.isEmpty()) { break; } for (var row : rows) { cursor = row.getId(); if (!row.getRowHmac().isEmpty()) { continue; } String rowHmac = rowHmacGenerator.computeRowHmac(SECRETS.getName(), List.of(row.getName(), row.getId())); jooq.update(SECRETS) .set(SECRETS.ROW_HMAC, rowHmac) .where(SECRETS.ID.eq(row.getId())) .execute(); processedRows += 1; } logger.info("backfill-secrets: updating from {} with {} rows processed", cursor, processedRows); } }
Example 5
Source File: BackfillRowHmacResource.java From keywhiz with Apache License 2.0 | 4 votes |
/** * Backfill row_hmac for this secrets content. */ @Timed @ExceptionMetered @Path("backfill-secrets-content/{cursor_start}/{max_rows}") @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) public void backfillSecretsContentRowHmac(@PathParam("cursor_start") Long cursorStart, @PathParam("max_rows") Long maxRows) { logger.info("backfill-secrets-content: processing secrets content"); long cursor; if (cursorStart != 0) { cursor = cursorStart; } else { cursor = jooq.select(min(SECRETS_CONTENT.ID)) .from(SECRETS_CONTENT) .fetch().get(0).value1() - 1; } long processedRows = 0; while (processedRows < maxRows) { Result<SecretsContentRecord> rows = jooq.selectFrom(SECRETS_CONTENT) .where(SECRETS_CONTENT.ID.greaterThan(cursor)) .orderBy(SECRETS_CONTENT.ID) .limit(1000) .fetchInto(SECRETS_CONTENT); if (rows.isEmpty()) { break; } for (var row : rows) { cursor = row.getId(); String rowHmac = rowHmacGenerator.computeRowHmac(SECRETS_CONTENT.getName(), List.of(row.getEncryptedContent(), row.getMetadata(), row.getId())); jooq.update(SECRETS_CONTENT) .set(SECRETS_CONTENT.ROW_HMAC, rowHmac) .where(SECRETS_CONTENT.ID.eq(row.getId())) .execute(); processedRows += 1; } logger.info("backfill-secrets-content: updating from {} with {} rows processed", cursor, processedRows); } }
Example 6
Source File: BackfillRowHmacResource.java From keywhiz with Apache License 2.0 | 4 votes |
/** * Backfill row_hmac for this client. */ @Timed @ExceptionMetered @Path("backfill-clients/{cursor_start}/{max_rows}") @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) public void backfillClientsRowHmac(@PathParam("cursor_start") Long cursorStart, @PathParam("max_rows") Long maxRows) { logger.info("backfill-clients: processing clients"); long cursor; if (cursorStart != 0) { cursor = cursorStart; } else { cursor = jooq.select(min(CLIENTS.ID)) .from(CLIENTS) .fetch().get(0).value1() - 1; } long processedRows = 0; while (processedRows < maxRows) { Result<ClientsRecord> rows = jooq.selectFrom(CLIENTS) .where(CLIENTS.ID.greaterThan(cursor)) .orderBy(CLIENTS.ID) .limit(1000) .fetchInto(CLIENTS); if (rows.isEmpty()) { break; } for (var row : rows) { cursor = row.getId(); String rowHmac = rowHmacGenerator.computeRowHmac(CLIENTS.getName(), List.of(row.getName(), row.getId())); jooq.update(CLIENTS) .set(CLIENTS.ROW_HMAC, rowHmac) .where(CLIENTS.ID.eq(row.getId())) .execute(); processedRows += 1; } logger.info("backfill-clients: updating from {} with {} rows processed", cursor, processedRows); } }
Example 7
Source File: BackfillRowHmacResource.java From keywhiz with Apache License 2.0 | 4 votes |
/** * Backfill row_hmac for this membership id. */ @Timed @ExceptionMetered @Path("backfill-memberships/{cursor_start}/{max_rows}") @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) public void backfillMembershipsRowHmac(@PathParam("cursor_start") Long cursorStart, @PathParam("max_rows") Long maxRows) { logger.info("backfill-memberships: processing memberships"); long cursor; if (cursorStart != 0) { cursor = cursorStart; } else { cursor = jooq.select(min(MEMBERSHIPS.ID)) .from(MEMBERSHIPS) .fetch().get(0).value1() - 1; } long processedRows = 0; while (processedRows < maxRows) { Result<MembershipsRecord> rows = jooq.selectFrom(MEMBERSHIPS) .where(MEMBERSHIPS.ID.greaterThan(cursor)) .orderBy(MEMBERSHIPS.ID) .limit(1000) .fetchInto(MEMBERSHIPS); if (rows.isEmpty()) { break; } for (var row : rows) { cursor = row.getId(); String rowHmac = rowHmacGenerator.computeRowHmac(MEMBERSHIPS.getName(), List.of(row.getClientid(), row.getGroupid())); jooq.update(MEMBERSHIPS) .set(MEMBERSHIPS.ROW_HMAC, rowHmac) .where(MEMBERSHIPS.ID.eq(row.getId())) .execute(); processedRows += 1; } logger.info("backfill-memberships: updating from {} with {} rows processed", cursor, processedRows); } }
Example 8
Source File: BackfillRowHmacResource.java From keywhiz with Apache License 2.0 | 4 votes |
/** * Backfill accessgrants for this membership id. */ @Timed @ExceptionMetered @Path("backfill-accessgrants/{cursor_start}/{max_rows}") @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) public void backfillAccessgrantsRowHmac(@PathParam("cursor_start") Long cursorStart, @PathParam("max_rows") Long maxRows) { logger.info("backfill-accessgrants: processing accessgrants"); long cursor; if (cursorStart != 0) { cursor = cursorStart; } else { cursor = jooq.select(min(ACCESSGRANTS.ID)) .from(ACCESSGRANTS) .fetch().get(0).value1() - 1; } long processedRows = 0; while (processedRows < maxRows) { Result<AccessgrantsRecord> rows = jooq.selectFrom(ACCESSGRANTS) .where(ACCESSGRANTS.ID.greaterThan(cursor)) .orderBy(ACCESSGRANTS.ID) .limit(1000) .fetchInto(ACCESSGRANTS); if (rows.isEmpty()) { break; } for (var row : rows) { cursor = row.getId(); String rowHmac = rowHmacGenerator.computeRowHmac(ACCESSGRANTS.getName(), List.of(row.getGroupid(), row.getSecretid())); jooq.update(ACCESSGRANTS) .set(ACCESSGRANTS.ROW_HMAC, rowHmac) .where(ACCESSGRANTS.ID.eq(row.getId())) .execute(); processedRows += 1; } logger.info("backfill-accessgrants: updating from {} with {} rows processed", cursor, processedRows); } }