From 6cc5d585fde2be77dbe1f28c4ba9f3315e965843 Mon Sep 17 00:00:00 2001 From: Pramod Kalapa Date: Wed, 27 Sep 2023 09:31:56 -0400 Subject: [PATCH 1/7] Updates for external template information file for tsv input --- docs/examples/animals_header.tsv | 2 + docs/examples/animals_no_header.owl | 55 +++++++++++++++++++ docs/examples/animals_no_header.tsv | 4 ++ docs/template.md | 12 +++- .../org/obolibrary/robot/TemplateCommand.java | 24 ++++++++ 5 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 docs/examples/animals_header.tsv create mode 100644 docs/examples/animals_no_header.owl create mode 100644 docs/examples/animals_no_header.tsv diff --git a/docs/examples/animals_header.tsv b/docs/examples/animals_header.tsv new file mode 100644 index 000000000..eb10730c5 --- /dev/null +++ b/docs/examples/animals_header.tsv @@ -0,0 +1,2 @@ +ID LABEL SC % A rdfs:comment + diff --git a/docs/examples/animals_no_header.owl b/docs/examples/animals_no_header.owl new file mode 100644 index 000000000..62c78e1c2 --- /dev/null +++ b/docs/examples/animals_no_header.owl @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + Any animal in the world. + animal + + + + + + + + + A member of the genus Canis. + canine + + + + + + + + + A member of the genus Felis. + feline + + + + + + + diff --git a/docs/examples/animals_no_header.tsv b/docs/examples/animals_no_header.tsv new file mode 100644 index 000000000..d684bd19c --- /dev/null +++ b/docs/examples/animals_no_header.tsv @@ -0,0 +1,4 @@ +CURIE Label Parent Comment +obo:0000001 animal Any animal in the world. +obo:0000002 canine animal A member of the genus Canis. +obo:0000003 feline animal A member of the genus Felis. diff --git a/docs/template.md b/docs/template.md index 94c974ba4..a1b5d4ca4 100644 --- a/docs/template.md +++ b/docs/template.md @@ -151,7 +151,7 @@ If the `TYPE` is a defined class, `owl:Individual`, or `owl:NamedIndividual`, an #### Example of Individual Template Strings -| Label | Entity Type | Individual Role | Property Assertions | Different Individuals | +| Label | Entity Type | Individual Role | Property Assertions | Different Individuals | | ------------ | ----------- | -------------------- | ------------------- | --------------------- | | LABEL | TYPE | TI 'has role' some % | I part_of | DI % | | Individual 1 | Class 1 | Role Class 1 | Individual 2 | | @@ -223,6 +223,13 @@ robot template --merge-before \ --output results/test_template.owl ``` +MEKS ROBOT header read from separate file + + robot template --template animals_no_header.tsv \ + --robot-header animals_header.tsv \ + --output results/animals_no_header.owl + + \* NOTE: the imports would be merged into the output if `--collapse-import-closure true` is included instead. Further examples can be found [in the OBI repository](https://github.com/obi-ontology/obi/tree/master/src/ontology/templates) @@ -313,7 +320,7 @@ AL rdfs:label@en The provided value cannot be parsed and may not be in proper Manchester syntax. See [Manchester Syntax](http://www.w3.org/2007/OWL/wiki/ManchesterSyntax) for more details. If you are using labels, make sure the labels are defined in the `--input` ontology or using the `LABEL` column. Also ensure that all properties use a label instead of a CURIE or IRI. -When using a restriction (`some`, `only`, `min`, `max`, `exactly`, or `value`) the term that preceeds the restriction must be a property. +When using a restriction (`some`, `only`, `min`, `max`, `exactly`, or `value`) the term that preceeds the restriction must be a property. Terms joined using `and` or `or` must be of the same entity type, e.g., you cannot join an object property and a class in an expression. @@ -366,3 +373,4 @@ An invalid `CHARACTERISTIC` value was passed. If you are providing multiple char ### Unknown Template Error Valid template strings are limited to the [described above](#template-strings). If a different template string is provided, this error message will be returned. + diff --git a/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java b/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java index 434936466..2e1aa41ce 100644 --- a/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java +++ b/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java @@ -28,6 +28,10 @@ public class TemplateCommand implements Command { private static final String missingTemplateError = NS + "MISSING TEMPLATE ERROR at least one template is required"; + /** Error message when the header file is not provided */ + private static final String missingRobotHeaderError = + NS + "MISSING ROBOT HEADER ERROR header is required"; + /** Store the command-line options for the command. */ private Options options; @@ -49,6 +53,7 @@ public TemplateCommand() { "A", "include-annotations", true, "if true, include ontology annotations from merge input"); o.addOption("f", "force", true, "if true, do not exit on error"); o.addOption("e", "errors", true, "write errors to this path (TSV or CSV)"); + o.addOption("h", "robot-header", true, "input robot header line file"); options = o; } @@ -143,6 +148,25 @@ public CommandState execute(CommandState state, String[] args) throws Exception tables.put(templatePath, TemplateHelper.readTable(templatePath)); } + for (String templatePath : templatePaths) { + tables.put(templatePath, TemplateHelper.readTable(templatePath)); + } + // Read the robot header line in + List robotHeaderPath = CommandLineHelper.getOptionValues(line, "robot-header"); + if (robotHeaderPath.size() > 0) { + // TODO for now only a single header line file is considered + List> headerLine = new ArrayList<>(); + headerLine = TemplateHelper.readTable(robotHeaderPath.get(0)); + if (headerLine.size() == 0) { + throw new IllegalArgumentException(missingRobotHeaderError); + } + // Insert headerLine into all the template file data appropriately + for (String templatePath : templatePaths) { + List> template = tables.get(templatePath); + template.add(1, headerLine.get(0)); + } + } + // Process the templates OWLOntology outputOntology = TemplateOperation.template(inputOntology, ioHelper, tables, templateOptions); From c251d60a8741953af75bebc09242209021675ea6 Mon Sep 17 00:00:00 2001 From: Pramod Kalapa Date: Thu, 28 Sep 2023 17:10:37 -0400 Subject: [PATCH 2/7] Renamed external template file input option --- .../{animals_no_header.owl => animals_ext_template.owl} | 0 .../{animals_no_header.tsv => animals_ext_template.tsv} | 0 .../examples/{animals_header.tsv => animals_template.tsv} | 0 docs/template.md | 8 ++++---- .../main/java/org/obolibrary/robot/TemplateCommand.java | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) rename docs/examples/{animals_no_header.owl => animals_ext_template.owl} (100%) rename docs/examples/{animals_no_header.tsv => animals_ext_template.tsv} (100%) rename docs/examples/{animals_header.tsv => animals_template.tsv} (100%) diff --git a/docs/examples/animals_no_header.owl b/docs/examples/animals_ext_template.owl similarity index 100% rename from docs/examples/animals_no_header.owl rename to docs/examples/animals_ext_template.owl diff --git a/docs/examples/animals_no_header.tsv b/docs/examples/animals_ext_template.tsv similarity index 100% rename from docs/examples/animals_no_header.tsv rename to docs/examples/animals_ext_template.tsv diff --git a/docs/examples/animals_header.tsv b/docs/examples/animals_template.tsv similarity index 100% rename from docs/examples/animals_header.tsv rename to docs/examples/animals_template.tsv diff --git a/docs/template.md b/docs/template.md index a1b5d4ca4..b203d799a 100644 --- a/docs/template.md +++ b/docs/template.md @@ -223,11 +223,11 @@ robot template --merge-before \ --output results/test_template.owl ``` -MEKS ROBOT header read from separate file +ROBOT template data read from separate external file - robot template --template animals_no_header.tsv \ - --robot-header animals_header.tsv \ - --output results/animals_no_header.owl + robot template --template animals_ext_template.tsv \ + --ext-template animals_template.tsv \ + --output results/animals_ext_template.owl \* NOTE: the imports would be merged into the output if `--collapse-import-closure true` is included instead. diff --git a/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java b/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java index 2e1aa41ce..bcddd5b23 100644 --- a/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java +++ b/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java @@ -53,7 +53,7 @@ public TemplateCommand() { "A", "include-annotations", true, "if true, include ontology annotations from merge input"); o.addOption("f", "force", true, "if true, do not exit on error"); o.addOption("e", "errors", true, "write errors to this path (TSV or CSV)"); - o.addOption("h", "robot-header", true, "input robot header line file"); + o.addOption("E", "ext-template", true, "external robot template data file"); options = o; } @@ -152,9 +152,9 @@ public CommandState execute(CommandState state, String[] args) throws Exception tables.put(templatePath, TemplateHelper.readTable(templatePath)); } // Read the robot header line in - List robotHeaderPath = CommandLineHelper.getOptionValues(line, "robot-header"); + List robotHeaderPath = CommandLineHelper.getOptionValues(line, "ext-template"); if (robotHeaderPath.size() > 0) { - // TODO for now only a single header line file is considered + // For now only a single header line file is considered List> headerLine = new ArrayList<>(); headerLine = TemplateHelper.readTable(robotHeaderPath.get(0)); if (headerLine.size() == 0) { From fa51df23d5377403ad2e6778885e2fc018794cda Mon Sep 17 00:00:00 2001 From: Pramod Kalapa Date: Thu, 28 Sep 2023 17:48:15 -0400 Subject: [PATCH 3/7] Added information about issue #1152 for external file input of template strings --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ad04bdae..88420b56a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ 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] + ## [1.9.5] - 2023-09-20 ### Added From b2bb4b2aed439afb25736e4d00155ac75bef845d Mon Sep 17 00:00:00 2001 From: Pramod Kalapa Date: Fri, 27 Oct 2023 16:17:31 -0400 Subject: [PATCH 4/7] #1152 Updates to adjust rowNum when ext-template option is used --- .../src/main/java/org/obolibrary/robot/Template.java | 6 ++++++ .../java/org/obolibrary/robot/TemplateOperation.java | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/robot-core/src/main/java/org/obolibrary/robot/Template.java b/robot-core/src/main/java/org/obolibrary/robot/Template.java index f98b331fa..fcf646930 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/Template.java +++ b/robot-core/src/main/java/org/obolibrary/robot/Template.java @@ -421,7 +421,13 @@ public OWLOntology generateOutputOntology(String outputIRI, boolean force, Strin return outputOntology; } + public int getRowNum() { + return rowNum; + } + public void setRowNum(int rowNum) { + this.rowNum = rowNum; + } /** * Given a list of rows for a table, first validate the headers and template strings. Then, get * the location of important columns (e.g. IDs and labels). Finally, add all template rows to the diff --git a/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java b/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java index 3385c1c62..57ed242ff 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java +++ b/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java @@ -109,6 +109,7 @@ public static Map getDefaultOptions() { Map options = new HashMap<>(); options.put("force", "false"); options.put("errors", null); + options.put("ext-template", null); return options; } @@ -158,7 +159,7 @@ public static OWLOntology template( * Given an OWLOntology, an IOHelper, a map of table names to table contents, and a map of * template options, use the tables as templates to generate a merged output ontology. * - * @param inputOntology OWLOntology to use to get existing entities + * @param inputOntology OWLOntology to use to get existing entitfies * @param ioHelper IOHelper to resolve prefixes * @param tables table names to table contents * @param options map of template options @@ -176,6 +177,10 @@ public static OWLOntology template( List outputOntologies = new ArrayList<>(); for (Map.Entry>> t : tables.entrySet()) { Template template = new Template(t.getKey(), t.getValue(), intermediate, ioHelper, checker); + // sufficient to check if ext-template option has a not null value + if(options.get("ext-template") != null) { + template.setRowNum(1); + } // Update the checker with new labels checker = template.getChecker(); boolean force = OptionsHelper.optionIsTrue(options, "force"); @@ -487,6 +492,8 @@ public static OWLOntology template( int idColumn = idColumns.get(tableName); int labelColumn = labelColumns.get(tableName); List> rows = tables.get(tableName); + // TODO The starting row has to be controlled by the approach used, ie, internal or external + // template for (int row = 2; row < rows.size(); row++) { addLogic(outputOntology, tableName, rows, row, idColumn, labelColumn, checker, parser); } From a5f7581b5c875354b5dfe9004204e4c3defa5991 Mon Sep 17 00:00:00 2001 From: Pramod Kalapa Date: Wed, 1 Nov 2023 18:29:22 -0400 Subject: [PATCH 5/7] PR#1152 Added ext test template file with error to show adjusted line numbers --- docs/examples/animals_ext_template_error.tsv | 4 ++ docs/examples/animals_template_combined.tsv | 5 ++ docs/template.md | 8 +++ results/animals_ext_template.owl | 55 +++++++++++++++++++ .../java/org/obolibrary/robot/Template.java | 1 + .../obolibrary/robot/TemplateOperation.java | 2 +- 6 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 docs/examples/animals_ext_template_error.tsv create mode 100644 docs/examples/animals_template_combined.tsv create mode 100644 results/animals_ext_template.owl diff --git a/docs/examples/animals_ext_template_error.tsv b/docs/examples/animals_ext_template_error.tsv new file mode 100644 index 000000000..4e78657d6 --- /dev/null +++ b/docs/examples/animals_ext_template_error.tsv @@ -0,0 +1,4 @@ +CURIE Label Parent Comment +obo:0000001 animal Any animal in the world. +0000002 canine animal A member of the genus Canis. +obo:0000003 feline animal A member of the genus Felis. diff --git a/docs/examples/animals_template_combined.tsv b/docs/examples/animals_template_combined.tsv new file mode 100644 index 000000000..ebba2f451 --- /dev/null +++ b/docs/examples/animals_template_combined.tsv @@ -0,0 +1,5 @@ +CURIE Label Parent Comment +ID LABEL SC % A rdfs:comment +obo:0000001 animal Any animal in the world. +0000002 canine animal A member of the genus Canis. +obo:0000003 feline animal A member of the genus Felis. \ No newline at end of file diff --git a/docs/template.md b/docs/template.md index b203d799a..164b33307 100644 --- a/docs/template.md +++ b/docs/template.md @@ -229,6 +229,14 @@ ROBOT template data read from separate external file --ext-template animals_template.tsv \ --output results/animals_ext_template.owl +Adjusted line numbers for error reporting for template data read from separate external file + +``` +robot template --template animals_ext_template_error.tsv \ + --ext-template animals_template.tsv \ + --output results/animals_ext_template.owl +``` + \* NOTE: the imports would be merged into the output if `--collapse-import-closure true` is included instead. diff --git a/results/animals_ext_template.owl b/results/animals_ext_template.owl new file mode 100644 index 000000000..d37e98c42 --- /dev/null +++ b/results/animals_ext_template.owl @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + Any animal in the world. + animal + + + + + + + + + A member of the genus Canis. + canine + + + + + + + + + A member of the genus Felis. + feline + + + + + + + diff --git a/robot-core/src/main/java/org/obolibrary/robot/Template.java b/robot-core/src/main/java/org/obolibrary/robot/Template.java index fcf646930..ed1eedd25 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/Template.java +++ b/robot-core/src/main/java/org/obolibrary/robot/Template.java @@ -421,6 +421,7 @@ public OWLOntology generateOutputOntology(String outputIRI, boolean force, Strin return outputOntology; } + public int getRowNum() { return rowNum; } diff --git a/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java b/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java index 57ed242ff..ec942da93 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java +++ b/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java @@ -178,7 +178,7 @@ public static OWLOntology template( for (Map.Entry>> t : tables.entrySet()) { Template template = new Template(t.getKey(), t.getValue(), intermediate, ioHelper, checker); // sufficient to check if ext-template option has a not null value - if(options.get("ext-template") != null) { + if (options.get("ext-template") != null) { template.setRowNum(1); } // Update the checker with new labels From 948de752d7ad9db7de3ff2dd953c91a90cff7099 Mon Sep 17 00:00:00 2001 From: Pramod Kalapa Date: Tue, 9 Jan 2024 15:17:37 -0500 Subject: [PATCH 6/7] PR#1152 Addressed code review --- CHANGELOG.md | 3 ++- ...imals_template_combined.tsv => animals_template_error.tsv} | 0 .../src/main/java/org/obolibrary/robot/TemplateOperation.java | 4 +--- 3 files changed, 3 insertions(+), 4 deletions(-) rename docs/examples/{animals_template_combined.tsv => animals_template_error.tsv} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7396178e9..4ade853c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] @@ -527,3 +527,4 @@ 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 \ No newline at end of file diff --git a/docs/examples/animals_template_combined.tsv b/docs/examples/animals_template_error.tsv similarity index 100% rename from docs/examples/animals_template_combined.tsv rename to docs/examples/animals_template_error.tsv diff --git a/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java b/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java index ec942da93..a4de0d696 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java +++ b/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java @@ -159,7 +159,7 @@ public static OWLOntology template( * Given an OWLOntology, an IOHelper, a map of table names to table contents, and a map of * template options, use the tables as templates to generate a merged output ontology. * - * @param inputOntology OWLOntology to use to get existing entitfies + * @param inputOntology OWLOntology to use to get existing entities * @param ioHelper IOHelper to resolve prefixes * @param tables table names to table contents * @param options map of template options @@ -492,8 +492,6 @@ public static OWLOntology template( int idColumn = idColumns.get(tableName); int labelColumn = labelColumns.get(tableName); List> rows = tables.get(tableName); - // TODO The starting row has to be controlled by the approach used, ie, internal or external - // template for (int row = 2; row < rows.size(); row++) { addLogic(outputOntology, tableName, rows, row, idColumn, labelColumn, checker, parser); } From 11d9aea7e9dcb2b4ff38bf1188e2bd28e9993d86 Mon Sep 17 00:00:00 2001 From: Pramod Kalapa Date: Wed, 27 Mar 2024 14:26:25 -0400 Subject: [PATCH 7/7] #1154 Code review changes and error checking for external template --- docs/examples/animals_ext_template.tsv | 4 +-- docs/examples/animals_template.tsv | 6 ++-- docs/template.md | 6 ++-- .../org/obolibrary/robot/TemplateCommand.java | 34 +++++++++++++++++-- .../obolibrary/robot/TemplateOperation.java | 2 +- 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/docs/examples/animals_ext_template.tsv b/docs/examples/animals_ext_template.tsv index d684bd19c..adcd38023 100644 --- a/docs/examples/animals_ext_template.tsv +++ b/docs/examples/animals_ext_template.tsv @@ -1,4 +1,2 @@ CURIE Label Parent Comment -obo:0000001 animal Any animal in the world. -obo:0000002 canine animal A member of the genus Canis. -obo:0000003 feline animal A member of the genus Felis. +ID LABEL SC % A rdfs:comment diff --git a/docs/examples/animals_template.tsv b/docs/examples/animals_template.tsv index eb10730c5..d684bd19c 100644 --- a/docs/examples/animals_template.tsv +++ b/docs/examples/animals_template.tsv @@ -1,2 +1,4 @@ -ID LABEL SC % A rdfs:comment - +CURIE Label Parent Comment +obo:0000001 animal Any animal in the world. +obo:0000002 canine animal A member of the genus Canis. +obo:0000003 feline animal A member of the genus Felis. diff --git a/docs/template.md b/docs/template.md index 164b33307..cacd47145 100644 --- a/docs/template.md +++ b/docs/template.md @@ -225,15 +225,15 @@ robot template --merge-before \ ROBOT template data read from separate external file - robot template --template animals_ext_template.tsv \ - --ext-template animals_template.tsv \ + robot template --template animals_template.tsv \ + --external-template animals_ext_template.tsv \ --output results/animals_ext_template.owl Adjusted line numbers for error reporting for template data read from separate external file ``` robot template --template animals_ext_template_error.tsv \ - --ext-template animals_template.tsv \ + --ext-template animals_ext_template.tsv \ --output results/animals_ext_template.owl ``` diff --git a/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java b/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java index bcddd5b23..220d7ac38 100644 --- a/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java +++ b/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java @@ -32,6 +32,10 @@ public class TemplateCommand implements Command { private static final String missingRobotHeaderError = NS + "MISSING ROBOT HEADER ERROR header is required"; + private static final String mismatchedRobotHeaderError = + NS + + "MISMATCHED ROBOT HEADER mismatched template file header and external template file header"; + /** Store the command-line options for the command. */ private Options options; @@ -53,7 +57,7 @@ public TemplateCommand() { "A", "include-annotations", true, "if true, include ontology annotations from merge input"); o.addOption("f", "force", true, "if true, do not exit on error"); o.addOption("e", "errors", true, "write errors to this path (TSV or CSV)"); - o.addOption("E", "ext-template", true, "external robot template data file"); + o.addOption("E", "external-template", true, "external robot template data file"); options = o; } @@ -152,7 +156,7 @@ public CommandState execute(CommandState state, String[] args) throws Exception tables.put(templatePath, TemplateHelper.readTable(templatePath)); } // Read the robot header line in - List robotHeaderPath = CommandLineHelper.getOptionValues(line, "ext-template"); + List robotHeaderPath = CommandLineHelper.getOptionValues(line, "external-template"); if (robotHeaderPath.size() > 0) { // For now only a single header line file is considered List> headerLine = new ArrayList<>(); @@ -163,7 +167,12 @@ public CommandState execute(CommandState state, String[] args) throws Exception // Insert headerLine into all the template file data appropriately for (String templatePath : templatePaths) { List> template = tables.get(templatePath); - template.add(1, headerLine.get(0)); + // check that header lines match + if (checkHeaders(template.get(0), headerLine.get(0))) { + template.add(1, headerLine.get(1)); + } else { + throw new IllegalArgumentException(mismatchedRobotHeaderError); + } } } @@ -218,4 +227,23 @@ public CommandState execute(CommandState state, String[] args) throws Exception return state; } + + /** + * Compare the headers for the template file and the external template file Return true or false + * for match and mismatch situations respectively + * + * @param templateHeader header from template file + * @param externalTemplateHeader header from external template file + * @return true for match, false for mismatch + */ + private boolean checkHeaders(List templateHeader, List externalTemplateHeader) { + if (templateHeader.size() == externalTemplateHeader.size()) { + int numElements = templateHeader.size(); + for (int index = 0; index < numElements; index++) { + if (!templateHeader.get(index).equals(externalTemplateHeader.get(index))) return false; + } + return true; + } + return false; + } } diff --git a/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java b/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java index a4de0d696..d00fadec8 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java +++ b/robot-core/src/main/java/org/obolibrary/robot/TemplateOperation.java @@ -109,7 +109,7 @@ public static Map getDefaultOptions() { Map options = new HashMap<>(); options.put("force", "false"); options.put("errors", null); - options.put("ext-template", null); + options.put("external-template", null); return options; }