From a3f461413bc759accb91beb0c55a8d0027879da5 Mon Sep 17 00:00:00 2001
From: Emanuela Epure <67077116+emanuelaepure10@users.noreply.github.com>
Date: Fri, 20 Oct 2023 23:55:40 +0200
Subject: [PATCH 1/4] fix: Enable loading XSLX with blank rows
It is possible to load XLSX with multiple sheets that may contain blank pages or rows, as source data or schema.
Merged cells are giving the top-left value to all the cells in the merged area.
Wizard: add the last 2 steps in one single step.
ING-4075
---
.../hale/io/csv/ui/DefaultSchemaTypePage.java | 2 +-
.../eu.esdihumboldt.hale.io.xls.ui/plugin.xml | 7 ----
.../XLSInstanceImportConfigurationPage.java | 26 ++++++--------
.../hale/io/xls/ui/XLSSchemaTypePage.java | 28 +++++++++------
.../META-INF/MANIFEST.MF | 1 +
.../hale/io/xls/AbstractAnalyseTable.java | 31 +++++++++++------
.../hale/io/xls/AnalyseXLSSchemaTable.java | 12 ++++---
.../eu/esdihumboldt/hale/io/xls/XLSUtil.java | 34 ++++++++++++++++++-
.../reader/DefaultXLSLookupTableReader.java | 6 ++--
9 files changed, 95 insertions(+), 52 deletions(-)
diff --git a/io/plugins/eu.esdihumboldt.hale.io.csv.ui/src/eu/esdihumboldt/hale/io/csv/ui/DefaultSchemaTypePage.java b/io/plugins/eu.esdihumboldt.hale.io.csv.ui/src/eu/esdihumboldt/hale/io/csv/ui/DefaultSchemaTypePage.java
index 8bf2576573..0cee09174f 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.csv.ui/src/eu/esdihumboldt/hale/io/csv/ui/DefaultSchemaTypePage.java
+++ b/io/plugins/eu.esdihumboldt.hale.io.csv.ui/src/eu/esdihumboldt/hale/io/csv/ui/DefaultSchemaTypePage.java
@@ -423,7 +423,7 @@ public boolean isValid() {
*/
private void showMessage() {
if (header == null || header.length == 0)
- setErrorMessage("The file contains no data");
+ setErrorMessage("The file contains no data or not valid data");
else if (!sfe.isValid())
setErrorMessage("Please enter a valid Type Name");
else if (!isValid)
diff --git a/io/plugins/eu.esdihumboldt.hale.io.xls.ui/plugin.xml b/io/plugins/eu.esdihumboldt.hale.io.xls.ui/plugin.xml
index eac0b88b13..0ccbadb4ca 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.xls.ui/plugin.xml
+++ b/io/plugins/eu.esdihumboldt.hale.io.xls.ui/plugin.xml
@@ -10,13 +10,6 @@
ref="eu.esdihumboldt.hale.io.xls.reader.schema">
-
-
-
-
diff --git a/io/plugins/eu.esdihumboldt.hale.io.xls.ui/src/eu/esdihumboldt/hale/io/xls/ui/XLSInstanceImportConfigurationPage.java b/io/plugins/eu.esdihumboldt.hale.io.xls.ui/src/eu/esdihumboldt/hale/io/xls/ui/XLSInstanceImportConfigurationPage.java
index f29296967a..1feadecb94 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.xls.ui/src/eu/esdihumboldt/hale/io/xls/ui/XLSInstanceImportConfigurationPage.java
+++ b/io/plugins/eu.esdihumboldt.hale.io.xls.ui/src/eu/esdihumboldt/hale/io/xls/ui/XLSInstanceImportConfigurationPage.java
@@ -34,14 +34,15 @@
import eu.esdihumboldt.hale.io.xls.reader.ReaderSettings;
import eu.esdihumboldt.hale.ui.io.config.AbstractConfigurationPage;
import eu.esdihumboldt.hale.ui.io.instance.InstanceImportWizard;
+import eu.esdihumboldt.hale.io.csv.ui.TypeSelectionPage;
/**
* Configuration page for the instance export provider of Excel files
*
* @author Patrick Lieb
*/
-public class XLSInstanceImportConfigurationPage
- extends AbstractConfigurationPage {
+
+public class XLSInstanceImportConfigurationPage extends TypeSelectionPage {
private static final ALogger log = ALoggerFactory
.getLogger(XLSInstanceImportConfigurationPage.class);
@@ -52,9 +53,8 @@ public class XLSInstanceImportConfigurationPage
* Default Constructor
*/
public XLSInstanceImportConfigurationPage() {
- super("xls.instance.import.sheet.selection");
setTitle("Sheet selection");
- setDescription("Select sheet to import instances");
+ setDescription("Select sheet to import instances, your Type and Data reading setting");
}
/**
@@ -63,21 +63,16 @@ public XLSInstanceImportConfigurationPage() {
@Override
protected void createContent(Composite page) {
- page.setLayout(new GridLayout(1, false));
-
- Composite menu = new Composite(page, SWT.NONE);
- menu.setLayout(new GridLayout(2, false));
-
- GridDataFactory.fillDefaults().grab(true, false).applyTo(menu);
+ page.setLayout(new GridLayout(2, false));
- Label sheetLabel = new Label(menu, SWT.None);
+ Label sheetLabel = new Label(page, SWT.None);
sheetLabel.setText("Select sheet");
- sheetSelection = new Combo(menu, SWT.DROP_DOWN | SWT.READ_ONLY);
+ sheetSelection = new Combo(page, SWT.DROP_DOWN | SWT.READ_ONLY);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false)
.applyTo(sheetSelection);
- setPageComplete(false);
+ super.createContent(page);
}
/**
@@ -108,7 +103,7 @@ protected void onShowPage(boolean firstShow) {
}
super.onShowPage(firstShow);
sheetSelection.select(0);
- setPageComplete(true);
+ setPageComplete(false);
}
/**
@@ -118,7 +113,8 @@ protected void onShowPage(boolean firstShow) {
public boolean updateConfiguration(InstanceReader provider) {
provider.setParameter(InstanceTableIOConstants.SHEET_INDEX,
Value.of(sheetSelection.getSelectionIndex()));
- return true;
+
+ return super.updateConfiguration(provider);
}
/**
diff --git a/io/plugins/eu.esdihumboldt.hale.io.xls.ui/src/eu/esdihumboldt/hale/io/xls/ui/XLSSchemaTypePage.java b/io/plugins/eu.esdihumboldt.hale.io.xls.ui/src/eu/esdihumboldt/hale/io/xls/ui/XLSSchemaTypePage.java
index f435e8980c..1cfb113deb 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.xls.ui/src/eu/esdihumboldt/hale/io/xls/ui/XLSSchemaTypePage.java
+++ b/io/plugins/eu.esdihumboldt.hale.io.xls.ui/src/eu/esdihumboldt/hale/io/xls/ui/XLSSchemaTypePage.java
@@ -107,7 +107,7 @@ public void widgetSelected(SelectionEvent event) {
} catch (Exception e) {
setPageComplete(false);
clearSuperPage();
- setErrorMessage("The sheet is empty!");
+ setErrorMessage("The sheet is empty or the header is not valid!");
}
}
@@ -123,7 +123,7 @@ public void widgetDefaultSelected(SelectionEvent e) {
} catch (Exception e1) {
setPageComplete(false);
clearSuperPage();
- setErrorMessage("The sheet is empty!");
+ setErrorMessage("The sheet is empty or the header is not valid!");
}
}
@@ -166,11 +166,12 @@ protected void onShowPage(boolean firstShow) {
}
ArrayList items = new ArrayList();
for (int i = 0; i < numberOfSheets; i++) {
- items.add(wb.getSheetAt(i).getSheetName());
// only add items if there is a header (no empty sheet)
Row row = wb.getSheetAt(i).getRow(0);
- if (row == null && newLocation != null && !newLocation.equals(oldLocation)) {
- sheetNum++;
+ items.add(wb.getSheetAt(i).getSheetName());
+ if (row != null) {
+ update(i);
+ sheetNum = i;
}
}
@@ -190,20 +191,25 @@ protected void onShowPage(boolean firstShow) {
} catch (OldExcelFormatException e) {
// the setup is not in a valid state
- clearPage();
- clearSuperPage();
setErrorMessage(
"Old excel format detected (format 5.0/7.0 (BIFF5)). Please convert the excel file to BIFF8 from Excel versions 97/2000/XP/2003.");
- setPageComplete(false);
+ clearFromException();
} catch (Exception e) {
log.error("Error loading Excel file", e);
- clearPage();
- clearSuperPage();
setErrorMessage("Excel file cannot be loaded!");
- setPageComplete(false);
+ clearFromException();
}
}
+ /**
+ * clear page and super page
+ */
+ private void clearFromException() {
+ clearPage();
+ clearSuperPage();
+ setPageComplete(false);
+ }
+
/**
* Use this if an error occurs
*
diff --git a/io/plugins/eu.esdihumboldt.hale.io.xls/META-INF/MANIFEST.MF b/io/plugins/eu.esdihumboldt.hale.io.xls/META-INF/MANIFEST.MF
index a7fb74faaa..48fc28d64b 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.xls/META-INF/MANIFEST.MF
+++ b/io/plugins/eu.esdihumboldt.hale.io.xls/META-INF/MANIFEST.MF
@@ -41,6 +41,7 @@ Import-Package: com.orientechnologies.orient.core.db.record;version="1.5.1";reso
org.apache.poi.openxml4j.opc;version="5.2.3",
org.apache.poi.poifs.filesystem;version="5.2.3",
org.apache.poi.ss.usermodel;version="5.2.3",
+ org.apache.poi.ss.util;version="5.2.3",
org.apache.poi.xssf.usermodel;version="5.2.3",
org.springframework.core.convert;version="5.2.0",
org.springframework.core.convert.support;version="5.2.0"
diff --git a/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/AbstractAnalyseTable.java b/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/AbstractAnalyseTable.java
index 24a9b5ecaa..482e5b500e 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/AbstractAnalyseTable.java
+++ b/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/AbstractAnalyseTable.java
@@ -113,13 +113,19 @@ public static Workbook loadWorkbook(InputStream input, URI location, boolean xls
*/
protected void analyseHeader(Sheet sheet) {
Row header = sheet.getRow(0);
-
- // identify columns
- for (int i = header.getFirstCellNum(); i < header.getLastCellNum(); i++) {
- Cell cell = header.getCell(i);
- String text = extractText(cell);
-
- headerCell(i, text);
+ if (header != null) {
+
+ // identify columns
+ int count = 0;
+ for (int i = header.getFirstCellNum(); i < header.getLastCellNum(); i++) {
+ Cell cell = header.getCell(i);
+ String text = extractText(cell, sheet);
+ // cell cannot be empty to extract the text
+ if (text != null) {
+ headerCell(count, text);
+ count++;
+ }
+ }
}
}
@@ -138,7 +144,9 @@ private void analyseContent(Sheet sheet) {
// for each row starting from the second
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
Row row = sheet.getRow(i);
- analyseRow(i, row);
+ if (row != null) {
+ analyseRow(i, row, sheet);
+ }
}
}
@@ -148,8 +156,9 @@ private void analyseContent(Sheet sheet) {
* @param num the row number (starting from one as the header row is handled
* separately)
* @param row the table row
+ * @param sheet the sheet
*/
- protected abstract void analyseRow(int num, Row row);
+ protected abstract void analyseRow(int num, Row row, Sheet sheet);
/**
* Extract the text from a given cell. Formulas are evaluated, for blank or
@@ -158,8 +167,8 @@ private void analyseContent(Sheet sheet) {
* @param cell the cell
* @return the cell text
*/
- protected String extractText(Cell cell) {
- return XLSUtil.extractText(cell, evaluator);
+ protected String extractText(Cell cell, Sheet sheet) {
+ return XLSUtil.extractText(cell, evaluator, sheet);
}
}
diff --git a/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/AnalyseXLSSchemaTable.java b/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/AnalyseXLSSchemaTable.java
index d9fc68c690..31cd0feb72 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/AnalyseXLSSchemaTable.java
+++ b/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/AnalyseXLSSchemaTable.java
@@ -23,6 +23,7 @@
import java.util.Map;
import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
import eu.esdihumboldt.hale.common.core.io.supplier.LocatableInputSupplier;
@@ -60,8 +61,9 @@ public AnalyseXLSSchemaTable(LocatableInputSupplier extends InputStream> sourc
*/
@Override
protected void headerCell(int num, String text) {
- if (num == header.size())
+ if (num == header.size()) {
header.add(text);
+ }
header.set(num, text);
}
@@ -70,12 +72,14 @@ protected void headerCell(int num, String text) {
* org.apache.poi.ss.usermodel.Row)
*/
@Override
- protected void analyseRow(int num, Row row) {
+ protected void analyseRow(int num, Row row, Sheet sheet) {
List rowContent = new ArrayList();
for (int i = 0; i < row.getLastCellNum(); i++) {
- rowContent.add(extractText(row.getCell(i)));
+ rowContent.add(extractText(row.getCell(i), sheet));
+ }
+ if (!rowContent.isEmpty() && rowContent.stream().anyMatch(text -> text != null)) {
+ rows.put(num, rowContent);
}
- rows.put(num, rowContent);
}
/**
diff --git a/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/XLSUtil.java b/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/XLSUtil.java
index c0da7b5c51..3bc8a6e05c 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/XLSUtil.java
+++ b/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/XLSUtil.java
@@ -19,6 +19,9 @@
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.util.CellRangeAddress;
/**
* General utilities when working with Excel files.
@@ -35,10 +38,19 @@ public class XLSUtil {
* @param evaluator the formula evaluator
* @return the cell text
*/
- public static String extractText(Cell cell, FormulaEvaluator evaluator) {
+ public static String extractText(Cell cell, FormulaEvaluator evaluator, Sheet sheet) {
if (cell == null)
return null;
+ if (isCellPartOfMergedRegion(cell, sheet)) {
+ // Get the merged region
+ CellRangeAddress mergedRegion = getMergedRegion(cell, sheet);
+
+ // Get the first cell of the merged region (top-left cell)
+ Row mergedRow = sheet.getRow(mergedRegion.getFirstRow());
+ cell = mergedRow.getCell(mergedRegion.getFirstColumn());
+ }
+
if (cell.getCellType() == CellType.BLANK) {
// do this check here as the evaluator seems to return null on a
// blank
@@ -73,4 +85,24 @@ else if (CellType.STRING.equals(value.getCellType())) {
}
}
+ private static boolean isCellPartOfMergedRegion(Cell cell, Sheet sheet) {
+ for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
+ CellRangeAddress region = sheet.getMergedRegion(i);
+ if (region.isInRange(cell.getRowIndex(), cell.getColumnIndex())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static CellRangeAddress getMergedRegion(Cell cell, Sheet sheet) {
+ for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
+ CellRangeAddress region = sheet.getMergedRegion(i);
+ if (region.isInRange(cell.getRowIndex(), cell.getColumnIndex())) {
+ return region;
+ }
+ }
+ return null;
+ }
+
}
diff --git a/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/reader/DefaultXLSLookupTableReader.java b/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/reader/DefaultXLSLookupTableReader.java
index 9a517cc572..0ad1a76ba3 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/reader/DefaultXLSLookupTableReader.java
+++ b/io/plugins/eu.esdihumboldt.hale.io.xls/src/eu/esdihumboldt/hale/io/xls/reader/DefaultXLSLookupTableReader.java
@@ -57,9 +57,11 @@ public Map read(Workbook workbook, boolean skipFirst, int keyColum
for (; row < sheet.getPhysicalNumberOfRows(); row++) {
Row currentRow = sheet.getRow(row);
if (currentRow != null) {
- String value = XLSUtil.extractText(currentRow.getCell(valueColumn), evaluator);
+ String value = XLSUtil.extractText(currentRow.getCell(valueColumn), evaluator,
+ sheet);
if (value != null && (!ignoreEmptyStrings || !value.isEmpty())) {
- map.put(Value.of(XLSUtil.extractText(currentRow.getCell(keyColumn), evaluator)),
+ map.put(Value.of(
+ XLSUtil.extractText(currentRow.getCell(keyColumn), evaluator, sheet)),
Value.of(value));
}
}
From 6f5c14104eaa674b08904a6384402e4a1e5b632a Mon Sep 17 00:00:00 2001
From: Emanuela Epure <67077116+emanuelaepure10@users.noreply.github.com>
Date: Mon, 23 Oct 2023 11:13:23 +0200
Subject: [PATCH 2/4] feat: add issue template
Add issue template files for adding a bug, a feature request or just send the user to the forum if they have a question
---
.../ask-a-question-on-hale-studio-usage.md | 12 ++++++++
.github/ISSUE_TEMPLATE/feature_request.md | 21 +++++++++++++
.github/ISSUE_TEMPLATE/report-a-bug.md | 30 +++++++++++++++++++
3 files changed, 63 insertions(+)
create mode 100644 .github/ISSUE_TEMPLATE/ask-a-question-on-hale-studio-usage.md
create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md
create mode 100644 .github/ISSUE_TEMPLATE/report-a-bug.md
diff --git a/.github/ISSUE_TEMPLATE/ask-a-question-on-hale-studio-usage.md b/.github/ISSUE_TEMPLATE/ask-a-question-on-hale-studio-usage.md
new file mode 100644
index 0000000000..7ab0ec4446
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/ask-a-question-on-hale-studio-usage.md
@@ -0,0 +1,12 @@
+---
+name: Ask a question on hale»studio usage
+about: If you have a question about using hale»studio, please use the forum.
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+If you have questions regarding the usage of hale»studio, please use the forum:
+
+https://discuss.wetransform.to/#/forum
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000000..bc43f8d72e
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,21 @@
+---
+name: Feature request
+about: If you have a feature request or an idea that you believe could improve our
+ software, we would love to hear from you.
+title: "[Feature]:"
+labels: ''
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is.
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/.github/ISSUE_TEMPLATE/report-a-bug.md b/.github/ISSUE_TEMPLATE/report-a-bug.md
new file mode 100644
index 0000000000..cc33548dc0
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/report-a-bug.md
@@ -0,0 +1,30 @@
+---
+name: Report a bug
+about: If you encounter any issues, errors, or unexpected behaviour while using our
+ software, we kindly request that you report it to us.
+title: "[BUG]:"
+labels: bug
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior:
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error
+
+**Expected behavior**
+A clear and concise description of what you expect to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+
+
+**Additional context**
+Add any other context about the problem here.
From befbc122e0056d84283b3c7afb30d32fd3243534 Mon Sep 17 00:00:00 2001
From: Florian Esser
Date: Wed, 15 Nov 2023 12:50:39 +0100
Subject: [PATCH 3/4] refactor: improve error message for missing source node
WGS-2507
---
.../model/transformation/tree/visitor/CellNodeValidator.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/plugins/eu.esdihumboldt.hale.common.align/src/eu/esdihumboldt/hale/common/align/model/transformation/tree/visitor/CellNodeValidator.java b/common/plugins/eu.esdihumboldt.hale.common.align/src/eu/esdihumboldt/hale/common/align/model/transformation/tree/visitor/CellNodeValidator.java
index daf9973c39..d958b67fe7 100644
--- a/common/plugins/eu.esdihumboldt.hale.common.align/src/eu/esdihumboldt/hale/common/align/model/transformation/tree/visitor/CellNodeValidator.java
+++ b/common/plugins/eu.esdihumboldt.hale.common.align/src/eu/esdihumboldt/hale/common/align/model/transformation/tree/visitor/CellNodeValidator.java
@@ -86,7 +86,7 @@ public boolean visit(CellNode node) {
}
}
else {
- log.error("Source node for entity not found.");
+ log.error("Source node for entity '" + entity.toString() + "' not found.");
}
}
}
From 67125c54ab11c09b3b43ba714751120ede7e4963 Mon Sep 17 00:00:00 2001
From: Emanuela Epure <67077116+emanuelaepure10@users.noreply.github.com>
Date: Tue, 14 Nov 2023 15:19:40 +0100
Subject: [PATCH 4/4] hale: Enable exporting feature types with no data
Users can select feature types without data for both:
Custom export configuration for hale-connect using Excel as output type
Export of transformed data as Excel from hale-studio
For the feature types without data there is the indication in the label that [no data] is present. Has been reintroduced the button "Exclude feature types without data"
ING-4107
---
.../hale/io/csv/InstanceTableIOConstants.java | 5 ++
.../hale/io/xls/test/XLSInstanceIOTest.java | 2 +
.../test/writer/XLSInstanceWriterTest.java | 8 ++
.../XLSInstanceExportConfigurationPage.java | 80 +++++++------------
.../eu.esdihumboldt.hale.io.xls/plugin.xml | 4 +-
.../hale/io/xls/writer/XLSInstanceWriter.java | 26 +++---
6 files changed, 65 insertions(+), 60 deletions(-)
diff --git a/io/plugins/eu.esdihumboldt.hale.io.csv/src/eu/esdihumboldt/hale/io/csv/InstanceTableIOConstants.java b/io/plugins/eu.esdihumboldt.hale.io.csv/src/eu/esdihumboldt/hale/io/csv/InstanceTableIOConstants.java
index b1b3c75ea8..cd19c2f91a 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.csv/src/eu/esdihumboldt/hale/io/csv/InstanceTableIOConstants.java
+++ b/io/plugins/eu.esdihumboldt.hale.io.csv/src/eu/esdihumboldt/hale/io/csv/InstanceTableIOConstants.java
@@ -60,4 +60,9 @@ public class InstanceTableIOConstants {
*/
public static final String URL_STRING = "url";
+ /**
+ * Parameter for exporting empty feature types to XLS Export
+ */
+ public static final String EXPORT_IGNORE_EMPTY_FEATURETYPES = "ignoreEmptyFeaturetypes";
+
}
diff --git a/io/plugins/eu.esdihumboldt.hale.io.xls.test/src/eu/esdihumboldt/hale/io/xls/test/XLSInstanceIOTest.java b/io/plugins/eu.esdihumboldt.hale.io.xls.test/src/eu/esdihumboldt/hale/io/xls/test/XLSInstanceIOTest.java
index 2b936fab65..40f022df45 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.xls.test/src/eu/esdihumboldt/hale/io/xls/test/XLSInstanceIOTest.java
+++ b/io/plugins/eu.esdihumboldt.hale.io.xls.test/src/eu/esdihumboldt/hale/io/xls/test/XLSInstanceIOTest.java
@@ -59,6 +59,8 @@ public void test() {
.getContentType("eu.esdihumboldt.hale.io.xls.xls");
writer.setParameter(InstanceTableIOConstants.SOLVE_NESTED_PROPERTIES, Value.of(false));
writer.setParameter(InstanceTableIOConstants.USE_SCHEMA, Value.of(true));
+ writer.setParameter(InstanceTableIOConstants.EXPORT_IGNORE_EMPTY_FEATURETYPES,
+ Value.of(false));
writer.setParameter(InstanceTableIOConstants.EXPORT_TYPE, Value.of("ItemType"));
File tempDir = Files.createTempDir();
diff --git a/io/plugins/eu.esdihumboldt.hale.io.xls.test/src/eu/esdihumboldt/hale/io/xls/test/writer/XLSInstanceWriterTest.java b/io/plugins/eu.esdihumboldt.hale.io.xls.test/src/eu/esdihumboldt/hale/io/xls/test/writer/XLSInstanceWriterTest.java
index cc70668d03..100d32a27e 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.xls.test/src/eu/esdihumboldt/hale/io/xls/test/writer/XLSInstanceWriterTest.java
+++ b/io/plugins/eu.esdihumboldt.hale.io.xls.test/src/eu/esdihumboldt/hale/io/xls/test/writer/XLSInstanceWriterTest.java
@@ -98,6 +98,8 @@ public void testWriteSimpleSchemaColOrder() throws Exception {
.getContentType("eu.esdihumboldt.hale.io.xls.xls");
writer.setParameter(InstanceTableIOConstants.SOLVE_NESTED_PROPERTIES, Value.of(true));
writer.setParameter(InstanceTableIOConstants.USE_SCHEMA, Value.of(true));
+ writer.setParameter(InstanceTableIOConstants.EXPORT_IGNORE_EMPTY_FEATURETYPES,
+ Value.of(false));
writer.setParameter(InstanceTableIOConstants.EXPORT_TYPE, Value.of("city"));
File tmpFile = tmpFolder.newFile("excelTestWriteSimpleSchema.xls");
@@ -148,6 +150,8 @@ public void testWriteComplexSchema() throws Exception {
.getContentType("eu.esdihumboldt.hale.io.xls.xls");
writer.setParameter(InstanceTableIOConstants.SOLVE_NESTED_PROPERTIES, Value.of(true));
writer.setParameter(InstanceTableIOConstants.USE_SCHEMA, Value.of(false));
+ writer.setParameter(InstanceTableIOConstants.EXPORT_IGNORE_EMPTY_FEATURETYPES,
+ Value.of(true));
writer.setParameter(InstanceTableIOConstants.EXPORT_TYPE, Value.of("person"));
File tmpFile = tmpFolder.newFile("excelTestWriteComplexSchema.xls");
@@ -197,6 +201,8 @@ public void testWriteNotNestedProperties() throws Exception {
.getContentType("eu.esdihumboldt.hale.io.xls.xls");
writer.setParameter(InstanceTableIOConstants.SOLVE_NESTED_PROPERTIES, Value.of(false));
writer.setParameter(InstanceTableIOConstants.USE_SCHEMA, Value.of(false));
+ writer.setParameter(InstanceTableIOConstants.EXPORT_IGNORE_EMPTY_FEATURETYPES,
+ Value.of(true));
writer.setParameter(InstanceTableIOConstants.EXPORT_TYPE, Value.of("person"));
File tmpFile = tmpFolder.newFile("excelNotNestedProperties.xls");
@@ -248,6 +254,8 @@ public void testExportMultiFeatureToExcel() throws Exception {
.getContentType("eu.esdihumboldt.hale.io.xls.xls");
writer.setParameter(InstanceTableIOConstants.SOLVE_NESTED_PROPERTIES, Value.of(false));
writer.setParameter(InstanceTableIOConstants.USE_SCHEMA, Value.of(false));
+ writer.setParameter(InstanceTableIOConstants.EXPORT_IGNORE_EMPTY_FEATURETYPES,
+ Value.of(false));
writer.setParameter(InstanceTableIOConstants.EXPORT_TYPE,
Value.of("{http://www.example.org/t2/}PersonType,{http://www.example.org/t2/}T2"));
diff --git a/io/plugins/eu.esdihumboldt.hale.io.xls.ui/src/eu/esdihumboldt/hale/io/xls/ui/XLSInstanceExportConfigurationPage.java b/io/plugins/eu.esdihumboldt.hale.io.xls.ui/src/eu/esdihumboldt/hale/io/xls/ui/XLSInstanceExportConfigurationPage.java
index 87dbd70d8c..18615c2982 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.xls.ui/src/eu/esdihumboldt/hale/io/xls/ui/XLSInstanceExportConfigurationPage.java
+++ b/io/plugins/eu.esdihumboldt.hale.io.xls.ui/src/eu/esdihumboldt/hale/io/xls/ui/XLSInstanceExportConfigurationPage.java
@@ -25,18 +25,15 @@
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.PlatformUI;
@@ -59,6 +56,7 @@ public class XLSInstanceExportConfigurationPage extends CommonInstanceExportConf
private Button selectAll = null;
private Group chooseFeatureTypes;
private Table table;
+ private Button ignoreEmptyFeaturetypes = null;
/**
*
@@ -95,6 +93,11 @@ protected void createContent(Composite page) {
protected void onShowPage(boolean firstShow) {
if (firstShow) {
+ ignoreEmptyFeaturetypes = new Button(chooseFeatureTypes, SWT.CHECK);
+ ignoreEmptyFeaturetypes.setText("Exclude feature types without data");
+ ignoreEmptyFeaturetypes
+ .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+
selectAll = new Button(chooseFeatureTypes, SWT.CHECK);
selectAll.setText("Select all");
selectAll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
@@ -110,14 +113,6 @@ public void widgetSelected(SelectionEvent e) {
}
});
- Label separatorLabel = new Label(page, SWT.NONE);
- separatorLabel.setText("Warning! Feature types with no data are not selectable");
-
- // Set the text colour of the label to yellow
- Color greyLabel = PlatformUI.getWorkbench().getDisplay()
- .getSystemColor(SWT.COLOR_DARK_GRAY);
- separatorLabel.setForeground(greyLabel);
-
table = new Table(chooseFeatureTypes, SWT.CHECK | SWT.MULTI | SWT.SCROLL_PAGE);
table.setHeaderVisible(false);
table.setLinesVisible(false);
@@ -131,6 +126,9 @@ public void widgetSelected(SelectionEvent e) {
@Override
public String getText(Object element) {
+ if ((element instanceof TypeDefinition) && checkboxState(element))
+ return ((TypeDefinition) element).getDisplayName() + " [no data]";
+
return ((TypeDefinition) element).getDisplayName();
}
@@ -155,48 +153,30 @@ public void checkStateChanged(CheckStateChangedEvent event) {
}
});
- featureTypeTable.setCheckStateProvider(new ICheckStateProvider() {
-
- @Override
- public boolean isChecked(Object element) {
- if (!(element instanceof TypeDefinition))
- return false;
- return checkboxState(element);
- }
+ page.layout();
+ page.pack();
+ }
+ }
- @Override
- public boolean isGrayed(Object element) {
- if (!(element instanceof TypeDefinition))
- return false;
- return checkboxState(element);
- }
+ /**
+ * @param element element to be checked
+ * @return true if the button cannot be selected
+ */
+ private boolean checkboxState(Object element) {
+ InstanceService instanceService = PlatformUI.getWorkbench()
+ .getService(InstanceService.class);
- /**
- * @param element
- * @return true if the button cannot be selected
- */
- private boolean checkboxState(Object element) {
- InstanceService instanceService = PlatformUI.getWorkbench()
- .getService(InstanceService.class);
-
- Set instanceSourceTypes = instanceService
- .getInstanceTypes(DataSet.SOURCE);
- if (instanceSourceTypes.contains(element)) {
- return false;
- }
-
- Set instanceTransformedTypes = instanceService
- .getInstanceTypes(DataSet.TRANSFORMED);
- if (instanceTransformedTypes.contains(element)) {
- return false;
- }
- return true;
- }
- });
+ Set instanceSourceTypes = instanceService.getInstanceTypes(DataSet.SOURCE);
+ if (instanceSourceTypes.contains(element)) {
+ return false;
+ }
- page.layout();
- page.pack();
+ Set instanceTransformedTypes = instanceService
+ .getInstanceTypes(DataSet.TRANSFORMED);
+ if (instanceTransformedTypes.contains(element)) {
+ return false;
}
+ return true;
}
private boolean validate() {
@@ -219,6 +199,8 @@ public boolean updateConfiguration(InstanceWriter provider) {
param = param + ((TypeDefinition) el).getName().toString() + ",";
}
provider.setParameter(InstanceTableIOConstants.EXPORT_TYPE, Value.of(param));
+ provider.setParameter(InstanceTableIOConstants.EXPORT_IGNORE_EMPTY_FEATURETYPES,
+ Value.of(ignoreEmptyFeaturetypes.getSelection()));
return true;
}
diff --git a/io/plugins/eu.esdihumboldt.hale.io.xls/plugin.xml b/io/plugins/eu.esdihumboldt.hale.io.xls/plugin.xml
index aa4c28501f..f2c94612dd 100644
--- a/io/plugins/eu.esdihumboldt.hale.io.xls/plugin.xml
+++ b/io/plugins/eu.esdihumboldt.hale.io.xls/plugin.xml
@@ -173,8 +173,8 @@
in a try block because is closable
// -
@@ -170,14 +174,18 @@ private void addSheetByQName(boolean solveNestedProperties, InstanceCollection i
try {
instance = instanceIterator.next();
} catch (NoSuchElementException e) {
+ if (!ignoreEmptyFeaturetypes) {
+ Sheet sheet = workbook.createSheet(selectedTypeName.getDisplayName());
+ Row headerRow = sheet.createRow(0);
+ writeHeaderRow(headerRow, headerRowStrings);
+ setCellStyle(sheet, headerRowStrings.size());
+ resizeSheet(sheet);
+ }
return;
}
headerRowStrings = new ArrayList();
- boolean useSchema = getParameter(InstanceTableIOConstants.USE_SCHEMA).as(Boolean.class,
- true);
-
// all instances with equal type definitions are stored in an
// extra
// sheet