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

Refactored core model classes and support for collections of model in… #256

Merged

Conversation

david-waltermire
Copy link
Collaborator

@david-waltermire david-waltermire commented Nov 13, 2023

Committer Notes

This PR does two things:

  1. Adds support for defining a Metaschema module's model as a Metaschema module.
  2. Defines a new constraints format that can target based on a Metapth against the Metaschema module as a Metaschema module.

This involves adding support for usnistgov/metaschema#228, which means this PR depends on usnistgov/metaschema#470, which addresses this issue.

To full support the features of usnistgov/metaschema#228, the following needs to be completed.

  • core: Add core XML model support for choice-group
  • core: Add Metapath support for choice groups
  • databind: Add code generation support for choice-group
  • databind: Add XML serialization/deserialization support for choice-group
    • serialization
    • deserialization
  • databind: Add JSON/YAML serialization/deserialization support for choice-group
    • serialization
    • deserialization
  • databind: Schema loader support
  • schema-gen: Add XML schema generation support for choice-group
  • schema-gen: Add JSON schema generation support for choice-group

As a stretch goal, it would be nice to add support for binding customization of the item type used for choice-group, to allow a base class or interface to be used instead of Object as the item item. This base class or interface would need to be implemented by each member of the choice-group.

  • Add support for choice-group binding customization

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you squashed any non-relevant commits and commit messages? [instructions]
  • Do all automated CI/CD checks pass?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you included examples of how to use your new feature(s)?
  • Have you updated all website](https://pages.nist.gov/metaschema) and readme documentation affected by the changes you made? Changes to the website can be made in the website/content directory of your branch.

@aj-stein-nist
Copy link
Collaborator

This PR does two things:

1. Adds support for defining a Metaschema module's model as a Metaschema module.

2. Defines a new constraints format that can target based on a Metapth against the Metaschema module as a Metaschema module.

And so it begins! I look forward to see this PR progress and reach it's final state. 😎

@david-waltermire
Copy link
Collaborator Author

This PR does two things:

1. Adds support for defining a Metaschema module's model as a Metaschema module.

2. Defines a new constraints format that can target based on a Metapth against the Metaschema module as a Metaschema module.

And so it begins! I look forward to see this PR progress and reach it's final state. 😎

Using this code I was able to produce an example Metaschema module in YAML. This module describes a Metaschema module, so it is self describing!

@david-waltermire david-waltermire force-pushed the feature-metaconstraints-2 branch from dfc8c7f to 269e746 Compare November 25, 2023 16:52
@david-waltermire david-waltermire force-pushed the feature-metaconstraints-2 branch from 8797d64 to ccf2772 Compare December 10, 2023 15:43
@david-waltermire david-waltermire force-pushed the feature-metaconstraints-2 branch 3 times, most recently from 7379ff8 to 1f716ce Compare December 18, 2023 16:56
@david-waltermire david-waltermire force-pushed the feature-metaconstraints-2 branch 4 times, most recently from cd8ce6f to 1c2517a Compare January 24, 2024 13:53
@david-waltermire david-waltermire marked this pull request as ready for review January 24, 2024 13:59
@david-waltermire
Copy link
Collaborator Author

Support for Metapath using choice groups is partially implemented, but not tested. I am going to work on this in a new PR, so this one can be merged as-is.

…interfaces.

Removed the need to instances of IDataTypeHandler. Now IClassDataTypeHandler functionality is provided by IFeatureComplexItemValueHandler and JavaTypeAdapterDataTypeHandler is provided by IFeatureScalarItemValueHandler.
Refactored bound class hierarchy to be more consistent with needed methods.
- Moved Java field handling to IFeatureJavaField from IBoundNamedModelInstance
- Moved JSON key and item handling to IBoundModelInstance.
- Reworked XML and JSON reading and writing.
- Added IBoundChoiceGroupInstance interface for choice groups.
Cleaned up IModelPropertyInfo and implementations, relocating supporting classes as child classes.
Implemented a IModelInstance item parsing as IModelPropertyInfo.IReadHandler, allowing all item parsing to be implemented in the format-specific parsing classes, i.e. MetaschemaJsonReader, MetaschemaXmlReader.
… parsed value. Eliminated the need for IPropertyCollector instances.
… of terminology. Prior the terms "property" and "instance" were used interchangeably, which could cause some confusion.
…llectionInfo.IWriteHandler implementation, allowing all item writing to be implemented in the format-specific classes, i.e. MetaschemaJsonWriter, MetaschemaXmlWriter.
Aligned annotations with class generation, adding support for many missing annotation entries.
…for unparsed model instances.

Refactored JSON key handling to determine the JSON key on a per item basis. This is needed for ChoiceGroups.
Fixed IBindingMatcher to use the correct class type.
…emaJsonReader and MetaschemaJsonWriter using dispatch methods. This allows are IO code to be implemented withing the JSON format-specific implementation.
…maXmlReader and MetaschemaXmlWriter using dispatch methods. This allows are IO code to be implemented withing the XML format-specific implementation.
…model instances, with minimal implementation.

Cleaned up getDefaultValue and getEffectiveDefaultValue methods.
Implemented choice group writing for XML, JSON, and YAML.
Initial commit of the Metaschema module bindings.
… complex form, since a grouped item must have a bound class to determine its item type.

Cleaned up JSON value key naming code.
Adjusted the name used during code generation to use the value key name if available. This provides a more sensible name for Java property get and set methods created during code generation.
Added support for deprecated on allowed value enumerations.
Fixed the compile error in SimpleFieldInstance by creating the ISimpleScalarItemValueJavaField interface to combine the interfaces used and point the getValue and setValue methods to the correct implementation.
Added support for parsing XML fields as a root element.
…ill.

Fixed miscellaneous compile errors in other modules.
Fixed compile errors for other modules to align with recent changes.
Fixed some compile issues.
Fixed remaining unit tests.
…h change integration.

Started work on Metaschema module wrappers for bound objects.
… module binding instead of the XML parser. Metaschema modules in XML, JSON, and YAML can now be fully read!
…tion where possible.

Refactored group-as namespace handling to allow for no namespace situations. Implemented getEffectiveGroupAsNamespace to handle the default case of using the module namespace where no group-as support is provided.
Relocated the IModulePostProcessor interface to the new IModuleLoader interface.
Refactored flag and field name handling for a cleaner implementation. This new approach uses "name" as the binding annotation value for flags, instead of "useName".
Completed binding support. All current JUnit tests run without error.
Added support for a model(node) Metapath function that gets a nodeset based on the underlying Metaschema module model for the node.
Fixed remaining JUnit and schema generation bugs.
Refactored JSON schema generator. Many improvements to the indexing approach used to determine which definitions become global definitions in the JSON schema.
Fixed missing properties in choice group items.
Improved JSON documentation to include titles and descriptions on properties.
JSON and XML schema generation for choice groups is working.
…end up as null.

Fixed a bug causing empty annotation documentation in XML for enumerated values with no description.
@david-waltermire david-waltermire force-pushed the feature-metaconstraints-2 branch from 1c2517a to 2da5a5d Compare January 24, 2024 15:11
@david-waltermire david-waltermire merged commit 2846899 into usnistgov:develop Jan 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants