private UpdateItemRequest buildUpdateStatement()

in src/main/java/com/amazonaws/partners/saasfactory/metering/onboarding/OnboardNewTenant.java [79:118]


    private UpdateItemRequest buildUpdateStatement(OnboardingEvent onboardingEvent) {
        HashMap<String, AttributeValue> compositeKey = new HashMap<>();

        AttributeValue primaryKeyValue = AttributeValue.builder()
                .s(String.format("%s%s%s",
                                    TENANT_PREFIX,
                                    ATTRIBUTE_DELIMITER,
                                    onboardingEvent.getTenantID()))
                .build();

        compositeKey.put(PRIMARY_KEY_NAME, primaryKeyValue);

        AttributeValue sortKeyValue = AttributeValue.builder()
                .s(CONFIG_SORT_KEY_VALUE)
                .build();
        compositeKey.put(SORT_KEY_NAME, sortKeyValue);

        HashMap<String, String> expressionAttributeNames = new HashMap<>();
        expressionAttributeNames.put(EXTERNAL_SUBSCRIPTION_IDENTIFIER_EXPRESSION_NAME, EXTERNAL_SUBSCRIPTION_IDENTIFIER_ATTRIBUTE_NAME);

        HashMap<String, AttributeValue> expressionAttributeValues = new HashMap<>();
        AttributeValue externalProductCodeValue = AttributeValue.builder()
                .s(onboardingEvent.getExternalSubscriptionIdentifier())
                .build();

        expressionAttributeValues.put(EXTERNAL_SUBSCRIPTION_IDENTIFIER_EXPRESSION_VALUE, externalProductCodeValue);

        String updateStatement = String.format("SET %s = %s",
                EXTERNAL_SUBSCRIPTION_IDENTIFIER_EXPRESSION_NAME,
                EXTERNAL_SUBSCRIPTION_IDENTIFIER_EXPRESSION_VALUE);

        return UpdateItemRequest.builder()
                .tableName(this.tableConfig.getTableName())
                .key(compositeKey)
                .updateExpression(updateStatement)
                .expressionAttributeNames(expressionAttributeNames)
                .expressionAttributeValues(expressionAttributeValues)
                .build();

    }