Skip to content

Commit

Permalink
Merge branch 'release/2.8.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
blavenie committed Nov 21, 2023
2 parents 61599d2 + 58ec3a9 commit cde86a6
Show file tree
Hide file tree
Showing 36 changed files with 461 additions and 90 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>2.8.12-SNAPSHOT</version>
<version>2.8.12</version>
<packaging>pom</packaging>
<name>SUMARiS</name>
<description>SUMARiS :: Maven parent</description>
Expand Down
2 changes: 1 addition & 1 deletion src/site/markdown/doc
Submodule doc updated from 9566e7 to 920145
23 changes: 15 additions & 8 deletions src/site/resources/sql/create-table-hsqldb.sql

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sumaris-core-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>2.8.12-SNAPSHOT</version>
<version>2.8.12</version>
</parent>

<artifactId>sumaris-core-shared</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ public void generateCreateSchemaFile(String filename, boolean doExecute, boolean
// Add table and columns comment
try {
appendRemarks(filename, metadata);
} catch (SQLException | IOException e) {
throw new SumarisTechnicalException("Error when appending comments on file", e);
} catch (Exception e) {
// FIXME java.lang.NullPointerException: Cannot invoke "org.hibernate.boot.model.relational.QualifiedName.getCatalogName()" because "name" is null
// throw new SumarisTechnicalException("Error when appending comments on file", e);
log.error("Failed to export remarks: {}", e.getMessage(), e);
}
}

Expand Down Expand Up @@ -785,9 +787,12 @@ private void appendRemarks(String filename, Metadata metadata) throws SQLExcepti
HibernateConnectionProvider.setConnection(connection);
}

try {
try (SessionFactory sf = metadata.buildSessionFactory()) {
String schemaName = connection.getSchema();
metadata.buildSessionFactory().getMetamodel().getEntities().stream()
sf.getMetamodel()
.getEntities()
.stream()
.filter(entityType -> entityType.getName() != null)
.sorted(Comparator.comparing(EntityType::getName))
.forEach(entityType -> {
Table table = entityType.getJavaType().getAnnotation(Table.class);
Expand All @@ -798,6 +803,7 @@ private void appendRemarks(String filename, Metadata metadata) throws SQLExcepti
}
// iterate attributes
entityType.getAttributes().stream()
.filter(attribute -> attribute.getName() != null)
.sorted(Comparator.comparing(Attribute::getName))
.forEach(attribute -> {
if (attribute.getJavaMember() instanceof Field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ public static String name(IEntityEnum enumeration) {
return enumeration.name();
}

public static boolean isResolved(IEntityEnum enumeration) {
return !isUnresolved(enumeration);
}

public static boolean isUnresolved(IEntityEnum enumeration) {
try {
Object id = Beans.getProperty((Object)enumeration, "id");
Expand Down
6 changes: 5 additions & 1 deletion sumaris-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>2.8.12-SNAPSHOT</version>
<version>2.8.12</version>
</parent>

<artifactId>sumaris-core</artifactId>
Expand Down Expand Up @@ -182,6 +182,10 @@
<artifactId>liquibase-slf4j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,14 @@ public class DenormalizedBatch implements IEntity<Integer> {
private DenormalizedBatch parent;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "operation_fk")
@JoinColumn(name = "operation_fk",
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, foreignKeyDefinition = "foreign key (operation_fk) references operation(id) on delete cascade"))
@ToString.Exclude
private Operation operation;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "sale_fk")
@JoinColumn(name = "sale_fk",
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, foreignKeyDefinition = "foreign key (sale_fk) references sale(id) on delete cascade"))
@ToString.Exclude
private Sale sale;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public class DenormalizedBatchSortingValue implements IEntity<Integer>
private QualitativeValue qualitativeValue;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "batch_fk", nullable = false)
@JoinColumn(name = "batch_fk", nullable = false,
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, foreignKeyDefinition = "foreign key (batch_fk) references denormalized_batch(id) on delete cascade"))
@ToString.Exclude
private DenormalizedBatch batch;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.12.xsd"
logicalFilePath="https://github.com/sumaris-net/sumaris-pod/blob/master/sumaris-core/src/main/resources/net/sumaris/core/db/changelog/hsqldb/db-changelog-2.8.12.xml">

<!-- Drop the denormalized_batch_operation_fkc constraint -->
<changeSet author="[email protected]" id="1700496722792-001">
<preConditions onFail="MARK_RAN">
<foreignKeyConstraintExists foreignKeyName="denormalized_batch_operation_fkc" />
</preConditions>
<dropForeignKeyConstraint baseTableName="denormalized_batch"
constraintName="denormalized_batch_operation_fkc"/>
</changeSet>

<!-- Add a new foreign key with delete cascade -->
<changeSet author="[email protected]" id="1700496722792-002">
<preConditions onFail="MARK_RAN">
<not>
<foreignKeyConstraintExists foreignKeyName="denormalized_batch_operation_fkc" />
</not>
</preConditions>
<addForeignKeyConstraint baseTableName="denormalized_batch"
baseColumnNames="operation_fk"
referencedTableName="operation"
referencedColumnNames="id"
constraintName="denormalized_batch_operation_fkc"
onDelete="CASCADE"/>
</changeSet>

<!-- Drop the denormalized_batch_sale_fkc constraint -->
<changeSet author="[email protected]" id="1700496722792-003">
<preConditions onFail="MARK_RAN">
<foreignKeyConstraintExists foreignKeyName="denormalized_batch_sale_fkc" />
</preConditions>
<dropForeignKeyConstraint baseTableName="denormalized_batch"
constraintName="denormalized_batch_sale_fkc"/>
</changeSet>

<!-- Add a new denormalized_batch_sale_fkc with delete cascade -->
<changeSet author="[email protected]" id="1700496722792-004">
<preConditions onFail="MARK_RAN">
<not>
<foreignKeyConstraintExists foreignKeyName="denormalized_batch_sale_fkc" />
</not>
</preConditions>
<addForeignKeyConstraint baseTableName="denormalized_batch"
baseColumnNames="sale_fk"
referencedTableName="sale"
referencedColumnNames="id"
constraintName="denormalized_batch_sale_fkc"
onDelete="CASCADE"/>
</changeSet>


<!-- Drop the denormalized_batch_sort_val_batch_fkc constraint -->
<changeSet author="[email protected]" id="1700496722792-005">
<preConditions onFail="MARK_RAN">
<foreignKeyConstraintExists foreignKeyName="denormalized_batch_sort_val_batch_fkc" />
</preConditions>
<dropForeignKeyConstraint baseTableName="denormalized_batch_sort_val"
constraintName="denormalized_batch_sort_val_batch_fkc"/>
</changeSet>

<!-- Add a new denormalized_batch_sort_val_batch_fkc with delete cascade -->
<changeSet author="[email protected]" id="1700496722792-006">
<preConditions onFail="MARK_RAN">
<not>
<foreignKeyConstraintExists foreignKeyName="denormalized_batch_sort_val_batch_fkc" />
</not>
</preConditions>
<addForeignKeyConstraint baseTableName="denormalized_batch_sort_val"
baseColumnNames="batch_fk"
referencedTableName="denormalized_batch"
referencedColumnNames="id"
constraintName="denormalized_batch_sort_val_batch_fkc"
onDelete="CASCADE"/>
</changeSet>

<!-- update SYSTEM_VERSION -->
<changeSet author="[email protected]" id="1700496722792-200" runOnChange="true">
<delete tableName="SYSTEM_VERSION">
<where>LABEL='2.8.12'</where>
</delete>
<insert tableName="SYSTEM_VERSION">
<column name="ID" valueComputed="NEXT VALUE FOR SYSTEM_VERSION_SEQ"/>
<column name="LABEL">2.8.12</column>
<column name="DESCRIPTION">
- Add ON DELETE CASCADE on DENORMALIZED_BATCH.OPERATION_FK;
</column>
<column name="CREATION_DATE" valueComputed="sysdate"/>
<column name="UPDATE_DATE" valueComputed="current_timestamp"/>
<column name="COMMENTS">
- Add ON DELETE CASCADE on DENORMALIZED_BATCH.OPERATION_FK;
</column>
</insert>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,11 @@

<include relativeToChangelogFile="true" file="db-changelog-2.7.0.xml"/>

<!-- Refresh schema objects (functions, procedures, triggers, ...) -->
<include relativeToChangelogFile="true" file="db-changelog-refresh.xml"/>

<include relativeToChangelogFile="true" file="db-changelog-2.8.2.xml"/>
<include relativeToChangelogFile="true" file="adap/db-changelog-2.8.2.xml"/>

<include relativeToChangelogFile="true" file="db-changelog-2.8.12.xml"/>

<!-- Refresh schema objects (functions, procedures, triggers, ...) -->
<include relativeToChangelogFile="true" file="db-changelog-refresh.xml"/>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.12.xsd"
logicalFilePath="https://github.com/sumaris-net/sumaris-pod/blob/master/sumaris-core/src/main/resources/net/sumaris/core/db/changelog/pgsql/db-changelog-2.8.12.xml">

<!-- Drop the denormalized_batch_operation_fkc constraint -->
<changeSet author="[email protected]" id="1700496722792-001">
<preConditions onFail="MARK_RAN">
<foreignKeyConstraintExists foreignKeyName="denormalized_batch_operation_fkc" />
</preConditions>
<dropForeignKeyConstraint baseTableName="denormalized_batch"
constraintName="denormalized_batch_operation_fkc"/>
</changeSet>

<!-- Add a new denormalized_batch_operation_fkc with delete cascade -->
<changeSet author="[email protected]" id="1700496722792-002">
<preConditions onFail="MARK_RAN">
<not>
<foreignKeyConstraintExists foreignKeyName="denormalized_batch_operation_fkc" />
</not>
</preConditions>
<addForeignKeyConstraint baseTableName="denormalized_batch"
baseColumnNames="operation_fk"
referencedTableName="operation"
referencedColumnNames="id"
constraintName="denormalized_batch_operation_fkc"
onDelete="CASCADE"/>
</changeSet>

<!-- Drop the denormalized_batch_sale_fkc constraint -->
<changeSet author="[email protected]" id="1700496722792-003">
<preConditions onFail="MARK_RAN">
<foreignKeyConstraintExists foreignKeyName="denormalized_batch_sale_fkc" />
</preConditions>
<dropForeignKeyConstraint baseTableName="denormalized_batch"
constraintName="denormalized_batch_sale_fkc"/>
</changeSet>

<!-- Add a new denormalized_batch_sale_fkc with delete cascade -->
<changeSet author="[email protected]" id="1700496722792-004">
<preConditions onFail="MARK_RAN">
<not>
<foreignKeyConstraintExists foreignKeyName="denormalized_batch_sale_fkc" />
</not>
</preConditions>
<addForeignKeyConstraint baseTableName="denormalized_batch"
baseColumnNames="sale_fk"
referencedTableName="sale"
referencedColumnNames="id"
constraintName="denormalized_batch_sale_fkc"
onDelete="CASCADE"/>
</changeSet>

<!-- Drop the denormalized_batch_sort_val_batch_fkc constraint -->
<changeSet author="[email protected]" id="1700496722792-005">
<preConditions onFail="MARK_RAN">
<foreignKeyConstraintExists foreignKeyName="denormalized_batch_sort_val_batch_fkc" />
</preConditions>
<dropForeignKeyConstraint baseTableName="denormalized_batch_sort_val"
constraintName="denormalized_batch_sort_val_batch_fkc"/>
</changeSet>

<!-- Add a new denormalized_batch_sort_val_batch_fkc with delete cascade -->
<changeSet author="[email protected]" id="1700496722792-006">
<preConditions onFail="MARK_RAN">
<not>
<foreignKeyConstraintExists foreignKeyName="denormalized_batch_sort_val_batch_fkc" />
</not>
</preConditions>
<addForeignKeyConstraint baseTableName="denormalized_batch_sort_val"
baseColumnNames="batch_fk"
referencedTableName="denormalized_batch"
referencedColumnNames="id"
constraintName="denormalized_batch_sort_val_batch_fkc"
onDelete="CASCADE"/>
</changeSet>

<!-- update SYSTEM_VERSION -->
<changeSet author="[email protected]" id="1700496722792-200" runOnChange="true">
<delete tableName="SYSTEM_VERSION">
<where>LABEL='2.8.12'</where>
</delete>
<insert tableName="SYSTEM_VERSION">
<column name="ID" valueComputed="nextval('system_version_seq')"/>
<column name="LABEL">2.8.12</column>
<column name="DESCRIPTION">
- Add ON DELETE CASCADE on DENORMALIZED_BATCH.OPERATION_FK;
</column>
<column name="CREATION_DATE" valueComputed="current_timestamp"/>
<column name="UPDATE_DATE" valueComputed="current_timestamp"/>
<column name="COMMENTS">
- Add ON DELETE CASCADE on DENORMALIZED_BATCH.OPERATION_FK;
</column>
</insert>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@

<include relativeToChangelogFile="true" file="db-changelog-2.3.6.xml"/>
<include relativeToChangelogFile="true" file="db-changelog-2.7.0.xml"/>
<include relativeToChangelogFile="true" file="db-changelog-2.8.12.xml"/>

<!-- Refresh schema objects (functions, procedures, triggers, ...) -->
<include relativeToChangelogFile="true" file="db-changelog-refresh.xml"/>
Expand Down
2 changes: 1 addition & 1 deletion sumaris-extraction/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>2.8.12-SNAPSHOT</version>
<version>2.8.12</version>
</parent>

<artifactId>sumaris-extraction</artifactId>
Expand Down
Loading

0 comments on commit cde86a6

Please sign in to comment.