From fd579bdd8c10cf16a4e3c8bde362a47184851232 Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Wed, 11 Oct 2023 14:31:11 +0530 Subject: [PATCH 01/11] Added code test changes --- .../controllers/accountController/getNoteDetails.scenarios.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/data/functional/controllers/accountController/getNoteDetails.scenarios.json b/src/test/resources/data/functional/controllers/accountController/getNoteDetails.scenarios.json index b2359c95..57766053 100644 --- a/src/test/resources/data/functional/controllers/accountController/getNoteDetails.scenarios.json +++ b/src/test/resources/data/functional/controllers/accountController/getNoteDetails.scenarios.json @@ -44,7 +44,7 @@ "note_detail": { "id": "0691e000001WY58AAG", "creator": "Ashfaq Bhojani", - "text": "\"

Let's use plural routes and have accountId in URL as per the API Convention.\\n/v1/account/content-notes => /v1/salesforce/accounts/{accountId}/content-notes\\n/v1/composite is generic. It can be under a salesforce route.\\n/v1/composite => /v1/salesforce/composite\\nQuestion:TextPreview in content notes response is a truncated version of the full text in notes?She suspicion dejection saw instantly. Well deny may real one told yet saw hard dear. Bed chief house rapid right the. Set noisy one state tears which. No girl oh part must fact high my he. Simplicity in excellence melancholy as remarkably discovered. Own partiality motionless was old excellence she inquietude contrasted. Sister giving so wicket cousin of an he rather marked. Of on game part body rich. Adapted mr savings venture it or comfort affixed friends.Prepared is me marianne pleasure likewise debating. Wonder an unable except better stairs do ye admire. His and eat secure sex called esteem praise. So moreover as speedily differed branched ignorant. Tall are her knew poor now does then. Procured to contempt oh he raptures amounted occasion. One boy assure income spirit lovers set.Passage its ten led hearted removal cordial. Preference any astonished unreserved mrs. Prosperous understood middletons in conviction an uncommonly do. Supposing so be resolving breakfast am or perfectly. Is drew am hill from mr. Valley by oh twenty direct me so. Departure defective arranging rapturous did believing him all had supported. Family months lasted simple set nature vulgar him. Picture for attempt joy excited ten carried manners talking how. Suspicion neglected he resolving agreement perceived at an.Dashwood contempt on mr unlocked resolved provided of of. Stanhill wondered it it welcomed oh. Hundred no prudent he however smiling at an offence. If earnestly extremity he he propriety something admitting convinced ye. Pleasant in to although as if differed horrible. Mirth his quick its set front enjoy hoped had there. Who connection imprudence middletons too but increasing celebrated principles joy. Herself too improve gay winding ask expense are compact. New all paid few hard pure she.That know ask case sex ham dear her spot. Weddings followed the all marianne nor whatever settling. Perhaps six prudent several her had offence. Did had way law dinner square tastes. Recommend concealed yet her procuring see consulted depending. Adieu

\"", + "text": "\"

Let's use plural routes and have accountId in URL as per the API Convention.\\n/v1/account/content-notes => /v1/salesforce/accounts/{accountId}/content-notes\\n/v1/composite is generic. It can be under a salesforce route.\\n/v1/composite => /v1/salesforce/composite\\nQuestion:TextPreview in content notes response is a truncated version of the full text in notes?She suspicion dejection saw instantly. Well deny may real one told yet saw hard dear. Bed chief house rapid right the. Set noisy one state tears which. No girl oh part must fact high my he. Simplicity in excellence melancholy as remarkably discovered. Own partiality motionless was old excellence she inquietude contrasted. Sister giving so wicket cousin of an he rather marked. Of on game part body rich. Adapted mr savings venture it or comfort affixed friends.Prepared is me marianne pleasure likewise debating. Wonder an unable except better stairs do ye admire. His and eat secure sex called esteem praise. So moreover as speedily differed branched ignorant. Tall are her knew poor now does then. Procured to contempt oh he raptures amounted occasion. One boy assure income spirit lovers set.Passage its ten led hearted removal cordial. Preference any astonished unreserved mrs. Prosperous understood middletons in conviction an uncommonly do. Supposing so be resolving breakfast am or perfectly. Is drew am hill from mr. Valley by oh twenty direct me so. Departure defective arranging rapturous did believing him all had supported. Family months lasted simple set nature vulgar him. Picture for attempt joy excited ten carried manners talking how. Suspicion neglected he resolving agreement perceived at an.Dashwood contempt on mr unlocked resolved provided of of. Stanhill wondered it it welcomed oh. Hundred no prudent he however smiling at an offence. If earnestly extremity he he propriety something admitting convinced ye. Pleasant in to although as if differed horrible. Mirth his quick its set front enjoy hoped had there. Who connection imprudence middletons too but increasing celebrated principles joy. Herself too improve gay winding ask expense are compact. New all paid few hard pure she.That know ask case sex ham dear her spot. Weddings followed the all marianne nor whatever settling. Perhaps six prudent several her had offence. Did had way law dinner square tastes. Recommend concealed yet her procuring see consulted depending. Adieu

\"", "last_modified_time": "2023-08-01T10:38:23.000+00:00" } } From 1504725da0a733a1efd2a592e784f7602396d36e Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Wed, 11 Oct 2023 14:54:13 +0530 Subject: [PATCH 02/11] Updated open ai prompt --- .../com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java b/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java index c2ffdd1a..4bf306c2 100644 --- a/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java +++ b/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java @@ -46,7 +46,7 @@ public String payloadForCrmActionsSuggestions(String text) { + " \"description\": \"Description for the event to add.\"\n" + " },\n" + " \"start_datetime\": {\n" + " \"type\": \"string\",\n" + " \"description\": \"Start Datetime for the event in yyyy-MM-dd'T'HH:mm:ss.SSS+0000 format.\"\n" - + " },\n" + " \"start_datetime\": {\n" + + " },\n" + " \"end_datetime\": {\n" + " \"type\": \"string\",\n" + " \"description\": \"End Datetime for the event in yyyy-MM-dd'T'HH:mm:ss.SSS+0000 format.\"\n" + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" From b3a76a991e9a451879ca9931fcf3692b9b1ebe4e Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Mon, 16 Oct 2023 10:28:46 +0530 Subject: [PATCH 03/11] Added TODO for payload of opan ai --- .../com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java b/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java index 4bf306c2..27913c85 100644 --- a/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java +++ b/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java @@ -19,6 +19,7 @@ public class OpenAiPayloadBuilder { public String payloadForCrmActionsSuggestions(String text) { String todayDate = getTodaysDate(); + // TODO - Use Jackson Library to build this JSON String payload = "{\n" + " \"model\": \"gpt-3.5-turbo-0613\",\n" + " \"messages\": [\n" + " {\n" + " \"role\": \"system\",\n" + " \"content\": \"You are an AI assistant that provides suggestions for creating tasks and events in CRM based solely on the content of the input message. The content of the task or event, if any found, should only be from the input message. If no task or event suggestions are found in the input message, return empty data. Suggestions can either be both task and event list or only tasks or only events or empty. If task suggestions are found, they should include description and due date. Due Date format should be YYYY-MM-DD. If event suggestions are found, they should include description and start datetime and end datetime. If end datetime not provided it should be start datetime + 1 hour. Start datetime and end datetime format is yyyy-MM-dd'T'HH:mm:ss.SSS+0000. Today's date is " From 53801c27ae245a0ef11f140c5d229414edeed65d Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Mon, 16 Oct 2023 10:31:12 +0530 Subject: [PATCH 04/11] Added null check for getTrimmedString --- src/main/java/com/salessparrow/api/lib/Util.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/salessparrow/api/lib/Util.java b/src/main/java/com/salessparrow/api/lib/Util.java index 0b6f5ac4..b14bbc85 100644 --- a/src/main/java/com/salessparrow/api/lib/Util.java +++ b/src/main/java/com/salessparrow/api/lib/Util.java @@ -188,6 +188,10 @@ public String replaceNewLineWithBreak(String input) { * @return String */ public String getTrimmedString(String input, Integer length) { + if (input == null) { + return null; + } + if (input.length() < length) { return input; } From 1bcc0722489038c166ad6f71f9b7e8480b285f2e Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Mon, 16 Oct 2023 10:51:54 +0530 Subject: [PATCH 05/11] Changed getTrimmedString to static method --- src/main/java/com/salessparrow/api/lib/Util.java | 8 ++++---- .../createAccountEvent/CreateSalesforceAccountEvent.java | 2 +- .../createAccountNote/CreateSalesforceNote.java | 2 +- .../updateAccountEvent/UpdateSalesforceAccountEvent.java | 2 +- .../updateAccountNote/UpdateSalesforceAccountNote.java | 2 +- .../updateAccountTask/UpdateSalesforceAccountTask.java | 2 +- .../salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/salessparrow/api/lib/Util.java b/src/main/java/com/salessparrow/api/lib/Util.java index b14bbc85..94470ccf 100644 --- a/src/main/java/com/salessparrow/api/lib/Util.java +++ b/src/main/java/com/salessparrow/api/lib/Util.java @@ -187,10 +187,10 @@ public String replaceNewLineWithBreak(String input) { * @param length * @return String */ - public String getTrimmedString(String input, Integer length) { - if (input == null) { - return null; - } + public static String getTrimmedString(String input, Integer length) { + if (input == null) { + return null; + } if (input.length() < length) { return input; diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java index 38c853ea..615a1238 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java @@ -53,7 +53,7 @@ public CreateEventFormatterDto createEvent(User user, String accountId, CreateAc Util util = new Util(); String eventDescription = util.unEscapeSpecialCharactersForPlainText(createEventDto.getDescription()); - String eventSubject = util.getTrimmedString(eventDescription, + String eventSubject = Util.getTrimmedString(eventDescription, salesforceConstants.salesforceEventSubjectLength()); Map createEventBody = new HashMap(); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateSalesforceNote.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateSalesforceNote.java index 3bc22745..bc5b751a 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateSalesforceNote.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateSalesforceNote.java @@ -57,7 +57,7 @@ public CreateNoteFormatterDto createNote(SalesforceUser user, String accountId, Util util = new Util(); String noteContent = note.getText(); String unEscapeNoteContent = util.unEscapeSpecialCharactersForPlainText(noteContent); - String noteTitle = util.getTrimmedString(unEscapeNoteContent, + String noteTitle = Util.getTrimmedString(unEscapeNoteContent, salesforceConstants.salesforceContentNoteTitleLength()); noteContent = util.replaceNewLineWithBreak(noteContent); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java index 947d9a34..3b26d569 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java @@ -51,7 +51,7 @@ public void updateEvent(User user, String accountId, String eventId, UpdateAccou Util util = new Util(); String eventDescription = util.unEscapeSpecialCharactersForPlainText(updateEventDto.getDescription()); - String eventSubject = util.getTrimmedString(eventDescription, + String eventSubject = Util.getTrimmedString(eventDescription, salesforceConstants.salesforceEventSubjectLength()); Map updateEventBody = new HashMap(); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java index b5d7a89e..ae74146c 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java @@ -57,7 +57,7 @@ public void updateNote(User user, String accountId, String noteId, AccountNoteDt String noteContent = accountNoteDto.getText(); String unEscapeNoteContent = util.unEscapeSpecialCharactersForPlainText(noteContent); - String noteTitle = util.getTrimmedString(unEscapeNoteContent, + String noteTitle = Util.getTrimmedString(unEscapeNoteContent, salesforceConstants.salesforceContentNoteTitleLength()); noteContent = util.replaceNewLineWithBreak(noteContent); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java index f67a4d0b..5f1804d0 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java @@ -51,7 +51,7 @@ public void updateTask(User user, String accountId, String taskId, UpdateAccount Util util = new Util(); String taskDescription = util.unEscapeSpecialCharactersForPlainText(updateTaskDto.getDescription()); - String taskSubject = util.getTrimmedString(taskDescription, salesforceConstants.salesforceTaskSubjectLength()); + String taskSubject = Util.getTrimmedString(taskDescription, salesforceConstants.salesforceTaskSubjectLength()); Map updateTaskBody = new HashMap(); updateTaskBody.put("Subject", taskSubject); diff --git a/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java b/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java index 27913c85..35ce37e0 100644 --- a/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java +++ b/src/main/java/com/salessparrow/api/lib/openAi/OpenAiPayloadBuilder.java @@ -19,7 +19,7 @@ public class OpenAiPayloadBuilder { public String payloadForCrmActionsSuggestions(String text) { String todayDate = getTodaysDate(); - // TODO - Use Jackson Library to build this JSON + // TODO - Use Jackson Library to build this JSON String payload = "{\n" + " \"model\": \"gpt-3.5-turbo-0613\",\n" + " \"messages\": [\n" + " {\n" + " \"role\": \"system\",\n" + " \"content\": \"You are an AI assistant that provides suggestions for creating tasks and events in CRM based solely on the content of the input message. The content of the task or event, if any found, should only be from the input message. If no task or event suggestions are found in the input message, return empty data. Suggestions can either be both task and event list or only tasks or only events or empty. If task suggestions are found, they should include description and due date. Due Date format should be YYYY-MM-DD. If event suggestions are found, they should include description and start datetime and end datetime. If end datetime not provided it should be start datetime + 1 hour. Start datetime and end datetime format is yyyy-MM-dd'T'HH:mm:ss.SSS+0000. Today's date is " From a93296bbdd7283b7298c244dbcc18108d4915a9b Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Mon, 16 Oct 2023 10:57:45 +0530 Subject: [PATCH 06/11] Added TODO to use Slf4j instead of logger --- .../com/salessparrow/api/controllers/AccountTaskController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/salessparrow/api/controllers/AccountTaskController.java b/src/main/java/com/salessparrow/api/controllers/AccountTaskController.java index 54a34218..0efc4823 100644 --- a/src/main/java/com/salessparrow/api/controllers/AccountTaskController.java +++ b/src/main/java/com/salessparrow/api/controllers/AccountTaskController.java @@ -34,6 +34,7 @@ @Validated public class AccountTaskController { + // TODO: Use Lombok's @Slf4j annotation instead of the following: Logger logger = LoggerFactory.getLogger(AccountTaskController.class); @Autowired From 39922f56fa983be953bd6f5a957762944073e15a Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Mon, 16 Oct 2023 11:11:12 +0530 Subject: [PATCH 07/11] Renamed Files --- ...CreateAccountTask.java => CreateAccountTaskInterface.java} | 4 ++-- .../createAccountTask/CreateSalesforceAccountTask.java | 2 +- ...leteAccountEvent.java => DeleteAccountEventInterface.java} | 4 ++-- .../deleteAccountEvent/DeleteSalesforceAccountEvent.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/{CreateAccountTask.java => CreateAccountTaskInterface.java} (75%) rename src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/{DeleteAccountEvent.java => DeleteAccountEventInterface.java} (66%) diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTask.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTaskInterface.java similarity index 75% rename from src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTask.java rename to src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTaskInterface.java index eb57e094..3ec40ba3 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTask.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTaskInterface.java @@ -7,10 +7,10 @@ import com.salessparrow.api.dto.requestMapper.CreateAccountTaskDto; /** - * CreateTask interface is interface for createTask for various CRM services + * CreateAccountTaskInterface interface is interface for createTask for various CRM services */ @Component -public interface CreateAccountTask { +public interface CreateAccountTaskInterface { public CreateTaskFormatterDto createAccountTask(User User, String accountId, CreateAccountTaskDto task); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateSalesforceAccountTask.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateSalesforceAccountTask.java index be02ebb9..9561abbd 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateSalesforceAccountTask.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateSalesforceAccountTask.java @@ -29,7 +29,7 @@ * CreateSalesforceTask class is responsible for creating a task in Salesforce */ @Component -public class CreateSalesforceAccountTask implements CreateAccountTask { +public class CreateSalesforceAccountTask implements CreateAccountTaskInterface { Logger logger = LoggerFactory.getLogger(CreateSalesforceAccountTask.class); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteAccountEvent.java b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteAccountEventInterface.java similarity index 66% rename from src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteAccountEvent.java rename to src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteAccountEventInterface.java index c93c59aa..d3572468 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteAccountEvent.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteAccountEventInterface.java @@ -5,10 +5,10 @@ import com.salessparrow.api.domain.User; /** - * DeleteAccountEvent is an interface for deleting an event in an account. + * DeleteAccountEventInterface is an interface for deleting an event in an account. */ @Component -public interface DeleteAccountEvent { +public interface DeleteAccountEventInterface { public void deleteAccountEvent(User user, String accountId, String eventId); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteSalesforceAccountEvent.java b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteSalesforceAccountEvent.java index 3d4e7aa0..e8129f75 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteSalesforceAccountEvent.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteSalesforceAccountEvent.java @@ -25,7 +25,7 @@ * account for salesforce. */ @Component -public class DeleteSalesforceAccountEvent implements DeleteAccountEvent { +public class DeleteSalesforceAccountEvent implements DeleteAccountEventInterface { Logger logger = LoggerFactory.getLogger(DeleteSalesforceAccountEvent.class); From b2ccfcbe9213fd0d9655026975dfbe7819e592f0 Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Mon, 16 Oct 2023 11:46:39 +0530 Subject: [PATCH 08/11] Changed util methods to static --- .../api/controllers/AccountTaskController.java | 2 +- src/main/java/com/salessparrow/api/lib/Util.java | 4 ++-- .../CreateSalesforceAccountEvent.java | 3 +-- .../createAccountNote/CreateSalesforceNote.java | 5 ++--- .../CreateAccountTaskInterface.java | 3 ++- .../CreateSalesforceAccountTask.java | 4 ++-- .../GetSalesforceAccountTaskDetails.java | 14 ++++++++------ .../UpdateSalesforceAccountEvent.java | 3 +-- .../UpdateSalesforceAccountNote.java | 6 ++---- .../UpdateSalesforceAccountTask.java | 3 +-- 10 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/salessparrow/api/controllers/AccountTaskController.java b/src/main/java/com/salessparrow/api/controllers/AccountTaskController.java index 0efc4823..0e9f38c9 100644 --- a/src/main/java/com/salessparrow/api/controllers/AccountTaskController.java +++ b/src/main/java/com/salessparrow/api/controllers/AccountTaskController.java @@ -34,7 +34,7 @@ @Validated public class AccountTaskController { - // TODO: Use Lombok's @Slf4j annotation instead of the following: + // TODO: Use Lombok's @Slf4j annotation instead of the following: Logger logger = LoggerFactory.getLogger(AccountTaskController.class); @Autowired diff --git a/src/main/java/com/salessparrow/api/lib/Util.java b/src/main/java/com/salessparrow/api/lib/Util.java index 94470ccf..afce9580 100644 --- a/src/main/java/com/salessparrow/api/lib/Util.java +++ b/src/main/java/com/salessparrow/api/lib/Util.java @@ -173,11 +173,11 @@ public String getDateFormatFromDatetime(Date date) { * @param input The original string containing escaped special characters. * @return A new string where certain special characters have been unescaped. */ - public String unEscapeSpecialCharactersForPlainText(String input) { + public static String unEscapeSpecialCharactersForPlainText(String input) { return input.replace("&", "&"); } - public String replaceNewLineWithBreak(String input) { + public static String replaceNewLineWithBreak(String input) { return input.replace("\n", "
"); } diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java index 615a1238..e93fc804 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java @@ -51,8 +51,7 @@ public CreateEventFormatterDto createEvent(User user, String accountId, CreateAc String salesforceUserId = user.getExternalUserId(); - Util util = new Util(); - String eventDescription = util.unEscapeSpecialCharactersForPlainText(createEventDto.getDescription()); + String eventDescription = Util.unEscapeSpecialCharactersForPlainText(createEventDto.getDescription()); String eventSubject = Util.getTrimmedString(eventDescription, salesforceConstants.salesforceEventSubjectLength()); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateSalesforceNote.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateSalesforceNote.java index bc5b751a..030a8635 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateSalesforceNote.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountNote/CreateSalesforceNote.java @@ -54,13 +54,12 @@ public class CreateSalesforceNote implements CreateNoteInterface { public CreateNoteFormatterDto createNote(SalesforceUser user, String accountId, AccountNoteDto note) { String salesforceUserId = user.getExternalUserId(); - Util util = new Util(); String noteContent = note.getText(); - String unEscapeNoteContent = util.unEscapeSpecialCharactersForPlainText(noteContent); + String unEscapeNoteContent = Util.unEscapeSpecialCharactersForPlainText(noteContent); String noteTitle = Util.getTrimmedString(unEscapeNoteContent, salesforceConstants.salesforceContentNoteTitleLength()); - noteContent = util.replaceNewLineWithBreak(noteContent); + noteContent = Util.replaceNewLineWithBreak(noteContent); String encodedNoteContent = base64Helper.base64Encode(noteContent); Map createNoteBody = new HashMap(); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTaskInterface.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTaskInterface.java index 3ec40ba3..8e044ea7 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTaskInterface.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateAccountTaskInterface.java @@ -7,7 +7,8 @@ import com.salessparrow.api.dto.requestMapper.CreateAccountTaskDto; /** - * CreateAccountTaskInterface interface is interface for createTask for various CRM services + * CreateAccountTaskInterface interface is interface for createTask for various CRM + * services */ @Component public interface CreateAccountTaskInterface { diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateSalesforceAccountTask.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateSalesforceAccountTask.java index 9561abbd..3a8e19de 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateSalesforceAccountTask.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountTask/CreateSalesforceAccountTask.java @@ -50,8 +50,8 @@ public CreateTaskFormatterDto createAccountTask(User User, String accountId, Cre String salesforceUserId = User.getExternalUserId(); logger.info("createAccountTask task description: {}", task.getDescription()); - Util util = new Util(); - String unEscapedTaskDescription = util.unEscapeSpecialCharactersForPlainText(task.getDescription()); + + String unEscapedTaskDescription = Util.unEscapeSpecialCharactersForPlainText(task.getDescription()); String taskSubject = getTaskSubjectFromDescription(unEscapedTaskDescription); logger.info("performing create task in salesforce"); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetSalesforceAccountTaskDetails.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetSalesforceAccountTaskDetails.java index 0af54c29..8fff05b5 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetSalesforceAccountTaskDetails.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetSalesforceAccountTaskDetails.java @@ -94,12 +94,14 @@ public GetTaskDetailsFormatterDto parseResponse(String responseBody) { ; TaskEntity taskEntity = new TaskEntity(); - for (JsonNode recordNode : recordsNode) { - ObjectMapper mapper = new ObjectMapper(); - mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - SalesforceGetTasksListDto salesforceGetTasksListDto = mapper.convertValue(recordNode, - SalesforceGetTasksListDto.class); - taskEntity = salesforceGetTasksListDto.taskEntity(); + if (recordsNode.size() > 0) { + for (JsonNode recordNode : recordsNode) { + ObjectMapper mapper = new ObjectMapper(); + mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + SalesforceGetTasksListDto salesforceGetTasksListDto = mapper.convertValue(recordNode, + SalesforceGetTasksListDto.class); + taskEntity = salesforceGetTasksListDto.taskEntity(); + } } GetTaskDetailsFormatterDto getTaskDetailsFormatterDto = new GetTaskDetailsFormatterDto(); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java index 3b26d569..ca1c10db 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java @@ -49,8 +49,7 @@ public void updateEvent(User user, String accountId, String eventId, UpdateAccou String salesforceUserId = user.getExternalUserId(); - Util util = new Util(); - String eventDescription = util.unEscapeSpecialCharactersForPlainText(updateEventDto.getDescription()); + String eventDescription = Util.unEscapeSpecialCharactersForPlainText(updateEventDto.getDescription()); String eventSubject = Util.getTrimmedString(eventDescription, salesforceConstants.salesforceEventSubjectLength()); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java index ae74146c..a16d58e6 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java @@ -53,14 +53,12 @@ public void updateNote(User user, String accountId, String noteId, AccountNoteDt logger.info("Update Salesforce Note started"); String salesforceUserId = user.getExternalUserId(); - Util util = new Util(); - String noteContent = accountNoteDto.getText(); - String unEscapeNoteContent = util.unEscapeSpecialCharactersForPlainText(noteContent); + String unEscapeNoteContent = Util.unEscapeSpecialCharactersForPlainText(noteContent); String noteTitle = Util.getTrimmedString(unEscapeNoteContent, salesforceConstants.salesforceContentNoteTitleLength()); - noteContent = util.replaceNewLineWithBreak(noteContent); + noteContent = Util.replaceNewLineWithBreak(noteContent); String encodedNoteContent = base64Helper.base64Encode(noteContent); Map updateNoteBody = new HashMap(); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java index 5f1804d0..7942b9f5 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java @@ -49,8 +49,7 @@ public void updateTask(User user, String accountId, String taskId, UpdateAccount String salesforceUserId = user.getExternalUserId(); - Util util = new Util(); - String taskDescription = util.unEscapeSpecialCharactersForPlainText(updateTaskDto.getDescription()); + String taskDescription = Util.unEscapeSpecialCharactersForPlainText(updateTaskDto.getDescription()); String taskSubject = Util.getTrimmedString(taskDescription, salesforceConstants.salesforceTaskSubjectLength()); Map updateTaskBody = new HashMap(); From be534d099e176dff250316decb637edd34e040dc Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Mon, 16 Oct 2023 12:06:12 +0530 Subject: [PATCH 09/11] Changed all logger to static final --- .../com/salessparrow/api/controllers/AccountController.java | 2 +- .../salessparrow/api/controllers/AccountEventController.java | 2 +- .../com/salessparrow/api/controllers/AccountNoteController.java | 2 +- .../com/salessparrow/api/controllers/SuggestionsController.java | 2 +- .../com/salessparrow/api/exception/GlobalExceptionHandler.java | 2 +- .../java/com/salessparrow/api/lib/GetCrmActionSuggestions.java | 2 +- .../createAccountEvent/CreateAccountEventFactory.java | 2 +- .../createAccountEvent/CreateSalesforceAccountEvent.java | 2 +- .../crmActions/deleteAccountNote/DeleteAccountNoteFactory.java | 2 +- .../deleteAccountNote/DeleteSalesforceAccountNote.java | 2 +- .../updateAccountEvent/UpdateAccountEventFactory.java | 2 +- .../updateAccountEvent/UpdateSalesforceAccountEvent.java | 2 +- .../crmActions/updateAccountNote/UpdateAccountNoteFactory.java | 2 +- .../updateAccountNote/UpdateSalesforceAccountNote.java | 2 +- .../crmActions/updateAccountTask/UpdateAccountTaskFactory.java | 2 +- .../updateAccountTask/UpdateSalesforceAccountTask.java | 2 +- .../java/com/salessparrow/api/lib/openAi/OpenAiRequest.java | 2 +- .../api/services/accountEvents/CreateAccountEventService.java | 2 +- .../api/services/accountNotes/DeleteAccountNoteService.java | 2 +- .../api/services/suggestions/CrmActionsSuggestionsService.java | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/salessparrow/api/controllers/AccountController.java b/src/main/java/com/salessparrow/api/controllers/AccountController.java index adaa9ab5..4050afa7 100644 --- a/src/main/java/com/salessparrow/api/controllers/AccountController.java +++ b/src/main/java/com/salessparrow/api/controllers/AccountController.java @@ -24,7 +24,7 @@ @Validated public class AccountController { - private Logger logger = org.slf4j.LoggerFactory.getLogger(AccountController.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(AccountController.class); @Autowired private GetAccountListService getAccountListService; diff --git a/src/main/java/com/salessparrow/api/controllers/AccountEventController.java b/src/main/java/com/salessparrow/api/controllers/AccountEventController.java index 1c313ae3..ac28d711 100644 --- a/src/main/java/com/salessparrow/api/controllers/AccountEventController.java +++ b/src/main/java/com/salessparrow/api/controllers/AccountEventController.java @@ -33,7 +33,7 @@ @Validated public class AccountEventController { - private Logger logger = org.slf4j.LoggerFactory.getLogger(AccountEventController.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(AccountEventController.class); @Autowired private CreateAccountEventService createEventService; diff --git a/src/main/java/com/salessparrow/api/controllers/AccountNoteController.java b/src/main/java/com/salessparrow/api/controllers/AccountNoteController.java index c2ef4167..c4bfd8d1 100644 --- a/src/main/java/com/salessparrow/api/controllers/AccountNoteController.java +++ b/src/main/java/com/salessparrow/api/controllers/AccountNoteController.java @@ -32,7 +32,7 @@ @Validated public class AccountNoteController { - private Logger logger = org.slf4j.LoggerFactory.getLogger(AccountNoteController.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(AccountNoteController.class); @Autowired private GetAccountNotesListService getNotesListService; diff --git a/src/main/java/com/salessparrow/api/controllers/SuggestionsController.java b/src/main/java/com/salessparrow/api/controllers/SuggestionsController.java index 0bef0c1e..f07c7df9 100644 --- a/src/main/java/com/salessparrow/api/controllers/SuggestionsController.java +++ b/src/main/java/com/salessparrow/api/controllers/SuggestionsController.java @@ -19,7 +19,7 @@ @Validated public class SuggestionsController { - private Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); @Autowired private CrmActionsSuggestionsService crmActionsSuggestionsService; diff --git a/src/main/java/com/salessparrow/api/exception/GlobalExceptionHandler.java b/src/main/java/com/salessparrow/api/exception/GlobalExceptionHandler.java index fe628eee..7ed1a7c0 100644 --- a/src/main/java/com/salessparrow/api/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/salessparrow/api/exception/GlobalExceptionHandler.java @@ -26,7 +26,7 @@ @ControllerAdvice public class GlobalExceptionHandler { - private Logger logger = org.slf4j.LoggerFactory.getLogger(GlobalExceptionHandler.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(GlobalExceptionHandler.class); @Autowired private ErrorResponse er; diff --git a/src/main/java/com/salessparrow/api/lib/GetCrmActionSuggestions.java b/src/main/java/com/salessparrow/api/lib/GetCrmActionSuggestions.java index 7d87c30f..fc14fb8c 100644 --- a/src/main/java/com/salessparrow/api/lib/GetCrmActionSuggestions.java +++ b/src/main/java/com/salessparrow/api/lib/GetCrmActionSuggestions.java @@ -39,7 +39,7 @@ public class GetCrmActionSuggestions { private DatetimeFormatValidator datetimeFormatValidator = new DatetimeFormatValidator(); - private Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); /** * Get the crm action suggestions. diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateAccountEventFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateAccountEventFactory.java index 434f8e29..54341752 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateAccountEventFactory.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateAccountEventFactory.java @@ -17,7 +17,7 @@ @Component public class CreateAccountEventFactory { - private Logger logger = org.slf4j.LoggerFactory.getLogger(CreateAccountEventFactory.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(CreateAccountEventFactory.class); @Autowired private CreateSalesforceAccountEvent createSalesforceEvent; diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java index e93fc804..0f689cbd 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/createAccountEvent/CreateSalesforceAccountEvent.java @@ -31,7 +31,7 @@ @Component public class CreateSalesforceAccountEvent implements CreateAccountEventInterface { - private Logger logger = org.slf4j.LoggerFactory.getLogger(CreateSalesforceAccountEvent.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(CreateSalesforceAccountEvent.class); @Autowired private SalesforceConstants salesforceConstants; diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteAccountNoteFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteAccountNoteFactory.java index c3cfce49..8f32eb8a 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteAccountNoteFactory.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteAccountNoteFactory.java @@ -16,7 +16,7 @@ @Component public class DeleteAccountNoteFactory { - private Logger logger = org.slf4j.LoggerFactory.getLogger(DeleteAccountNoteFactory.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(DeleteAccountNoteFactory.class); @Autowired DeleteSalesforceAccountNote getSalesforceNoteDetails; diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteSalesforceAccountNote.java b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteSalesforceAccountNote.java index 07bd0299..434f08bb 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteSalesforceAccountNote.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountNote/DeleteSalesforceAccountNote.java @@ -26,7 +26,7 @@ @Component public class DeleteSalesforceAccountNote implements DeleteAccountNoteInterface { - private Logger logger = org.slf4j.LoggerFactory.getLogger(DeleteSalesforceAccountNote.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(DeleteSalesforceAccountNote.class); @Autowired private SalesforceConstants salesforceConstants; diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateAccountEventFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateAccountEventFactory.java index ad9cb5ae..44fe8d5d 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateAccountEventFactory.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateAccountEventFactory.java @@ -16,7 +16,7 @@ @Component public class UpdateAccountEventFactory { - private Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateAccountEventFactory.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateAccountEventFactory.class); @Autowired private UpdateSalesforceAccountEvent updateSalesforceEvent; diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java index ca1c10db..2c1299ed 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountEvent/UpdateSalesforceAccountEvent.java @@ -29,7 +29,7 @@ @Component public class UpdateSalesforceAccountEvent implements UpdateAccountEventInterface { - private Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateSalesforceAccountEvent.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateSalesforceAccountEvent.class); @Autowired private SalesforceConstants salesforceConstants; diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateAccountNoteFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateAccountNoteFactory.java index 3f08cd00..1b304287 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateAccountNoteFactory.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateAccountNoteFactory.java @@ -16,7 +16,7 @@ @Component public class UpdateAccountNoteFactory { - private Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateAccountNoteFactory.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateAccountNoteFactory.class); @Autowired private UpdateSalesforceAccountNote updateSalesforceNote; diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java index a16d58e6..63ec6929 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountNote/UpdateSalesforceAccountNote.java @@ -30,7 +30,7 @@ @Component public class UpdateSalesforceAccountNote implements UpdateAccountNoteInterface { - private Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateSalesforceAccountNote.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateSalesforceAccountNote.class); @Autowired private SalesforceConstants salesforceConstants; diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateAccountTaskFactory.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateAccountTaskFactory.java index fefefb57..85b14968 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateAccountTaskFactory.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateAccountTaskFactory.java @@ -16,7 +16,7 @@ @Component public class UpdateAccountTaskFactory { - private Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateAccountTaskFactory.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateAccountTaskFactory.class); @Autowired private UpdateSalesforceAccountTask updateSalesforceTask; diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java index 7942b9f5..6bf18ae4 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/updateAccountTask/UpdateSalesforceAccountTask.java @@ -29,7 +29,7 @@ @Component public class UpdateSalesforceAccountTask implements UpdateAccountTaskInterface { - private Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateSalesforceAccountTask.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(UpdateSalesforceAccountTask.class); @Autowired private SalesforceConstants salesforceConstants; diff --git a/src/main/java/com/salessparrow/api/lib/openAi/OpenAiRequest.java b/src/main/java/com/salessparrow/api/lib/openAi/OpenAiRequest.java index c9389108..e29c828d 100644 --- a/src/main/java/com/salessparrow/api/lib/openAi/OpenAiRequest.java +++ b/src/main/java/com/salessparrow/api/lib/openAi/OpenAiRequest.java @@ -24,7 +24,7 @@ public class OpenAiRequest { @Autowired private OpenAiConstants openAiConstants; - private Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); /** * Make a request to the OpenAI API. diff --git a/src/main/java/com/salessparrow/api/services/accountEvents/CreateAccountEventService.java b/src/main/java/com/salessparrow/api/services/accountEvents/CreateAccountEventService.java index 6ce0a0dd..ae21eb43 100644 --- a/src/main/java/com/salessparrow/api/services/accountEvents/CreateAccountEventService.java +++ b/src/main/java/com/salessparrow/api/services/accountEvents/CreateAccountEventService.java @@ -18,7 +18,7 @@ @Service public class CreateAccountEventService { - private Logger logger = org.slf4j.LoggerFactory.getLogger(CreateAccountEventService.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(CreateAccountEventService.class); @Autowired private CreateAccountEventFactory createAccountEventFactory; diff --git a/src/main/java/com/salessparrow/api/services/accountNotes/DeleteAccountNoteService.java b/src/main/java/com/salessparrow/api/services/accountNotes/DeleteAccountNoteService.java index 2c5843b9..2aaf22bf 100644 --- a/src/main/java/com/salessparrow/api/services/accountNotes/DeleteAccountNoteService.java +++ b/src/main/java/com/salessparrow/api/services/accountNotes/DeleteAccountNoteService.java @@ -16,7 +16,7 @@ @Service public class DeleteAccountNoteService { - private Logger logger = org.slf4j.LoggerFactory.getLogger(DeleteAccountNoteService.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(DeleteAccountNoteService.class); @Autowired private DeleteAccountNoteFactory deleteAccountNoteFactory; diff --git a/src/main/java/com/salessparrow/api/services/suggestions/CrmActionsSuggestionsService.java b/src/main/java/com/salessparrow/api/services/suggestions/CrmActionsSuggestionsService.java index 2923e2e2..f2ad3ecd 100644 --- a/src/main/java/com/salessparrow/api/services/suggestions/CrmActionsSuggestionsService.java +++ b/src/main/java/com/salessparrow/api/services/suggestions/CrmActionsSuggestionsService.java @@ -18,7 +18,7 @@ public class CrmActionsSuggestionsService { @Autowired private GetCrmActionSuggestions getCrmActionSuggestions; - private Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); + private static final Logger logger = org.slf4j.LoggerFactory.getLogger(SuggestionsController.class); public CrmActionSuggestionsFormatterDto getSuggestions(CrmActionsSuggestionsDto crmActionsSuggestionsDto) { logger.info("Crm actions service called"); From 491cff015d4a366ba30266d4b51da04bb6043b9f Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Mon, 16 Oct 2023 14:08:23 +0530 Subject: [PATCH 10/11] Removed Owner class from SalesforceGetEventsListDto --- .../deleteAccountEvent/DeleteSalesforceAccountEvent.java | 3 ++- .../lib/salesforce/dto/SalesforceGetEventsListDto.java | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteSalesforceAccountEvent.java b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteSalesforceAccountEvent.java index e8129f75..9bb2200a 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteSalesforceAccountEvent.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/deleteAccountEvent/DeleteSalesforceAccountEvent.java @@ -27,6 +27,8 @@ @Component public class DeleteSalesforceAccountEvent implements DeleteAccountEventInterface { + private final Util util = new Util(); + Logger logger = LoggerFactory.getLogger(DeleteSalesforceAccountEvent.class); @Autowired @@ -67,7 +69,6 @@ public void deleteAccountEvent(User user, String accountId, String eventId) { */ private void parseResponse(String responseBody) { logger.info("Parsing response body"); - Util util = new Util(); JsonNode rootNode = util.getJsonNode(responseBody); JsonNode deleteEventCompositeResponse = rootNode.get("compositeResponse").get(0); diff --git a/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetEventsListDto.java b/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetEventsListDto.java index 496a49cb..26bf7e84 100644 --- a/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetEventsListDto.java +++ b/src/main/java/com/salessparrow/api/lib/salesforce/dto/SalesforceGetEventsListDto.java @@ -32,14 +32,6 @@ private class CreatedBy { } - @Data - @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class) - private class Owner { - - private String name; - - } - public EventEntity eventEntity() { EventEntity eventEntity = new EventEntity(); From 32264e69dc47ce5b6a5a25554dd207ebc5ecbed3 Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Mon, 16 Oct 2023 16:39:03 +0530 Subject: [PATCH 11/11] Removed extra semicolons --- .../GetSalesforceAccountEventDetails.java | 15 ++++++++------- .../GetSalesforceAccountEventsList.java | 1 - .../GetSalesforceAccountTaskDetails.java | 5 ++--- .../GetSalesforceAccountTasksList.java | 1 - 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetSalesforceAccountEventDetails.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetSalesforceAccountEventDetails.java index a32eae5b..7a29d623 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetSalesforceAccountEventDetails.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventDetails/GetSalesforceAccountEventDetails.java @@ -91,15 +91,16 @@ public GetEventDetailsFormatterDto parseResponse(String responseBody) { } JsonNode recordsNode = rootNode.get("compositeResponse").get(0).get("body").get("records"); - ; EventEntity eventEntity = new EventEntity(); - for (JsonNode recordNode : recordsNode) { - ObjectMapper mapper = new ObjectMapper(); - mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - SalesforceGetEventsListDto salesforceGetEventsListDto = mapper.convertValue(recordNode, - SalesforceGetEventsListDto.class); - eventEntity = salesforceGetEventsListDto.eventEntity(); + if (recordsNode.size() > 0) { + for (JsonNode recordNode : recordsNode) { + ObjectMapper mapper = new ObjectMapper(); + mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + SalesforceGetEventsListDto salesforceGetEventsListDto = mapper.convertValue(recordNode, + SalesforceGetEventsListDto.class); + eventEntity = salesforceGetEventsListDto.eventEntity(); + } } GetEventDetailsFormatterDto getEventDetailsFormatterDto = new GetEventDetailsFormatterDto(); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetSalesforceAccountEventsList.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetSalesforceAccountEventsList.java index 4e1ae8ab..6802ffcf 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetSalesforceAccountEventsList.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountEventsList/GetSalesforceAccountEventsList.java @@ -98,7 +98,6 @@ public GetEventsListFormatterDto parseResponse(String responseBody) { } JsonNode recordsNode = rootNode.get("compositeResponse").get(0).get("body").get("records"); - ; for (JsonNode recordNode : recordsNode) { ObjectMapper mapper = new ObjectMapper(); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetSalesforceAccountTaskDetails.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetSalesforceAccountTaskDetails.java index 8fff05b5..f269ec86 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetSalesforceAccountTaskDetails.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTaskDetails/GetSalesforceAccountTaskDetails.java @@ -91,13 +91,12 @@ public GetTaskDetailsFormatterDto parseResponse(String responseBody) { } JsonNode recordsNode = rootNode.get("compositeResponse").get(0).get("body").get("records"); - ; TaskEntity taskEntity = new TaskEntity(); if (recordsNode.size() > 0) { + ObjectMapper mapper = new ObjectMapper(); + mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); for (JsonNode recordNode : recordsNode) { - ObjectMapper mapper = new ObjectMapper(); - mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); SalesforceGetTasksListDto salesforceGetTasksListDto = mapper.convertValue(recordNode, SalesforceGetTasksListDto.class); taskEntity = salesforceGetTasksListDto.taskEntity(); diff --git a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTasksList/GetSalesforceAccountTasksList.java b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTasksList/GetSalesforceAccountTasksList.java index 5d29e90d..24bc2a27 100644 --- a/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTasksList/GetSalesforceAccountTasksList.java +++ b/src/main/java/com/salessparrow/api/lib/crmActions/getAccountTasksList/GetSalesforceAccountTasksList.java @@ -98,7 +98,6 @@ public GetTasksListFormatterDto parseResponse(String responseBody) { } JsonNode recordsNode = rootNode.get("compositeResponse").get(0).get("body").get("records"); - ; for (JsonNode recordNode : recordsNode) { ObjectMapper mapper = new ObjectMapper();