Loading src/main/java/org/etsi/osl/hypo/api/tmf/common/model/BaseEntity.java +10 −2 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/common/model/BaseEntity.java: 10 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -11,11 +11,19 @@ import jakarta.persistence.Id; import jakarta.persistence.MappedSuperclass; import jakarta.persistence.PrePersist; import java.util.UUID; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; @Data @Getter @Setter @MappedSuperclass @EqualsAndHashCode(onlyExplicitlyIncluded = true) @ToString(onlyExplicitlyIncluded = true) public class BaseEntity { @EqualsAndHashCode.Include @ToString.Include @Column(name = TMFID, nullable = false, updatable = false) private String id; Loading src/main/java/org/etsi/osl/hypo/api/tmf/common/model/BaseFieldsEntity.java +7 −3 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/common/model/BaseFieldsEntity.java: 7 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -2,12 +2,16 @@ package org.etsi.osl.hypo.api.tmf.common.model; import com.fasterxml.jackson.annotation.JsonProperty; import jakarta.persistence.MappedSuperclass; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; @Data @Getter @Setter @MappedSuperclass @EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true, onlyExplicitlyIncluded = true) @ToString(callSuper = true, onlyExplicitlyIncluded = true) public class BaseFieldsEntity extends BaseEntity { @JsonProperty("@baseType") Loading src/main/java/org/etsi/osl/hypo/api/tmf/common/schema/validations/BaseFieldsEntityWithHref.java +7 −3 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/common/schema/validations/BaseFieldsEntityWithHref.java: 7 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -8,13 +8,17 @@ import jakarta.persistence.PrePersist; import jakarta.persistence.Transient; import jakarta.ws.rs.core.UriBuilder; import java.net.URI; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; import org.etsi.osl.hypo.api.tmf.common.model.BaseEntity; @Getter @Setter @MappedSuperclass @Data @EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true, onlyExplicitlyIncluded = true) @ToString(callSuper = true, onlyExplicitlyIncluded = true) public class BaseFieldsEntityWithHref extends BaseEntity { @Transient @JsonIgnore private URI uri; Loading src/main/java/org/etsi/osl/hypo/api/tmf/peering/PeeredOrganizationData.java −2 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/peering/PeeredOrganizationData.java: 0 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -3,12 +3,10 @@ package org.etsi.osl.hypo.api.tmf.peering; import java.util.List; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; import org.etsi.osl.hypo.api.tmf.services.catalog.schema.ServiceSpecificationEntity; @Data @NoArgsConstructor @ToString public class PeeredOrganizationData { private String status; private String organizationId; Loading src/main/java/org/etsi/osl/hypo/api/tmf/services/common/model/Characteristic.java +23 −21 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/services/common/model/Characteristic.java: 23 added lines, 21 removed lines. Original line number Diff line number Diff line Loading @@ -3,23 +3,23 @@ package org.etsi.osl.hypo.api.tmf.services.common.model; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.Set; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; import org.etsi.osl.hypo.api.tmf.common.schema.CharacteristicRelationship; import org.etsi.osl.hypo.api.tmf.value.SetValue; import org.etsi.osl.hypo.api.tmf.value.TextValue; import org.etsi.osl.hypo.api.tmf.value.Value; import org.etsi.osl.hypo.api.tmf.value.ValueDeserializer; @Getter @Setter @NoArgsConstructor @EqualsAndHashCode @ToString @JsonInclude(JsonInclude.Include.NON_NULL) @EqualsAndHashCode(callSuper = false) @JsonPropertyOrder({"id", "name", "value", "valueType"}) public class Characteristic { Loading @@ -36,25 +36,27 @@ public class Characteristic { private String name; // --- CRITICAL JACKSON POLYMORPHISM SETUP --- // This tells Jackson: "The type of 'value' is determined by a sibling property named // 'valueType'." @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, // The discriminator uses a string name ("TEXT", "SET") include = JsonTypeInfo.As .EXTERNAL_PROPERTY, // The discriminator property is NOT inside the 'value' JSON property = "valueType", // The name of the sibling property is "valueType" defaultImpl = TextValue.class) @JsonSubTypes({ @JsonSubTypes.Type(value = TextValue.class, name = "TEXT"), // Map "TEXT" to TextValue.class @JsonSubTypes.Type(value = SetValue.class, name = "SET"), @JsonSubTypes.Type(value = SetValue.class, name = "ARRAY"), // Map "ARRAY" to SetValue.class @JsonSubTypes.Type(value = TextValue.class, name = "ENUM") // Map "SET" to SetValue.class }) @JsonDeserialize(using = ValueDeserializer.class) // <--- Handles REST API payloads safely! private Value value; // This is the polymorphic field that stores the actual value private String valueType; private Set<CharacteristicRelationship> characteristicRelationship; // --- ENFORCE VALUE & VALUE_TYPE SYNCHRONIZATION --- public void setValue(Value value) { this.value = value; // If valueType is null or blank, derive it directly from the concrete Value class if (value != null && (this.valueType == null || this.valueType.isBlank())) { this.valueType = value.getValueType(); } } public void setValueType(String valueType) { if (valueType != null && !valueType.isBlank()) { this.valueType = valueType; } else if (this.value != null) { this.valueType = this.value.getValueType(); } } } Loading
src/main/java/org/etsi/osl/hypo/api/tmf/common/model/BaseEntity.java +10 −2 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/common/model/BaseEntity.java: 10 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -11,11 +11,19 @@ import jakarta.persistence.Id; import jakarta.persistence.MappedSuperclass; import jakarta.persistence.PrePersist; import java.util.UUID; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; @Data @Getter @Setter @MappedSuperclass @EqualsAndHashCode(onlyExplicitlyIncluded = true) @ToString(onlyExplicitlyIncluded = true) public class BaseEntity { @EqualsAndHashCode.Include @ToString.Include @Column(name = TMFID, nullable = false, updatable = false) private String id; Loading
src/main/java/org/etsi/osl/hypo/api/tmf/common/model/BaseFieldsEntity.java +7 −3 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/common/model/BaseFieldsEntity.java: 7 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -2,12 +2,16 @@ package org.etsi.osl.hypo.api.tmf.common.model; import com.fasterxml.jackson.annotation.JsonProperty; import jakarta.persistence.MappedSuperclass; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; @Data @Getter @Setter @MappedSuperclass @EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true, onlyExplicitlyIncluded = true) @ToString(callSuper = true, onlyExplicitlyIncluded = true) public class BaseFieldsEntity extends BaseEntity { @JsonProperty("@baseType") Loading
src/main/java/org/etsi/osl/hypo/api/tmf/common/schema/validations/BaseFieldsEntityWithHref.java +7 −3 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/common/schema/validations/BaseFieldsEntityWithHref.java: 7 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -8,13 +8,17 @@ import jakarta.persistence.PrePersist; import jakarta.persistence.Transient; import jakarta.ws.rs.core.UriBuilder; import java.net.URI; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; import org.etsi.osl.hypo.api.tmf.common.model.BaseEntity; @Getter @Setter @MappedSuperclass @Data @EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true, onlyExplicitlyIncluded = true) @ToString(callSuper = true, onlyExplicitlyIncluded = true) public class BaseFieldsEntityWithHref extends BaseEntity { @Transient @JsonIgnore private URI uri; Loading
src/main/java/org/etsi/osl/hypo/api/tmf/peering/PeeredOrganizationData.java −2 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/peering/PeeredOrganizationData.java: 0 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -3,12 +3,10 @@ package org.etsi.osl.hypo.api.tmf.peering; import java.util.List; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; import org.etsi.osl.hypo.api.tmf.services.catalog.schema.ServiceSpecificationEntity; @Data @NoArgsConstructor @ToString public class PeeredOrganizationData { private String status; private String organizationId; Loading
src/main/java/org/etsi/osl/hypo/api/tmf/services/common/model/Characteristic.java +23 −21 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/services/common/model/Characteristic.java: 23 added lines, 21 removed lines. Original line number Diff line number Diff line Loading @@ -3,23 +3,23 @@ package org.etsi.osl.hypo.api.tmf.services.common.model; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.Set; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; import org.etsi.osl.hypo.api.tmf.common.schema.CharacteristicRelationship; import org.etsi.osl.hypo.api.tmf.value.SetValue; import org.etsi.osl.hypo.api.tmf.value.TextValue; import org.etsi.osl.hypo.api.tmf.value.Value; import org.etsi.osl.hypo.api.tmf.value.ValueDeserializer; @Getter @Setter @NoArgsConstructor @EqualsAndHashCode @ToString @JsonInclude(JsonInclude.Include.NON_NULL) @EqualsAndHashCode(callSuper = false) @JsonPropertyOrder({"id", "name", "value", "valueType"}) public class Characteristic { Loading @@ -36,25 +36,27 @@ public class Characteristic { private String name; // --- CRITICAL JACKSON POLYMORPHISM SETUP --- // This tells Jackson: "The type of 'value' is determined by a sibling property named // 'valueType'." @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, // The discriminator uses a string name ("TEXT", "SET") include = JsonTypeInfo.As .EXTERNAL_PROPERTY, // The discriminator property is NOT inside the 'value' JSON property = "valueType", // The name of the sibling property is "valueType" defaultImpl = TextValue.class) @JsonSubTypes({ @JsonSubTypes.Type(value = TextValue.class, name = "TEXT"), // Map "TEXT" to TextValue.class @JsonSubTypes.Type(value = SetValue.class, name = "SET"), @JsonSubTypes.Type(value = SetValue.class, name = "ARRAY"), // Map "ARRAY" to SetValue.class @JsonSubTypes.Type(value = TextValue.class, name = "ENUM") // Map "SET" to SetValue.class }) @JsonDeserialize(using = ValueDeserializer.class) // <--- Handles REST API payloads safely! private Value value; // This is the polymorphic field that stores the actual value private String valueType; private Set<CharacteristicRelationship> characteristicRelationship; // --- ENFORCE VALUE & VALUE_TYPE SYNCHRONIZATION --- public void setValue(Value value) { this.value = value; // If valueType is null or blank, derive it directly from the concrete Value class if (value != null && (this.valueType == null || this.valueType.isBlank())) { this.valueType = value.getValueType(); } } public void setValueType(String valueType) { if (valueType != null && !valueType.isBlank()) { this.valueType = valueType; } else if (this.value != null) { this.valueType = this.value.getValueType(); } } }