Package com.amazonaws.services.dynamodb.model

Examples of com.amazonaws.services.dynamodb.model.KeySchemaElement


  /**
   * Builds range condition based on elements set
   * @return
   */
  private Condition buildRangeCondition(){
  KeySchemaElement kRangeSchema = getKeySchema().getRangeKeyElement();
  Condition rangeKeyCondition = null;
  if(kRangeSchema != null){
    rangeKeyCondition = new Condition();
    rangeKeyCondition.setComparisonOperator(ComparisonOperator.BETWEEN.toString());
    AttributeValue startVal = null, endVal = null;
    //startVal = buildKeyHashAttribute();
    if(kRangeSchema.getAttributeType().equals("S")){
      startVal = new AttributeValue().withS(getRangeKey(query.getStartKey()).toString());
      endVal = new AttributeValue().withS(getRangeKey(query.getEndKey()).toString());
    }
    else if (kRangeSchema.getAttributeType().equals("N")){
      startVal = new AttributeValue().withN(getRangeKey(query.getStartKey()).toString());
      endVal = new AttributeValue().withN(getRangeKey(query.getEndKey()).toString());
    }
    rangeKeyCondition.withAttributeValueList(startVal, endVal);
  }
View Full Code Here


        assertEquals("FULL_DESCRIBE_TABLE", ddbClient.describeTableRequest.getTableName());
        assertEquals("FULL_DESCRIBE_TABLE", exchange.getIn().getHeader(DdbConstants.TABLE_NAME));
        assertEquals("ACTIVE", exchange.getIn().getHeader(DdbConstants.TABLE_STATUS));
        assertEquals(new Date(AmazonDDBClientMock.NOW), exchange.getIn().getHeader(DdbConstants.CREATION_DATE));
        assertEquals(100L, exchange.getIn().getHeader(DdbConstants.ITEM_COUNT));
        assertEquals(new KeySchema(new KeySchemaElement().withAttributeName("name")),
                exchange.getIn().getHeader(DdbConstants.KEY_SCHEMA));
        assertEquals(20L, exchange.getIn().getHeader(DdbConstants.READ_CAPACITY));
        assertEquals(10L, exchange.getIn().getHeader(DdbConstants.WRITE_CAPACITY));
        assertEquals(1000L, exchange.getIn().getHeader(DdbConstants.TABLE_SIZE));
    }
View Full Code Here

            return new DescribeTableResult().withTable(new TableDescription()
                    .withTableName(tableName)
                    .withTableStatus(TableStatus.ACTIVE)
                    .withCreationDateTime(new Date(NOW))
                    .withItemCount(100L)
                    .withKeySchema(new KeySchema(new KeySchemaElement().withAttributeName("name")))
                    .withProvisionedThroughput(new ProvisionedThroughputDescription()
                            .withReadCapacityUnits(20L)
                            .withWriteCapacityUnits(10L))
                    .withTableSizeBytes(1000L));
        }
View Full Code Here

    }

    private TableDescription createTable(String tableName) {
        CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName)
                .withKeySchema(new KeySchema(
                        new KeySchemaElement().withAttributeName(
                                configuration.getKeyAttributeName())
                                .withAttributeType(configuration.getKeyAttributeType())))
                .withProvisionedThroughput(
                        new ProvisionedThroughput().withReadCapacityUnits(configuration.getReadCapacity())
                                .withWriteCapacityUnits(configuration.getWriteCapacity()));
View Full Code Here

    }

    private TableDescription createTable(String tableName) {
        CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName)
                .withKeySchema(new KeySchema(
                        new KeySchemaElement().withAttributeName(
                                configuration.getKeyAttributeName())
                                .withAttributeType(configuration.getKeyAttributeType())))
                .withProvisionedThroughput(
                        new ProvisionedThroughput().withReadCapacityUnits(configuration.getReadCapacity())
                                .withWriteCapacityUnits(configuration.getWriteCapacity()));
View Full Code Here

                                                         .withReadCapacityUnits(readTP)
                                                         .withWriteCapacityUnits(writeTP)));
    }

    private KeySchemaElement makeKeySchemaElement(Field field) {
        KeySchemaElement    elem = new KeySchemaElement();
        String              attrType;

        if (isN(field.getType()))
            attrType = "N";
        else
            attrType = "S";     // everything else has string attribute type.
       
        return elem.withAttributeName(field.getName()).withAttributeType(attrType);
    }
View Full Code Here

   * @param pKeySchemaThe key schema for a specific table
   * @param pIdenNumber of spaces used for indentation
   * @throws IOException
   */
  private void setKeyMethods(KeySchema pKeySchema, int pIden) throws IOException{
    KeySchemaElement hashKey = pKeySchema.getHashKeyElement();
    KeySchemaElement rangeKey = pKeySchema.getRangeKeyElement();
    StringBuilder strBuilder = new StringBuilder();
    // hash key
    if(hashKey != null){
      strBuilder.append("@DynamoDBHashKey(attributeName=\"" + hashKey.getAttributeName() + "\") \n");
      strBuilder.append("    public String getHashKey() {  return " + hashKey.getAttributeName() + "; } \n");
      strBuilder.append("    public void setHashKey(" + (hashKey.getAttributeType().equals("S")?"String ":"double "));
      strBuilder.append("p" + camelCasify(hashKey.getAttributeName()) + "){  this." + hashKey.getAttributeName());
      strBuilder.append(" = p" + camelCasify(hashKey.getAttributeName()) + "; }");
      line(pIden, strBuilder.toString());
    }
    strBuilder.delete(0, strBuilder.length());
    // range key
    if(rangeKey != null){
      strBuilder.append("@DynamoDBRangeKey(attributeName=\"" + rangeKey.getAttributeName() + "\") \n");
      strBuilder.append("    public String getRangeKey() {  return " + rangeKey.getAttributeName() + "; } \n");
      strBuilder.append("    public void setRangeKey(" + (rangeKey.getAttributeType().equals("S")?"String ":"double "));
      strBuilder.append("p" + camelCasify(rangeKey.getAttributeName()) + "){  this." + rangeKey.getAttributeName());
      strBuilder.append(" = p" + camelCasify(rangeKey.getAttributeName()) + "; }");
      line(pIden, strBuilder.toString());
    }
    line(0, "");
  }
View Full Code Here

   * @param pKeySchemaKey schema
   * @param pIdenNumber of spaces used for indentation
   * @throws IOException
   */
  private void setKeyAttributes(KeySchema pKeySchema, int pIden) throws IOException{
    KeySchemaElement hashKey = pKeySchema.getHashKeyElement();
    KeySchemaElement rangeKey = pKeySchema.getRangeKeyElement();
    StringBuilder strBuilder = new StringBuilder();
    // hash key
    if(hashKey != null){
      strBuilder.append("private " + (hashKey.getAttributeType().equals("S")?"String ":"double "));
      strBuilder.append(hashKey.getAttributeName() + ";");
      line(pIden, strBuilder.toString());
    }
    strBuilder.delete(0, strBuilder.length());
    // range key
    if(rangeKey != null){
      strBuilder.append("private " + (rangeKey.getAttributeType().equals("S")?"String ":"double "));
      strBuilder.append(rangeKey.getAttributeName() + ";");
      line(pIden, strBuilder.toString());
    }
    line(0, "");
  }
View Full Code Here

  /**
   * Builds range condition based on elements set
   * @return
   */
  private Condition buildRangeCondition(){
  KeySchemaElement kRangeSchema = getKeySchema().getRangeKeyElement();
  Condition rangeKeyCondition = null;
  if(kRangeSchema != null){
    rangeKeyCondition = new Condition();
    rangeKeyCondition.setComparisonOperator(ComparisonOperator.BETWEEN.toString());
    AttributeValue startVal = null, endVal = null;
    //startVal = buildKeyHashAttribute();
    if(kRangeSchema.getAttributeType().equals("S")){
      startVal = new AttributeValue().withS(getRangeKey(query.getStartKey()).toString());
      endVal = new AttributeValue().withS(getRangeKey(query.getEndKey()).toString());
    }
    else if (kRangeSchema.getAttributeType().equals("N")){
      startVal = new AttributeValue().withN(getRangeKey(query.getStartKey()).toString());
      endVal = new AttributeValue().withN(getRangeKey(query.getEndKey()).toString());
    }
    rangeKeyCondition.withAttributeValueList(startVal, endVal);
  }
View Full Code Here

    public void setHashRangeKeySchema(String tableName, String rangeKeyName, String rangeKeyType){
      KeySchema kSchema = tablesToKeySchemas.get(tableName);
      if ( kSchema == null)
        kSchema = new KeySchema();
  
      KeySchemaElement rangeKeyElement = new KeySchemaElement().withAttributeName(rangeKeyName).withAttributeType(rangeKeyType);
      kSchema.setRangeKeyElement(rangeKeyElement);
      tablesToKeySchemas.put(tableName, kSchema);
    }
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodb.model.KeySchemaElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.