32
32
from .._internal .compare import ComparableTuple as _ComparableTuple
33
33
from ..exception .model import MutuallyExclusivePropertiesException
34
34
from ..exception .serialization import CycloneDxDeserializationException
35
- from ..schema .schema import SchemaVersion1Dot6
36
- from . import AttachedText , XsUri
35
+ from ..schema .schema import SchemaVersion1Dot6 , SchemaVersion1Dot5
36
+ from . import AttachedText , XsUri , BomRef
37
+ from .._internal .bom_ref import bom_ref_from_str as _bom_ref_from_str
37
38
38
39
39
40
@serializable .serializable_enum
@@ -75,6 +76,7 @@ class DisjunctiveLicense:
75
76
76
77
def __init__ (
77
78
self , * ,
79
+ bom_ref : Optional [Union [str , BomRef ]] = None ,
78
80
id : Optional [str ] = None , name : Optional [str ] = None ,
79
81
text : Optional [AttachedText ] = None , url : Optional [XsUri ] = None ,
80
82
acknowledgement : Optional [LicenseAcknowledgement ] = None ,
@@ -86,12 +88,31 @@ def __init__(
86
88
'Both `id` and `name` have been supplied - `name` will be ignored!' ,
87
89
category = RuntimeWarning , stacklevel = 1
88
90
)
91
+ self ._bom_ref = _bom_ref_from_str (bom_ref )
89
92
self ._id = id
90
93
self ._name = name if not id else None
91
94
self ._text = text
92
95
self ._url = url
93
96
self ._acknowledgement = acknowledgement
94
97
98
+ @property
99
+ @serializable .view (SchemaVersion1Dot5 )
100
+ @serializable .view (SchemaVersion1Dot6 )
101
+ @serializable .type_mapping (BomRef )
102
+ @serializable .xml_attribute ()
103
+ @serializable .xml_name ('bom-ref' )
104
+ @serializable .json_name ('bom-ref' )
105
+ def bom_ref (self ) -> BomRef :
106
+ """
107
+ An optional identifier which can be used to reference the component elsewhere in the BOM. Every bom-ref MUST be
108
+ unique within the BOM.
109
+
110
+ Returns:
111
+ `BomRef`
112
+ """
113
+ return self ._bom_ref
114
+
115
+
95
116
@property
96
117
@serializable .xml_sequence (1 )
97
118
def id (self ) -> Optional [str ]:
@@ -186,16 +207,6 @@ def url(self, url: Optional[XsUri]) -> None:
186
207
# def properties(self, ...) -> None:
187
208
# ... # TODO since CDX1.5
188
209
189
- # @property
190
- # @serializable.json_name('bom-ref')
191
- # @serializable.type_mapping(BomRefHelper)
192
- # @serializable.view(SchemaVersion1Dot5)
193
- # @serializable.view(SchemaVersion1Dot6)
194
- # @serializable.xml_attribute()
195
- # @serializable.xml_name('bom-ref')
196
- # def bom_ref(self) -> BomRef:
197
- # ... # TODO since CDX1.5
198
-
199
210
@property
200
211
@serializable .view (SchemaVersion1Dot6 )
201
212
@serializable .xml_attribute ()
@@ -227,6 +238,7 @@ def __comparable_tuple(self) -> _ComparableTuple:
227
238
self ._id , self ._name ,
228
239
self ._url ,
229
240
self ._text ,
241
+ self ._bom_ref ,
230
242
))
231
243
232
244
def __eq__ (self , other : object ) -> bool :
@@ -264,11 +276,31 @@ class LicenseExpression:
264
276
265
277
def __init__ (
266
278
self , value : str , * ,
279
+ bom_ref : Optional [Union [str , BomRef ]] = None ,
267
280
acknowledgement : Optional [LicenseAcknowledgement ] = None ,
268
281
) -> None :
282
+ self ._bom_ref = _bom_ref_from_str (bom_ref )
269
283
self ._value = value
270
284
self ._acknowledgement = acknowledgement
271
285
286
+ @property
287
+ @serializable .view (SchemaVersion1Dot5 )
288
+ @serializable .view (SchemaVersion1Dot6 )
289
+ @serializable .type_mapping (BomRef )
290
+ @serializable .xml_attribute ()
291
+ @serializable .xml_name ('bom-ref' )
292
+ @serializable .json_name ('bom-ref' )
293
+ def bom_ref (self ) -> BomRef :
294
+ """
295
+ An optional identifier which can be used to reference the component elsewhere in the BOM. Every bom-ref MUST be
296
+ unique within the BOM.
297
+
298
+ Returns:
299
+ `BomRef`
300
+ """
301
+ return self ._bom_ref
302
+
303
+
272
304
@property
273
305
@serializable .xml_name ('.' )
274
306
@serializable .xml_string (serializable .XmlStringSerializationType .NORMALIZED_STRING )
@@ -286,16 +318,6 @@ def value(self) -> str:
286
318
def value (self , value : str ) -> None :
287
319
self ._value = value
288
320
289
- # @property
290
- # @serializable.json_name('bom-ref')
291
- # @serializable.type_mapping(BomRefHelper)
292
- # @serializable.view(SchemaVersion1Dot5)
293
- # @serializable.view(SchemaVersion1Dot6)
294
- # @serializable.xml_attribute()
295
- # @serializable.xml_name('bom-ref')
296
- # def bom_ref(self) -> BomRef:
297
- # ... # TODO since CDX1.5
298
-
299
321
@property
300
322
@serializable .view (SchemaVersion1Dot6 )
301
323
@serializable .xml_attribute ()
@@ -325,6 +347,7 @@ def __comparable_tuple(self) -> _ComparableTuple:
325
347
return _ComparableTuple ((
326
348
self ._acknowledgement ,
327
349
self ._value ,
350
+ self .bom_ref ,
328
351
))
329
352
330
353
def __hash__ (self ) -> int :
0 commit comments