@@ -124,6 +124,10 @@ class Type(Enum):
124124 RADIO = "radio"
125125 DROPDOWN = "dropdown"
126126
127+ class Scope (Enum ):
128+ GLOBAL = "global"
129+ INDEX = "index"
130+
127131 _REQUIRES_OPTIONS = {Type .CHECKLIST , Type .RADIO , Type .DROPDOWN }
128132
129133 class_type : Type
@@ -132,6 +136,7 @@ class Type(Enum):
132136 options : List [Option ] = field (default_factory = list )
133137 schema_id : Optional [str ] = None
134138 feature_schema_id : Optional [str ] = None
139+ scope : Scope = None
135140
136141 def __post_init__ (self ):
137142 if self .class_type == Classification .Type .DROPDOWN :
@@ -151,21 +156,31 @@ def from_dict(cls, dictionary: Dict[str, Any]) -> Dict[str, Any]:
151156 required = dictionary .get ("required" , False ),
152157 options = [Option .from_dict (o ) for o in dictionary ["options" ]],
153158 schema_id = dictionary .get ("schemaNodeId" , None ),
154- feature_schema_id = dictionary .get ("featureSchemaId" , None ))
159+ feature_schema_id = dictionary .get ("featureSchemaId" , None ),
160+ scope = cls .Scope (dictionary .get ("scope" , cls .Scope .GLOBAL )))
155161
156162 def asdict (self ) -> Dict [str , Any ]:
157163 if self .class_type in self ._REQUIRES_OPTIONS \
158164 and len (self .options ) < 1 :
159165 raise InconsistentOntologyException (
160166 f"Classification '{ self .instructions } ' requires options." )
161167 return {
162- "type" : self .class_type .value ,
163- "instructions" : self .instructions ,
164- "name" : self .name ,
165- "required" : self .required ,
168+ "type" :
169+ self .class_type .value ,
170+ "instructions" :
171+ self .instructions ,
172+ "name" :
173+ self .name ,
174+ "required" :
175+ self .required ,
166176 "options" : [o .asdict () for o in self .options ],
167- "schemaNodeId" : self .schema_id ,
168- "featureSchemaId" : self .feature_schema_id
177+ "schemaNodeId" :
178+ self .schema_id ,
179+ "featureSchemaId" :
180+ self .feature_schema_id ,
181+ "scope" :
182+ self .scope .value
183+ if self .scope is not None else self .Scope .GLOBAL .value
169184 }
170185
171186 def add_option (self , option : Option ) -> None :
0 commit comments