Skip to content

D43121_ RQM Category and Custom attributes update fix#4019

Merged
Maheshkale447 merged 3 commits into
Releases/Official-Releasefrom
BugFix/RQMUpdateCategoryFix
Dec 5, 2024
Merged

D43121_ RQM Category and Custom attributes update fix#4019
Maheshkale447 merged 3 commits into
Releases/Official-Releasefrom
BugFix/RQMUpdateCategoryFix

Conversation

@prashelke

@prashelke prashelke commented Dec 4, 2024

Copy link
Copy Markdown
Contributor

Thank you for your contribution.
Before submitting this PR, please make sure:

  • PR description and commit message should describe the changes done in this PR
  • Verify the PR is pointing to correct branch i.e. Release or Beta branch if the code fix is for specific release , else point it to master
  • Latest Code from master or specific release branch is merged to your branch
  • No unwanted\commented\junk code is included
  • No new warning upon build solution
  • Code Summary\Comments are added to my code which explains what my code is doing
  • Existing unit test cases are passed
  • New Unit tests are added for your development
  • Sanity Tests are successfully executed for New and Existing Functionality
  • Verify that changes are compatible with all relevant browsers and platforms.
  • After creating pull request there should not be any conflicts
  • Resolve all Codacy comments
  • Builds and checks are passed before PR is sent for review
  • Resolve code review comments
  • Update the Help Library document to match any feature changes

Summary by CodeRabbit

  • New Features

    • Introduced new properties PossibleValueKeys and SelectedValueKey for enhanced management of external item fields.
    • Added methods to retrieve and update selected value keys based on current selections.
  • Bug Fixes

    • Improved error handling and logging during export processes to ensure better user feedback.
    • Enhanced synchronization of selected values with their corresponding keys during refresh processes.
  • Documentation

    • Updated documentation to reflect new properties and methods related to external item fields.

@coderabbitai

coderabbitai Bot commented Dec 4, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The changes involve modifications to the ExternalItemFieldBase class and related components within the GingerCore library. New properties, PossibleValueKeys and SelectedValueKey, have been added to enhance the management of external item fields. Additionally, methods across various classes have been updated to incorporate these new properties, improving the synchronization and handling of selected values and their corresponding keys during operations such as refresh and export/import processes.

Changes

File Path Change Summary
Ginger/GingerCoreCommon/Repository/ALMLib/ExternalItemFieldBase.cs - Added properties: PossibleValueKeys, SelectedValueKey.
- Updated SelectedValue logic to include UpdateSelectedValueKey.
Ginger/GingerCoreNET/ALMLib/Generic/ALMCore.cs - Updated RefreshALMItemFields method to handle PossibleValueKeys during field updates.
Ginger/GingerCoreNET/ALMLib/RQM/ExportToRQM.cs - Added SelectedValueKey property.
- Enhanced error handling and logging in export methods.
Ginger/GingerCoreNET/ALMLib/RQM/ImportFromRQM.cs - Added properties: PossibleValueKeys, SelectedValueKey.
- Updated methods to utilize new properties.
Ginger/GingerCoreNET/External/JsonExternalItemField.cs - Added properties: PossibleValueKeys, SelectedKey.
Ginger/GingerCoreNET/GeneralLib/General.cs - Added method: UpdateSelectedValueKey to retrieve key based on SelectedValue and ProjectGuid.
- Updated MapExternalField method to include SelectedValueKey.

Possibly related PRs

  • RQM Changes for Dynamic Field Mapping #3984: This PR introduces a new method for retrieving external fields and modifies the UpdateALMType method to handle RQM, which is directly related to the changes made in the main PR regarding the ExternalItemFieldBase class and its properties.
  • D44105_D44104_D44103 RQM BugFix related to dynamic filed mapping #3987: This PR refactors the ExportBusinessFlowToALM method to improve the handling of external fields, which aligns with the main PR's focus on adding properties to ExternalItemFieldBase for managing possible values and selected keys.
  • RQM fixes for custom Attributes #3997: This PR enhances the export functionality for execution details to RQM, including validation of external fields, which is closely related to the changes in the main PR that involve managing external item fields and their properties.

Suggested reviewers

  • Maheshkale447

🐰 "In fields of data, we hop and play,
New keys and values brighten the way.
With every change, our burrow grows,
In code we trust, as the rabbit knows!
So let’s celebrate, with a joyful cheer,
For enhancements made, we hold so dear!" 🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fc7b6c5 and 7cfd752.

📒 Files selected for processing (1)
  • Ginger/GingerCoreCommon/Repository/ALMLib/ExternalItemFieldBase.cs (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Ginger/GingerCoreCommon/Repository/ALMLib/ExternalItemFieldBase.cs

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
Ginger/GingerCoreNET/External/JsonExternalItemField.cs (1)

30-32: LGTM! Consider adding documentation.

The new properties PossibleValueKeys and SelectedKey align well with the existing structure. Consider adding XML documentation comments to explain their purpose and relationship with PossibleValues and Selected properties.

 public class JsonExternalItemField
 {
     public string ID { get; set; }
     public string Name { get; set; }
     public string ItemType { get; set; }
     public bool Mandatory { get; set; }
     public ObservableList<string> PossibleValues { get; set; }
+    /// <summary>
+    /// Gets or sets the keys corresponding to each possible value in PossibleValues.
+    /// </summary>
     public ObservableList<string> PossibleValueKeys { get; set; }
     public string Selected { get; set; }
+    /// <summary>
+    /// Gets or sets the key corresponding to the Selected value.
+    /// </summary>
     public string SelectedKey { get; set; }
Ginger/GingerCoreNET/ALMLib/Generic/ALMCore.cs (1)

374-375: Consider improving the robustness of field synchronization.

The synchronization of value keys is implemented correctly, but the code could be more maintainable:

  1. The logic for updating selected values and keys is spread across multiple conditions
  2. Similar code is repeated in multiple branches

Consider extracting the synchronization logic into a separate method:

+private void SyncFieldValues(ExternalItemFieldBase currentField, ExternalItemFieldBase latestField)
+{
+    int selectedElementIndex = latestField.PossibleValues.IndexOf(currentField.SelectedValue);
+    if (selectedElementIndex != -1)
+    {
+        currentField.SelectedValue = latestField.PossibleValues[selectedElementIndex];
+        currentField.SelectedValueKey = latestField.PossibleValueKeys[selectedElementIndex];
+    }
+    else
+    {
+        currentField.SelectedValue = latestField.SelectedValue;
+        currentField.SelectedValueKey = latestField.SelectedValueKey;
+    }
+}

Then use it in the refresh method:

 if ((latestField.PossibleValues.Count == 0 && currentField.SelectedValue != latestField.SelectedValue) || 
     (latestField.PossibleValues.Count > 0 && latestField.PossibleValues.Contains(currentField.SelectedValue) && 
      currentField.SelectedValue != latestField.PossibleValues[0]))
 {
     currentField.ToUpdate = true;
-    int SelectedElementIndex = latestField.PossibleValues.IndexOf(currentField.SelectedValue);
-    if(SelectedElementIndex != -1)
-    {
-        currentField.SelectedValue = latestField.PossibleValues[SelectedElementIndex];
-        currentField.SelectedValueKey = latestField.PossibleValueKeys[SelectedElementIndex];
-    }
-    else
-    {
-        currentField.SelectedValue = latestField.SelectedValue;
-        currentField.SelectedValueKey = latestField.SelectedValueKey;
-    }
+    SyncFieldValues(currentField, latestField);
 }

Also applies to: 382-392, 397-397, 404-404

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7c3a169 and 031ec8c.

⛔ Files ignored due to path filters (3)
  • Ginger/GingerCoreNET/DLLS/ACL_Data_Contract.dll is excluded by !**/*.dll, !**/*.dll
  • Ginger/GingerCoreNET/DLLS/RQMExportStd.dll is excluded by !**/*.dll, !**/*.dll
  • Ginger/GingerCoreNET/DLLS/RQM_RepositoryStd.dll is excluded by !**/*.dll, !**/*.dll
📒 Files selected for processing (6)
  • Ginger/GingerCoreCommon/Repository/ALMLib/ExternalItemFieldBase.cs (5 hunks)
  • Ginger/GingerCoreNET/ALMLib/Generic/ALMCore.cs (1 hunks)
  • Ginger/GingerCoreNET/ALMLib/RQM/ExportToRQM.cs (1 hunks)
  • Ginger/GingerCoreNET/ALMLib/RQM/ImportFromRQM.cs (4 hunks)
  • Ginger/GingerCoreNET/External/JsonExternalItemField.cs (1 hunks)
  • Ginger/GingerCoreNET/GeneralLib/General.cs (4 hunks)
👮 Files not reviewed due to content moderation or server errors (3)
  • Ginger/GingerCoreNET/GeneralLib/General.cs
  • Ginger/GingerCoreNET/ALMLib/RQM/ExportToRQM.cs
  • Ginger/GingerCoreNET/ALMLib/RQM/ImportFromRQM.cs
🔇 Additional comments (1)
Ginger/GingerCoreCommon/Repository/ALMLib/ExternalItemFieldBase.cs (1)

85-97: LGTM! Properties are well-implemented.

The new properties PossibleValueKeys and SelectedValueKey are properly implemented with:

  • Private backing fields
  • Property change notifications
  • Serialization attributes where needed

Also applies to: 118-134

Comment thread Ginger/GingerCoreCommon/Repository/ALMLib/ExternalItemFieldBase.cs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
Ginger/GingerCoreNET/ALMLib/RQM/ImportFromRQM.cs (3)

Line range hint 1224-1252: Add null check and optimize the code.

The code has several potential improvements:

  1. Add null check before accessing index at line 1251
  2. Use LINQ for more efficient and cleaner code
  3. Use consistent string comparison

Consider this refactor:

-                        var titles = doc.Descendants(ns + "entry")
-                                        .Select(entry => entry)
-                                        .Where(title => title != null);
+                        var entries = doc.Descendants(ns + "entry")
+                                        .Where(entry => entry != null);

-                            foreach (var title in titles)
-                            {
-                                field.PossibleValues.Add(title.Element(ns + "title")?.Value);
-                                string PossibleValueKey = title.Element(ns + "id")?.Value;
-                                string PossibleValueKeyID = PossibleValueKey[(PossibleValueKey.LastIndexOf(':') + 1)..];
-                                field.PossibleValueKeys.Add(PossibleValueKeyID);
-                            }
+                            foreach (var entry in entries)
+                            {
+                                var titleValue = entry.Element(ns + "title")?.Value;
+                                var idValue = entry.Element(ns + "id")?.Value;
+                                
+                                if (titleValue != null && idValue != null)
+                                {
+                                    field.PossibleValues.Add(titleValue);
+                                    field.PossibleValueKeys.Add(idValue[(idValue.LastIndexOf(':') + 1)..]);
+                                }
+                            }

-                            if (field.SelectedValue.Equals("Unassigned",StringComparison.CurrentCultureIgnoreCase) && field.PossibleValues.Count > 0)
+                            if (string.Equals(field.SelectedValue, "Unassigned", StringComparison.CurrentCultureIgnoreCase) && field.PossibleValues.Count > 0)
                            {
                                field.SelectedValue = field.PossibleValues[0];
                                field.SelectedValueKey = field.PossibleValueKeys[0];
                            }
                            else
                            {
-                               int SelectedElementIndex = field.PossibleValues.IndexOf(field.SelectedValue);
-                               field.SelectedValueKey = field.PossibleValueKeys[SelectedElementIndex];
+                               int selectedElementIndex = field.PossibleValues.IndexOf(field.SelectedValue);
+                               if (selectedElementIndex >= 0 && selectedElementIndex < field.PossibleValueKeys.Count)
+                               {
+                                   field.SelectedValueKey = field.PossibleValueKeys[selectedElementIndex];
+                               }
                            }

Line range hint 4-4: Address TODO comment for test coverage.

The TODO comment indicates missing tests. This should be addressed to ensure proper test coverage.

Would you like me to help create unit tests for this functionality?


Line range hint 1-1600: Consider reducing code duplication in error handling.

There are several instances of duplicated error handling code throughout the file. Consider extracting common error handling logic into a reusable method.

Consider creating a helper method:

+ private static void HandleRQMError(string methodName, Exception ex, string customMessage = null)
+ {
+     string message = customMessage ?? $"Method - {methodName}, Error - {ex.Message}";
+     Reporter.ToLog(eLogLevel.ERROR, message, ex);
+ }

Then use it consistently throughout the code:

- catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex); }
+ catch (Exception ex) { HandleRQMError(MethodBase.GetCurrentMethod().Name, ex); }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 031ec8c and fc7b6c5.

📒 Files selected for processing (2)
  • Ginger/GingerCoreCommon/Repository/ALMLib/ExternalItemFieldBase.cs (5 hunks)
  • Ginger/GingerCoreNET/ALMLib/RQM/ImportFromRQM.cs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Ginger/GingerCoreCommon/Repository/ALMLib/ExternalItemFieldBase.cs
🔇 Additional comments (2)
Ginger/GingerCoreNET/ALMLib/RQM/ImportFromRQM.cs (2)

952-954: LGTM! Properties are correctly serialized.

The new properties PossibleValueKeys and SelectedValueKey are properly included in the JSON serialization process, maintaining consistency with the existing property serialization pattern.


915-929: LGTM! Verify data consistency between values and keys.

The addition of PossibleValueKeys and SelectedValueKey properties is implemented correctly, with proper initialization and default value handling. The implementation maintains consistency with the existing PossibleValues property.

✅ Verification successful

Based on the search results, I can now generate the final response since I have enough information to verify the data consistency between PossibleValues and PossibleValueKeys:

Data consistency between values and keys is properly maintained

The codebase shows consistent handling of PossibleValues and PossibleValueKeys arrays:

  • Both arrays are initialized together in ExternalItemFieldBase.cs with empty lists
  • The arrays are always modified in pairs:
    • In ImportFromRQM.cs when populating from JSON
    • In ALMCore.cs when updating fields
    • In RQM integration code when adding new values
  • The code includes validation to ensure array lengths match before accessing indices
  • Default/fallback values are handled consistently for both arrays
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that PossibleValueKeys and PossibleValues are always in sync
# Search for any instances where these properties might be modified independently

rg -A 5 "PossibleValueKeys|PossibleValues" --type cs

Length of output: 65914

@Maheshkale447
Maheshkale447 merged commit 43c27b5 into Releases/Official-Release Dec 5, 2024
@Maheshkale447
Maheshkale447 deleted the BugFix/RQMUpdateCategoryFix branch December 5, 2024 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants