当前位置: 首页>>代码示例>>Java>>正文


Java CloudantClient类代码示例

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


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

示例1: getHelper

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
public static Application.Helper getHelper() throws Exception {
    if(systemProperties.containsKey("PROP_FILE")) {
        properties.load(new FileInputStream(systemProperties.get("PROP_FILE")));
    }

    CloudantClient cloudantClient = ClientBuilder
            .url(new URL(getProperty("cloudant.url")))
            .username(getProperty("cloudant.username"))
            .password(getProperty("cloudant.password"))
            .build();
    WolframRepository wolframRepository = new WolframRepository(getProperty("wolfram.apiKey"));
    return new Application.Helper(
            cloudantClient,
            wolframRepository,
            getProperty("cloudant.chatDB"),
            getProperty("cloudant.feedbackDB"),
            getProperty("cloudant.explorerDB"),
            getProperty("tmdb.apiKey")
    );
}
 
开发者ID:dbpedia,项目名称:chatbot,代码行数:21,代码来源:TestUtility.java

示例2: client

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Profile("kubernetes")
@Bean
/*
 * Load the CloudantClient from the Kubernetes Secrets file.
 * This method is only loaded when the kubernetes profile is activated
 */
public CloudantClient client() throws IOException {

	String secrets = readKubeSecretsFiles();
	String secretsJson = StringUtils.newStringUtf8(Base64.decodeBase64(secrets));
	ObjectMapper mapper = new ObjectMapper();
	Map<String, Object> map = new HashMap<String, Object>();

	// convert JSON string to Map
	map = mapper.readValue(secretsJson, new TypeReference<Map<String, String>>(){});

	String username = (String) map.get("username");
	String password = (String) map.get("password");
	String url = "http://" + map.get("username") + ".cloudant.com";

	return ClientBuilder.url(new URL(url))
			.username(username)
			.password(password)
			.build();
}
 
开发者ID:IBM,项目名称:spring-boot-continuous-delivery,代码行数:26,代码来源:Application.java

示例3: Helper

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Autowired
public Helper(final CloudantClient cloudantClient,
              WolframRepository wolframRepository,
              @Value("${cloudant.chatDB}") String chatDBName,
              @Value("${cloudant.feedbackDB}") String feedbackDBName,
              @Value("${cloudant.explorerDB}") String explorerDBName,
              @Value("${tmdb.apiKey}") String tmdbApiKey) {
    try {
        chatDB = cloudantClient.database(chatDBName, true);
        feedbackDB = cloudantClient.database(feedbackDBName, true);
        explorerDB = cloudantClient.database(explorerDBName, true);
    }
    catch(Exception e) {
        logger.info("ERROR HERE");
        e.printStackTrace();
    }
    finally {
        this.tmdbApiKey = tmdbApiKey;
        this.wolframRepository = wolframRepository;

        riveScriptBot = new RiveScriptBot();
        eliza = new ElizaMain();
        eliza.readScript(true, "src/main/resources/eliza/script");

        sparql = new SPARQL(explorerDB);
        languageTool = new JLanguageTool(new AmericanEnglish());
        for (Rule rule : languageTool.getAllActiveRules()) {
            if (rule instanceof SpellingCheckRule) {
                List<String> wordsToIgnore = Arrays.asList("nlp");
                ((SpellingCheckRule) rule).addIgnoreTokens(wordsToIgnore);
            }
        }
    }
}
 
开发者ID:dbpedia,项目名称:chatbot,代码行数:35,代码来源:Application.java

示例4: client

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public CloudantClient client() {
	ClientBuilder builder = ClientBuilder
		.url(config.getUrl())
		.username(config.getUsername())
		.password(config.getPassword());
	return builder.build();
}
 
开发者ID:IBM,项目名称:greeting-cloudant-spring,代码行数:9,代码来源:CloudantConfiguration.java

示例5: createClient

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
private static CloudantClient createClient() {
	
	String url;

	if (System.getenv("VCAP_SERVICES") != null) {
		// When running in Bluemix, the VCAP_SERVICES env var will have the credentials for all bound/connected services
		// Parse the VCAP JSON structure looking for cloudant.
		JsonObject cloudantCredentials = VCAPHelper.getCloudCredentials("cloudant");
		if(cloudantCredentials == null){
			System.out.println("No cloudant database service bound to this application");
			return null;
		}
		url = cloudantCredentials.get("url").getAsString();
	} else {
		System.out.println("Running locally. Looking for credentials in cloudant.properties");
		url = VCAPHelper.getLocalProperties("cloudant.properties").getProperty("cloudant_url");
		if(url == null || url.length()==0){
			System.out.println("To use a database, set the Cloudant url in src/main/resources/cloudant.properties");
			return null;
		}
	}

	try {
		System.out.println("Connecting to Cloudant");
		CloudantClient client = ClientBuilder.url(new URL(url)).build();
		return client;
	} catch (Exception e) {
		System.out.println("Unable to connect to database");
		//e.printStackTrace();
		return null;
	}
}
 
开发者ID:IBM-Cloud,项目名称:get-started-java,代码行数:33,代码来源:CloudantVisitorStore.java

示例6: clientBeanCreation

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Test
public void clientBeanCreation() {
    when(mockBuilder.build()).thenReturn(mockClient);
    
    this.context.register(MockClientBuilderConfig.class);
    EnvironmentTestUtils.addEnvironment(this.context, "cloudant.url=http://cloudant.com");
    this.context.refresh();
    CloudantClient client = this.context.getBean(CloudantClient.class);
    assertEquals(mockClient, client);
}
 
开发者ID:cloudant-labs,项目名称:cloudant-spring,代码行数:11,代码来源:EnableCloudantTest.java

示例7: clientBeanCreation

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Test
public void clientBeanCreation() {
    when(mockBuilder.build()).thenReturn(mockClient);
    
    this.context.register(MockClientBuilderConfig.class, CloudantAutoConfiguration.class);
    this.context.refresh();
    CloudantClient client = this.context.getBean(CloudantClient.class);
    assertEquals(mockClient, client);
}
 
开发者ID:cloudant-labs,项目名称:cloudant-spring,代码行数:10,代码来源:AutoConfigurationTest.java

示例8: connect

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
/**
 * Create the connection to the Cloudant database that we'll use for this
 * service.
 */
private void connect() {
	CloudantClient cloudant = new CloudantClient(
			AppPropertiesReader.getStringProperty(Constants.CLOUDANT_ACCOUNT),
			AppPropertiesReader.getStringProperty(Constants.CLOUDANT_USERNAME),
			AppPropertiesReader.getStringProperty(Constants.CLOUDANT_PASSWORD));
	db = cloudant.database(AppPropertiesReader.getStringProperty(Constants.CLOUDANT_DB_NAME), true);
	
}
 
开发者ID:IBM-MIL,项目名称:IBM-Ready-App-for-Telecommunications,代码行数:13,代码来源:CloudantService.java

示例9: CloudantConnector

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
public CloudantConnector(ICloudantSettings cs){
    cloudantSettings = cs;
    ConnectOptions connectOptions = new ConnectOptions()
            .setConnectionTimeout(cloudantSettings.getConnectionTimeout())
            .setMaxConnections(cloudantSettings.getMaxConnections());
    cloudantClient = new CloudantClient(cloudantSettings.getUrl(),cloudantSettings.getUsername(),cloudantSettings.getPassword(), connectOptions);
}
 
开发者ID:SeniorAdvisor,项目名称:spring-data-cloudant,代码行数:8,代码来源:CloudantConnector.java

示例10: afterPropertiesSet

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    ConnectOptions connectionOptions = new ConnectOptions()
            .setConnectionTimeout(connectionTimeout)
            .setMaxConnections(maxConnections);
    cloudantClient = new CloudantClient(account,username,password,connectionOptions);
    gsonBuilder = new GsonBuilder().registerTypeHierarchyAdapter(BaseDocument.class,new UnmappedDataAdapter());
    cloudantClient.setGsonBuilder(gsonBuilder);
}
 
开发者ID:SeniorAdvisor,项目名称:spring-data-cloudant,代码行数:10,代码来源:CloudantFactoryBean.java

示例11: CloudantLocationStore

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
public CloudantLocationStore(){
	CloudantClient cloudant = createClient();
	if(cloudant!=null){
	 db = cloudant.database(databaseName, true);
	}
}
 
开发者ID:IBM,项目名称:liberty-outage-reporter,代码行数:7,代码来源:CloudantLocationStore.java

示例12: hrsDb

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public Database hrsDb(CloudantClient cloudant) {
	return cloudant.database("hrs", true);
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:CouchDbConfig.java

示例13: database

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public Database database(CloudantClient client) {
	Database db = client.database(config.getDb(), true);
	return db;
}
 
开发者ID:IBM,项目名称:greeting-cloudant-spring,代码行数:6,代码来源:CloudantConfiguration.java

示例14: CloudantVisitorStore

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
public CloudantVisitorStore(){
	CloudantClient cloudant = createClient();
	if(cloudant!=null){
	 db = cloudant.database(databaseName, true);
	}
}
 
开发者ID:IBM-Cloud,项目名称:get-started-java,代码行数:7,代码来源:CloudantVisitorStore.java

示例15: client

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public CloudantClient client(ClientBuilder builder) {
    return builder.build();
}
 
开发者ID:cloudant-labs,项目名称:cloudant-spring,代码行数:5,代码来源:CloudantConfiguration.java


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