Skip to content

Commit

Permalink
Use FormulationCompProp for java generator for consistency with comma…
Browse files Browse the repository at this point in the history
…nd lines

Signed-off-by: Stewart X Addison <[email protected]>
  • Loading branch information
sxa committed Dec 6, 2023
1 parent 2d4fd00 commit 1cd7515
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions cyclonedx-lib/src/temurin/sbom/TemurinGenSBOM.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@ public static void main(final String[] args) {
writeJSONfile(bom, fileName);
break;

case "addFormulation": // Adds Formulation --> name
bom = addFormula(fileName);
case "addFormulation": // Adds Formulation --> name
bom = addFormulation(fileName);
writeJSONfile(bom, fileName);
break;

case "addFormulationComp": // Adds Formulation --> Component--> name
bom = addFormulaComponent(fileName, name, type);
case "addFormulationComp": // Adds Formulation --> Component--> name
bom = addFormulationComp(fileName, name, type);
writeJSONfile(bom, fileName);
break;
case "addFormulationCompProp": // Adds Formulation--> Property --> name-value:
bom = addFormulaComponentProperty(fileName, compName, name, value);
case "addFormulationCompProp": // Adds Formulation --> Component -> name-value:
bom = addFormulationCompProp(fileName, compName, name, value);
writeJSONfile(bom, fileName);
break;

Expand Down Expand Up @@ -324,7 +324,7 @@ static Bom addComponentExternalReference(final String fileName, final String has
return bom;
}

static Bom addFormula(final String fileName) { // Method to store Formulation
static Bom addFormulation(final String fileName) { // Method to store Formulation
Bom bom = readJSONfile(fileName);
List<Formula> formulation = bom.getFormulation();
if (formulation == null) {
Expand All @@ -336,21 +336,9 @@ static Bom addFormula(final String fileName) { // Method to store Formu
return bom;
}

static Bom addFormulaComponent(final String fileName, final String name, final String type/*, final String version, final String description */) {
// START OF SECTION FROM addFormula
static Bom addFormulationComp(final String fileName, final String name, final String type/*, final String version, final String description */) {
Bom bom = readJSONfile(fileName);
List<Formula> formulation = bom.getFormulation();
if (formulation == null) {
formulation = new LinkedList<Formula>();
Formula formula = new Formula();
formulation.add(formula);
bom.setFormulation(formulation);
} else {
System.out.println("addFormula() has done nothing as there is a already a formulation object in the BoM");
}
// END OF SECTION FROM addFormula
// Bom bom = readJSONfile(fileName);
// List<Formula> formulation = bom.getFormulation();
// SXA TODO: Not ideal to just be pulling the first entry here
// But the formula is currently unnamed
Formula formula = formulation.get(0);
Expand All @@ -369,7 +357,7 @@ static Bom addFormulaComponent(final String fileName, final String name, final S
return bom;
}

static Bom addFormulaComponentProperty(final String fileName, final String componentName, final String name, final String value) { // Method to store metadata --> Properties List --> name-values
static Bom addFormulationCompProp(final String fileName, final String componentName, final String name, final String value) { // Method to store metadata --> Properties List --> name-values
Bom bom = readJSONfile(fileName);
List<Formula> formulation = bom.getFormulation();
Formula formula = formulation.get(0);
Expand All @@ -378,8 +366,8 @@ static Bom addFormulaComponentProperty(final String fileName, final String compo
List<Component> components = formulation.get(0).getComponents();
for (Component item : components) {

// What if the name wasn't found - this won't create a new one
// Should we skip the "already exists" case and just issue an add?
// What if the name wasn't found - this won't create a new one
// Should we skip the "already exists" case and just issue an add?
if (item.getName().equals(componentName)) {
Property prop1 = new Property();
prop1.setName(name);
Expand Down

0 comments on commit 1cd7515

Please sign in to comment.