Bulk operations errors fixed:

- outbound countries db lookup fixed
- node lookup by mapping id fixed
- allowing blank excel cells (outbound countries and pre-node list)
Fix:
- missing properties added again
This commit is contained in:
Jan 2025-09-23 17:42:03 +02:00
parent 55e072146f
commit aa054ab706
8 changed files with 33 additions and 17 deletions

View file

@ -320,9 +320,12 @@ public class NodeRepository {
FROM node
WHERE node.external_mapping_id = ?""";
var node = jdbcTemplate.queryForObject(query, new NodeMapper(), mappingId);
var node = jdbcTemplate.query(query, new NodeMapper(), mappingId);
return Optional.ofNullable(node);
if(node.isEmpty())
return Optional.empty();
return Optional.of(node.getFirst());
}

View file

@ -152,7 +152,7 @@ public class CountryRepository {
String sql = "SELECT * FROM country WHERE iso_code IN (:isoCodes)";
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("isoCodes", outboundCountries);
parameters.addValue("isoCodes", outboundCountries.stream().map(Enum::name).toList());
return namedParameterJdbcTemplate.query(sql, parameters, new CountryMapper());
}

View file

@ -209,9 +209,13 @@ public class ConstraintGenerator {
}
public void validateStringCell(Row row, int columnIdx) {
public void validateStringCell(Row row, int columnIdx, Boolean allowEmpty) {
CellType cellType = row.getCell(columnIdx).getCellType();
if(cellType == CellType.BLANK && allowEmpty) {
return;
}
if (cellType == CellType.STRING) {
String value = row.getCell(columnIdx).getStringCellValue();
@ -222,6 +226,10 @@ public class ConstraintGenerator {
}
public void validateStringCell(Row row, int columnIdx) {
validateStringCell(row, columnIdx, false);
}
public void validateIntegerConstraint(Row row, int columnIdx, int min, int max) {
CellType cellType = row.getCell(columnIdx).getCellType();

View file

@ -127,8 +127,8 @@ public class NodeExcelMapper {
constraintGenerator.validateStringCell(row, NodeHeader.MAPPING_ID.ordinal());
constraintGenerator.validateStringCell(row, NodeHeader.COUNTRY.ordinal());
constraintGenerator.validateStringCell(row, NodeHeader.OUTBOUND_COUNTRIES.ordinal());
constraintGenerator.validateStringCell(row, NodeHeader.PREDECESSOR_NODES.ordinal());
constraintGenerator.validateStringCell(row, NodeHeader.OUTBOUND_COUNTRIES.ordinal(), true);
constraintGenerator.validateStringCell(row, NodeHeader.PREDECESSOR_NODES.ordinal(), true);
constraintGenerator.validateStringCell(row, NodeHeader.NAME.ordinal());
constraintGenerator.validateStringCell(row, NodeHeader.ADDRESS.ordinal());

View file

@ -5,6 +5,10 @@
-- Description -> name
-- ===================================================
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule, description, property_group, sequence_number) VALUES ( '2_Reference route: Port of origin', 'START_REF', 'TEXT', '{}','2_Reference route used to demonstrate sea freight fluctuation, port in country of origin','2_Reference route','1');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule, description, property_group, sequence_number) VALUES ( '2_Reference route: Port of destination', 'END_REF', 'TEXT', '{}','2_Reference route used to demonstrate sea freight fluctuation, port in country of destination','2_Reference route','2');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule, description, property_group, sequence_number) VALUES ( 'All-time-high container rate (40 ft.) [EUR]', 'RISK_REF', 'CURRENCY', '{"GT":0}','Highest container rate to be used to demonstrate sea freight fluctuation, cost for 40 Ft. (FEU) general purpose container','2_Reference route','3');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule, description, property_group, sequence_number) VALUES ( 'All-time-low container rate (40 ft.) [EUR]', 'CHANCE_REF', 'CURRENCY', '{"GT":0}','Lowest container rate to be used to demonstrate sea freight fluctuation, cost for 40 Ft. (FEU) general purpose container','2_Reference route','4');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule, description, property_group, sequence_number) VALUES ( 'Payment terms [days]', 'PAYMENT_TERMS', 'INT', '{}','Payment terms [days] agreed with suppliers.','1_General','3');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule, description, property_group, sequence_number) VALUES ( 'Annual working days', 'WORKDAYS', 'INT', '{"GT": 0, "LT": 366}','Annual production working days.','1_General','2');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule, description, property_group, sequence_number) VALUES ( 'Interest rate inventory [%]', 'INTEREST_RATE', 'PERCENTAGE', '{"GTE": 0}','Interest rate for inventories and payment terms.','1_General','4');

View file

@ -4,11 +4,11 @@
-- Zuerst die packaging_property_types für stackable und rust prevention erstellen
-- (falls sie noch nicht existieren)
INSERT INTO packaging_property_type (name, external_mapping_id, data_type, validation_rule, is_required)
INSERT INTO packaging_property_type (name, external_mapping_id, data_type, validation_rule, is_required, description, property_group, sequence_number)
VALUES
('Stackable', 'STACKABLE', 'BOOLEAN', NULL, FALSE),
('Rust Prevention', 'RUST_PREVENTION', 'BOOLEAN', NULL, FALSE),
('Mixable', 'MIXABLE', 'BOOLEAN', NULL, FALSE)
('Stackable', 'STACKABLE', 'BOOLEAN', NULL, FALSE, 'desc', 'general', 1),
('Rust Prevention', 'RUST_PREVENTION', 'BOOLEAN', NULL, FALSE, 'desc', 'general', 2),
('Mixable', 'MIXABLE', 'BOOLEAN', NULL, FALSE, 'desc', 'general', 3)
ON DUPLICATE KEY UPDATE
name = VALUES(name),
data_type = VALUES(data_type);

View file

@ -52,9 +52,6 @@ CREATE TABLE IF NOT EXISTS `country`
`iso_code` CHAR(2) NOT NULL COMMENT 'ISO 3166-1 alpha-2 country code',
`region_code` CHAR(5) NOT NULL COMMENT 'Geographic region code (EMEA/LATAM/APAC/NAM)',
`name` VARCHAR(255) NOT NULL,
`description` VARCHAR(255) NOT NULL,
`property_group` VARCHAR(32) NOT NULL,
`sequence_number` INT NOT NULL,
`is_deprecated` BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_country_iso_code` (`iso_code`),
@ -69,6 +66,9 @@ CREATE TABLE IF NOT EXISTS `country_property_type`
`external_mapping_id` VARCHAR(16),
`data_type` VARCHAR(16) NOT NULL,
`validation_rule` VARCHAR(64),
`description` VARCHAR(255) NOT NULL,
`property_group` VARCHAR(32) NOT NULL,
`sequence_number` INT NOT NULL,
`is_required` BOOLEAN NOT NULL DEFAULT FALSE,
CONSTRAINT `chk_country_data_type_values` CHECK (`data_type` IN
('INT', 'PERCENTAGE', 'BOOLEAN', 'CURRENCY', 'ENUMERATION',
@ -142,7 +142,7 @@ CREATE TABLE IF NOT EXISTS `sys_user_node`
-- logistic nodes
CREATE TABLE IF NOT EXISTS node
(
id INT PRIMARY KEY,
id INT AUTO_INCREMENT PRIMARY KEY,
country_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
address VARCHAR(500) NOT NULL,

View file

@ -60,10 +60,11 @@ VALUES ('28523500576', '028523500576', '85015230', 'traction motor assy. ''AE35-
-- Zuerst die packaging_property_types für stackable und rust prevention erstellen
-- (falls sie noch nicht existieren)
INSERT INTO packaging_property_type (name, external_mapping_id, data_type, validation_rule, is_required)
INSERT INTO packaging_property_type (name, external_mapping_id, data_type, validation_rule, is_required, description, property_group, sequence_number)
VALUES
('Stackable', 'STACKABLE', 'BOOLEAN', NULL, FALSE),
('Rust Prevention', 'RUST_PREVENTION', 'BOOLEAN', NULL, FALSE)
('Stackable', 'STACKABLE', 'BOOLEAN', NULL, FALSE, 'desc', 'general', 1),
('Rust Prevention', 'RUST_PREVENTION', 'BOOLEAN', NULL, FALSE, 'desc', 'general', 2),
('Mixable', 'MIXABLE', 'BOOLEAN', NULL, FALSE, 'desc', 'general', 3)
ON DUPLICATE KEY UPDATE
name = VALUES(name),
data_type = VALUES(data_type);