Search in sources :

Example 1 with VOMOptionType

use of com.helger.phive.engine.vom.v10.VOMOptionType in project phive by phax.

the class VOM1Converter method _createExecutorEdifact.

@Nonnull
private IValidationExecutor<IValidationSourceXML> _createExecutorEdifact(@Nonnull final VOMEdifactType aEdifact) {
    final IEdifactValidationExecutorProviderXML aProvider = m_aComplianceSettings.getEdifactValidationExecutorProviderXML();
    final StringMap aOptions = new StringMap();
    for (final VOMOptionType aOption : aEdifact.getOption()) aOptions.put(aOption.getName(), aOption.getValue());
    LOGGER.info("Trying to resolve Edifact artifact '" + aEdifact.getDirectory() + '/' + aEdifact.getMessage() + "'");
    final IValidationExecutor<IValidationSourceXML> aVES = aProvider.createValidationExecutor(aEdifact.getDirectory(), aEdifact.getMessage(), aOptions);
    if (aVES == null)
        throw new IllegalStateException("Failed to resolve Edifact artifact '" + aEdifact.getDirectory() + '/' + aEdifact.getMessage() + "'");
    return aVES;
}
Also used : StringMap(com.helger.commons.collection.attr.StringMap) VOMOptionType(com.helger.phive.engine.vom.v10.VOMOptionType) IValidationSourceXML(com.helger.phive.engine.source.IValidationSourceXML) IEdifactValidationExecutorProviderXML(com.helger.phive.engine.vom.VOM1ComplianceSettings.IEdifactValidationExecutorProviderXML) Nonnull(javax.annotation.Nonnull)

Example 2 with VOMOptionType

use of com.helger.phive.engine.vom.v10.VOMOptionType in project phive by phax.

the class VOM1Validator method validateOptions.

public static void validateOptions(@Nonnull final String sXPath, @Nonnull final String sLocalXPath, @Nullable final List<VOMOptionType> aOptions, @Nonnull final ErrorList aErrorList) {
    if (aOptions != null) {
        int nIndex = 1;
        final ICommonsSet<String> aNames = new CommonsHashSet<>();
        for (final VOMOptionType aOption : aOptions) {
            // Name must be neither null nor empty
            final String sName = aOption.getName();
            if (StringHelper.hasNoText(sName))
                aErrorList.add(_createError(EVOMErrorCode.REQUIRED_NOT_EMPTY, sXPath + sLocalXPath + '[' + nIndex + "]/name"));
            else if (!aNames.add(sName))
                aErrorList.add(_createError(EVOMErrorCode.OPTION_NAME_NOT_UNIQUE.getErrorMessage(sName, sXPath), sXPath + '[' + nIndex + "]/name"));
            // Value may be empty
            final String sValue = aOption.getValue();
            if (sValue == null)
                aErrorList.add(_createError(EVOMErrorCode.REQUIRED, sXPath + sLocalXPath + '[' + nIndex + "]/value"));
            nIndex++;
        }
    }
}
Also used : VOMOptionType(com.helger.phive.engine.vom.v10.VOMOptionType) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet)

Aggregations

VOMOptionType (com.helger.phive.engine.vom.v10.VOMOptionType)2 StringMap (com.helger.commons.collection.attr.StringMap)1 CommonsHashSet (com.helger.commons.collection.impl.CommonsHashSet)1 IValidationSourceXML (com.helger.phive.engine.source.IValidationSourceXML)1 IEdifactValidationExecutorProviderXML (com.helger.phive.engine.vom.VOM1ComplianceSettings.IEdifactValidationExecutorProviderXML)1 Nonnull (javax.annotation.Nonnull)1