Commit 67ec15f0 authored by Artem Hrybeniuk's avatar Artem Hrybeniuk
Browse files

Merge branch 'viab-normalCount-nullable' into 'main'

Viability: Allow null for normalCount

See merge request grin-global/grin-global-server!386
parents e796f19f b962ef76
......@@ -124,9 +124,9 @@ public class InventoryViabilityData extends CooperatorOwnedModel implements Copy
private Integer replicationCount;
@Basic
@Column(name = "normal_count", nullable = false)
@Column(name = "normal_count")
@Min(0)
private int normalCount;
private Integer normalCount;
@Basic
@Column(name = "abnormal_count")
......@@ -307,11 +307,11 @@ public class InventoryViabilityData extends CooperatorOwnedModel implements Copy
this.inventoryViability = inventoryViability;
}
public int getNormalCount() {
public Integer getNormalCount() {
return normalCount;
}
public void setNormalCount(final int normalCount) {
public void setNormalCount(final Integer normalCount) {
this.normalCount = normalCount;
}
......
......@@ -504,7 +504,7 @@ public class InventoryViabilityServiceImpl extends FilteredCRUDServiceImpl<Inven
}
summarized.setReplicationCount(Optional.ofNullable(summarized.getReplicationCount()).orElse(0) + Optional.ofNullable(extra.getReplicationCount()).orElse(0));
summarized.setNormalCount(summarized.getNormalCount() + extra.getNormalCount());
summarized.setNormalCount(Optional.ofNullable(summarized.getNormalCount()).orElse(0) + Optional.ofNullable(extra.getNormalCount()).orElse(0));
summarized.setAbnormalCount(Optional.ofNullable(summarized.getAbnormalCount()).orElse(0) + Optional.ofNullable(extra.getAbnormalCount()).orElse(0));
summarized.setUnknownCount(Optional.ofNullable(summarized.getUnknownCount()).orElse(0) + Optional.ofNullable(extra.getUnknownCount()).orElse(0));
......
......@@ -9275,3 +9275,14 @@ databaseChangeLog:
(1, 'gg-ce', 'password_reset', 'password.webuser.reset',
'<h2>Reset password for {{username}}</h2><p>Click <a href="{{url}}/#/pwdreset/{{tokenUUID}}?key={{tokenKey}}" rel="nofollow">this link</a> to reset your password.</p><h2>Validation key: {{tokenKey}}</h2><p>If you didn&#39;t make this request, <a href="{{url}}/#/pwdreset/{{tokenUUID}}/cancel" rel="nofollow">click here to cancel</a>.</p>',
'Reset password', 1, GETDATE(), 1, GETDATE(), 1, GETDATE());
- changeSet:
id: 1648790361000-1
author: mobreza
comment: Drop notnull constraint on inventory_viability_data#normal_count
changes:
- dropNotNullConstraint:
tableName: inventory_viability_data
columnName: normal_count
columnDataType: int
......@@ -162,10 +162,15 @@ public class InventoryViabilityServiceTest extends AbstractServicesTest {
inventoryViabilityData.setReplicationNumber(1); // first replicate
inventoryViabilityData.setCountNumber(10); // number of seed tested
inventoryViabilityData.setCountDate(new Date()); // date of count
inventoryViabilityData.setNormalCount(0); // normal seed
inventoryViabilityData.setNormalCount(null); // normal seed
inventoryViabilityData.setNormalCount(-10);
assertThrows(ConstraintViolationException.class, () -> inventoryViabilityDataRepository.save(inventoryViabilityData));
inventoryViabilityData.setNormalCount(null); // normal seed
var ivd = inventoryViabilityDataRepository.save(inventoryViabilityData);
assertThat(ivd.getId(), not(nullValue()));
assertThat(ivd.getNormalCount(), nullValue());
}
@Test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment