Skip to content

Commit

Permalink
feat(businessattribute): filter schema rows on business-attribute pro…
Browse files Browse the repository at this point in the history
…perties
  • Loading branch information
deepgarg-visa committed Oct 1, 2024
1 parent 171aad1 commit 862e038
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ function matchesTagsOrTermsOrDescription(field: SchemaField, filterText: string,
);
}

function matchesBusinessAttributesProperties(field: SchemaField, filterText: string, entityRegistry: EntityRegistry) {
if (!field.schemaFieldEntity?.businessAttributes) return false;
const businessAttributeProperties =
field.schemaFieldEntity?.businessAttributes?.businessAttribute?.businessAttribute?.properties;
return (
businessAttributeProperties?.description?.toLocaleLowerCase().includes(filterText) ||
businessAttributeProperties?.name?.toLocaleLowerCase().includes(filterText) ||
businessAttributeProperties?.glossaryTerms?.terms?.find((termAssociation) =>
entityRegistry
.getDisplayName(EntityType.GlossaryTerm, termAssociation.term)
.toLocaleLowerCase()
.includes(filterText),
) ||
businessAttributeProperties?.tags?.tags?.find((tagAssociation) =>
entityRegistry.getDisplayName(EntityType.Tag, tagAssociation.tag).toLocaleLowerCase().includes(filterText),
)
);
}

// returns list of fieldPaths for fields that have Terms or Tags or Descriptions matching the filterText
function getFilteredFieldPathsByMetadata(editableSchemaMetadata: any, entityRegistry, filterText) {
return (
Expand Down Expand Up @@ -56,7 +75,8 @@ export function filterSchemaRows(
if (
matchesFieldName(row.fieldPath, formattedFilterText) ||
matchesEditableTagsOrTermsOrDescription(row, filteredFieldPathsByEditableMetadata) ||
matchesTagsOrTermsOrDescription(row, formattedFilterText, entityRegistry) // non-editable tags, terms and description
matchesTagsOrTermsOrDescription(row, formattedFilterText, entityRegistry) || // non-editable tags, terms and description
matchesBusinessAttributesProperties(row, formattedFilterText, entityRegistry)
) {
finalFieldPaths.add(row.fieldPath);
}
Expand All @@ -65,7 +85,8 @@ export function filterSchemaRows(
if (
matchesFieldName(fieldName, formattedFilterText) ||
matchesEditableTagsOrTermsOrDescription(row, filteredFieldPathsByEditableMetadata) ||
matchesTagsOrTermsOrDescription(row, formattedFilterText, entityRegistry) // non-editable tags, terms and description
matchesTagsOrTermsOrDescription(row, formattedFilterText, entityRegistry) || // non-editable tags, terms and description
matchesBusinessAttributesProperties(row, formattedFilterText, entityRegistry)
) {
// if we match specifically on this field (not just its parent), add and expand all parents
splitFieldPath.reduce((previous, current) => {
Expand Down

0 comments on commit 862e038

Please sign in to comment.