Skip to content

Commit

Permalink
1.6 Add Environmental considerations for ML and address for organization
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Alzate <[email protected]>
  • Loading branch information
mr-zepol authored Apr 7, 2024
1 parent dbd43cf commit 9ecb826
Show file tree
Hide file tree
Showing 14 changed files with 486 additions and 5 deletions.
17 changes: 15 additions & 2 deletions src/main/java/org/cyclonedx/model/OrganizationalEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@
import java.util.Objects;

import org.cyclonedx.Version;
import org.cyclonedx.model.organization.PostalAddress;
import org.cyclonedx.util.deserializer.OrganizationalEntityDeserializer;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonPropertyOrder({"name", "url", "contact"})
@JsonPropertyOrder({"name", "address", "url", "contact"})
@JsonDeserialize(using = OrganizationalEntityDeserializer.class)
public class OrganizationalEntity {

Expand All @@ -46,6 +47,9 @@ public class OrganizationalEntity {

private String name;

@VersionFilter(Version.VERSION_16)
private PostalAddress address;

private List<String> url;
@JsonProperty("contact")
private List<OrganizationalContact> contact;
Expand Down Expand Up @@ -95,6 +99,14 @@ public void setBomRef(final String bomRef) {
this.bomRef = bomRef;
}

public PostalAddress getAddress() {
return address;
}

public void setAddress(final PostalAddress address) {
this.address = address;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -103,11 +115,12 @@ public boolean equals(Object o) {
return Objects.equals(name, that.name) &&
Objects.equals(url, that.url) &&
Objects.equals(contact, that.contact) &&
Objects.equals(address, that.address) &&
Objects.equals(bomRef, that.bomRef);
}

@Override
public int hashCode() {
return Objects.hash(name, url, contact, bomRef);
return Objects.hash(name, url, contact, bomRef, address);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import org.cyclonedx.Version;
import org.cyclonedx.model.ExtensibleElement;
import org.cyclonedx.model.VersionFilter;
import org.cyclonedx.model.component.modelCard.consideration.EnvironmentalConsideration;
import org.cyclonedx.model.component.modelCard.consideration.FairnessAssessment;
import org.cyclonedx.model.component.modelCard.consideration.Risk;

Expand All @@ -24,6 +27,8 @@ public class Considerations extends ExtensibleElement

private List<Risk> ethicalConsiderations;

@VersionFilter(Version.VERSION_16)
private EnvironmentalConsideration environmentalConsiderations;

private List<FairnessAssessment> fairnessAssessments;

Expand Down Expand Up @@ -86,4 +91,12 @@ public List<FairnessAssessment> getFairnessAssessments() {
public void setFairnessAssessments(final List<FairnessAssessment> fairnessAssessments) {
this.fairnessAssessments = fairnessAssessments;
}

public EnvironmentalConsideration getEnvironmentalConsiderations() {
return environmentalConsiderations;
}

public void setEnvironmentalConsiderations(final EnvironmentalConsideration environmentalConsiderations) {
this.environmentalConsiderations = environmentalConsiderations;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.cyclonedx.model.component.modelCard.consideration;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import org.cyclonedx.model.Property;
import org.cyclonedx.model.component.modelCard.consideration.consumption.EnergyConsumption;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class EnvironmentalConsideration
{
private List<EnergyConsumption> energyConsumptions;

private List<Property> properties;

public List<EnergyConsumption> getEnergyConsumptions() {
return energyConsumptions;
}

public void setEnergyConsumptions(final List<EnergyConsumption> energyConsumptions) {
this.energyConsumptions = energyConsumptions;
}

@JacksonXmlElementWrapper(localName = "properties")
@JacksonXmlProperty(localName = "property")
public List<Property> getProperties() {
return properties;
}

public void setProperties(final List<Property> properties) {
this.properties = properties;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.cyclonedx.model.component.modelCard.consideration.consumption;

import com.fasterxml.jackson.annotation.JsonProperty;

public enum Activity
{
@JsonProperty("design")
DESIGN("design"),
@JsonProperty("data-collection")
DATA_COLLECTION("data-collection"),
@JsonProperty("data-preparation")
DATA_PREPARATION("data-preparation"),
@JsonProperty("training")
TRAINING("training"),
@JsonProperty("fine-tuning")
FINE_TUNING("fine-tuning"),
@JsonProperty("validation")
VALIDATION("validation"),
@JsonProperty("deployment")
DEPLOYMENT("deployment"),
@JsonProperty("inference")
INFERENCE("inference"),
@JsonProperty("other")
OTHER("other");

private final String name;

Activity(String name) {
this.name = name;
}

public String getName() {
return name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.cyclonedx.model.component.modelCard.consideration.consumption;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import org.cyclonedx.model.Property;
import org.cyclonedx.model.component.modelCard.consideration.consumption.co2.CO2Measure;
import org.cyclonedx.model.component.modelCard.consideration.consumption.energy.EnergyMeasure;
import org.cyclonedx.model.component.modelCard.consideration.consumption.energy.EnergyProvider;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class EnergyConsumption
{
private Activity activity;
private List<EnergyProvider> energyProviders;
private EnergyMeasure activityEnergyCost;
private CO2Measure co2CostEquivalent;
private CO2Measure co2CostOffset;
private List<Property> properties;

public Activity getActivity() {
return activity;
}

public void setActivity(final Activity activity) {
this.activity = activity;
}

@JacksonXmlElementWrapper(useWrapping = false)
public List<EnergyProvider> getEnergyProviders() {
return energyProviders;
}

public void setEnergyProviders(final List<EnergyProvider> energyProviders) {
this.energyProviders = energyProviders;
}

public EnergyMeasure getActivityEnergyCost() {
return activityEnergyCost;
}

public void setActivityEnergyCost(final EnergyMeasure activityEnergyCost) {
this.activityEnergyCost = activityEnergyCost;
}

public CO2Measure getCo2CostEquivalent() {
return co2CostEquivalent;
}

public void setCo2CostEquivalent(final CO2Measure co2CostEquivalent) {
this.co2CostEquivalent = co2CostEquivalent;
}

public CO2Measure getCo2CostOffset() {
return co2CostOffset;
}

public void setCo2CostOffset(final CO2Measure co2CostOffset) {
this.co2CostOffset = co2CostOffset;
}

@JacksonXmlElementWrapper(localName = "properties")
@JacksonXmlProperty(localName = "property")
public List<Property> getProperties() {
return properties;
}

public void setProperties(final List<Property> properties) {
this.properties = properties;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.cyclonedx.model.component.modelCard.consideration.consumption.co2;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class CO2Measure
{
private double value;
private Unit unit;

public double getValue() {
return value;
}

public void setValue(final double value) {
this.value = value;
}

public Unit getUnit() {
return unit;
}

public void setUnit(final Unit unit) {
this.unit = unit;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.cyclonedx.model.component.modelCard.consideration.consumption.co2;

import com.fasterxml.jackson.annotation.JsonProperty;

public enum Unit
{
@JsonProperty("tCO2eq")
TCO2EQ("tCO2eq");

private final String name;

Unit(String name) {
this.name = name;
}

public String getName() {
return name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.cyclonedx.model.component.modelCard.consideration.consumption.energy;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class EnergyMeasure
{
private double value;
private Unit unit;

public double getValue() {
return value;
}

public void setValue(final double value) {
this.value = value;
}

public Unit getUnit() {
return unit;
}

public void setUnit(final Unit unit) {
this.unit = unit;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.cyclonedx.model.component.modelCard.consideration.consumption.energy;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import org.cyclonedx.model.ExternalReference;
import org.cyclonedx.model.OrganizationalEntity;
import org.cyclonedx.util.deserializer.ExternalReferencesDeserializer;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class EnergyProvider
{
@JacksonXmlProperty(isAttribute = true, localName = "bom-ref")
@JsonProperty("bom-ref")
private String bomRef;
private String description;
private OrganizationalEntity organization;
private EnergySource energySource;
private EnergyMeasure energyProvided;
private List<ExternalReference> externalReferences;

public String getBomRef() {
return bomRef;
}

public void setBomRef(final String bomRef) {
this.bomRef = bomRef;
}

public String getDescription() {
return description;
}

public void setDescription(final String description) {
this.description = description;
}

public OrganizationalEntity getOrganization() {
return organization;
}

public void setOrganization(final OrganizationalEntity organization) {
this.organization = organization;
}

public EnergySource getEnergySource() {
return energySource;
}

public void setEnergySource(final EnergySource energySource) {
this.energySource = energySource;
}

public EnergyMeasure getEnergyProvided() {
return energyProvided;
}

public void setEnergyProvided(final EnergyMeasure energyProvided) {
this.energyProvided = energyProvided;
}

@JacksonXmlElementWrapper(localName = "externalReferences")
@JacksonXmlProperty(localName = "reference")
@JsonDeserialize(using = ExternalReferencesDeserializer.class)
public List<ExternalReference> getExternalReferences() {
return externalReferences;
}

public void setExternalReferences(final List<ExternalReference> externalReferences) {
this.externalReferences = externalReferences;
}
}
Loading

0 comments on commit 9ecb826

Please sign in to comment.