...
Using PostgreSQL special type as "json" or "jsonb" rather than "text", all applications will lose any compatibility with H2 and MariaDB. They will be mentioned in this document but not recommended.
Type | DataStore | Validation | Support Query | Index | Preserve Order |
---|
longtext
| MariaDB | SELECT | Yes | No | Yes |
PostgreSQL | No | No | No | Yes |
json | PostgreSQL | INSERT / UPDATE | Yes | No | Yes |
jsonb | PostgreSQL | INSERT / UPDATE | Yes | Yes | No |
Requirements
- Policy types/Policies/Node Types/Node Templates are first order items
- Data Types have a scope of a first order item, so a data type definition only applies in the scope of a policy type or node type definition
- We should keep our current APIs, all changes should be internal
- We must provide an upgrade path to the new data structure and a rollback to the current structure
...
Code Block |
---|
language | java |
---|
title | Persistence Model |
---|
collapse | true |
---|
|
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class DocToscaServiceTemplate extends DocToscaEntity<ToscaServiceTemplate> {
@SerializedName("data_types")
private Map<String, @Valid DocToscaDataType> dataTypes;
-------
public DocToscaServiceTemplate(ToscaServiceTemplate authorativeConcept) {
this.fromAuthorative(authorativeConcept);
}
@Override
public ToscaServiceTemplate toAuthorative() {
final var toscaServiceTemplate = new ToscaServiceTemplate();
super.setToscaEntity(toscaServiceTemplate);
super.toAuthorative();
if (dataTypes != null) {
toscaServiceTemplate.setDataTypes(PfUtilsDocUtil.mapMapdocMapMap(dataTypes, DocToscaDataType::toAuthorative));
}
-------
return toscaServiceTemplate;
}
@Override
public void fromAuthorative(ToscaServiceTemplate toscaServiceTemplate) {
super.fromAuthorative(toscaServiceTemplate);
if (toscaServiceTemplate.getDataTypes() != null) {
dataTypes = DocUtil.mapMapmapDocMap(toscaServiceTemplate.getDataTypes(), DocToscaDataType::new);
}
-------
}
}
|
...
Code Block |
---|
language | java |
---|
title | Persistence Model |
---|
collapse | true |
---|
|
@Entity
@Table(name = "ToscaServiceTemplate")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Data
@EqualsAndHashCode(callSuper = false)
public class JpaToscaServiceTemplate extends PfConcept implements PfAuthorative<ToscaServiceTemplate> {
@EmbeddedId
@VerifyKey
@NotNull
private PfConceptKey key;
@Lob
@Convert(converter = StringToServiceTemplateConverter.class)
@NotNull
@Valid
private DocToscaServiceTemplate serviceTemplate;
-------
@Override
public ToscaServiceTemplate toAuthorative() {
return serviceTemplate.toAuthorative();
}
@Override
public void fromAuthorative(ToscaServiceTemplate authorativeConcept) {
serviceTemplate = new DocToscaServiceTemplate(authorativeConcept);
setKey(serviceTemplate.getKey().asIdentifier().asConceptKey());
}
-------
}
|
...
Code Block |
---|
language | java |
---|
title | Persistence Model |
---|
collapse | true |
---|
|
@Document(collection = "ToscaServiceTemplate")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Data
@EqualsAndHashCode(callSuper = false)
public class JpaToscaServiceTemplate extends PfConcept implements PfAuthorative<ToscaServiceTemplate> {
@Id
@VerifyKey
@NonNull
private PfConceptKey key;
@NonNull
@Valid
private DocToscaServiceTemplate serviceTemplate;
-------
@Override
public ToscaServiceTemplate toAuthorative() {
return serviceTemplate.toAuthorative();
}
@Override
public void fromAuthorative(ToscaServiceTemplate authorativeConcept) {
serviceTemplate = new DocToscaServiceTemplate(authorativeConcept);
setKey(serviceTemplate.getKey().asIdentifier().asConceptKey());
}
-------
}
|
...