Java 类com.amazonaws.geo.model.PutPointRequest 实例源码

项目:dynamodb-geo    文件:DynamoDBManager.java   
public PutPointResult putPoint(PutPointRequest putPointRequest) {
    long geohash = S2Manager.generateGeohash(putPointRequest.getGeoPoint());
    long hashKey = S2Manager.generateHashKey(geohash, config.getHashKeyLength());
    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);

    return putPointResult;
}
项目:UnitedWayRESTBackend    文件:DynamoGeoService.java   
public void putPoint(PointData pd) { 
    GeoPoint geoPoint = new GeoPoint(pd.getLatitude(), pd.getLongitude());
    AttributeValue rangeKeyValue = new AttributeValue().withS(pd.getRangeKey());

    PutPointRequest putPointRequest = new PutPointRequest(geoPoint, rangeKeyValue);

    for (Entry<String, String> e : pd.getData().entrySet()) {
        AttributeValue value = new AttributeValue().withS(e.getValue());
        putPointRequest.getPutItemRequest().getItem().put(e.getKey(), value);
    }

    geoDataManager.putPoint(putPointRequest);
}
项目:reinvent2013-mobile-photo-share    文件:GeoDynamoDBServlet.java   
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(requestObject.getString("s3-photo-url"));
    AttributeValue titleAttributeValue = new AttributeValue().withS(requestObject.getString("title"));
    AttributeValue userIdAttributeValue = new AttributeValue().withS(requestObject.getString("userId"));

    PutPointRequest putPointRequest = new PutPointRequest(geoPoint, rangeKeyAttributeValue);
    putPointRequest.getPutItemRequest().addItemEntry("title", titleAttributeValue);
    putPointRequest.getPutItemRequest().addItemEntry("userId", userIdAttributeValue);

    PutPointResult putPointResult = geoDataManager.putPoint(putPointRequest);
    printPutPointResult(putPointResult, out);
}
项目:dynamodb-geo    文件:DynamoDBManager.java   
public BatchWritePointResult batchWritePoints(List<PutPointRequest> putPointRequests) {
    BatchWriteItemRequest batchItemRequest = new BatchWriteItemRequest();
    List<WriteRequest> writeRequests = new ArrayList<WriteRequest>();
    for (PutPointRequest putPointRequest : putPointRequests) {
        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);
    }
    Map<String, List<WriteRequest>> requestItems = new HashMap<String, List<WriteRequest>>();
    requestItems.put(config.getTableName(), writeRequests);
    batchItemRequest.setRequestItems(requestItems);
    BatchWriteItemResult batchWriteItemResult = config.getDynamoDBClient().batchWriteItem(batchItemRequest);
    BatchWritePointResult batchWritePointResult = new BatchWritePointResult(batchWriteItemResult);
    return batchWritePointResult;
}
项目:dynamodb-geo    文件:GeoDynamoDBServlet.java   
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);

    printPutPointResult(putPointResult, out);
}
项目:dynamodb-geo    文件:GeoDataManager.java   
/**
 * <p>
 * Put a point into the Amazon DynamoDB table. Once put, you cannot update attributes specified in
 * GeoDataManagerConfiguration: hash key, range key, geohash and geoJson. If you want to update these columns, you
 * need to insert a new record and delete the old record.
 * </p>
 * <b>Sample usage:</b>
 * 
 * <pre>
 * GeoPoint geoPoint = new GeoPoint(47.5, -122.3);
 * AttributeValue rangeKeyValue = new AttributeValue().withS(&quot;a6feb446-c7f2-4b48-9b3a-0f87744a5047&quot;);
 * AttributeValue titleValue = new AttributeValue().withS(&quot;Original title&quot;);
 * 
 * PutPointRequest putPointRequest = new PutPointRequest(geoPoint, rangeKeyValue);
 * putPointRequest.getPutItemRequest().getItem().put(&quot;title&quot;, titleValue);
 * 
 * PutPointResult putPointResult = geoDataManager.putPoint(putPointRequest);
 * </pre>
 * 
 * @param putPointRequest
 *            Container for the necessary parameters to execute put point request.
 * 
 * @return Result of put point request.
 */
public PutPointResult putPoint(PutPointRequest putPointRequest) {
    return dynamoDBManager.putPoint(putPointRequest);
}
项目:dynamodb-geo    文件:GeoDataManager.java   
/**
 * <p>
 * Put a list of points into the Amazon DynamoDB table. Once put, you cannot update attributes specified in
 * GeoDataManagerConfiguration: hash key, range key, geohash and geoJson. If you want to update these columns, you
 * need to insert a new record and delete the old record.
 * </p>
 * <b>Sample usage:</b>
 * 
 * <pre>
 * GeoPoint geoPoint = new GeoPoint(47.5, -122.3);
 * AttributeValue rangeKeyValue = new AttributeValue().withS(&quot;a6feb446-c7f2-4b48-9b3a-0f87744a5047&quot;);
 * AttributeValue titleValue = new AttributeValue().withS(&quot;Original title&quot;);
 * 
 * PutPointRequest putPointRequest = new PutPointRequest(geoPoint, rangeKeyValue);
 * putPointRequest.getPutItemRequest().getItem().put(&quot;title&quot;, titleValue);
 * List<PutPointRequest> putPointRequests = new ArrayList<PutPointRequest>();
 * putPointRequests.add(putPointRequest);
 * BatchWritePointResult batchWritePointResult = geoDataManager.batchWritePoints(putPointRequests);
 * </pre>
 * 
 * @param putPointRequests
 *            Container for the necessary parameters to execute put point request.
 * 
 * @return Result of batch put point request.
 */ 
public BatchWritePointResult batchWritePoints(List<PutPointRequest> putPointRequests) {
    return dynamoDBManager.batchWritePoints(putPointRequests);
}