Skip to content

Commit 2e91fac

Browse files
Code refactoring and cleanup for 1.0.0 release (#204)
* Migrated modules: - Relocated metaschema-model-common to metaschema-core in folder core. - Relocated metaschema-model to metaschema-core in folder core. - Moved metaschema submodule to core. - Relocated the "metaschema-java-binding" and "metaschema-java-codegen" modules to the databind module. - Moved metaschema-schema-generator to schemagen. * Cleaned up reports. * Ensured generated resources are included for site generation. * Cleaned up some unneeded generics in the implementation. * Added many Javadoc comments. * Relocated unit tests to match new package structure. * Added a new mock model builder (MockedModelTestSupport) to facilitate creation of unit tests around using a mocked Metaschema model. * Setup JPMS module-info for the core module. * Some Maven dependency cleanup, including removing unused dependencies. - Removed dependency on JAXB. * Removed aggregate javadoc. * Eliminated a significant number of compile, PMD, CPD duplications, and Spotbugs warnings. * Cleaned up some unused/unneeded classes and methods. * Improved some logging messages. * Use treeless Git clones on GHA builds * Updating to latest oss-maven release. * Core changes: - Added `true()` and `false()` metapath function. - 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. - Refactored code to remove the IRequiredValue* interfaces. - Migrated node item classes to a new package. - Refactored INodeItem handling to implement the following correct behaviors: - 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. - Refactored node item implementation to provide better interface segregation and to limit class responsibility. - Refactored 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, which now use static objects for evaluation. Refactored the Step and ParentItem ASTs to use the new Axis support. - Added support for function namespaces. - Removed collapsible per usnistgov/metaschema#354. - Moved property info factory to static method on IModelPropertyInfo. - Adjusted IDataTypeHandler creation to avoid extra method callbacks. - Reduced unnecessary overridden methods. - Removed the need for specific root assembly model interfaces and classes. - Renamed IMetaschema to IModule to be more consistent with terminology. Deleted unused submodule. - For index constraints, enhanced index key miss error reporting to include the key data that missed. - Added new String initializer for IAnyAtomicItem. * Databind changes: - Refactored JSON reader and writer to use common instance logic. The collection of instances are now lazy generated and cached, improving read and write performance for commonly accessed Metaschema-based JSON objects. - Refactored XML parsing, extracting XML parsing logic into the XmlParser 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. - Refactored JSON parsing, extracting JSON parsing logic into the MetaschemaJsonParser class. This resulted in a cleaner set of bound definition/property classes that no contain no parsing code. - Renamed XmlParser to MetaschemaXmlReader, MetaschemaJsonParser to MetaschemaJsonReader, and MetaschemaXmlGenerator to MetaschemaXmlWriter. - Cleaned up some collapse unit testing files. - Implemented XML problem handler for parsing. Further code cleanup and refactoring of XML parsing code. - Implemented the JSON problem handler. Resolved #131. - Refactored JSON parser tests. - Refactored input stream handling. Input streams should now be properly closed. - Adjusted problem handlers to use interface defaults and a common implementation of default handling for missing instances. - Refactored binding context to allow for dynamic class generation, compilation, and loading. Removed DynamicBindingContext.java, which is no longer needed. - Adjusted YAML parser configuration to set a higher default codepoint limit. - Refactored code generation, moving code generation methods into a dedicated class. - Refactored code generation production classes to simplify and reduce the number of classes. * Schema generation changes: - Refactored XML and JSON generation by moving generation code into format specific classes (i.e. MetaschemaJsonWriter, MetaschemaXmlWriter). - Improved XML schema generation testing. * Metaschema Maven plugin changes: - Adjusted generate sources mojo default phase to a more reasonable value (generate-sources).
1 parent 151d97b commit 2e91fac

File tree

973 files changed

+25219
-22800
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

973 files changed

+25219
-22800
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
2828
with:
2929
submodules: recursive
30-
fetch-depth: 0
30+
filter: tree:0
3131
# -------------------------
3232
# Java Environment Setup
3333
# -------------------------
@@ -79,6 +79,11 @@ jobs:
7979
- name: Perform CodeQL Analysis
8080
if: github.event_name == 'push'
8181
uses: github/codeql-action/analyze@6a28655e3dcb49cb0840ea372fd6d17733edd8a4
82+
- name: Upload CodeQL SARIF file
83+
uses: github/codeql-action/upload-sarif@a09933a12a80f87b87005513f0abb1494c27a716
84+
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref_name == 'develop'
85+
with:
86+
token: ${{ secrets.COMMIT_TOKEN }}
8287
- name: Test Website
8388
run: |
8489
# this needs to be run as a second build to ensure source is fully generated by the previous step

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
1616
with:
1717
submodules: recursive
18-
fetch-depth: 0
18+
filter: tree:0
1919
# -------------------------
2020
# Java
2121
# -------------------------

.gitmodules

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
[submodule "metaschema"]
2-
path = metaschema-model/metaschema
3-
url = https://github.com/usnistgov/metaschema
4-
branch = master
1+
[submodule "core/core/metaschema"]
2+
path = core/metaschema
3+
url = https://github.com/usnistgov/metaschema.git
4+
branch = main
5+
[submodule "core/qt3tests"]
6+
path = core/qt3tests
7+
url = https://github.com/w3c/qt3tests.git

.mvn/maven-build-cache-config.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,13 @@
1313
</discovery>
1414
</multiModule>
1515
</configuration>
16+
<executionControl>
17+
<runAlways>
18+
<plugins>
19+
<!-- the two following plugins are needed to add sources to the source list -->
20+
<plugin groupId="org.antlr" artifactId="antlr4-maven-plugin"/>
21+
<plugin groupId="org.codehaus.mojo" artifactId="build-helper-maven-plugin"/>
22+
</plugins>
23+
</runAlways>
24+
</executionControl>
1625
</cache>

cli-processor/pom.xml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependencies>
2121
<dependency>
2222
<groupId>gov.nist.secauto.metaschema</groupId>
23-
<artifactId>metaschema-model-common</artifactId>
23+
<artifactId>metaschema-core</artifactId>
2424
</dependency>
2525
<dependency>
2626
<groupId>com.github.spotbugs</groupId>
@@ -43,7 +43,7 @@
4343
</dependency>
4444
<dependency>
4545
<groupId>com.google.auto.service</groupId>
46-
<artifactId>auto-service</artifactId>
46+
<artifactId>auto-service-annotations</artifactId>
4747
</dependency>
4848
<dependency>
4949
<groupId>org.apache.logging.log4j</groupId>
@@ -53,17 +53,6 @@
5353
<groupId>org.apache.logging.log4j</groupId>
5454
<artifactId>log4j-jul</artifactId>
5555
</dependency>
56-
57-
<dependency>
58-
<groupId>org.junit.jupiter</groupId>
59-
<artifactId>junit-jupiter-api</artifactId>
60-
<scope>test</scope>
61-
</dependency>
62-
<dependency>
63-
<groupId>org.junit.jupiter</groupId>
64-
<artifactId>junit-jupiter-engine</artifactId>
65-
<scope>test</scope>
66-
</dependency>
6756
</dependencies>
6857
<build>
6958
<plugins>

cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/CLIProcessor.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
import gov.nist.secauto.metaschema.cli.processor.command.ExtraArgument;
3333
import gov.nist.secauto.metaschema.cli.processor.command.ICommand;
3434
import gov.nist.secauto.metaschema.cli.processor.command.ICommandExecutor;
35-
import gov.nist.secauto.metaschema.model.common.util.IVersionInfo;
36-
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
35+
import gov.nist.secauto.metaschema.core.util.IVersionInfo;
36+
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
3737

3838
import org.apache.commons.cli.CommandLine;
3939
import org.apache.commons.cli.CommandLineParser;
@@ -183,7 +183,8 @@ private ExitStatus parseCommand(String... args) {
183183
CallingContext callingContext = new CallingContext(commandArgs);
184184

185185
ExitStatus status;
186-
// the first two arguments should be the <command> and <operation>, where <type> is the object type
186+
// the first two arguments should be the <command> and <operation>, where <type>
187+
// is the object type
187188
// the <operation> is performed against.
188189
if (commandArgs.isEmpty()) {
189190
status = ExitCode.INVALID_COMMAND.exit();
@@ -205,9 +206,9 @@ private static void handleNoColor() {
205206
AnsiConsole.systemUninstall();
206207
}
207208

209+
@SuppressWarnings("resource")
208210
public static void handleQuiet() {
209-
@SuppressWarnings("resource") LoggerContext ctx = (LoggerContext) LogManager.getContext(false); // NOPMD not
210-
// closable here
211+
LoggerContext ctx = (LoggerContext) LogManager.getContext(false); // NOPMD not closable here
211212
Configuration config = ctx.getConfiguration();
212213
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
213214
Level oldLevel = loggerConfig.getLevel();
@@ -240,7 +241,8 @@ protected void showVersion() {
240241
// @SuppressWarnings("null")
241242
// @NonNull
242243
// public String[] getArgArray() {
243-
// return Stream.concat(options.stream(), extraArgs.stream()).toArray(size -> new String[size]);
244+
// return Stream.concat(options.stream(), extraArgs.stream()).toArray(size ->
245+
// new String[size]);
244246
// }
245247

246248
public class CallingContext {
@@ -367,7 +369,8 @@ public ExitStatus processCommand() {
367369
retval = ExitCode.OK.exit();
368370
// } else {
369371
// retval = handleInvalidCommand(commandResult, options,
370-
// "Invalid command arguments: " + cmdLine.getArgList().stream().collect(Collectors.joining(" ")));
372+
// "Invalid command arguments: " +
373+
// cmdLine.getArgList().stream().collect(Collectors.joining(" ")));
371374
}
372375

373376
if (retval == null) {
@@ -578,9 +581,10 @@ public void showHelp() {
578581
AnsiPrintStream out = AnsiConsole.out();
579582
int terminalWidth = Math.max(out.getTerminalWidth(), 40);
580583

581-
@SuppressWarnings("resource") PrintWriter writer = new PrintWriter(out, true, StandardCharsets.UTF_8); // NOPMD -
582-
// not
583-
// owned
584+
@SuppressWarnings("resource") PrintWriter writer = new PrintWriter( // NOPMD not owned
585+
out,
586+
true,
587+
StandardCharsets.UTF_8);
584588
formatter.printHelp(
585589
writer,
586590
terminalWidth,

cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/ExitCode.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public enum ExitCode {
4242
*/
4343
IO_ERROR(2),
4444
/**
45-
* A command was requested by name that doesn't exist or required arguments are missing.
45+
* A command was requested by name that doesn't exist or required arguments are
46+
* missing.
4647
*/
4748
INVALID_COMMAND(3),
4849
/**
@@ -58,7 +59,8 @@ public enum ExitCode {
5859
*/
5960
RUNTIME_ERROR(6),
6061
/**
61-
* The provided argument information for a command fails to match argument use requirements.
62+
* The provided argument information for a command fails to match argument use
63+
* requirements.
6264
*/
6365
INVALID_ARGUMENTS(7);
6466

cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/InvalidArgumentException.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public InvalidArgumentException(String message) {
5454
}
5555

5656
/**
57-
* Return the option requiring an argument that wasn't provided on the command line.
57+
* Return the option requiring an argument that wasn't provided on the command
58+
* line.
5859
*
5960
* @return the related option
6061
*/
@@ -64,7 +65,8 @@ public Option getOption() {
6465
}
6566

6667
/**
67-
* Assign the option requiring an argument that wasn't provided on the command line.
68+
* Assign the option requiring an argument that wasn't provided on the command
69+
* line.
6870
*
6971
* @param option
7072
* the option to set

cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/MessageExitStatus.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public class MessageExitStatus
4242
* @param code
4343
* the exit code to use.
4444
* @param messageArguments
45-
* the arguments that can be passed to a formatted string to generate the message
45+
* the arguments that can be passed to a formatted string to generate
46+
* the message
4647
*/
4748
public MessageExitStatus(@NonNull ExitCode code, @NonNull Object... messageArguments) {
4849
super(code);

cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/command/AbstractCommandExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import gov.nist.secauto.metaschema.cli.processor.CLIProcessor.CallingContext;
3030
import gov.nist.secauto.metaschema.cli.processor.ExitStatus;
31-
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
31+
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
3232

3333
import org.apache.commons.cli.CommandLine;
3434

cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/command/ICommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import gov.nist.secauto.metaschema.cli.processor.CLIProcessor.CallingContext;
3030
import gov.nist.secauto.metaschema.cli.processor.InvalidArgumentException;
31-
import gov.nist.secauto.metaschema.model.common.util.CollectionUtil;
31+
import gov.nist.secauto.metaschema.core.util.CollectionUtil;
3232

3333
import org.apache.commons.cli.CommandLine;
3434
import org.apache.commons.cli.Option;

cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/command/ICommandExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public ExitStatus execute() {
5252
}
5353

5454
@FunctionalInterface
55-
public interface ExecutionFunction {
55+
interface ExecutionFunction {
5656
@NonNull
5757
ExitStatus execute(
5858
@NonNull CallingContext callingContext,

core/metaschema

Submodule metaschema added at e54d01d

0 commit comments

Comments
 (0)