Skip to content

Commit

Permalink
Merge pull request #1190 from ontodev/robot-header-update
Browse files Browse the repository at this point in the history
ROBOT Header Update
  • Loading branch information
jamesaoverton authored Mar 29, 2024
2 parents 7173c55 + f1b680b commit 3d75b32
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 76 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
-- Added option to input template strings from external file [#1152]
- Added option to input template strings from external file [#1152]

### Fixed
- '--annotate-with-source true' does not work with extract --method subset [#1160]
Expand Down Expand Up @@ -391,6 +391,7 @@ First official release of ROBOT!
[#1171]: https://github.com/ontodev/robot/pull/1171
[#1168]: https://github.com/ontodev/robot/pull/1168
[#1160]: https://github.com/ontodev/robot/pull/1160
[#1152]: https://github.com/ontodev/robot/issues/1152
[#1148]: https://github.com/ontodev/robot/pull/1148
[#1135]: https://github.com/ontodev/robot/pull/1135
[#1119]: https://github.com/ontodev/robot/pull/1119
Expand Down Expand Up @@ -535,4 +536,3 @@ First official release of ROBOT!
[#246]: https://github.com/ontodev/robot/issues/246
[#174]: https://github.com/ontodev/robot/issues/174
[#158]: https://github.com/ontodev/robot/issues/158
[#1152]: https://github.com/ontodev/robot/issues/1152
4 changes: 0 additions & 4 deletions docs/examples/animals_ext_template_error.tsv

This file was deleted.

2 changes: 1 addition & 1 deletion docs/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ ROBOT template data read from separate external file
Adjusted line numbers for error reporting for template data read from separate external file
<!-- DO NOT TEST -->
```
robot template --template animals_ext_template_error.tsv \
robot template --template animals_template_error.tsv \
--ext-template animals_ext_template.tsv \
--output results/animals_ext_template.owl
```
Expand Down
55 changes: 0 additions & 55 deletions results/animals_ext_template.owl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,22 @@ public CommandState execute(CommandState state, String[] args) throws Exception
for (String templatePath : templatePaths) {
tables.put(templatePath, TemplateHelper.readTable(templatePath));
}
// Read the robot header line in
List<String> robotHeaderPath = CommandLineHelper.getOptionValues(line, "external-template");
if (robotHeaderPath.size() > 0) {
// For now only a single header line file is considered
List<List<String>> headerLine = new ArrayList<>();
headerLine = TemplateHelper.readTable(robotHeaderPath.get(0));
if (headerLine.size() == 0) {

// Handle external template files.
List<String> externalTemplatePath =
CommandLineHelper.getOptionValues(line, "external-template");
if (externalTemplatePath.size() > 0) {
List<List<String>> externalTemplate = new ArrayList<>();
externalTemplate = TemplateHelper.readTable(externalTemplatePath.get(0));
if (externalTemplate.size() == 0) {
throw new IllegalArgumentException(missingRobotHeaderError);
}
// Insert headerLine into all the template file data appropriately
// Insert externalTemplate into all the template file data appropriately
for (String templatePath : templatePaths) {
List<List<String>> template = tables.get(templatePath);
// check that header lines match
if (checkHeaders(template.get(0), headerLine.get(0))) {
template.add(1, headerLine.get(1));
// check that the first lines (headers) are the same
if (compareHeaders(template.get(0), externalTemplate.get(0))) {
template.add(1, externalTemplate.get(1));
} else {
throw new IllegalArgumentException(mismatchedRobotHeaderError);
}
Expand Down Expand Up @@ -229,14 +230,14 @@ public CommandState execute(CommandState state, String[] args) throws Exception
}

/**
* Compare the headers for the template file and the external template file Return true or false
* for match and mismatch situations respectively
* Compare the headers for the template file and the external template file. Return true if they
* match, false otherwise.
*
* @param templateHeader header from template file
* @param externalTemplateHeader header from external template file
* @return true for match, false for mismatch
*/
private boolean checkHeaders(List<String> templateHeader, List<String> externalTemplateHeader) {
private boolean compareHeaders(List<String> templateHeader, List<String> externalTemplateHeader) {
if (templateHeader.size() == externalTemplateHeader.size()) {
int numElements = templateHeader.size();
for (int index = 0; index < numElements; index++) {
Expand Down

0 comments on commit 3d75b32

Please sign in to comment.