org.jdbi.v3.core.statement.StatementContext Java Examples
The following examples show how to use
org.jdbi.v3.core.statement.StatementContext.
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: QueryPairMapper.java From presto with Apache License 2.0 | 6 votes |
@Override public QueryPair map(ResultSet resultSet, StatementContext context) throws SQLException { Map<String, String> sessionProperties = ImmutableMap.of(); String json = resultSet.getString("session_properties_json"); if (json != null) { sessionProperties = propertiesJsonCodec.fromJson(json); } return new QueryPair( resultSet.getString("suite"), resultSet.getString("name"), new Query(resultSet.getString("test_catalog"), resultSet.getString("test_schema"), fromJsonString(resultSet.getString("test_prequeries")), resultSet.getString("test_query"), fromJsonString(resultSet.getString("test_postqueries")), resultSet.getString("test_username"), resultSet.getString("test_password"), sessionProperties), new Query(resultSet.getString("control_catalog"), resultSet.getString("control_schema"), fromJsonString(resultSet.getString("control_prequeries")), resultSet.getString("control_query"), fromJsonString(resultSet.getString("control_postqueries")), resultSet.getString("control_username"), resultSet.getString("control_password"), sessionProperties)); }
Example #2
Source File: PropertyExtractorMapper.java From irontest with Apache License 2.0 | 6 votes |
public PropertyExtractor map(ResultSet rs, StatementContext ctx) throws SQLException { PropertyExtractor propertyExtractor; String type = rs.getString("type"); if (rs.getString("other_properties") != null) { String tempPropertyExtractorJSON = "{\"type\":\"" + type + "\",\"otherProperties\":" + rs.getString("other_properties") + "}"; try { propertyExtractor = new ObjectMapper().readValue(tempPropertyExtractorJSON, PropertyExtractor.class); } catch (IOException e) { throw new SQLException("Failed to deserialize other_properties JSON.", e); } } else { propertyExtractor = new PropertyExtractor(); } propertyExtractor.setId(rs.getLong("id")); propertyExtractor.setPropertyName(rs.getString("property_name")); propertyExtractor.setType(type); return propertyExtractor; }
Example #3
Source File: AssertionMapper.java From irontest with Apache License 2.0 | 6 votes |
public Assertion map(ResultSet rs, StatementContext ctx) throws SQLException { Assertion assertion; String type = rs.getString("type"); String tempAssertionJSON = "{\"type\":\"" + type + "\",\"otherProperties\":" + rs.getString("other_properties") + "}"; try { assertion = new ObjectMapper().readValue(tempAssertionJSON, Assertion.class); } catch (IOException e) { throw new SQLException("Failed to deserialize other_properties JSON.", e); } assertion.setId(rs.getLong("id")); assertion.setTeststepId(rs.getLong("teststep_id")); assertion.setName(rs.getString("name")); assertion.setType(type); return assertion; }
Example #4
Source File: UserMapper.java From irontest with Apache License 2.0 | 6 votes |
@Override public User map(ResultSet rs, StatementContext ctx) throws SQLException { List<String> fields = IronTestUtils.getFieldsPresentInResultSet(rs); User user = new User(); user.setId(rs.getLong("id")); user.setUsername(rs.getString("username")); user.setPassword(fields.contains("password") ? rs.getString("password") : null); user.setSalt(fields.contains("salt") ? rs.getString("salt") : null); if (fields.contains("roles") && rs.getString("roles") != null) { try { user.getRoles().addAll(new ObjectMapper().readValue(rs.getString("roles"), HashSet.class)); } catch (IOException e) { throw new SQLException("Failed to deserialize roles JSON.", e); } } return user; }
Example #5
Source File: CodegenProjectRowMapper.java From apicurio-studio with Apache License 2.0 | 6 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public CodegenProject map(ResultSet rs, StatementContext ctx) throws SQLException { try { CodegenProject project = new CodegenProject(); project.setId(String.valueOf(rs.getLong("id"))); project.setCreatedBy(rs.getString("created_by")); project.setCreatedOn(rs.getTimestamp("created_on")); project.setModifiedBy(rs.getString("modified_by")); project.setModifiedOn(rs.getTimestamp("modified_on")); project.setDesignId(String.valueOf(rs.getLong("design_id"))); project.setType(CodegenProjectType.valueOf(rs.getString("ptype"))); project.setAttributes(toMap(IOUtils.toString(rs.getCharacterStream("attributes")))); return project; } catch (IOException e) { throw new SQLException(e); } }
Example #6
Source File: ApiDesignChangeRowMapper.java From apicurio-studio with Apache License 2.0 | 6 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public ApiDesignChange map(ResultSet rs, StatementContext ctx) throws SQLException { try { ApiDesignChange change = new ApiDesignChange(); change.setApiId(rs.getString("design_id")); change.setApiName(rs.getString("name")); change.setBy(rs.getString("created_by")); change.setData(IOUtils.toString(rs.getCharacterStream("data"))); change.setOn(rs.getTimestamp("created_on")); change.setType(ApiContentType.fromId(rs.getInt("type"))); change.setVersion(rs.getLong("version")); return change; } catch (IOException e) { throw new SQLException(e); } }
Example #7
Source File: SingularityMappers.java From Singularity with Apache License 2.0 | 6 votes |
@Override public SingularityRequestHistory map(ResultSet r, StatementContext ctx) throws SQLException { try { SingularityRequest request; String json = r.getString("json"); if (json != null) { request = objectMapper.readValue(json, SingularityRequest.class); } else { request = objectMapper.readValue(r.getBytes("request"), SingularityRequest.class); } return new SingularityRequestHistory( r.getTimestamp("createdAt").getTime(), Optional.ofNullable(r.getString(userColumn)), RequestHistoryType.valueOf(r.getString("requestState")), request, Optional.ofNullable(r.getString("message")) ); } catch (IOException e) { throw new ResultSetException("Could not deserialize database result", e, ctx); } }
Example #8
Source File: SingularityMappers.java From Singularity with Apache License 2.0 | 6 votes |
@Override public SingularityDeployHistory map(ResultSet r, StatementContext ctx) throws SQLException { SingularityDeployMarker marker = new SingularityDeployMarker( r.getString("requestId"), r.getString("deployId"), r.getTimestamp("createdAt").getTime(), Optional.ofNullable(r.getString(userColumn)), Optional.ofNullable(r.getString("message")) ); SingularityDeployResult deployState = new SingularityDeployResult( DeployState.valueOf(r.getString("deployState")), Optional.<String>empty(), Optional.<SingularityLoadBalancerUpdate>empty(), Collections.<SingularityDeployFailure>emptyList(), r.getTimestamp("deployStateAt").getTime() ); return new SingularityDeployHistory( Optional.of(deployState), marker, Optional.<SingularityDeploy>empty(), Optional.<SingularityDeployStatistics>empty() ); }
Example #9
Source File: SessionMatchSpec.java From presto with Apache License 2.0 | 6 votes |
@Override public SessionMatchSpec map(ResultSet resultSet, StatementContext context) throws SQLException { Map<String, String> sessionProperties = getProperties( Optional.ofNullable(resultSet.getString("session_property_names")), Optional.ofNullable(resultSet.getString("session_property_values"))); return new SessionMatchSpec( Optional.ofNullable(resultSet.getString("user_regex")).map(Pattern::compile), Optional.ofNullable(resultSet.getString("source_regex")).map(Pattern::compile), Optional.ofNullable(resultSet.getString("client_tags")).map(tag -> Splitter.on(",").splitToList(tag)), Optional.ofNullable(resultSet.getString("query_type")), Optional.ofNullable(resultSet.getString("group_regex")).map(Pattern::compile), sessionProperties); }
Example #10
Source File: JdbcStorage.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see io.apicurio.hub.core.storage.IStorage#lookupEditingSessionUuid(java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ @Override public long lookupEditingSessionUuid(String uuid, String designId, String userId, String hash) throws StorageException { logger.debug("Looking up an editing session UUID: {}", uuid); long now = System.currentTimeMillis(); try { return this.jdbi.withHandle( handle -> { String statement = sqlStatements.selectEditingSessionUuid(); Long contentVersion = handle.createQuery(statement) .bind(0, uuid) .bind(1, Long.valueOf(designId)) .bind(2, hash) .bind(3, now) .map(new RowMapper<Long>() { @Override public Long map(ResultSet rs, StatementContext ctx) throws SQLException { return rs.getLong("version"); } }) .one(); return contentVersion; }); } catch (Exception e) { throw new StorageException("Error getting Editing Session UUID.", e); } }
Example #11
Source File: ValidationProfileRowMapper.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public ValidationProfile map(ResultSet rs, StatementContext ctx) throws SQLException { try { ValidationProfile profile = new ValidationProfile(); profile.setId(rs.getLong("id")); profile.setName(rs.getString("name")); profile.setDescription(rs.getString("description")); profile.setSeverities(ValidationProfileRowMapper.toSeverities(IOUtils.toString(rs.getCharacterStream("severities")))); return profile; } catch (IOException e) { throw new SQLException(e); } }
Example #12
Source File: ApiMockRowMapper.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public ApiMock map(ResultSet rs, StatementContext ctx) throws SQLException { try { ApiMock publication = new ApiMock(); publication.setBy(rs.getString("created_by")); publication.setInfo(IOUtils.toString(rs.getCharacterStream("data"))); publication.setOn(rs.getTimestamp("created_on")); return publication; } catch (IOException e) { throw new SQLException(e); } }
Example #13
Source File: DataTableColumnMapper.java From irontest with Apache License 2.0 | 5 votes |
public DataTableColumn map(ResultSet rs, StatementContext ctx) throws SQLException { DataTableColumn result = new DataTableColumn(); result.setId(rs.getLong("id")); result.setName(rs.getString("name")); result.setType(DataTableColumnType.getByText(rs.getString("type"))); result.setSequence(rs.getShort("sequence")); return result; }
Example #14
Source File: ApiDesignCollaboratorRowMapper.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public ApiDesignCollaborator map(ResultSet rs, StatementContext ctx) throws SQLException { ApiDesignCollaborator collaborator = new ApiDesignCollaborator(); collaborator.setUserName(rs.getString("user_id")); collaborator.setUserId(rs.getString("user_id")); collaborator.setRole(rs.getString("role")); return collaborator; }
Example #15
Source File: SelectorRecord.java From presto with Apache License 2.0 | 5 votes |
@Override public SelectorRecord map(ResultSet resultSet, StatementContext context) throws SQLException { return new SelectorRecord( resultSet.getLong("resource_group_id"), resultSet.getLong("priority"), Optional.ofNullable(resultSet.getString("user_regex")).map(Pattern::compile), Optional.ofNullable(resultSet.getString("source_regex")).map(Pattern::compile), Optional.ofNullable(resultSet.getString("query_type")), Optional.ofNullable(resultSet.getString("client_tags")).map(LIST_STRING_CODEC::fromJson), Optional.ofNullable(resultSet.getString("selector_resource_estimate")).map(SELECTOR_RESOURCE_ESTIMATE_JSON_CODEC::fromJson)); }
Example #16
Source File: SharingConfigurationRowMapper.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public SharingConfiguration map(ResultSet rs, StatementContext ctx) throws SQLException { SharingConfiguration design = new SharingConfiguration(); design.setUuid(rs.getString("uuid")); design.setLevel(SharingLevel.valueOf(rs.getString("level"))); return design; }
Example #17
Source File: TestcaseRunMapper.java From irontest with Apache License 2.0 | 5 votes |
public TestcaseRun map(ResultSet rs, StatementContext ctx) throws SQLException { TestcaseRun testcaseRun = new TestcaseRun(); testcaseRun.setId(rs.getLong("id")); testcaseRun.setTestcaseId(rs.getLong("testcase_id")); testcaseRun.setTestcaseName(rs.getString("testcase_name")); testcaseRun.setTestcaseFolderPath(rs.getString("testcase_folderpath")); testcaseRun.setStartTime(rs.getTimestamp("starttime")); testcaseRun.setDuration(rs.getLong("duration")); testcaseRun.setResult(TestResult.getByText(rs.getString("result"))); return testcaseRun; }
Example #18
Source File: InvitationRowMapper.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public Invitation map(ResultSet rs, StatementContext ctx) throws SQLException { Invitation invite = new Invitation(); invite.setCreatedBy(rs.getString("created_by")); invite.setCreatedOn(rs.getTimestamp("created_on")); invite.setDesignId(rs.getString("design_id")); invite.setInviteId(rs.getString("invite_id")); invite.setModifiedBy(rs.getString("modified_by")); invite.setModifiedOn(rs.getTimestamp("modified_on")); invite.setStatus(rs.getString("status")); invite.setRole(rs.getString("role")); invite.setSubject(rs.getString("subject")); return invite; }
Example #19
Source File: ApiPublicationRowMapper.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public ApiPublication map(ResultSet rs, StatementContext ctx) throws SQLException { try { ApiPublication publication = new ApiPublication(); publication.setBy(rs.getString("created_by")); publication.setInfo(IOUtils.toString(rs.getCharacterStream("data"))); publication.setOn(rs.getTimestamp("created_on")); return publication; } catch (IOException e) { throw new SQLException(e); } }
Example #20
Source File: ApiDesignCommandRowMapper.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public ApiDesignCommand map(ResultSet rs, StatementContext ctx) throws SQLException { try { ApiDesignCommand cmd = new ApiDesignCommand(); cmd.setContentVersion(rs.getLong("version")); cmd.setCommand(IOUtils.toString(rs.getCharacterStream("data"))); cmd.setAuthor(rs.getString("created_by")); cmd.setReverted(rs.getInt("reverted") > 0); return cmd; } catch (IOException e) { throw new SQLException(e); } }
Example #21
Source File: ApiDesignRowMapper.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public ApiDesign map(ResultSet rs, StatementContext ctx) throws SQLException { ApiDesign design = new ApiDesign(); design.setId(rs.getString("id")); design.setName(rs.getString("name")); design.setDescription(rs.getString("description")); design.setCreatedBy(rs.getString("created_by")); design.setCreatedOn(rs.getTimestamp("created_on")); String tags = rs.getString("tags"); design.getTags().addAll(toSet(tags)); design.setType(ApiDesignType.valueOf(rs.getString("api_type"))); return design; }
Example #22
Source File: ContributorRowMapper.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public Contributor map(ResultSet rs, StatementContext ctx) throws SQLException { Contributor contributor = new Contributor(); contributor.setName(rs.getString("created_by")); contributor.setEdits(rs.getInt("edits")); return contributor; }
Example #23
Source File: SharingInfoRowMapper.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public SharingInfo map(ResultSet rs, StatementContext ctx) throws SQLException { SharingInfo design = new SharingInfo(); design.setDesignId(rs.getString("design_id")); design.setShareUuid(rs.getString("uuid")); design.setLevel(SharingLevel.valueOf(rs.getString("level"))); return design; }
Example #24
Source File: ApiDesignContentRowMapper.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @see org.jdbi.v3.core.mapper.RowMapper#map(java.sql.ResultSet, org.jdbi.v3.core.statement.StatementContext) */ @Override public ApiDesignContent map(ResultSet rs, StatementContext ctx) throws SQLException { try { ApiDesignContent content = new ApiDesignContent(); content.setContentVersion(rs.getLong("version")); content.setDocument(IOUtils.toString(rs.getCharacterStream("data"))); return content; } catch (IOException e) { throw new SQLException(e); } }
Example #25
Source File: AdvancedPlayerSqlObject.java From jdit with MIT License | 5 votes |
@Override public Player map(ResultSet r, StatementContext ctx) throws SQLException { int height = r.getInt("height"); int weight = r.getInt("weight"); return new Player(Optional.of(r.getLong("id")), r.getString("first_name"), r.getString("last_name"), r.getTimestamp("birth_date"), height != 0 ? Optional.of(height) : Optional.empty(), weight != 0 ? Optional.of(weight) : Optional.empty()); }
Example #26
Source File: PlayerSqlObject.java From jdit with MIT License | 5 votes |
@Override public Player map(ResultSet r, StatementContext ctx) throws SQLException { int height = r.getInt("height"); int weight = r.getInt("weight"); return new Player(Optional.of(r.getLong("id")), r.getString("first_name"), r.getString("last_name"), r.getTimestamp("birth_date"), height != 0 ? Optional.of(height) : Optional.empty(), weight != 0 ? Optional.of(weight) : Optional.empty()); }
Example #27
Source File: SingularityMappers.java From Singularity with Apache License 2.0 | 5 votes |
@Override public SingularityRequestAndTime map(ResultSet r, StatementContext ctx) throws SQLException { try { return new SingularityRequestAndTime( objectMapper.readValue(r.getBytes("request"), SingularityRequest.class), r.getTimestamp("createdAt").getTime() ); } catch (IOException e) { throw new ResultSetException("Could not deserialize database result", e, ctx); } }
Example #28
Source File: SingularityMappers.java From Singularity with Apache License 2.0 | 5 votes |
@Override public SingularityTaskUsage map(ResultSet r, StatementContext ctx) throws SQLException { return new SingularityTaskUsage( r.getLong("memoryTotalBytes"), r.getLong("timestamp"), r.getDouble("cpuSeconds"), r.getLong("diskTotalBytes"), r.getLong("cpusNrPeriods"), r.getLong("cpusNrThrottled"), r.getDouble("cpusThrottledTimeSecs") ); }
Example #29
Source File: CarModelMapper.java From tutorials with MIT License | 5 votes |
@Override public CarModel map(ResultSet rs, StatementContext ctx) throws SQLException { return CarModel.builder() .id(rs.getLong("id")) .name(rs.getString("name")) .sku(rs.getString("sku")) .year(rs.getInt("year")) .build(); }
Example #30
Source File: CarMakerMapper.java From tutorials with MIT License | 5 votes |
@Override public CarMaker map(ResultSet rs, StatementContext ctx) throws SQLException { CarMaker maker = CarMaker.builder() .id(rs.getLong("id")) .name(rs.getString("name")) .models(new ArrayList<CarModel>()) .build(); return maker; }