Package com.amazonaws.services.dynamodb.model

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


  public void buildExpression(){
    AttributeValue hashAttrValue = buildKeyHashAttribute();
    if (hashAttrValue == null)
      throw new IllegalStateException("There is not a key schema defined.");
    if (DynamoDBQuery.getType().equals(RANGE_QUERY)){
      Condition newCondition = buildRangeCondition();
      buildQueryExpression(newCondition, hashAttrValue);
    }
    if (DynamoDBQuery.getType().equals(SCAN_QUERY))
      buildScanExpression(hashAttrValue);
  }
View Full Code Here


  /**
   * Builds key scan condition using scan comparator, and hash key attribute
   * @return
   */
  private Condition buildKeyScanCondition(){
  Condition scanKeyCondition = new Condition();
  scanKeyCondition.setComparisonOperator(getScanCompOp());
  scanKeyCondition.withAttributeValueList(buildKeyHashAttribute());
  return scanKeyCondition;
  }
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);
  }
  return rangeKeyCondition;
  }
View Full Code Here

    @Test
    public void execute() {

        Key startKey = new Key(new AttributeValue("startKey"));
        AttributeValue attributeValue = new AttributeValue().withN("1985");
        Condition condition = new Condition()
                .withComparisonOperator(ComparisonOperator.GT.toString())
                .withAttributeValueList(new AttributeValue().withN("1985"));

        List<String> attributeNames = Arrays.asList("attrNameOne", "attrNameTwo");
        exchange.getIn().setHeader(DdbConstants.ATTRIBUTE_NAMES, attributeNames);
View Full Code Here

    }

    @Test
    public void execute() {
        HashMap<String, Condition> scanFilter = new HashMap<String, Condition>();
        Condition condition = new Condition()
                .withComparisonOperator(ComparisonOperator.GT.toString())
                .withAttributeValueList(new AttributeValue().withN("1985"));
        scanFilter.put("year", condition);
        exchange.getIn().setHeader(DdbConstants.SCAN_FILTER, scanFilter);
View Full Code Here

    }

    @Test
    public void execute() {
        Map<String, Condition> scanFilter = new HashMap<String, Condition>();
        Condition condition = new Condition()
                .withComparisonOperator(ComparisonOperator.GT.toString())
                .withAttributeValueList(new AttributeValue().withN("1985"));
        scanFilter.put("year", condition);
        exchange.getIn().setHeader(DdbConstants.SCAN_FILTER, scanFilter);
View Full Code Here

        return doQuery;
    }

    private <T> void addQueryFilter(Query<T> query, QueryRequest queryReq) {
        AttributeValue  hashKeyValue = null;
        Condition       rangeCondition = null;

        for (Filter filter : query.filters) {
            if (jsoda.isIdField(query.modelName, filter.fieldName)) {
                if (filter.operator.equals(Filter.EQ))
                    if (filter.operand == null)
View Full Code Here

    private Condition toCondition(Filter filter) {

        if (Filter.BINARY_OPERATORS.contains(filter.operator)) {
            if (filter.operand == null)
                throw new IllegalArgumentException("Operand of a condition cannot be null.");
            return new Condition()
                .withComparisonOperator(sOperatorMap.get(filter.operator))
                .withAttributeValueList(valueToAttr(filter.field, filter.operand));
        }

        if (Filter.UNARY_OPERATORS.contains(filter.operator)) {
            return new Condition()
                .withComparisonOperator(sOperatorMap.get(filter.operator));
        }

        if (Filter.TRINARY_OPERATORS.contains(filter.operator)) {
            if (filter.operand == null || filter.operand2 == null)
                throw new IllegalArgumentException("Operand of a condition cannot be null.");
            return new Condition()
                .withComparisonOperator(sOperatorMap.get(filter.operator))
                .withAttributeValueList(valueToAttr(filter.field, filter.operand),
                                        valueToAttr(filter.field, filter.operand2));
        }

        if (Filter.LIST_OPERATORS.contains(filter.operator)) {
            Condition   cond = new Condition()
                .withComparisonOperator(sOperatorMap.get(filter.operator));
            List<AttributeValue>    attrs = new ArrayList<AttributeValue>();
            for (Object valueObj : filter.operands) {
                attrs.add(valueToAttr(filter.field, valueObj));
            }
            cond.setAttributeValueList(attrs);
            return cond;
        }

        throw new UnsupportedOperationException("Condition operator " + filter.operator + " is not supported.");
    }
View Full Code Here

  public void buildExpression(){
    AttributeValue hashAttrValue = buildKeyHashAttribute();
    if (hashAttrValue == null)
      throw new IllegalStateException("There is not a key schema defined.");
    if (DynamoDBQuery.getType().equals(RANGE_QUERY)){
      Condition newCondition = buildRangeCondition();
      buildQueryExpression(newCondition, hashAttrValue);
    }
    if (DynamoDBQuery.getType().equals(SCAN_QUERY))
      buildScanExpression(hashAttrValue);
  }
View Full Code Here

  /**
   * Builds key scan condition using scan comparator, and hash key attribute
   * @return
   */
  private Condition buildKeyScanCondition(){
  Condition scanKeyCondition = new Condition();
  scanKeyCondition.setComparisonOperator(getScanCompOp());
  scanKeyCondition.withAttributeValueList(buildKeyHashAttribute());
  return scanKeyCondition;
  }
View Full Code Here

TOP

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

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.