Skip to content

If a role is duplicated and only one has a group, do not include the duplicate. - #434

Open
amandasinha wants to merge 2 commits into
developfrom
ams/RDFBROWSER-619-deduplicate-roles
Open

If a role is duplicated and only one has a group, do not include the duplicate.#434
amandasinha wants to merge 2 commits into
developfrom
ams/RDFBROWSER-619-deduplicate-roles

Conversation

@amandasinha

Copy link
Copy Markdown
Contributor

No description provided.

@amandasinha
amandasinha marked this pull request as ready for review August 3, 2026 19:40
@@ -157,6 +157,10 @@ export class Concept {
this.roles = new Array();
if (input.roles) {
for (let i = 0; i < input.roles.length; i++) {

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.

What you're doing here may work for your examples, but the logic is not quite right. There may be more than one that has different groups. What you want to do is have a "key" that takes into account the "identity" of the role independently of the group. Internally the java hashcode function uses relatedCode,relatedName,type,source. So the idea is to put them into a set based on a hash key and then extract that back to a list. something like this

const key = o => JSON.stringify([o.relatedCode, o.relatedName, o.source, o.type]);
this.roles = [...new Map(input.roles.map(o => [key(o), o])).values()];

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