Skip to content

Commit

Permalink
Updated the column names after KIE discussions
Browse files Browse the repository at this point in the history
  • Loading branch information
josedee committed Dec 17, 2024
1 parent 41b5035 commit decba6a
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public class NodeEntity extends AbstractEntity {
@CollectionTable(name = "definitions_nodes_metadata", joinColumns = { @JoinColumn(name = "node_id", referencedColumnName = "id"),
@JoinColumn(name = "process_id", referencedColumnName = "process_id"), @JoinColumn(name = "process_version", referencedColumnName = "process_version") },
foreignKey = @ForeignKey(name = "fk_definitions_nodes_metadata_definitions_nodes"))
@MapKeyColumn(name = "metadata_key")
@Column(name = "metadata_value")
@MapKeyColumn(name = "name")
@Column(name = "meta_value")
private Map<String, String> metadata;

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public class ProcessDefinitionEntity extends AbstractEntity {
@CollectionTable(name = "definitions_metadata", joinColumns = {
@JoinColumn(name = "process_id", referencedColumnName = "id"), @JoinColumn(name = "process_version", referencedColumnName = "version") },
foreignKey = @ForeignKey(name = "fk_definitions_metadata"))
@MapKeyColumn(name = "metadata_key")
@Column(name = "metadata_value")
@MapKeyColumn(name = "name")
@Column(name = "meta_value")
private Map<String, String> metadata;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

alter table definitions_nodes_metadata alter column key rename to metadata_key;
alter table definitions_nodes_metadata alter column value rename to metadata_value;
alter table definitions_metadata alter column key rename to metadata_key;
alter table definitions_metadata alter column value rename to metadata_value;
alter table definitions_nodes_metadata alter column key rename to name;
alter table definitions_nodes_metadata alter column value rename to meta_value;
alter table definitions_metadata alter column key rename to name;
alter table definitions_metadata alter column value rename to meta_value;
alter table definitions_annotations alter column value rename to annotation;
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

alter table definitions_nodes_metadata rename column key to metadata_key;
alter table definitions_nodes_metadata rename column value to metadata_value;
alter table definitions_metadata rename column key to metadata_key;
alter table definitions_metadata rename column value to metadata_value;
alter table definitions_nodes_metadata rename column key to name;
alter table definitions_nodes_metadata rename column value to meta_value;
alter table definitions_metadata rename column key to name;
alter table definitions_metadata rename column value to meta_value;
alter table definitions_annotations rename column value to annotation;
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@

@Entity
@IdClass(CacheId.class)
@Table(name = "kogito_data_cache", uniqueConstraints = @UniqueConstraint(columnNames = { "name",
"cache_key" }), indexes = @Index(columnList = "name,cache_key", unique = true))
@Table(name = "kogito_data_cache", uniqueConstraints = @UniqueConstraint(columnNames = { "cache_name",
"var_name" }), indexes = @Index(columnList = "cache_name,var_name", unique = true))
public class CacheEntity {

@Id
@Column(nullable = false)
@Column(name = "cache_name", nullable = false)
private String name;

@Id
@Column(name = "cache_key", nullable = false)
@Column(name = "var_name", nullable = false)
private String key;

@Convert(converter = JsonBinaryConverter.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
* under the License.
*/

alter table kogito_data_cache alter column key rename to cache_key;
alter table kogito_data_cache alter column name rename to cache_name;
alter table kogito_data_cache alter column key rename to var_name;
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@


create table if not exists kogito_data_cache (
cache_key varchar(255) not null,
name varchar(255) not null,
var_name varchar(255) not null,
cache_name varchar(255) not null,
json_value jsonb,
primary key (cache_key, name)
primary key (var_name, cache_name)
);
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
* under the License.
*/

alter table kogito_data_cache rename column key to cache_key;
alter table kogito_data_cache rename column name to cache_name;
alter table kogito_data_cache rename column key to var_name;
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class BasicTypeMappingIT {
private static final String CACHE_NAME = "BasicType";

private static final String SQL = "SELECT " +
"ROW_NUMBER() OVER (ORDER BY name, cache_key) as id, " +
"name, " +
"cache_key, " +
"ROW_NUMBER() OVER (ORDER BY cache_name, var_name) as id, " +
"cache_name, " +
"var_name, " +
"field1MappedField, " +
"field2MappedField " +
"FROM " +
Expand Down Expand Up @@ -174,8 +174,8 @@ private void assertResultSize(final int expected) {
@EntityResult(
entityClass = BasicTypeExtractRow.class,
fields = { @FieldResult(name = "id", column = "id"),
@FieldResult(name = "key", column = "cache_key"),
@FieldResult(name = "name", column = "name"),
@FieldResult(name = "key", column = "var_name"),
@FieldResult(name = "name", column = "cache_name"),
@FieldResult(name = "field1MappedField", column = "field1MappedField"),
@FieldResult(name = "field2MappedField", column = "field2MappedField") })
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class ComplexHierarchicalTypeMappingIT {
private static final String CACHE_NAME = "ComplexHierarchicalType";

private static final String SQL = "SELECT " +
"ROW_NUMBER() OVER (ORDER BY name, cache_key) as id, " +
"name, " +
"cache_key, " +
"ROW_NUMBER() OVER (ORDER BY cache_name, var_name) as id, " +
"cache_name, " +
"var_name, " +
"root, " +
"nestedBasicMappedField, " +
"nestedComplexCollectionMappedField1, " +
Expand Down Expand Up @@ -210,8 +210,8 @@ private void assertResultSize(final int expected) {
@EntityResult(
entityClass = ComplexHierarchicalTypeExtractRow.class,
fields = { @FieldResult(name = "id", column = "id"),
@FieldResult(name = "key", column = "cache_key"),
@FieldResult(name = "name", column = "name"),
@FieldResult(name = "key", column = "var_name"),
@FieldResult(name = "name", column = "cache_name"),
@FieldResult(name = "root", column = "root"),
@FieldResult(name = "nestedBasicMappedField", column = "nestedBasicMappedField"),
@FieldResult(name = "nestedComplexCollectionMappedField1", column = "nestedComplexCollectionMappedField1"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class HierarchicalTypeMappingIT {
private static final String CACHE_NAME = "HierarchicalType";

private static final String SQL = "SELECT " +
"ROW_NUMBER() OVER (ORDER BY name, cache_key) as id, " +
"name, " +
"cache_key, " +
"ROW_NUMBER() OVER (ORDER BY cache_name, var_name) as id, " +
"cache_name, " +
"var_name, " +
"root, " +
"nestedBasicMappedField, " +
"nestedBasicCollectionMappedField " +
Expand Down Expand Up @@ -194,8 +194,8 @@ private void assertResultSize(final int expected) {
@EntityResult(
entityClass = HierarchicalTypeExtractRow.class,
fields = { @FieldResult(name = "id", column = "id"),
@FieldResult(name = "key", column = "cache_key"),
@FieldResult(name = "name", column = "name"),
@FieldResult(name = "key", column = "var_name"),
@FieldResult(name = "name", column = "cache_name"),
@FieldResult(name = "root", column = "root"),
@FieldResult(name = "nestedBasicMappedField", column = "nestedBasicMappedField"),
@FieldResult(name = "nestedBasicCollectionMappedField", column = "nestedBasicCollectionMappedField") })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ void dynamicMappingDefinitionCreation() {
final PostgresMappingDefinition definition = new PostgresMappingDefinition("ExampleMappingId",
"kogito_data_cache",
"json_value",
List.of(new PostgresField("cache_key")),
List.of(new PostgresPartitionField("name", "Example")),
List.of(new PostgresField("var_name")),
List.of(new PostgresPartitionField("cache_name", "Example")),
"Example",
List.of(new PostgresMapping("field1",
new PostgresJsonField("field1", JsonType.STRING))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class PostgresApplyMappingSqlBuilderIT {
private static final String CACHE_NAME = "DynamicType";

private static final String SQL = "SELECT " +
"ROW_NUMBER() OVER (ORDER BY name, cache_key) as id, " +
"name, " +
"cache_key, " +
"ROW_NUMBER() OVER (ORDER BY cache_name, var_name) as id, " +
"cache_name, " +
"var_name, " +
"field1MappedField, " +
"field2MappedField " +
"FROM " +
Expand Down Expand Up @@ -89,8 +89,8 @@ void testApplyMappingToExistingData() {
databaseManager.createArtifacts(new PostgresMappingDefinition("dynamicMappingId",
"kogito_data_cache",
"json_value",
List.of(new PostgresField("cache_key")),
List.of(new PostgresPartitionField("name", CACHE_NAME)),
List.of(new PostgresField("var_name")),
List.of(new PostgresPartitionField("cache_name", CACHE_NAME)),
"DynamicTypeExtract",
List.of(new PostgresMapping("field1",
new PostgresJsonField("field1MappedField", JsonType.STRING)),
Expand Down Expand Up @@ -120,8 +120,8 @@ private void assertResultSize(final int expected) {
@EntityResult(
entityClass = DynamicTypeExtractRow.class,
fields = { @FieldResult(name = "id", column = "id"),
@FieldResult(name = "key", column = "cache_key"),
@FieldResult(name = "name", column = "name"),
@FieldResult(name = "key", column = "var_name"),
@FieldResult(name = "name", column = "cache_name"),
@FieldResult(name = "field1MappedField", column = "field1MappedField"),
@FieldResult(name = "field2MappedField", column = "field2MappedField") })
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"sourceTableJsonFieldName": "json_value",
"sourceTableIdentityFields": [
{
"fieldName": "cache_key"
"fieldName": "var_name"
}
],
"sourceTablePartitionFields": [
{
"fieldName": "name",
"fieldName": "cache_name",
"fieldValue": "BasicType"
}
],
Expand Down Expand Up @@ -39,12 +39,12 @@
"sourceTableJsonFieldName": "json_value",
"sourceTableIdentityFields": [
{
"fieldName": "cache_key"
"fieldName": "var_name"
}
],
"sourceTablePartitionFields": [
{
"fieldName": "name",
"fieldName": "cache_name",
"fieldValue": "HierarchicalType"
}
],
Expand Down Expand Up @@ -79,12 +79,12 @@
"sourceTableJsonFieldName": "json_value",
"sourceTableIdentityFields": [
{
"fieldName": "cache_key"
"fieldName": "var_name"
}
],
"sourceTablePartitionFields": [
{
"fieldName": "name",
"fieldName": "cache_name",
"fieldValue": "ComplexHierarchicalType"
}
],
Expand Down

0 comments on commit decba6a

Please sign in to comment.