Example usage for com.amazonaws.services.dynamodbv2.model ProjectionType fromValue

List of usage examples for com.amazonaws.services.dynamodbv2.model ProjectionType fromValue

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model ProjectionType fromValue.

Prototype

public static ProjectionType fromValue(String value) 

Source Link

Document

Use this in place of valueOf.

Usage

From source file:jp.classmethod.aws.dynamodb.DynamoDbRepository.java

License:Open Source License

/**
 * gets a full item from a GSI/*from w  ww  . j a  v  a2s.co m*/
 * @param indexName name of GSI
 * @param spec query spec for gsi query
 * @return a full item keyed at keys in the GSI. If the GSI does not project all attributes, will read the item from
 * the base table
 *
 * TODO, ideally, return a wrapper of the last evaluated key from the query result and the list, but since we are
 * not filtering on the server side, do this later.
 */
private Chunk<E> getFromGSI(String indexName, QuerySpec spec, boolean isUnique) {
    Preconditions.checkNotNull(spec, "query spec was null");
    Chunk<Item> chunk = getItemListForGsi(indexName, spec);
    //check if the index was not a unique index
    if (isUnique) {
        Preconditions.checkState(chunk.getContent().size() < 2,
                "the index had more than one item at spec=" + spec.toString());
    }

    if (ProjectionType
            .fromValue(gsis.get(indexName).getProjection().getProjectionType()) == ProjectionType.ALL) {
        //the GSI had the full item so return it.
        return new ChunkImpl<>(chunk.getContent().parallelStream().map(i -> convertItemToDomain(i))
                .collect(Collectors.toList()), chunk.getPaginationToken(), null /*chunkable*/);
    }
    //else read the item from the base table
    try {
        List<AttributeValue> pks = chunk.getContent().stream().map(i -> getPrimaryKeyFromItem(i))
                .map(pk -> Iterables.getOnlyElement(pk.getComponents().stream()
                        .filter(c -> c.getName().equals(hashKeyName)).map(Attribute::getValue)
                        .map(InternalUtils::toAttributeValue).collect(Collectors.toList())))
                .collect(Collectors.toList());
        return new ChunkImpl<>(findAll(pks, true), chunk.getPaginationToken(), null /*chunkable*/);
    } catch (AmazonClientException e) {
        throw convertDynamoDBException(e, "read", null /*condition failed exception provider*/);
    }
}

From source file:org.socialsignin.spring.data.dynamodb.repository.util.Entity2DynamoDBTableSynchronizer.java

License:Apache License

@Autowired
public Entity2DynamoDBTableSynchronizer(AmazonDynamoDB amazonDynamoDB, DynamoDBMapper mapper,
        @Value(CONFIGURATION_KEY_entity2ddl_auto) String mode,
        @Value(CONFIGURATION_KEY_entity2ddl_gsiProjectionType) String gsiProjectionType,
        @Value(CONFIGURATION_KEY_entity2ddl_readCapacity) long readCapacity,
        @Value(CONFIGURATION_KEY_entity2ddl_writeCapacity) long writeCapacity) {
    this.amazonDynamoDB = amazonDynamoDB;
    this.mapper = mapper;

    this.mode = Entity2DDL.fromValue(mode);
    this.pt = new ProvisionedThroughput(readCapacity, writeCapacity);
    this.gsiProjectionType = ProjectionType.fromValue(gsiProjectionType);
}