Skip to content

Commit

Permalink
add code for add_domain operation
Browse files Browse the repository at this point in the history
  • Loading branch information
harsha-mandadi-4026 committed May 3, 2024
1 parent 9193d18 commit e8cfcf4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions metadata-ingestion/src/datahub/utilities/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from datahub.emitter.mce_builder import OwnerType
from datahub.metadata.schema_classes import (
AuditStampClass,
DomainsClass,
InstitutionalMemoryClass,
InstitutionalMemoryMetadataClass,
OwnerClass,
Expand Down Expand Up @@ -65,12 +66,14 @@ class Constants:
ADD_TERM_OPERATION = "add_term"
ADD_TERMS_OPERATION = "add_terms"
ADD_OWNER_OPERATION = "add_owner"
ADD_DOMAIN_OPERATION = "add_domain"
OPERATION = "operation"
OPERATION_CONFIG = "config"
TAG = "tag"
TERM = "term"
DOC_LINK = "link"
DOC_DESCRIPTION = "description"
DOMAIN = "domain"
OWNER_TYPE = "owner_type"
OWNER_CATEGORY = "owner_category"
MATCH = "match"
Expand Down Expand Up @@ -288,6 +291,10 @@ def convert_to_aspects(
f"Error while constructing aspect for documentation link and description : {e}"
)

if Constants.ADD_DOMAIN_OPERATION in operation_map:
domain_aspect = DomainsClass(domains=[operation_map[Constants.ADD_DOMAIN_OPERATION]])
aspect_map[Constants.ADD_DOMAIN_OPERATION] = domain_aspect

return aspect_map

def get_operation_value(
Expand Down Expand Up @@ -370,6 +377,8 @@ def get_operation_value(
for term in captured_terms.split(separator)
if term.strip()
]
elif operation_type == Constants.ADD_DOMAIN_OPERATION:
return mce_builder.make_domain_urn(operation_config[Constants.DOMAIN])
return None

def sanitize_owner_ids(self, owner_id: str) -> str:
Expand Down

0 comments on commit e8cfcf4

Please sign in to comment.