Search in sources :

Example 1 with DMNMessageManager

use of org.kie.dmn.core.api.DMNMessageManager in project drools by kiegroup.

the class DMNValidatorImpl method validate.

@Override
public List<DMNMessage> validate(Reader reader, Validation... options) {
    DMNMessageManager results = new DefaultDMNMessagesManager();
    EnumSet<Validation> flags = EnumSet.copyOf(Arrays.asList(options));
    try {
        String content = readContent(reader);
        if (flags.contains(VALIDATE_SCHEMA)) {
            results.addAll(validateSchema(new StringReader(content)));
        }
        if (flags.contains(VALIDATE_MODEL) || flags.contains(VALIDATE_COMPILATION)) {
            Definitions dmndefs = DMNMarshallerFactory.newDefaultMarshaller().unmarshal(new StringReader(content));
            Definitions.normalize(dmndefs);
            validateModelCompilation(dmndefs, results, flags);
        }
    } catch (Throwable t) {
        MsgUtil.reportMessage(LOG, DMNMessage.Severity.ERROR, null, results, t, null, Msg.FAILED_VALIDATOR);
    }
    return results.getMessages();
}
Also used : DMNMessageManager(org.kie.dmn.core.api.DMNMessageManager) Definitions(org.kie.dmn.model.v1_1.Definitions) StringReader(java.io.StringReader) DefaultDMNMessagesManager(org.kie.dmn.core.util.DefaultDMNMessagesManager)

Example 2 with DMNMessageManager

use of org.kie.dmn.core.api.DMNMessageManager in project drools by kiegroup.

the class DMNValidatorImpl method validate.

@Override
public List<DMNMessage> validate(Definitions dmnModel, Validation... options) {
    DMNMessageManager results = new DefaultDMNMessagesManager();
    EnumSet<Validation> flags = EnumSet.copyOf(Arrays.asList(options));
    if (flags.contains(VALIDATE_SCHEMA)) {
        MsgUtil.reportMessage(LOG, DMNMessage.Severity.ERROR, dmnModel, results, null, null, Msg.FAILED_NO_XML_SOURCE);
    }
    try {
        validateModelCompilation(dmnModel, results, flags);
    } catch (Throwable t) {
        MsgUtil.reportMessage(LOG, DMNMessage.Severity.ERROR, dmnModel, results, t, null, Msg.FAILED_VALIDATOR);
    }
    return results.getMessages();
}
Also used : DMNMessageManager(org.kie.dmn.core.api.DMNMessageManager) DefaultDMNMessagesManager(org.kie.dmn.core.util.DefaultDMNMessagesManager)

Example 3 with DMNMessageManager

use of org.kie.dmn.core.api.DMNMessageManager in project drools by kiegroup.

the class DMNValidatorImpl method validate.

@Override
public List<DMNMessage> validate(File xmlFile, Validation... options) {
    DMNMessageManager results = new DefaultDMNMessagesManager();
    EnumSet<Validation> flags = EnumSet.copyOf(Arrays.asList(options));
    if (flags.contains(VALIDATE_SCHEMA)) {
        results.addAll(validateSchema(xmlFile));
    }
    if (flags.contains(VALIDATE_MODEL) || flags.contains(VALIDATE_COMPILATION)) {
        Definitions dmndefs = null;
        try {
            dmndefs = DMNMarshallerFactory.newDefaultMarshaller().unmarshal(new FileReader(xmlFile));
            Definitions.normalize(dmndefs);
            validateModelCompilation(dmndefs, results, flags);
        } catch (Throwable t) {
            MsgUtil.reportMessage(LOG, DMNMessage.Severity.ERROR, null, results, t, null, Msg.FAILED_VALIDATOR);
        }
    }
    return results.getMessages();
}
Also used : DMNMessageManager(org.kie.dmn.core.api.DMNMessageManager) Definitions(org.kie.dmn.model.v1_1.Definitions) FileReader(java.io.FileReader) DefaultDMNMessagesManager(org.kie.dmn.core.util.DefaultDMNMessagesManager)

Aggregations

DMNMessageManager (org.kie.dmn.core.api.DMNMessageManager)3 DefaultDMNMessagesManager (org.kie.dmn.core.util.DefaultDMNMessagesManager)3 Definitions (org.kie.dmn.model.v1_1.Definitions)2 FileReader (java.io.FileReader)1 StringReader (java.io.StringReader)1