You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before executing any of the model class methods, the model versions need to be intialized. This is done by calling:
8
+
9
+
```
10
+
SpdxModelFactory.init();
11
+
```
12
+
13
+
SPDX data is stored in a "model store" and copying between model stores requires a copy manager.
14
+
15
+
A simple store is provided in the java library. To create the simple in-memory model store and a copy manager, execute the following:
16
+
17
+
```
18
+
InMemSpdxStore modelStore = new InMemSpdxStore();
19
+
IModelCopyManager copyManager = new ModelCopyManager();
20
+
```
21
+
22
+
All SPDX elements are required to have a unique SPDX ID which is an Object URI. In the SPDX Java libraries, this is commonly referred to as the `objectUri` to avoid confusion with the SPDX 2.X version short SPDX IDs.
23
+
24
+
A good practice is to create a common prefix to use for your programatic session. The prefix should be unique to the session. There are convenience methods in the library to append identifiers uniques to the model store.
Since SPDX 3.0 requires creation info on every element, the easiest way to start is to use the SPDX 3 model convenience method `SpdxModelClassFactory.createCreationInfo(...)` which will create the `Agent` and `CreationInfo` classes which can be added to all of the subsequent elements.
From here on, things get easier. We can get and set properties to the sbom we just created.
59
+
60
+
If we want to create another SPDX object or element, we can use the builder convenience methods available to all SPDX objects. For example, if we want to create a package to add to the SBOM we can call:
The model store, creation info, copy manager, and prefix information will all be copied from the sbom allowing you to focus just on the properties you need to add.
0 commit comments