private void initializeItem()

in src/main/java/com/amazonaws/partners/saasfactory/metering/aggregation/BillingEventAggregation.java [190:219]


    private void initializeItem(Map<String, AttributeValue> compositeKey, ZonedDateTime time) {
        // Format the statements
        AttributeValue idempotencyKeyValue = AttributeValue.builder()
                .s(UUID.randomUUID().toString().split(UUID_DELIMITER)[SELECTED_UUID_INDEX])
                .build();
        compositeKey.put(IDEMPOTENTCY_KEY_ATTRIBUTE_NAME, idempotencyKeyValue);

        AttributeValue submittedValue = AttributeValue.builder()
                .bool(false)
                .build();
        compositeKey.put(SUBMITTED_KEY_ATTRIBUTE_NAME, submittedValue);

        String conditionalStatement = String.format("attribute_not_exists(%s)", QUANTITY_ATTRIBUTE_NAME);

        PutItemRequest putItemRequest = PutItemRequest.builder()
                .tableName(this.tableConfig.getTableName())
                .item(compositeKey)
                .conditionExpression(conditionalStatement)
                .build();

        try {
            ddb.putItem(putItemRequest);
        } catch (ResourceNotFoundException|InternalServerErrorException e) {
            this.logger.error("{}", e.toString());
        } catch (ConditionalCheckFailedException e) {
            // Repeat the transaction and see if it works
            this.logger.error("Entry at {} already exists",
                    time.toInstant());
        }
    }