Search in sources :

Example 6 with MbengException

use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.

the class TestCaseRun method sendMessage.

protected String sendMessage(TestCaseAsset testCaseAsset, String protocol, String msg, String reference) throws IOException, DataAccessException {
    TestDataFilter filter = new TestDataFilter(msg, log, true);
    Map<String, String> map = new HashMap<>();
    map.put(TestDataFilter.MasterRequestId, this.masterRequestId);
    map.put(TestDataFilter.RunNumber, Integer.toString(runNumber));
    MbengDocument refdoc;
    if (reference != null) {
        try {
            refdoc = TestDataFilter.parseRequest(reference);
        } catch (MbengException e) {
            log.println("Failed to parse reference document as XML/JSON: " + e.getMessage());
            refdoc = null;
        }
    } else
        refdoc = null;
    // TODO: XLSX asset instead of CSV
    File mapfile;
    if (testcase.isLegacy())
        mapfile = new File(testcase.getCaseDirectory().getPath() + "/" + TestCase.PLACEHOLDER_MAP_FILENAME);
    else
        mapfile = new File(testCaseAsset.getPackageDir() + "/" + TestCase.PLACEHOLDER_MAP_FILENAME);
    TestDataFilter.loadPlaceHolderMap(mapfile, map, runNumber);
    msg = filter.applyFilters(map, refdoc);
    String server = getNextServer();
    if (server == null)
        return dao.sendMessage(protocol, msg, getDefaultMessageHeaders());
    else
        return dao.engineCall(dao.getPeerServerUrl(server), msg, getDefaultMessageHeaders());
}
Also used : MbengException(com.qwest.mbeng.MbengException) HashMap(java.util.HashMap) MbengDocument(com.qwest.mbeng.MbengDocument) File(java.io.File)

Example 7 with MbengException

use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.

the class TestDataFilter method evaluateExpression.

private String evaluateExpression(String exp, MbengDocument refdata) {
    try {
        if (exp.startsWith("/")) {
            // assuming XPath expression
            XmlPath xpathobj = new XmlPath(exp);
            MbengNode node = xpathobj.findNode(refdata);
            return node == null ? null : node.getValue();
        } else {
            MbengRuleSet ruleset = new MyRuleSet("filter_exp", MbengRuleSet.RULESET_EXPR);
            ruleset.parse(exp);
            MbengRuntime runtime = new MbengRuntime(ruleset, new StreamLogger(System.out));
            runtime.bind("$", refdata);
            return runtime.evaluate();
        }
    } catch (MbengException e) {
        log.println("Exception in evaluating expression in test data filter " + exp + ": " + e.getMessage());
        return null;
    }
}
Also used : XmlPath(com.qwest.mbeng.XmlPath) MbengRuntime(com.qwest.mbeng.MbengRuntime) MbengRuleSet(com.qwest.mbeng.MbengRuleSet) MbengException(com.qwest.mbeng.MbengException) StreamLogger(com.qwest.mbeng.StreamLogger) MbengNode(com.qwest.mbeng.MbengNode)

Example 8 with MbengException

use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.

the class SwingFormGenerator method evaluateCondition.

private boolean evaluateCondition(String name, String cond) {
    try {
        if (cond == null || cond.length() == 0)
            return true;
        MbengRuleSet ruleset = new MyRuleSet(name, MbengRuleSet.RULESET_COND);
        ruleset.parse(cond);
        MbengRuntime runtime = new MbengRuntime(ruleset, new StreamLogger(System.out));
        runtime.bind("$", dataxml);
        return runtime.verify();
    } catch (MbengException e) {
        e.printStackTrace();
        return false;
    }
}
Also used : MbengRuntime(com.qwest.mbeng.MbengRuntime) MbengRuleSet(com.qwest.mbeng.MbengRuleSet) MbengException(com.qwest.mbeng.MbengException) StreamLogger(com.qwest.mbeng.StreamLogger)

Example 9 with MbengException

use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.

the class BamMonitoringSection method saveOverrideAttributes.

@Override
protected void saveOverrideAttributes() {
    // remove empty bam defs
    Map<String, BamMessageDefinition> defs = new HashMap<String, BamMessageDefinition>();
    for (String key : bamEventDefs.keySet()) {
        BamMessageDefinition def = bamEventDefs.get(key);
        def.setAttributes(removeEmpty(def.getAttributes()));
        if (!def.isEmpty())
            defs.put(key, def);
    }
    bamEventDefs = defs;
    // sync attributes
    for (String overrideAttr : getOverrideAttributes().keySet()) {
        if (!bamEventDefs.containsKey(overrideAttr))
            // to delete
            element.setAttribute(overrideAttr, null);
    }
    try {
        for (String key : bamEventDefs.keySet()) element.setAttribute(key, bamEventDefs.get(key).format());
        String msg = bamEvtVal.validateBamEventAttributes(bamEventDefs);
        if (msg.length() > 0) {
            msg += "\n Please correct the above errors before you continue.";
            MessageDialog.openError(getShell(), "Save Monitoring Attributes", msg);
        } else {
            super.saveOverrideAttributes();
        }
    } catch (MbengException ex) {
        PluginMessages.uiError(getShell(), ex, "Save Monitoring Attributes", element.getProject());
    }
}
Also used : MbengException(com.qwest.mbeng.MbengException) HashMap(java.util.HashMap) BamMessageDefinition(com.centurylink.mdw.model.value.event.BamMessageDefinition)

Example 10 with MbengException

use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.

the class BindingsSection method findBindingsNode.

private MbengNode findBindingsNode(Activity activity) {
    String attrXml = activity.getActivityImpl().getAttrDescriptionXml();
    FormatXml formatter = new FormatXml();
    MbengDocumentClass mbengDocument = new MbengDocumentClass();
    try {
        formatter.load(mbengDocument, attrXml);
        for (MbengNode currentNode = mbengDocument.getRootNode().getFirstChild(); currentNode != null; currentNode = currentNode.getNextSibling()) {
            if (MappingEditor.TYPE_MAPPING.equals(currentNode.getName()) && PropertyEditor.SECTION_BINDINGS.equals(currentNode.getAttribute("SECTION")))
                return currentNode;
        }
    } catch (MbengException ex) {
        PluginMessages.uiError(getShell(), ex, "Parse Attr XML");
    }
    return null;
}
Also used : MbengException(com.qwest.mbeng.MbengException) MbengNode(com.qwest.mbeng.MbengNode) FormatXml(com.qwest.mbeng.FormatXml) MbengDocumentClass(com.qwest.mbeng.MbengDocumentClass)

Aggregations

MbengException (com.qwest.mbeng.MbengException)14 MbengNode (com.qwest.mbeng.MbengNode)6 MbengDocument (com.qwest.mbeng.MbengDocument)3 MbengRuleSet (com.qwest.mbeng.MbengRuleSet)3 MbengRuntime (com.qwest.mbeng.MbengRuntime)3 StreamLogger (com.qwest.mbeng.StreamLogger)3 XmlPath (com.qwest.mbeng.XmlPath)3 HashMap (java.util.HashMap)3 ArrayList (java.util.ArrayList)2 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 FormDataDocument (com.centurylink.mdw.model.FormDataDocument)1 ActivityVO (com.centurylink.mdw.model.value.activity.ActivityVO)1 AttributeVO (com.centurylink.mdw.model.value.attribute.AttributeVO)1 BamMessageDefinition (com.centurylink.mdw.model.value.event.BamMessageDefinition)1 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)1 TaskInstanceVO (com.centurylink.mdw.model.value.task.TaskInstanceVO)1 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)1 WorkTransitionInstanceVO (com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO)1 WorkTransitionVO (com.centurylink.mdw.model.value.work.WorkTransitionVO)1 DomDocument (com.qwest.mbeng.DomDocument)1