Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor schema parsing code #56

Merged
merged 34 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f217225
Refactor schema parsing code
happy5214 Apr 3, 2022
6e6d4ab
Add remaining HED 3 schema XML categories to XPath implementation
happy5214 Apr 5, 2022
1e0a8e8
Switch tests to stable HED 8.0.0 schema
happy5214 Apr 5, 2022
3583ffd
Implement classes for schema properties and attributes
happy5214 Apr 5, 2022
ee69b3e
Convert Memoizer into more flexible pure mixin
happy5214 Apr 12, 2022
8d70559
Rewrite unit-related schema parsing and validation
happy5214 Apr 12, 2022
fb8a825
Improve code quality
happy5214 Apr 12, 2022
409828e
Re-implement schema tag parsing
happy5214 Apr 19, 2022
780f700
Refactor new schema parsing code and add Schema subclasses
happy5214 Apr 19, 2022
2f67890
Refactor two similar methods
happy5214 Apr 19, 2022
16e0777
Use existing property and new method to condense conditionals
happy5214 Apr 19, 2022
54a60e4
Temporarily disable HED 3 schema tests until they can be rewritten fo…
happy5214 Apr 19, 2022
f608bba
Create and use "map filter" method in SchemaEntryManager
happy5214 Apr 19, 2022
8f3999f
Surround validateDataset in try-catch to create internal BidsIssue in…
happy5214 Apr 20, 2022
fdee07c
Clean up rogue search-replace operation
happy5214 Apr 20, 2022
4480bd7
Condense for loop into map call
happy5214 Apr 20, 2022
a4ed4aa
Delete useless argument from super constructor call
happy5214 Apr 20, 2022
d40c3cd
Switch mappingData to Map type and add takesValue flag
happy5214 Apr 22, 2022
05e93bb
Update converter to deal with value-taking tag issue
happy5214 Apr 22, 2022
f2662ac
Unnesting if statement
happy5214 Apr 22, 2022
05497a5
Use ParsedHedTag superclass for syntax-only validation
happy5214 Apr 27, 2022
254a42a
Update stringParser tests to use stable v8.0.0 schema
happy5214 Apr 27, 2022
a8b3dc1
Update converter tests to use stable v8.0.0 schema
happy5214 Apr 29, 2022
326cd09
Delete obsolete HED 3 alpha schemas used for testing
happy5214 Apr 29, 2022
18049ec
Use Jest API features to improve test code quality and runtime
happy5214 Apr 29, 2022
d8d0f1b
Rename converter test modules for consistency with other testcases
happy5214 Apr 29, 2022
757d08b
Always perform HED column validation when doing BIDS TSV validation
happy5214 May 10, 2022
a4ca538
Add name of missing internal code to generic error message
happy5214 May 11, 2022
3960eee
Add context-aware dataset-validation entry point
happy5214 May 12, 2022
64c920c
Fix issues in BIDS validation
happy5214 May 12, 2022
46004e3
Add recursive map utility function
happy5214 May 13, 2022
1ee7b32
Add method to return full nested tag structure from ParsedHedGroup
happy5214 May 13, 2022
7cb334a
Add string parser tests involving deeply nested groups
happy5214 May 13, 2022
8e691c9
Modify test to use multiple top-level groups
happy5214 May 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/issues/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const issueData = {
genericError: {
hedCode: 'HED_GENERIC_ERROR',
level: 'error',
message: stringTemplate`Unknown HED error.`,
message: stringTemplate`Unknown HED error "${'internalCode'}".`,
},
}

Expand Down
1 change: 1 addition & 0 deletions common/issues/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const generateIssue = function (internalCode, parameters) {
const issueCodeData = issueData[internalCode] || issueData.genericError
const { hedCode, level, message } = issueCodeData
const bounds = parameters.bounds || []
parameters.internalCode = internalCode
const parsedMessage = message(...bounds, parameters)

return new Issue(internalCode, hedCode, level, parsedMessage)
Expand Down
48 changes: 48 additions & 0 deletions common/schema/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,52 @@ class Schema {
get isHed3() {
return this.generation === 3
}

/**
* Determine if a HED tag has a particular attribute in this schema.
*
* @param {string} tag The HED tag to check.
* @param {string} tagAttribute The attribute to check for.
* @return {boolean} Whether this tag has this attribute.
* @abstract
*/
// eslint-disable-next-line no-unused-vars
tagHasAttribute(tag, tagAttribute) {}
}

class Hed2Schema extends Schema {
/**
* Determine if a HED tag has a particular attribute in this schema.
*
* @param {string} tag The HED tag to check.
* @param {string} tagAttribute The attribute to check for.
* @return {boolean} Whether this tag has this attribute.
*/
tagHasAttribute(tag, tagAttribute) {
return this.attributes.tagHasAttribute(tag, tagAttribute)
}
}

class Hed3Schema extends Schema {
constructor(xmlData, entries, mapping) {
super(xmlData, null, mapping)
/**
* The collection of schema entries.
* @type {SchemaEntries}
*/
this.entries = entries
}

/**
* Determine if a HED tag has a particular attribute in this schema.
*
* @param {string} tag The HED tag to check.
* @param {string} tagAttribute The attribute to check for.
* @return {boolean} Whether this tag has this attribute.
*/
tagHasAttribute(tag, tagAttribute) {
return this.entries.tagHasAttribute(tag, tagAttribute)
}
}

/**
Expand Down Expand Up @@ -121,5 +167,7 @@ class Schemas {

module.exports = {
Schema: Schema,
Hed2Schema: Hed2Schema,
Hed3Schema: Hed3Schema,
Schemas: Schemas,
}
Loading