Skip to content

Commit 73b4781

Browse files
authored
Xlsx decision tables (#365)
* Allow XLSX as format for decision table data * Replace starter decision table files with new .xlsx versions
1 parent 958838d commit 73b4781

16 files changed

Lines changed: 58 additions & 38 deletions

core/src/main/java/com/devonfw/tools/solicitor/common/LogMessages.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public enum LogMessages {
7575
SHORTENING_XLS_CELL_CONTENT(49, "Shortening text content for XLS"), //
7676
REPLACING_EXCESSIVE_HTML_CONTENT(50,
7777
"At least one license text contained a large amount of raw HTML and was substituted by placeholder text '{}'"), //
78-
MULTIPLE_DECISIONTABLES(51, "Multiple decision tables in both .xls and .csv format. Prioritizing '{}.xls'."), //
78+
MULTIPLE_DECISIONTABLES(51, "Multiple decision tables in .xlsx, .xls and/or .csv format. Prioritizing '{}'."), //
7979
ADDING_ADDITIONALWRITER_CONFIG(52, "Merging config: Adding additional writers to base config from {}"), //
8080
NOT_A_VALID_NPM_PACKAGE_IDENTIFIER(53, "{} is not a valid identifier for an NPM package"), //
8181
SCANCODE_PROCESSOR_STARTING(54,

core/src/main/java/com/devonfw/tools/solicitor/common/ResourceToFileCopier.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -236,18 +236,18 @@ public String copyReourcesToFile(ResourceGroup resourceGroup, String targetDir)
236236
.withCopyOperation("classpath:starters/solicitor.cfg", "new_project/solicitor.cfg")
237237
.withCopyOperation("classpath:starters/input/licenses_starter.xml",
238238
"new_project/input/licenses_starter.xml")
239-
.withCopyOperation("classpath:starters/rules/LegalEvaluationProject.xls",
240-
"new_project/rules/LegalEvaluationProject.xls")
241-
.withCopyOperation("classpath:starters/rules/LegalPreEvaluationProject.xls",
242-
"new_project/rules/LegalPreEvaluationProject.xls")
243-
.withCopyOperation("classpath:starters/rules/LicenseAssignmentV2Project.xls",
244-
"new_project/rules/LicenseAssignmentV2Project.xls")
245-
.withCopyOperation("classpath:starters/rules/LicenseNameMappingProject.xls",
246-
"new_project/rules/LicenseNameMappingProject.xls")
247-
.withCopyOperation("classpath:starters/rules/LicenseSelectionProject.xls",
248-
"new_project/rules/LicenseSelectionProject.xls")
249-
.withCopyOperation("classpath:starters/rules/MultiLicenseSelectionProject.xls",
250-
"new_project/rules/MultiLicenseSelectionProject.xls")
239+
.withCopyOperation("classpath:starters/rules/LegalEvaluationProject.xlsx",
240+
"new_project/rules/LegalEvaluationProject.xlsx")
241+
.withCopyOperation("classpath:starters/rules/LegalPreEvaluationProject.xlsx",
242+
"new_project/rules/LegalPreEvaluationProject.xlsx")
243+
.withCopyOperation("classpath:starters/rules/LicenseAssignmentV2Project.xlsx",
244+
"new_project/rules/LicenseAssignmentV2Project.xlsx")
245+
.withCopyOperation("classpath:starters/rules/LicenseNameMappingProject.xlsx",
246+
"new_project/rules/LicenseNameMappingProject.xlsx")
247+
.withCopyOperation("classpath:starters/rules/LicenseSelectionProject.xlsx",
248+
"new_project/rules/LicenseSelectionProject.xlsx")
249+
.withCopyOperation("classpath:starters/rules/MultiLicenseSelectionProject.xlsx",
250+
"new_project/rules/MultiLicenseSelectionProject.xlsx")
251251
.withCopyOperation("classpath:starters/readme.txt", "new_project/readme.txt");
252252
optionallyAddExtensionFiles(csb2);
253253
csb2.replaceInTarget("new_project", targetDir).execute();

core/src/main/java/com/devonfw/tools/solicitor/ruleengine/drools/DroolsRuleEngine.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,40 @@ private int executeRuleGroup(ModelRoot modelRoot, RuleConfig rc) {
121121

122122
/**
123123
* Determine the final rule source name. If the resource given by {@link RuleConfig#getRuleSource()} exists then take
124-
* this. Otherwise check for alternatives by appending xls or csv suffix (with xls taking priority over csv).
124+
* this. Otherwise check for alternatives by appending xlsx, xls or csv suffix (with decreasing priority: xlsx, xls,
125+
* csv).
125126
*
126127
* @param rc the configuration of the rule
127128
*/
128129
private void determineFinalRuleSourceName(RuleConfig rc) {
129130

130131
if (!this.inputStreamFactory.isExisting(rc.getRuleSource())) {
132+
boolean xlsxExists = false;
133+
boolean xlsExists = false;
134+
boolean csvExists = false;
135+
int countExisting = 0;
136+
if (this.inputStreamFactory.isExisting(rc.getRuleSource() + ".xlsx")) {
137+
xlsxExists = true;
138+
countExisting++;
139+
}
131140
if (this.inputStreamFactory.isExisting(rc.getRuleSource() + ".xls")) {
132-
if (this.inputStreamFactory.isExisting(rc.getRuleSource() + ".csv")) {
133-
LOG.warn(LogMessages.MULTIPLE_DECISIONTABLES.msg(), rc.getRuleSource());
134-
}
141+
xlsExists = true;
142+
countExisting++;
143+
}
144+
if (this.inputStreamFactory.isExisting(rc.getRuleSource() + ".csv")) {
145+
csvExists = true;
146+
countExisting++;
147+
}
148+
if (xlsxExists) {
149+
rc.setRuleSource(rc.getRuleSource() + ".xlsx");
150+
} else if (xlsExists) {
135151
rc.setRuleSource(rc.getRuleSource() + ".xls");
136-
} else if (this.inputStreamFactory.isExisting(rc.getRuleSource() + ".csv")) {
152+
} else if (csvExists) {
137153
rc.setRuleSource(rc.getRuleSource() + ".csv");
138154
}
155+
if (countExisting > 1) {
156+
LOG.warn(LogMessages.MULTIPLE_DECISIONTABLES.msg(), rc.getRuleSource());
157+
}
139158
}
140159
}
141160

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)