• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StringMapper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.skife.jdbi.v2.util.StringMapper的典型用法代码示例。如果您正苦于以下问题:Java StringMapper类的具体用法?Java StringMapper怎么用?Java StringMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StringMapper类属于org.skife.jdbi.v2.util包,在下文中一共展示了StringMapper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: loadAllKeys

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@Override
public Set<UUID> loadAllKeys() {
	// TODO define how many keys will be pre-loaded
	log.debug("loading all keys from table {}", tableName);
	Set<UUID> result = dbi.withHandle(new HandleCallback<Set<UUID>>() {
		@Override
		public Set<UUID> withHandle(Handle h) throws Exception {
			List<String> strResult = h.createQuery(String.format("select id from %s", tableName))
									  .map(new StringMapper()).list();
			Set<UUID> uResult = new HashSet<>();
			for (String uuid : strResult){
				uResult.add(UUID.fromString(uuid));
			}
			return uResult;
		}
	});
	log.debug("{} keys within table {} were loaded", result.size(), tableName);
	return result;	
}
 
开发者ID:rodolfodpk,项目名称:myeslib,代码行数:20,代码来源:HzStringMapStore.java


示例2: updateUserPassword

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
public void updateUserPassword(int id, String oldPassword, String newPassword) {
    final String scrypt = SCryptUtil.scrypt(newPassword, 2 << 14, 8, 1);

    if (!PASSWORD_PATTERN.matcher(newPassword).matches()) {
        throw new RakamException("Password is not valid. Your password must contain at least one lowercase character, uppercase character and digit and be at least 8 characters. ", BAD_REQUEST);
    }

    if (config.getHashPassword()) {
        oldPassword = CryptUtil.encryptWithHMacSHA1(oldPassword, encryptionConfig.getSecretKey());
    }

    try (Handle handle = dbi.open()) {
        String hashedPass = handle.createQuery("SELECT password FROM web_user WHERE id = :id")
                .bind("id", id).map(StringMapper.FIRST).first();
        if (hashedPass == null) {
            throw new RakamException("User does not exist", BAD_REQUEST);
        }
        if (!SCryptUtil.check(oldPassword, hashedPass)) {
            throw new RakamException("Password is wrong", BAD_REQUEST);
        }
        handle.createStatement("UPDATE web_user SET password = :password WHERE id = :id")
                .bind("id", id)
                .bind("password", scrypt).execute();
    }
}
 
开发者ID:rakam-io,项目名称:rakam,代码行数:26,代码来源:WebUserService.java


示例3: shouldCreate

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
public void shouldCreate() {
  Map<String, AlarmSubExpression> subExpressions =
      ImmutableMap
          .<String, AlarmSubExpression>builder()
          .put(
              "4433",
              AlarmSubExpression
                  .of("avg(hpcs.compute{flavor_id=777, image_id=888, metric_name=cpu}) > 10"))
          .build();

  AlarmDefinition alarmA =
      repo.create("555", "2345", "90% CPU", null, "LOW",
          "avg(hpcs.compute{flavor_id=777, image_id=888, metric_name=cpu}) > 10", subExpressions,
          Arrays.asList("flavor_id", "image_id"), alarmActions, null, null);
  AlarmDefinition alarmB = repo.findById("555", alarmA.getId());

  assertEquals(alarmA, alarmB);

  // Assert that sub-alarm and sub-alarm-dimensions made it to the db
  assertEquals(
      handle.createQuery("select count(*) from sub_alarm_definition where id = 4433")
          .map(StringMapper.FIRST).first(), "1");
  assertEquals(
      handle.createQuery("select count(*) from sub_alarm_definition_dimension where sub_alarm_definition_id = 4433")
          .map(StringMapper.FIRST).first(), "3");
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:27,代码来源:AlarmDefinitionMySqlRepositoryImplTest.java


示例4: testFixturesArePresent

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@Test
public void testFixturesArePresent() throws Exception
{
    DataSource ds = mysql.getDataSource();
    List<String> rs = new DBI(ds).withHandle(new HandleCallback<List<String>>()
    {
        @Override
        public List<String> withHandle(final Handle handle) throws Exception
        {
            return handle.createQuery("select name from something order by id")
                         .map(StringMapper.FIRST)
                         .list();
        }
    });

    assertThat(rs).containsExactly("Gene", "Brian");
}
 
开发者ID:groupon,项目名称:mysql-junit4,代码行数:18,代码来源:MySQLRuleExample.java


示例5: testFixturesEstablished

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@Test
public void testFixturesEstablished() throws Exception
{
    DataSource ds = mysql.getDataSource();
    List<String> rs = new DBI(ds).withHandle(new HandleCallback<List<String>>()
    {
        @Override
        public List<String> withHandle(final Handle handle) throws Exception
        {
            return handle.createQuery("select name from something order by id")
                         .map(StringMapper.FIRST)
                         .list();
        }
    });

    assertThat(rs).containsExactly("Gene", "Brian");
}
 
开发者ID:groupon,项目名称:mysql-junit4,代码行数:18,代码来源:FlywayFixtureExample.java


示例6: getAllChildCopyRoles

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
public List<CopyRole> getAllChildCopyRoles(Long workId) {
    List<String> copyRoleCodes = new ArrayList<>();
    try (Handle h = graph.dbi().open()) {
        copyRoleCodes = h.createQuery(
                "SELECT DISTINCT p2.copyRole " +
                "FROM node v, flatedge e, flatedge e2, work p, work p2 " +
                "WHERE e.v_in = :workId " +
                " AND e.v_out = v.id " +
                " AND e.label = 'isPartOf' " +
                " AND p.id = v.id " +
                " AND p.type IN ('Work', 'Page', 'EADWork')" +
                " AND e2.v_in = p.id " +
                " AND e2.v_out = p2.id " +
                " AND e2.label = 'isCopyOf' ")
                .bind("workId", workId)
                .map(StringMapper.FIRST).list();
    }

    List<CopyRole> copyRoles = new ArrayList<CopyRole>();
    for (String code : copyRoleCodes) {
        copyRoles.add(CopyRole.fromString(code));
    }
    return copyRoles;
}
 
开发者ID:nla,项目名称:amberdb,代码行数:25,代码来源:WorkChildrenQuery.java


示例7: getAllCopyRoles

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
public List<CopyRole> getAllCopyRoles(List<Long> workIds){
    List<CopyRole> copyRoles = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(workIds)){
        List<String> copyRoleCodes;
        try (Handle h = graph.dbi().open()) {
            copyRoleCodes = h.createQuery(
                    "select distinct copyRole " +
                            "from work p, flatedge e, node v " +
                            "where p.id = e.v_out and v.id = p.id " +
                            "and e.label = 'isCopyOf' and e.v_in in (" + Joiner.on(",").join(workIds) + ")")
                    .map(StringMapper.FIRST).list();
        }
        for (String code : copyRoleCodes) {
            CopyRole copyRole = CopyRole.fromString(code);
            if (copyRole != null){
                copyRoles.add(copyRole);
            }
        }
    }
    return copyRoles;
}
 
开发者ID:nla,项目名称:amberdb,代码行数:22,代码来源:WorkChildrenQuery.java


示例8: get

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
public String get() {
    String name;
    Handle handle = dbi.open();
    try {
        name = handle.createQuery("select description from my_test")
                .map(StringMapper.FIRST)
                .first();
    } finally {
        handle.close();
    }
    return name;
}
 
开发者ID:dhagge,项目名称:spring-boot-jdbi-seed,代码行数:14,代码来源:TestResource.java


示例9: revokeSingleToken

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
public Optional<String> revokeSingleToken(String accountId, String tokenLink) {
    return Optional.ofNullable(jdbi.withHandle(handle ->
            handle.createQuery("UPDATE tokens SET revoked=(now() at time zone 'utc') WHERE account_id=:accountId AND token_link=:tokenLink AND revoked IS NULL RETURNING to_char(revoked,'DD Mon YYYY')")
                    .bind("accountId", accountId)
                    .bind("tokenLink", tokenLink)
                    .map(StringMapper.FIRST)
                    .first()));
}
 
开发者ID:alphagov,项目名称:pay-publicauth,代码行数:9,代码来源:AuthTokenDao.java


示例10: lookupColumnForTokenTable

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
public java.util.Optional<String> lookupColumnForTokenTable(String column, String idKey, String idValue) {
    return java.util.Optional.ofNullable(jdbi.withHandle(handle ->
            handle.createQuery("SELECT " + column + " FROM tokens WHERE " + idKey + "=:placeholder")
                    .bind("placeholder", idValue)
                    .map(StringMapper.FIRST)
                    .first()));

}
 
开发者ID:alphagov,项目名称:pay-publicauth,代码行数:9,代码来源:DatabaseTestHelper.java


示例11: keySet

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@Override
public Set<String> keySet() {
    final Handle handle = dbi.open();
    final Query<String> query = handle
            .createQuery(String.format("select %s from %s order by %s", keyColumnName, tableName, keyColumnName))
            .map(StringMapper.FIRST);

    return new IteratingSet<String>() {
        @Override
        public Iterator<String> createIterator() {
            return new QueryResultIterator<>(query, handle);
        }
    };
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:15,代码来源:SqlMap.java


示例12: putStoresExtraColumns

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@Test
public void putStoresExtraColumns() {
    ExtraColumnsJdbcMap extraMap = new ExtraColumnsJdbcMap("map", "key", "value", serializer);
    SerializableThing thing = new SerializableThing(42);
    extraMap.put("thing", thing);
    int num = handle.createQuery("select num from map where key = ?")
            .bind(0, "thing")
            .map(IntegerMapper.FIRST).first();
    assertThat(num, equalTo(42));
    String str = handle.createQuery("select str from map where key = ?")
            .bind(0, "thing")
            .map(StringMapper.FIRST).first();
    assertThat(str, equalTo("value42"));
    assertThat(extraMap.get("thing"), equalTo(thing));
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:16,代码来源:SqlMapTest.java


示例13: getRacesWithFrequencies

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@Override
public Set<DetailRace> getRacesWithFrequencies() {
    try (Handle handle = dbi.open()) {
        return handle.createQuery("select distinct detail_race from race_freq")
            .map(StringMapper.FIRST)
            .list()
            .stream()
            .map(r -> DetailRace.valueOf(r))
            .collect(Collectors.toSet());
    }
}
 
开发者ID:nmdp-bioinformatics,项目名称:service-epitope,代码行数:12,代码来源:DbiManagerImpl.java


示例14: getFamilyAlleleMap

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@Override
public Map<String, Set<String>> getFamilyAlleleMap() {
    try (Handle handle = dbi.open()) {
        return StreamSupport.stream(handle.createQuery("select distinct allele from ("
        		+ " select allele from race_freq where locus='HLA-DPB1'"
        		+ " union select allele from allele_group where locus='HLA-DPB1'"
        		+ " union select allele from hla_g_group where locus='HLA-DPB1')")
            .map(StringMapper.FIRST)
            .spliterator(), false)
            .collect(Collectors.groupingBy(a -> a.substring(0, a.indexOf(":")), Collectors.toSet()));
    }
}
 
开发者ID:nmdp-bioinformatics,项目名称:service-epitope,代码行数:13,代码来源:DbiManagerImpl.java


示例15: getGGroupForAllele

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
/** 
  * {@inheritDoc} 
  */
 @Override
 public String getGGroupForAllele(String allele) {
     try (Handle handle = dbi.open()) {
Matcher m = ALLELE_PATTERN.matcher(allele);
if (!m.matches()) return null;
String group = handle.createQuery("select g_group from hla_g_group where locus = :locus and allele = :allele")
                 .bind("locus", m.group("locus"))
                 .bind("allele", m.group("allele"))
                 .map(StringMapper.FIRST)
                 .first();
return (group == null) ? null : m.group("locus") + "*" + group;
     }
 }
 
开发者ID:nmdp-bioinformatics,项目名称:service-epitope,代码行数:17,代码来源:DbiManagerImpl.java


示例16: getPGroupForAllele

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@Override
public String getPGroupForAllele(String allele) {
	try (Handle handle = dbi.open()) {
		Matcher m = ALLELE_PATTERN.matcher(allele);
		if (!m.matches()) return null;
		String group = handle.createQuery("select p_group from hla_p_group where locus = :locus and allele = :allele")
				.bind("locus", m.group("locus"))
				.bind("allele", m.group("allele"))
				.map(StringMapper.FIRST)
				.first();
		return (group == null) ? null : m.group("locus") + "*" + group;
	}
}
 
开发者ID:nmdp-bioinformatics,项目名称:service-epitope,代码行数:14,代码来源:DbiManagerImpl.java


示例17: process

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@Override
public void process(Exchange e) throws Exception {
	final BigDecimal previousSeqNumber = e.getIn().getHeader(PREVIOUS_SEQ_NUMBER, BigDecimal.class);
	final BigDecimal latestSeqNumber = e.getIn().getHeader(LATEST_SEQ_NUMBER, BigDecimal.class);
	List<String> ids = dbi.withHandle(new HandleCallback<List<String>>() {
		@Override
		public List<String> withHandle(Handle handle) throws Exception {
			String sqlGetIdsSinceLastSeqNumber = 
					String.format("select distinct id from %s where seq_number between :previous_seq_number +1 and :latest_seq_number", 
							tablesMetadata.getUnitOfWorkTable());
			log.debug(sqlGetIdsSinceLastSeqNumber);
			return handle.createQuery(sqlGetIdsSinceLastSeqNumber)
					.bind("previous_seq_number", previousSeqNumber)
					.bind("latest_seq_number", latestSeqNumber)
					.map(StringMapper.FIRST)
					.list();
		}
	});
	List<UUID> uuids = Lists.transform(ids, new Function<String, UUID>() {
		@Override
		public UUID apply(String input) {
			return UUID.fromString((String) input);
		}
	});				
	e.getOut().setBody(uuids, List.class);
	e.getOut().setHeader(HOW_MANY_UOWS_FOUND, ids.size());
	e.getOut().setHeader(LATEST_SEQ_NUMBER, latestSeqNumber);
}
 
开发者ID:rodolfodpk,项目名称:myeslib,代码行数:29,代码来源:JdbiConsumeEventsRoute.java


示例18: getProjects

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@Override
public Set<String> getProjects() {
    try (Handle handle = dbi.open()) {
        return ImmutableSet.copyOf(
                handle.createQuery("select name from project")
                        .map(StringMapper.FIRST).iterator());
    }
}
 
开发者ID:rakam-io,项目名称:rakam,代码行数:9,代码来源:PrestoMetastore.java


示例19: types

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@Override
public List<String> types(int project) {
    try (Handle handle = dbi.open()) {
        return handle.createQuery("SELECT DISTINCT report_type FROM custom_reports WHERE project_id = :project")
                .bind("project", project)
                .map(StringMapper.FIRST).list();
    }
}
 
开发者ID:rakam-io,项目名称:rakam,代码行数:9,代码来源:JDBCCustomReportMetadata.java


示例20: list

import org.skife.jdbi.v2.util.StringMapper; //导入依赖的package包/类
@JsonRequest
@ProtectEndpoint(requiresProject = false)
@ApiOperation(value = "List cluster", authorizations = @Authorization(value = "read_key"))
@Path("/list")
@GET
public List<String> list(@javax.inject.Named("user_id") Project project) {
    try (Handle handle = dbi.open()) {
        return handle.createQuery("SELECT api_url FROM rakam_cluster WHERE user_id = :userId")
                .bind("userId", project.userId).map(StringMapper.FIRST).list();
    }
}
 
开发者ID:rakam-io,项目名称:rakam,代码行数:12,代码来源:ClusterService.java



注:本文中的org.skife.jdbi.v2.util.StringMapper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SerializedException类代码示例发布时间:2022-05-22
下一篇:
Java TernaryNode类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap