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


Java DynamoDBMapper类代码示例

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


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

示例1: getDevicePlatform

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
private Platform getDevicePlatform(DynamoDBMapper mapper,String token)
{
	Dispositivo d = mapper.load(Dispositivo.class, token);
	if(null==d)
		return null;
	
	
	
	if(d.getOs()==1)
		return Platform.APNS_SANDBOX;
	if(d.getOs()==2)
		return Platform.GCM;
	
	//Just for testing 
	return Platform.APNS_SANDBOX;
		//return null;
	
}
 
开发者ID:krito19,项目名称:DenunciaMXBackEnd,代码行数:19,代码来源:SecretariaService.java

示例2: init

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
@PostConstruct
protected void init() {
    configureAWSLogAgent();
    credentialsProvider = new InstanceProfileCredentialsProvider();
    region = Regions.getCurrentRegion();
    amazonDynamoDB.setRegion(region);
    dbPrefix = AmazonConfigProvider.getDynamoDbPrefix();
    DynamoDBMapperConfig config = new DynamoDBMapperConfig.Builder().withTableNameOverride(DynamoDBMapperConfig.TableNameOverride.
            withTableNamePrefix(dbPrefix)).build();
    mapper = new DynamoDBMapper(amazonDynamoDB, config);
    tablesWithPrefix = Arrays.stream(tables).map(s -> dbPrefix.concat(s)).collect(Collectors.toList());
    if (customBucketName != null) {
        customBucketName = customBucketName.toLowerCase();
    }
    if ((customBucketName.isEmpty() || CUSTOM_BUCKET_NAME_DEFAULT_VALUE.equals(customBucketName)) && !validateBucketName(customBucketName).isValid()) {
        customBucketName = null;
    }
}
 
开发者ID:SungardAS,项目名称:enhanced-snapshots,代码行数:19,代码来源:InitConfigurationServiceImpl.java

示例3: put

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
/**
 * Puts an object identified by a key
 *
 * @param key
 * @param obj
 */
@Override
public void put(K key, T obj) {
  try {
    Object hashKey = getHashKey(key, obj);
    Object rangeKey = getRangeKey(key, obj);
    if (hashKey != null) {
      DynamoDBMapper mapper = new DynamoDBMapper(
          dynamoDBStoreHandler.getDynamoDbClient());
      if (rangeKey != null) {
        mapper.load(persistentClass, hashKey, rangeKey);
      } else {
        mapper.load(persistentClass, hashKey);
      }
      mapper.save(obj);
    } else
      throw new GoraException("No HashKey found in Key nor in Object.");
  } catch (NullPointerException npe) {
    LOG.error("Error while putting an item. " + npe.toString());
    throw new NullArgumentException(npe.getMessage());
  } catch (Exception e) {
    LOG.error("Error while putting an item. " + obj.toString());
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:gora,代码行数:31,代码来源:DynamoDBNativeStore.java

示例4: FindBooksPricedLessThanSpecifiedValue

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
private static void FindBooksPricedLessThanSpecifiedValue(
        DynamoDBMapper mapper,
        String value) throws Exception {
 
    System.out.println("FindBooksPricedLessThanSpecifiedValue: Scan ProductCatalog.");
            
    DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
    scanExpression.addFilterCondition("Price", 
            new Condition()
               .withComparisonOperator(ComparisonOperator.LT)
               .withAttributeValueList(new AttributeValue().withN(value)));
    scanExpression.addFilterCondition("ProductCategory", 
            new Condition()
                .withComparisonOperator(ComparisonOperator.EQ)
                .withAttributeValueList(new AttributeValue().withS("Book")));
    List<Book> scanResult = mapper.scan(Book.class, scanExpression);
    
    for (Book book : scanResult) {
        System.out.println(book);
    }
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:22,代码来源:ObjectPersistenceQueryScanExample.java

示例5: FindBicyclesOfSpecificTypeWithMultipleThreads

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
private static void FindBicyclesOfSpecificTypeWithMultipleThreads(
        DynamoDBMapper mapper, 
        int numberOfThreads,
        String bicycleType) throws Exception {
 
    System.out.println("FindBicyclesOfSpecificTypeWithMultipleThreads: Scan ProductCatalog With Multiple Threads.");
            
    DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
    scanExpression.addFilterCondition("ProductCategory", 
            new Condition()
                .withComparisonOperator(ComparisonOperator.EQ)
                .withAttributeValueList(new AttributeValue().withS("Bicycle")));
    scanExpression.addFilterCondition("BicycleType", 
            new Condition()
                .withComparisonOperator(ComparisonOperator.EQ)
                .withAttributeValueList(new AttributeValue().withS(bicycleType)));
    List<Bicycle> scanResult = mapper.parallelScan(Bicycle.class, scanExpression, numberOfThreads);
    for (Bicycle bicycle : scanResult) {
        System.out.println(bicycle);
    }
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:22,代码来源:ObjectPersistenceQueryScanExample.java

示例6: main

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    try {
 
        DynamoDBMapper mapper = new DynamoDBMapper(client);

        testBatchSave(mapper);
        testBatchDelete(mapper);
        testBatchWrite(mapper);
        
        System.out.println("Example complete!");

    } catch (Throwable t) {
        System.err.println("Error running the ObjectPersistenceBatchWriteExample: " + t);
        t.printStackTrace();
    }
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:17,代码来源:ObjectPersistenceBatchWriteExample.java

示例7: setup

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
@Before
public void setup() throws NoSuchFieldException, IllegalAccessException {

	underTest = spy(new DynamoDbConfig(environment, awsKms));

	when(underTest.encryptionTransformer(any(String.class))).thenReturn(transformer);
	when(underTest.tableNameOverrideConfig(any(String.class))).thenReturn(mapConfigNamed);
	when(underTest.getDynamoDbMapperConfig()).thenReturn(mapConfig);

	mockStatic(DynamoDBMapper.class);
	mockStatic(DynamoDbConfigFactory.class);

	MockitoAnnotations.initMocks(DynamoDbConfigTest.class);
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:15,代码来源:DynamoDbConfigTest.java

示例8: dbMapperNoAudit

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
@Test
public void dbMapperNoAudit() {
	when(environment.getProperty(eq(Constants.NO_AUDIT_ENV_VARIABLE))).thenReturn("true");
	when(environment.getProperty(eq(Constants.DYNAMO_TABLE_NAME_ENV_VARIABLE))).thenReturn(null);
	when(environment.getProperty(eq(Constants.KMS_KEY_ENV_VARIABLE))).thenReturn(null);

	DynamoDBMapper dynamoDBMapper = underTest.dynamoDbMapper(amazonDynamoDB);

	assertThat(dynamoDBMapper).isNull();
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:11,代码来源:DynamoDbConfigTest.java

示例9: setup

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
@Before
@Override
public void setup() {
    super.setup();
    final DynamoDBMapper mapper = new DynamoDBMapper(dynamodbClient);
    resourceTripleDao = new DynamoDBResourceTripleDao(mapper);

    addResourceData();
}
 
开发者ID:duraspace,项目名称:lambdora,代码行数:10,代码来源:DynamoDBResourceTripleDaoTest.java

示例10: addUser

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
public static User addUser(DynamoDBMapper dbMapper, String firstName, String lastName, String address, String facebookId) {
    User user = new User();
    user.setUserId(UUID.randomUUID().toString());
    user.setFirstName(firstName);
    user.setLastName(lastName);
    if(address != null)
        user.setAddress(address);
    if(facebookId != null)
        user.setFacebookId(facebookId);
    dbMapper.save(user);
    return user;
}
 
开发者ID:satr,项目名称:aws-amazon-shopping-bot-lambda-func,代码行数:13,代码来源:TestRepositoryHelper.java

示例11: DBConnector

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
/**
 * generate dynamo db mapper etc. to connect to database
 */
private DBConnector() {
    AWSPropertiesProvider awsPropertiesProvider = new AWSPropertiesProvider("dynamoDb.properties");
    AmazonDynamoDBClient dbClient = new AmazonDynamoDBClient(awsPropertiesProvider.getCredentials());
    dbClient.setRegion(awsPropertiesProvider.getRegion());
    dynamoDB = new DynamoDB(dbClient);
    dynamoDBMapper = new DynamoDBMapper(dbClient);
}
 
开发者ID:LogicalOverflow,项目名称:MasterStats,代码行数:11,代码来源:DBConnector.java

示例12: GenericDynamoDbDao

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
public GenericDynamoDbDao(DynamoDbClientFactory clientFactory, Class<T> clazz) {
    DynamoDBTableMapper<T, K, ?> tableMapper = new DynamoDBMapper(clientFactory.client()).newTableMapper(clazz);
    log.info("Building table for " + clazz.getName());
    boolean tableIfNotExists = tableMapper.createTableIfNotExists(new ProvisionedThroughput().withReadCapacityUnits(1L).withWriteCapacityUnits(1L));
    log.info("table created?: "+tableIfNotExists);
    this.tableMapper = tableMapper;
}
 
开发者ID:wakingrufus,项目名称:elo-api,代码行数:8,代码来源:GenericDynamoDbDao.java

示例13: GenericDynamoDbRangeDao

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
public GenericDynamoDbRangeDao(DynamoDbClientFactory clientFactory, Class<T> clazz) {
    DynamoDBTableMapper<T, K, R> tableMapper = new DynamoDBMapper(clientFactory.client()).newTableMapper(clazz);
    log.info("Building table for " + clazz.getName());
    tableMapper.deleteTableIfExists();
    tableMapper.createTableIfNotExists(new ProvisionedThroughput().withReadCapacityUnits(1L).withWriteCapacityUnits(1L));
    this.tableMapper = tableMapper;
}
 
开发者ID:wakingrufus,项目名称:elo-api,代码行数:8,代码来源:GenericDynamoDbRangeDao.java

示例14: beforeClass

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() {
    sDynamoDB = DynamoDBEmbedded.create().amazonDynamoDB();
    sDynamoDBMapper = new DynamoDBMapper(sDynamoDB);
    sDynamoDBRepository = new DynamoDBRepository();
    sDynamoDBRepository.setDynamoDBMapper(sDynamoDBMapper);
    sDynamoDBRepository.setLockDurationMs(LOCK_DURATION_MS);
}
 
开发者ID:milton0825,项目名称:plano,代码行数:9,代码来源:DynamoDBRepositoryTests.java

示例15: handleRequest

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; //导入依赖的package包/类
@Override
public String handleRequest(Book request, Context context) {
	DynamoDBMapper mapper = new DynamoDBMapper(DynamoDBUtil.getClient());
	mapper.save(request);

	return "success";
}
 
开发者ID:arun-gupta,项目名称:serverless,代码行数:8,代码来源:BookPost.java


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