Package com.amazonaws.services.dynamodbv2.model

Examples of com.amazonaws.services.dynamodbv2.model.AttributeValue


          String schoolName = columns[1];
          double latitude = Double.parseDouble(columns[2]);
          double longitude = Double.parseDouble(columns[3]);

          GeoPoint geoPoint = new GeoPoint(latitude, longitude);
          AttributeValue rangeKeyValue = new AttributeValue().withS(schoolId);
          AttributeValue schoolNameValue = new AttributeValue().withS(schoolName);

          PutPointRequest putPointRequest = new PutPointRequest(geoPoint, rangeKeyValue);
          putPointRequest.getPutItemRequest().getItem().put("schoolName", schoolNameValue);

          geoDataManager.putPoint(putPointRequest);
View Full Code Here


    }
  }

  private void putPoint(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
    GeoPoint geoPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
    AttributeValue rangeKeyAttributeValue = new AttributeValue().withS(UUID.randomUUID().toString());
    AttributeValue schoolNameKeyAttributeValue = new AttributeValue().withS(requestObject.getString("schoolName"));

    PutPointRequest putPointRequest = new PutPointRequest(geoPoint, rangeKeyAttributeValue);
    putPointRequest.getPutItemRequest().addItemEntry("schoolName", schoolNameKeyAttributeValue);

    PutPointResult putPointResult = geoDataManager.putPoint(putPointRequest);
View Full Code Here

    out.flush();
  }

  private void getPoint(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
    GeoPoint geoPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
    AttributeValue rangeKeyAttributeValue = new AttributeValue().withS(requestObject.getString("rangeKey"));

    GetPointRequest getPointRequest = new GetPointRequest(geoPoint, rangeKeyAttributeValue);
    GetPointResult getPointResult = geoDataManager.getPoint(getPointRequest);

    printGetPointRequest(getPointResult, out);
View Full Code Here

    out.flush();
  }

  private void updatePoint(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
    GeoPoint geoPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
    AttributeValue rangeKeyAttributeValue = new AttributeValue().withS(requestObject.getString("rangeKey"));

    String schoolName = requestObject.getString("schoolName");
    AttributeValueUpdate schoolNameValueUpdate = null;

    String memo = requestObject.getString("memo");
    AttributeValueUpdate memoValueUpdate = null;

    if (schoolName == null || schoolName.equalsIgnoreCase("")) {
      schoolNameValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.DELETE);
    } else {
      AttributeValue schoolNameAttributeValue = new AttributeValue().withS(schoolName);
      schoolNameValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.PUT).withValue(
          schoolNameAttributeValue);
    }

    if (memo == null || memo.equalsIgnoreCase("")) {
      memoValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.DELETE);
    } else {
      AttributeValue memoAttributeValue = new AttributeValue().withS(memo);
      memoValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.PUT).withValue(memoAttributeValue);
    }

    UpdatePointRequest updatePointRequest = new UpdatePointRequest(geoPoint, rangeKeyAttributeValue);
    updatePointRequest.getUpdateItemRequest().addAttributeUpdatesEntry("schoolName", schoolNameValueUpdate);
View Full Code Here

    out.flush();
  }

  private void deletePoint(JSONObject requestObject, PrintWriter out) throws IOException, JSONException {
    GeoPoint geoPoint = new GeoPoint(requestObject.getDouble("lat"), requestObject.getDouble("lng"));
    AttributeValue rangeKeyAttributeValue = new AttributeValue().withS(requestObject.getString("rangeKey"));

    DeletePointRequest deletePointRequest = new DeletePointRequest(geoPoint, rangeKeyAttributeValue);
    DeletePointResult deletePointResult = geoDataManager.deletePoint(deletePointRequest);

    printDeletePointResult(deletePointResult, out);
View Full Code Here

    do {
      Map<String, Condition> keyConditions = new HashMap<String, Condition>();

      Condition hashKeyCondition = new Condition().withComparisonOperator(ComparisonOperator.EQ)
          .withAttributeValueList(new AttributeValue().withN(String.valueOf(hashKey)));
      keyConditions.put(config.getHashKeyAttributeName(), hashKeyCondition);

      AttributeValue minRange = new AttributeValue().withN(Long.toString(range.getRangeMin()));
      AttributeValue maxRange = new AttributeValue().withN(Long.toString(range.getRangeMax()));

      Condition geohashCondition = new Condition().withComparisonOperator(ComparisonOperator.BETWEEN)
          .withAttributeValueList(minRange, maxRange);
      keyConditions.put(config.getGeohashAttributeName(), geohashCondition);
View Full Code Here

    long hashKey = S2Manager.generateHashKey(geohash, config.getHashKeyLength());

    GetItemRequest getItemRequest = getPointRequest.getGetItemRequest();
    getItemRequest.setTableName(config.getTableName());

    AttributeValue hashKeyValue = new AttributeValue().withN(String.valueOf(hashKey));
    getItemRequest.getKey().put(config.getHashKeyAttributeName(), hashKeyValue);
    getItemRequest.getKey().put(config.getRangeKeyAttributeName(), getPointRequest.getRangeKeyValue());

    GetItemResult getItemResult = config.getDynamoDBClient().getItem(getItemRequest);
    GetPointResult getPointResult = new GetPointResult(getItemResult);
View Full Code Here

    String geoJson = GeoJsonMapper.stringFromGeoObject(putPointRequest.getGeoPoint());

    PutItemRequest putItemRequest = putPointRequest.getPutItemRequest();
    putItemRequest.setTableName(config.getTableName());

    AttributeValue hashKeyValue = new AttributeValue().withN(String.valueOf(hashKey));
    putItemRequest.getItem().put(config.getHashKeyAttributeName(), hashKeyValue);
    putItemRequest.getItem().put(config.getRangeKeyAttributeName(), putPointRequest.getRangeKeyValue());
    AttributeValue geohashValue = new AttributeValue().withN(Long.toString(geohash));
    putItemRequest.getItem().put(config.getGeohashAttributeName(), geohashValue);
    AttributeValue geoJsonValue = new AttributeValue().withS(geoJson);
    putItemRequest.getItem().put(config.getGeoJsonAttributeName(), geoJsonValue);

    PutItemResult putItemResult = config.getDynamoDBClient().putItem(putItemRequest);
    PutPointResult putPointResult = new PutPointResult(putItemResult);
View Full Code Here

      long geohash = S2Manager.generateGeohash(putPointRequest.getGeoPoint());
      long hashKey = S2Manager.generateHashKey(geohash, config.getHashKeyLength());
      String geoJson = GeoJsonMapper.stringFromGeoObject(putPointRequest.getGeoPoint());

      PutRequest putRequest = putPointRequest.getPutRequest();
      AttributeValue hashKeyValue = new AttributeValue().withN(String.valueOf(hashKey));
      putRequest.getItem().put(config.getHashKeyAttributeName(), hashKeyValue);
      putRequest.getItem().put(config.getRangeKeyAttributeName(), putPointRequest.getRangeKeyValue());
      AttributeValue geohashValue = new AttributeValue().withN(Long.toString(geohash));
      putRequest.getItem().put(config.getGeohashAttributeName(), geohashValue);
      AttributeValue geoJsonValue = new AttributeValue().withS(geoJson);
      putRequest.getItem().put(config.getGeoJsonAttributeName(), geoJsonValue);     
     
      WriteRequest writeRequest = new WriteRequest(putRequest);
      writeRequests.add(writeRequest);
    }
View Full Code Here

    long hashKey = S2Manager.generateHashKey(geohash, config.getHashKeyLength());

    UpdateItemRequest updateItemRequest = updatePointRequest.getUpdateItemRequest();
    updateItemRequest.setTableName(config.getTableName());

    AttributeValue hashKeyValue = new AttributeValue().withN(String.valueOf(hashKey));
    updateItemRequest.getKey().put(config.getHashKeyAttributeName(), hashKeyValue);
    updateItemRequest.getKey().put(config.getRangeKeyAttributeName(), updatePointRequest.getRangeKeyValue());

    // Geohash and geoJson cannot be updated.
    updateItemRequest.getAttributeUpdates().remove(config.getGeohashAttributeName());
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodbv2.model.AttributeValue

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.