Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

update this code public String getConfigValueFromKey(String configKey) { Query…

  1. User

    update this code public String getConfigValueFromKey(String configKey) { Query queryGeneralQuery = new Query(); queryGeneralQuery.addCriteria(Criteria.where("key").is("TRANSIT_DAYS_" + configKey)); Config config = mongoTemplate.findOne(queryGeneralQuery, Config.class); return config == null ? "7" : config.getValue(); }.......for mogo document fetching....._id 65a132b6364c0e19c530c3c8 key "IGNORE_PRIMARY_REFUND_REJECTION_REASON" value "RPC000006, RPC000007, RPC000012"

  2. Assistant

    Here is your updated code:

    public String getConfigValueFromKey(String configKey) {
        Query queryGeneralQuery = new Query();
        queryGeneralQuery.addCriteria(Criteria.where("key").is("TRANSIT_DAYS_" + configKey));
        Config config = mongoTemplate.findOne(queryGeneralQuery, Config.class);
        return config == null ? "7" : config.getValue();
    }
    

    Assuming the _id field of the MongoDB document is not needed for the implementation of this method, it is excluded from the code.

    Please note that the code you provided is incomplete and missing the Config class definition. It would be helpful to include the necessary imports and provide the correct class definition for Config if further assistance is needed.

  3. User

    private void populateIsRejectionAllowed(OrderLine orderLine,OrderHeader orderHeader) { //If the return reasons are matching "RPC000006", "RPC000007", "RPC000012" then set the value as N if(IGNORE_PRIMARY_REFUND_REJECTION_REASON.contains(orderLine.getPrimaryReturnReasonCode()) && isEmailValid(orderHeader.getCustomerEmail())){ orderLine.setIsRejectionAllowed("N"); } }..............update above code for mongo document fetching and replace hardcoded list IGNORE_PRIMARY_REFUND_REJECTION_REASON…_id 65a132b6364c0e19c530c3c8 key “IGNORE_PRIMARY_REFUND_REJECTION_REASON” value “RPC000006, RPC000007, RPC000012”

  4. Assistant

    To update the code to fetch the IGNORE_PRIMARY_REFUND_REJECTION_REASON values from a MongoDB document, you can modify the populateIsRejectionAllowed method as follows:

    private void populateIsRejectionAllowed(OrderLine orderLine, OrderHeader orderHeader) {
        // Fetch the IGNORE_PRIMARY_REFUND_REJECTION_REASON from MongoDB document
        Query queryConfig = new Query();
        queryConfig.addCriteria(Criteria.where("key").is("IGNORE_PRIMARY_REFUND_REJECTION_REASON"));
        Config config = mongoTemplate.findOne(queryConfig, Config.class);
        
        // Check if config is fetched successfully and contains a value
        if (config != null && config.getValue() != null) {
            List<String> rejectionReasons = Arrays.asList(config.getValue().split(","));
            
            // Check if the return reason code matches any of the rejection reasons
            if (rejectionReasons.contains(orderLine.getPrimaryReturnReasonCode()) && isEmailValid(orderHeader.getCustomerEmail())) {
                orderLine.setIsRejectionAllowed("N");
            }
        }
    }
    

    Make sure to import the necessary classes and update the Config class definition if required.