Skip to content

Commit

Permalink
Some renamings
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Mar 13, 2024
1 parent f052c13 commit 9b15d83
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class DefaultVESLoaderSchematron implements IVESLoaderSchematron
@Nonnull
public IValidationExecutor <IValidationSourceXML> loadSchematron (@Nonnull final IRepoStorageBase aRepo,
@Nonnull final VesSchematronType aSCH,
@Nullable final LoadedVES.Requirement aRequirement,
@Nullable final LoadedVES.RequiredVES aLoadingRequiredVES,
@Nonnull final ErrorList aErrorList,
@Nonnull final IVESAsyncLoader aAsyncLoader)
{
Expand Down Expand Up @@ -190,10 +190,10 @@ public IValidationExecutor <IValidationSourceXML> loadSchematron (@Nonnull final
}

// Are we changing the output levels on a "required" resource?
if (aRequirement != null && aRequirement.getOutput ().customErrorLevels ().isNotEmpty ())
if (aLoadingRequiredVES != null && aLoadingRequiredVES.getOutput ().customErrorLevels ().isNotEmpty ())
{
// These ones overwrite the original ones
aCustomErrorLevels.putAll (aRequirement.getOutput ().customErrorLevels ());
aCustomErrorLevels.putAll (aLoadingRequiredVES.getOutput ().customErrorLevels ());
}

if (aCustomErrorLevels.isNotEmpty ())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private static final String _unifyPath (@Nullable final String x)
@Nonnull
public IValidationExecutor <IValidationSourceXML> loadXSD (@Nonnull final IRepoStorageBase aRepo,
@Nonnull final VesXsdType aXSD,
@Nullable final LoadedVES.Requirement aRequirement,
@Nullable final LoadedVES.RequiredVES aLoadingRequiredVES,
@Nonnull final ErrorList aErrorList,
@Nonnull final IVESAsyncLoader aAsyncLoader)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,29 @@
*/
public interface IVESLoaderEdifact
{
/**
* Load an Edifact validation from a VES.
*
* @param aRepo
* The repository to load the data from. May not be <code>null</code>.
* @param aEDI
* The JAXB VES Edifact object with the details. May not be
* <code>null</code>.
* @param aLoadingRequiredVES
* In case the loading was recursively triggered via a "requires"
* (=include), this is the data of the requirements. May be
* <code>null</code>.
* @param aErrorList
* The error list to be filled. May not be <code>null</code>.
* @param aAsyncLoader
* The callback to be invoked, if loading this artefacts needs to
* trigger the loading of another artefact.
* @return The validation executor to be used. May not be <code>null</code>.
*/
@Nonnull
IValidationExecutor <IValidationSourceBinary> loadEdifact (@Nonnull IRepoStorageBase aRepo,
@Nonnull VesEdifactType aEDI,
@Nullable LoadedVES.Requirement aRequirement,
@Nullable LoadedVES.RequiredVES aLoadingRequiredVES,
@Nonnull ErrorList aErrorList,
@Nonnull IVESAsyncLoader aAsyncLoader);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,29 @@
*/
public interface IVESLoaderSchematron
{
/**
* Load a Schematron validation from a VES.
*
* @param aRepo
* The repository to load the data from. May not be <code>null</code>.
* @param aSCH
* The JAXB VES Schematron object with the details. May not be
* <code>null</code>.
* @param aLoadingRequiredVES
* In case the loading was recursively triggered via a "requires"
* (=include), this is the data of the requirements. May be
* <code>null</code>.
* @param aErrorList
* The error list to be filled. May not be <code>null</code>.
* @param aAsyncLoader
* The callback to be invoked, if loading this artefacts needs to
* trigger the loading of another artefact.
* @return The validation executor to be used. May not be <code>null</code>.
*/
@Nonnull
IValidationExecutor <IValidationSourceXML> loadSchematron (@Nonnull IRepoStorageBase aRepo,
@Nonnull VesSchematronType aSCH,
@Nullable LoadedVES.Requirement aRequirement,
@Nullable LoadedVES.RequiredVES aLoadingRequiredVES,
@Nonnull ErrorList aErrorList,
@Nonnull IVESAsyncLoader aAsyncLoader);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,29 @@
*/
public interface IVESLoaderXSD
{
/**
* Load an XSD validation from a VES.
*
* @param aRepo
* The repository to load the data from. May not be <code>null</code>.
* @param aXSD
* The JAXB VES XSD object with the details. May not be
* <code>null</code>.
* @param aLoadingRequiredVES
* In case the loading was recursively triggered via a "requires"
* (=include), this is the data of the requirements. May be
* <code>null</code>.
* @param aErrorList
* The error list to be filled. May not be <code>null</code>.
* @param aAsyncLoader
* The callback to be invoked, if loading this artefacts needs to
* trigger the loading of another artefact.
* @return The validation executor to be used. May not be <code>null</code>.
*/
@Nonnull
IValidationExecutor <IValidationSourceXML> loadXSD (@Nonnull IRepoStorageBase aRepo,
@Nonnull VesXsdType aXSD,
@Nullable LoadedVES.Requirement aRequirement,
@Nullable LoadedVES.RequiredVES aLoadingRequiredVES,
@Nonnull ErrorList aErrorList,
@Nonnull IVESAsyncLoader aAsyncLoader);
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ public ICommonsMap <String, EErrorLevel> customErrorLevels ()
* @author Philip Helger
*/
@NotThreadSafe
public static final class Requirement
public static final class RequiredVES
{
private final VESID m_aRequiredVESID;
private final MapBasedNamespaceContext m_aNSCtx;
private final OutputType m_aOutput;
private final boolean m_bStopOnError;

Requirement (@Nonnull final VESID aRequiredVESID,
RequiredVES (@Nonnull final VESID aRequiredVESID,
@Nonnull final MapBasedNamespaceContext aNSCtx,
@Nonnull final OutputType aOutput,
final boolean bStopOnError)
Expand Down Expand Up @@ -270,7 +270,7 @@ public boolean isStopOnError ()

private final Header m_aHeader;
private final Status m_aStatus;
private Requirement m_aRequires;
private RequiredVES m_aRequires;
private IVESSpecificDeferredLoader m_aRequiresLoader;
private LoadedVES m_aLoadedRequires;
private IValidationExecutor <? extends IValidationSource> m_aExecutor;
Expand Down Expand Up @@ -301,7 +301,7 @@ public Status getStatus ()
return m_aStatus;
}

void setLazyRequires (@Nonnull final Requirement aRequirement,
void setLazyRequires (@Nonnull final RequiredVES aRequirement,
@Nonnull final IVESSpecificDeferredLoader aDeferredLoader)
{
ValueEnforcer.notNull (aRequirement, "Requirement");
Expand All @@ -313,7 +313,7 @@ void setLazyRequires (@Nonnull final Requirement aRequirement,
m_aRequiresLoader = aDeferredLoader;
}

void setEagerRequires (@Nonnull final Requirement aRequirement, @Nonnull final LoadedVES aLoadedVES)
void setEagerRequires (@Nonnull final RequiredVES aRequirement, @Nonnull final LoadedVES aLoadedVES)
{
ValueEnforcer.notNull (aRequirement, "Requirement");
ValueEnforcer.notNull (aLoadedVES, "LoadedVES");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public LoadedVES convertToLoadedVES (@Nonnull final LoadedVES.Status aStatus,

@Nullable
private LoadedVES _convertToLoadedVES (@Nonnull final LoadedVES.Status aStatus,
@Nullable final LoadedVES.Requirement aLoadingRequirement,
@Nullable final LoadedVES.RequiredVES aLoadingRequiredVES,
@Nonnull final VesType aSrcVes,
@Nonnull final VESLoaderStatus aLoaderStatus,
@Nonnull final ErrorList aLoadingErrors) throws VESLoadingException
Expand All @@ -318,47 +318,47 @@ private LoadedVES _convertToLoadedVES (@Nonnull final LoadedVES.Status aStatus,
if (aSrcVes.getRequires () != null)
{
final VesRequiresType aSrcReq = aSrcVes.getRequires ();
final LoadedVES.Requirement aRequirement = new LoadedVES.Requirement (new VESID (aSrcReq.getGroupId (),
aSrcReq.getArtifactId (),
aSrcReq.getVersion ()),
_wrap (aSrcReq.getNamespaces ()),
_wrap (aSrcReq.getOutput ()),
aSrcReq.isStopOnError ());
final LoadedVES.RequiredVES aSrcRequiredVES = new LoadedVES.RequiredVES (new VESID (aSrcReq.getGroupId (),
aSrcReq.getArtifactId (),
aSrcReq.getVersion ()),
_wrap (aSrcReq.getNamespaces ()),
_wrap (aSrcReq.getOutput ()),
aSrcReq.isStopOnError ());
if (isUseEagerRequirementLoading ())
{
// Eager loading

// Recursive load required artefact; required to have this in scope
final LoadedVES aLoadedRequirement = _loadVESFromRepo (aRequirement.getRequiredVESID (),
aRequirement,
final LoadedVES aLoadedRequirement = _loadVESFromRepo (aSrcRequiredVES.getRequiredVESID (),
aSrcRequiredVES,
aLoaderStatus,
aLoadingErrors);
if (aLoadedRequirement == null)
{
aLoadingErrors.add (SingleError.builderError ()
.errorText ("Failed to load required VESID '" +
aRequirement.getRequiredVESID ().getAsSingleID () +
aSrcRequiredVES.getRequiredVESID ().getAsSingleID () +
"' [eager]")
.build ());
return null;
}

ret.setEagerRequires (aRequirement, aLoadedRequirement);
ret.setEagerRequires (aSrcRequiredVES, aLoadedRequirement);
}
else
{
// Lazy loading
ret.setLazyRequires (aRequirement, aLocalErrorList -> {
ret.setLazyRequires (aSrcRequiredVES, aLocalErrorList -> {
// Use this deferred loader, to ensure the same surrounding VESLoader
// instance is used
// Recursive load required artefact; required to have this in scope
final LoadedVES aLoadedRequirement = _loadVESFromRepo (aRequirement.getRequiredVESID (),
aRequirement,
final LoadedVES aLoadedRequirement = _loadVESFromRepo (aSrcRequiredVES.getRequiredVESID (),
aSrcRequiredVES,
aLoaderStatus,
aLocalErrorList);
if (aLoadedRequirement == null)
throw new VESLoadingException ("Failed to load required VESID '" +
aRequirement.getRequiredVESID ().getAsSingleID () +
aSrcRequiredVES.getRequiredVESID ().getAsSingleID () +
"' [lazy]: " +
StringHelper.getImplodedMapped ("\n ",
aLocalErrorList,
Expand All @@ -382,7 +382,7 @@ private LoadedVES _convertToLoadedVES (@Nonnull final LoadedVES.Status aStatus,
if (aLoader != null)
ret.setExecutor (aLoader.loadXSD (m_aRepo,
aSrcVes.getXsd (),
aLoadingRequirement,
aLoadingRequiredVES,
aLoadingErrors,
aAsyncLoader));
else
Expand All @@ -398,7 +398,7 @@ private LoadedVES _convertToLoadedVES (@Nonnull final LoadedVES.Status aStatus,
if (aLoader != null)
ret.setExecutor (aLoader.loadSchematron (m_aRepo,
aSrcVes.getSchematron (),
aLoadingRequirement,
aLoadingRequiredVES,
aLoadingErrors,
aAsyncLoader));
else
Expand All @@ -414,7 +414,7 @@ private LoadedVES _convertToLoadedVES (@Nonnull final LoadedVES.Status aStatus,
if (aLoader != null)
ret.setExecutor (aLoader.loadEdifact (m_aRepo,
aSrcVes.getEdifact (),
aLoadingRequirement,
aLoadingRequiredVES,
aLoadingErrors,
aAsyncLoader));
else
Expand Down Expand Up @@ -529,8 +529,8 @@ public LoadedVES loadVESFromRepo (@Nonnull final VESID aVESID,
*
* @param aVESID
* The VESID to load. May not be <code>null</code>.
* @param aRequirement
* The requirement that is currently loaded. May be <code>null</code>.
* @param aLoadingRequiredVES
* The required VES that is currently loaded. May be <code>null</code>.
* @param aLoaderStatus
* The internal loader status to be used, to make sure no cycles etc.
* are contained
Expand All @@ -540,7 +540,7 @@ public LoadedVES loadVESFromRepo (@Nonnull final VESID aVESID,
*/
@Nullable
private LoadedVES _loadVESFromRepo (@Nonnull final VESID aVESID,
@Nullable final LoadedVES.Requirement aRequirement,
@Nullable final LoadedVES.RequiredVES aLoadingRequiredVES,
@Nonnull final VESLoaderStatus aLoaderStatus,
@Nonnull final ErrorList aLoadingErrors)
{
Expand Down Expand Up @@ -635,7 +635,7 @@ private LoadedVES _loadVESFromRepo (@Nonnull final VESID aVESID,
}

// Now read into data model
ret = _convertToLoadedVES (aStatus, aRequirement, aVES, aLoaderStatus, aLoadingErrors);
ret = _convertToLoadedVES (aStatus, aLoadingRequiredVES, aVES, aLoaderStatus, aLoadingErrors);
return ret;
}
finally
Expand Down

0 comments on commit 9b15d83

Please sign in to comment.