From ca9d8d8c60db14df7a40449226f36541407977e7 Mon Sep 17 00:00:00 2001 From: Reguel Wermelinger Date: Tue, 24 Oct 2023 15:31:03 +0200 Subject: [PATCH 1/3] fix: missbehaving with germanized column names --- .../util/excel/test/ArzneimittelLight.xlsx | Bin 0 -> 21951 bytes .../excel/test/TestEntityClassCreator.java | 19 ++++++++++++++++++ .../excel/importer/EntityClassReader.java | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 excel-importer-test/src_test/com/axonivy/util/excel/test/ArzneimittelLight.xlsx diff --git a/excel-importer-test/src_test/com/axonivy/util/excel/test/ArzneimittelLight.xlsx b/excel-importer-test/src_test/com/axonivy/util/excel/test/ArzneimittelLight.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..8e2b0f32185863d3999ca10111029a681f4b92b1 GIT binary patch literal 21951 zcmeHvby$>J^e){E3eqW{z|bKjB1osw9U=$}(hU*=h)5~|Qc?mEf)c_o(%sDfLk-rG%H?in8=={159KBTAKb>8wB$6hp?ZU=T^5b>Ouxb2F*`H5F_95HW>RAp zCi?y(zl_(S6p7Vzk`SM2X_X>N3-;$}g(m)0^f>>Hhh1=qY?$j)pin9$6A*38 z!(|=LJ$N3N{vyDt_~Ga$6l;AV`~Y1Gpn?(Aoz!av-<+UCrY?wtM{=U3j2UOA5&PQ8 z8gFP`?NOGR>v5YRQE?6)DIU}ChSTscu(c)xJCNXgjgzF0YgFP0>}uNTn6~w8rs`*y zyxnR1`m>TPUqMi4?qIXN0JDw9eo;%=je%EL*-l1A6&-^j*%j|ss&+Rw z(mL08O`Y^LIa8}JDsU*KCQ3CrQ%rpccxrA)98y;tOKJjcsso+6(Nre87&A`XbqkL; zXo)~Cu^W&Qd>P9YdW`SU;n@-$uKB8Qj#NnO+DKrEBi>?&n4`cQ6Y9Gls_EKuT>6xqbiS-5L8@e4BFePt7| zq3x%md(g{vBa#uI7vuxL)0W=Q^yA(g%HN~3O5liXJ!ZYtnXa-WuXomDb8458He&P) z8vnMC>qcns?3}s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VhFiTfs$D_uHh z|NFHbglkQCFA)@#&5&u0b(Q^Y2RUm>jYLpfHba*6RrZG+*sLiP56zA7*&lXz z(#OwlO_|7#ubc?FsVp6voi5+slWBcb{FhC*l%?ad(-r%BvaA>T_?@jOzw+Z7CW5Yt zf7pbgj~~yP62y-$od{x3u8+z#mFwruw7x3-%O>o~^>Nvz3jN$!)^Gdxm8>bV`SCRq zL082;Y@*Z0&tXmZh96%s5yYZgACqk=-(Q?*eO3IIO*ob7-(;IA_7`VakM!}|T2q$s zhl5R~AnQkpST{x}sKLEH2B>MYp$#mMqcdo8KEKods1(W}=N4SE?|JWm3 z!Q_AJ5w0-upEn3s82OJIge#2v=MBOYM*ial;R+-Fd4q6;k^itkctSaE{)F;RDESgY z+X`QP=j!_10>T##^eb=j@2>PKZ}LA}=~v$5f4I`G{K$WFqW=*lUb&b53=^;1%YTH4 zSMKFM!^A81@*iO0m3x^g5wu5<2>O1Q;$M8pe|eg@s0c2;b9Mb;0Rk$nt3wz6@Ty-O zy7=9z{tt)hm5=$4F!AaL#{bV}EzZl6Ko0;lU#qJTOBZLVFOCsIDm`6Kk`~Ifhr5l$ z4wtuQS_ex3#?{F??MeBp5V6=vC-^};>+!`g;VKs+m;nNQJi6A{-_4aeVKnKTdN_4) zU>TaR9^5qPVG)PZPwNIh~ zVjkP7Fkiny3B=)XYiugy-4u0YX9^QwUEnVfUN%TxN^tCPDX03@W94UCK6Dr6Kgq@Rq3zjD}J zG9Lat{l2?{(_cM84aN7NB#=ph&{Vwa**s;IMa;5oqSwAD? zewX!YeAeI1<8UGRXS*&V4ZoY`U$y%+=I8I`(V;^^`j^PA-<$F4a`g9RC@}m!^?wEm YsVSmg%wr@Zl8e8}3;v}|wadHz1-HbjO#lD@ literal 0 HcmV?d00001 diff --git a/excel-importer-test/src_test/com/axonivy/util/excel/test/TestEntityClassCreator.java b/excel-importer-test/src_test/com/axonivy/util/excel/test/TestEntityClassCreator.java index 65212e5..267dac3 100644 --- a/excel-importer-test/src_test/com/axonivy/util/excel/test/TestEntityClassCreator.java +++ b/excel-importer-test/src_test/com/axonivy/util/excel/test/TestEntityClassCreator.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.nio.file.Path; +import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -12,6 +13,7 @@ import com.axonivy.util.excel.importer.EntityClassReader; import ch.ivyteam.ivy.environment.IvyTest; +import ch.ivyteam.ivy.scripting.dataclass.IEntityClassField; @IvyTest public class TestEntityClassCreator { @@ -26,6 +28,23 @@ void readToEntity(@TempDir Path dir) throws IOException { var entity = reader.getEntity(path); assertThat(entity).isNotNull(); } + + @Test + void readGermanized(@TempDir Path dir) throws Exception { + Path path = dir.resolve("Arzneimittel.xlsx"); + TstRes.loadTo(path, "ArzneimittelLight.xlsx"); + + var entity = reader.getEntity(path); + assertThat(entity).isNotNull(); + List fields = entity.getFields().stream().map(IEntityClassField::getName).toList(); + for(String field : fields) { + assertThat(field) + .as("no whitespaces") + .doesNotContain(" ") + .doesNotContain("(") + .doesNotContain("รค"); + } + } @BeforeEach void setup() { diff --git a/excel-importer/src/com/axonivy/util/excel/importer/EntityClassReader.java b/excel-importer/src/com/axonivy/util/excel/importer/EntityClassReader.java index bf8feb5..0286281 100644 --- a/excel-importer/src/com/axonivy/util/excel/importer/EntityClassReader.java +++ b/excel-importer/src/com/axonivy/util/excel/importer/EntityClassReader.java @@ -57,9 +57,12 @@ private void withIdField(IEntityClass entity) { } private String fieldName(String colName) { + colName = colName.replaceAll(" ", ""); if (StringUtils.isAllUpperCase(colName)) { return colName.toLowerCase(); } + colName = colName.replaceAll("\\W", ""); + colName = colName.replaceAll("[^\\p{ASCII}]", ""); return StringUtils.uncapitalize(colName); } From b44f9eb5ac878631b5815105d994bfea5e42bc27 Mon Sep 17 00:00:00 2001 From: Reguel Wermelinger Date: Tue, 24 Oct 2023 15:46:10 +0200 Subject: [PATCH 2/3] fix: represent empty cells with null values --- .../util/excel/test/TestEntityDataLoader.java | 21 +++++++++++++++++++ .../util/excel/importer/EntityDataLoader.java | 18 +++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/excel-importer-test/src_test/com/axonivy/util/excel/test/TestEntityDataLoader.java b/excel-importer-test/src_test/com/axonivy/util/excel/test/TestEntityDataLoader.java index 3ebef60..fe04c4b 100644 --- a/excel-importer-test/src_test/com/axonivy/util/excel/test/TestEntityDataLoader.java +++ b/excel-importer-test/src_test/com/axonivy/util/excel/test/TestEntityDataLoader.java @@ -51,6 +51,27 @@ void loadDataToEntity(@TempDir Path dir) throws IOException, CoreException { customer.getResource().delete(true, new NullProgressMonitor()); } } + + @Test + void loadArznei(@TempDir Path dir) throws IOException, CoreException { + Path path = dir.resolve("meds.xlsx"); + TstRes.loadTo(path, "ArzneimittelLight.xlsx"); + + Workbook wb = ExcelLoader.load(path); + Sheet customerSheet = wb.getSheetAt(0); + + IEntityClass customer = reader.toEntity(customerSheet, "meds"); + try { + customer.save(new NullProgressMonitor()); + Class entity = loader.createTable(customer); + assertThat(unit.findAll(entity)).isEmpty(); + loader.load(customerSheet, customer); + List records = unit.findAll(entity); + assertThat(records).hasSizeGreaterThanOrEqualTo(2); + } finally { + customer.getResource().delete(true, new NullProgressMonitor()); + } + } @BeforeEach void setup() { diff --git a/excel-importer/src/com/axonivy/util/excel/importer/EntityDataLoader.java b/excel-importer/src/com/axonivy/util/excel/importer/EntityDataLoader.java index 23341b4..6a157db 100644 --- a/excel-importer/src/com/axonivy/util/excel/importer/EntityDataLoader.java +++ b/excel-importer/src/com/axonivy/util/excel/importer/EntityDataLoader.java @@ -56,15 +56,14 @@ public void load(Sheet sheet, IEntityClass entity) { } private void insertCallValuesAsParameter(List fields, Row row, Query insert) { - Iterator cells = row.cellIterator(); - int c = 0; - c++; // consumed by 'id' - while(cells.hasNext()) { - Cell cell = cells.next(); - IEntityClassField field = fields.get(c); - String column = field.getName(); - insert.setParameter(column, getValue(cell)); + int c = -1; + for(var field : fields) { c++; + if (field.getName().equals("id")) { + continue; + } + Cell cell = row.getCell(c); + insert.setParameter(field.getName(), getValue(cell)); } } @@ -93,6 +92,9 @@ public Class createTable(IEntityClass entity) { } private Object getValue(Cell cell) { + if (cell == null) { + return null; + } if (cell.getCellType() == CellType.NUMERIC) { return cell.getNumericCellValue(); } From dd3a192cd53bbc5f1c67493dfe66b7a2933b4020 Mon Sep 17 00:00:00 2001 From: Reguel Wermelinger Date: Tue, 24 Oct 2023 15:52:49 +0200 Subject: [PATCH 3/3] limit data rendered to UI > paginate --- .../util/excel/importer/EntityManager/EntityManager.xhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/excel-importer/src_hd/com/axonivy/util/excel/importer/EntityManager/EntityManager.xhtml b/excel-importer/src_hd/com/axonivy/util/excel/importer/EntityManager/EntityManager.xhtml index 800699a..1e74384 100644 --- a/excel-importer/src_hd/com/axonivy/util/excel/importer/EntityManager/EntityManager.xhtml +++ b/excel-importer/src_hd/com/axonivy/util/excel/importer/EntityManager/EntityManager.xhtml @@ -15,7 +15,7 @@ - +