@@ -4842,7 +4842,7 @@ def _get_synonym_info(
48424842 def set_synonym (
48434843 self ,
48444844 culture : str ,
4845- object : Union ["TOM.Table" , "TOM.Column" ],
4845+ object : Union ["TOM.Table" , "TOM.Column" , "TOM.Measure" , "TOM.Hierarchy" ],
48464846 synonym_name : str ,
48474847 weight : Optional [Decimal ] = None ,
48484848 ):
@@ -4851,12 +4851,12 @@ def set_synonym(
48514851
48524852 object_type = object .ObjectType
48534853
4854- if not any ( c . Name == culture for c in self . model . Cultures ):
4855- raise ValueError (
4856- f" { icons . red_dot } The ' { culture } ' culture does not exist within the semantic model."
4857- )
4858-
4859- if object_type not in [ TOM . ObjectType . Table , TOM . ObjectType . Column ]:
4854+ if object_type not in [
4855+ TOM . ObjectType . Table ,
4856+ TOM . ObjectType . Column ,
4857+ TOM . ObjectType . Measure ,
4858+ TOM . ObjectType . Hierarchy ,
4859+ ]:
48604860 raise ValueError (
48614861 f"{ icons .red_dot } This function only supports adding synonyms for tables or columns."
48624862 )
@@ -4865,9 +4865,7 @@ def set_synonym(
48654865 self ._add_linguistic_schema (culture = culture )
48664866
48674867 # Extract linguistic metadata content
4868- c = self .model .Cultures [culture ]
4869- lm_content = c .LinguisticMetadata .Content
4870- lm = json .loads (lm_content )
4868+ lm = json .loads (self .model .Cultures [culture ].LinguisticMetadata .Content )
48714869
48724870 # Generate synonym dictionary
48734871 _validate_weight (weight )
@@ -4916,7 +4914,9 @@ def set_synonym(
49164914 del lm ["Entities" ][obj ]["State" ]
49174915
49184916 if updated :
4919- c .LinguisticMetadata .Content = json .dumps (lm , indent = 4 )
4917+ self .model .Cultures [culture ].LinguisticMetadata .Content = json .dumps (
4918+ lm , indent = 4
4919+ )
49204920 if object_type == TOM .ObjectType .Table :
49214921 print (
49224922 f"{ icons .green_dot } The '{ synonym_name } ' synonym was set for the '{ object .Name } ' table."
@@ -4929,7 +4929,7 @@ def set_synonym(
49294929 def delete_synonym (
49304930 self ,
49314931 culture : str ,
4932- object : Union ["TOM.Table" , "TOM.Column" ],
4932+ object : Union ["TOM.Table" , "TOM.Column" , "TOM.Measure" , "TOM.Hierarchy" ],
49334933 synonym_name : str ,
49344934 ):
49354935
@@ -4940,14 +4940,17 @@ def delete_synonym(
49404940 f"{ icons .red_dot } The '{ culture } ' culture does not exist within the semantic model."
49414941 )
49424942
4943- if object .ObjectType not in [TOM .ObjectType .Table , TOM .ObjectType .Column ]:
4943+ if object .ObjectType not in [
4944+ TOM .ObjectType .Table ,
4945+ TOM .ObjectType .Column ,
4946+ TOM .ObjectType .Measure ,
4947+ TOM .ObjectType .Hierarchy ,
4948+ ]:
49444949 raise ValueError (
49454950 f"{ icons .red_dot } This function only supports tables or columns."
49464951 )
49474952
4948- c = self .model .Cultures [culture ]
4949- lm_content = c .LinguisticMetadata .Content
4950- lm = json .loads (lm_content )
4953+ lm = json .loads (self .model .Cultures [culture ].LinguisticMetadata .Content )
49514954
49524955 if "Entities" not in lm :
49534956 print (
@@ -4971,7 +4974,9 @@ def delete_synonym(
49714974 None ,
49724975 )
49734976
4974- c .LinguisticMetadata .Content = json .dumps (lm , indent = 4 )
4977+ self .model .Cultures [culture ].LinguisticMetadata .Content = json .dumps (
4978+ lm , indent = 4
4979+ )
49754980 print (
49764981 f"{ icons .green_dot } The '{ synonym_name } ' synonym was marked as status 'Deleted' for the '{ object .Name } ' object."
49774982 )
0 commit comments