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

Code refactoring and cleanup for 1.0.0 release #204

Conversation

david-waltermire
Copy link
Collaborator

@david-waltermire david-waltermire commented Aug 2, 2023

Committer Notes

This PR contains refactored code to prepare for a 1.0 codebase.

The following refactoring work is included.

  • Combine metaschema-model-common and metaschema-model into a core module.
    • Combine modules
    • Refactor package names to use gov.nist.secauto.metaschema.core
    • Create relocation pom.xml entries
  • Combine metaschema-java-codegen and metaschema-java-binding into a databind module.
    • Merge modules
    • Refactor package names to use gov.nist.secauto.metaschema.databind
    • Create relocation pom.xml entries
  • Migrate content parsing code out of the model classes into format specific parser classes. Reduce code where possible.
    • XML
    • JSON/YAML
  • Migrate content generation code out of the model classes into format specific parser classes. Reduce code where possible.
    • XML
    • JSON/YAML
  • Fully implement problem handlers in parsing code (relates to CLI Silently Drops Undefined Assembly Instances During Format Conversion #131)
    • XML
    • JSON/YAML
  • Properly handle resource closure in content parsing and generating code
    • Parsing
      • XML
      • JSON/YAML
    • Generation
      • XML
      • JSON/YAML
  • Metapath improvements
    • Refactor Metapath focus to allow for Metapath evaluations against no focus, as well as cases where the focus is not a node item.
    • Improved memory footprint for Axis expressions to use static objects for evaluation.
    • Refactor the Step and ParentItem ASTs to use the new Axis support.
  • Implement JPMS module-info.java declarations for modules. This will help to better identify and separate the stable API from implementation classes.
    • core
    • databind
    • metaschema-schema-generator

Many of these changes are breaking changes for users of the API, which is why these changes are targeting a major release.

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.

@david-waltermire david-waltermire force-pushed the feature-reorganize-modules-for-1.0 branch from c3d6207 to 6caba4f Compare August 4, 2023 00:54
@david-waltermire david-waltermire force-pushed the feature-reorganize-modules-for-1.0 branch from 62355f3 to 6eccab1 Compare August 14, 2023 22:03
@david-waltermire david-waltermire force-pushed the feature-reorganize-modules-for-1.0 branch from 6eccab1 to 98c0b29 Compare August 15, 2023 22:23
@david-waltermire david-waltermire force-pushed the feature-reorganize-modules-for-1.0 branch 3 times, most recently from dd454d0 to 8c9f969 Compare August 28, 2023 02:59
@david-waltermire david-waltermire marked this pull request as ready for review August 28, 2023 23:40
@david-waltermire david-waltermire force-pushed the feature-reorganize-modules-for-1.0 branch from eaaf338 to 0628bf3 Compare August 28, 2023 23:42
Relocated metaschema-model-common to metaschema-core.
Relocated metaschema-model to metaschema-core.
Refactored error handling for step-related Metapath expressions to ensure the provided context node item is non-null and a document. This also lays ground work for null node contexts in Metapath expressions that do not require a focused node.
…viors:

- IDocumentNodeItem instances will never have a value (i.e. getValue == null)
- Root metapaths (i.e. `/`) must be executed against an IDocumentNodeItem or an error should be raised.
Added some Javadoc comments.
Added a new mock model builder (MockedModelTestSupport) to facilitate creation of unit tests around using a mocked Metaschema model.
…o focus, as well as cases where the focus is not a node item.

Improved memory footprint for Axis expressions, which now use static objects for evaluation. Refactored the Step and ParentItem ASTs to use the new Axis support.
…er class. This resulted in a cleaner set of bound definition/property classes. Also optimized deserialization to return the Object value directly, instead of first creating an unneeded node item.
Some Javadoc improvements.
Refactored code generation, moving code generation methods into a dedicated class, DefaultMetaschemaClassFactory.java.
Refactored code generation production classes to simplify and reduce the number of classes.
… refactoring of XML parsing code.

Created more javadocs.
Completed some code reformatting.
Refactored JSON parser tests.
Eliminated a significant number of compile, PMD, and Spotbugs warnings.
…mat specific classes (i.e. MetaschemaJsonWriter, MetaschemaXmlWriter).

Adjusted problem handlers to use interface defaults and a common implementation of default handling for missing instances.
Renamed MetaschemaXmlParser to MetaschemaXmlReader, MetaschemaJsonParser to MetaschemaJsonReader, and MetaschemaXmlGenerator to MetaschemaXmlWriter.
Adjusted IDataTypeHandler creation to avoid extra method callbacks.
Reduced unnecessary overridden methods.
Cleaned up unneed classes and methods.
Reduced PMD warnings.
Created Javadocs.
…ollection of instances are now lazy generated and cached, improving read and write performance for commonly accessed Metaschema-based JSON objects.
Refactored binding context to allow for dynamic class generation, compilation, and loading. Removed DynamicBindingContext.java, which is no longer needed.
Cleaned up unused dependencies.
Added Javadoc comments.
Moved metaschema-schema-generator to schemagen.
…urce loading and compilation issues due to module restrictions.

Generate test classes in a temp directory.
@david-waltermire david-waltermire merged commit 2e91fac into usnistgov:develop Sep 26, 2023
1 check passed
@david-waltermire david-waltermire deleted the feature-reorganize-modules-for-1.0 branch September 26, 2023 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant