Search in sources :

Example 1 with WSRoutingRuleExpression

use of com.amalto.workbench.webservices.WSRoutingRuleExpression in project tmdm-studio-se by Talend.

the class Util method convertLineRoute.

public static WSRoutingRuleExpression convertLineRoute(String[] values) {
    WSRoutingRuleExpression wc = new WSRoutingRuleExpression();
    wc.setXpath(values[0]);
    WSRoutingRuleOperator operator = null;
    if (values[1].equals("Contains")) {
        // $NON-NLS-1$
        operator = WSRoutingRuleOperator.CONTAINS;
    } else if (values[1].equals("Matches")) {
        // $NON-NLS-1$
        operator = WSRoutingRuleOperator.MATCHES;
    } else if (values[1].equals("=")) {
        // $NON-NLS-1$
        operator = WSRoutingRuleOperator.EQUALS;
    } else if (values[1].equals(">")) {
        // $NON-NLS-1$
        operator = WSRoutingRuleOperator.GREATER_THAN;
    } else if (values[1].equals(">=")) {
        // $NON-NLS-1$
        operator = WSRoutingRuleOperator.GREATER_THAN_OR_EQUAL;
    } else if (values[1].equals("<")) {
        // $NON-NLS-1$
        operator = WSRoutingRuleOperator.LOWER_THAN;
    } else if (values[1].equals("<=")) {
        // $NON-NLS-1$
        operator = WSRoutingRuleOperator.LOWER_THAN_OR_EQUAL;
    } else if (values[1].equals("!=")) {
        // $NON-NLS-1$
        operator = WSRoutingRuleOperator.NOT_EQUALS;
    } else if (values[1].equals("Starts With")) {
        // $NON-NLS-1$
        operator = WSRoutingRuleOperator.STARTSWITH;
    } else if (values[1].equals("Is Null")) {
        // $NON-NLS-1$
        operator = WSRoutingRuleOperator.IS_NULL;
    } else if (values[1].equals("Is Not Null")) {
        // $NON-NLS-1$
        operator = WSRoutingRuleOperator.IS_NOT_NULL;
    }
    wc.setWsOperator(operator);
    wc.setValue((values[2]));
    wc.setName((values[3]));
    return wc;
}
Also used : WSRoutingRuleOperator(com.amalto.workbench.webservices.WSRoutingRuleOperator) WSRoutingRuleExpression(com.amalto.workbench.webservices.WSRoutingRuleExpression)

Example 2 with WSRoutingRuleExpression

use of com.amalto.workbench.webservices.WSRoutingRuleExpression in project tmdm-studio-se by Talend.

the class RoutingRuleMainPage method refreshData.

@Override
protected void refreshData() {
    try {
        if (this.comitting) {
            return;
        }
        this.refreshing = true;
        WSRoutingRule wsRoutingRule = (WSRoutingRule) (getXObject().getWsObject());
        descriptionText.setText(wsRoutingRule.getDescription());
        isSynchronousButton.setSelection(wsRoutingRule.isSynchronous());
        if (wsRoutingRule.isDeactive() != null) {
            deactiveButton.setSelection(wsRoutingRule.isDeactive());
        }
        if (wsRoutingRule.isSynchronous()) {
            orderLabel.setEnabled(true);
            orderText.setEnabled(true);
            orderText.setText(String.valueOf(wsRoutingRule.getExecuteOrder()));
        }
        // serviceNameText.setText(wsRoutingRule.getServiceJNDI().replaceFirst("amalto/local/service/", ""));
        // $NON-NLS-1$//$NON-NLS-2$
        serviceNameCombo.setText(wsRoutingRule.getServiceJNDI().replaceFirst("amalto/local/service/", ""));
        // serviceParametersText.setText(wsRoutingRule.getParameters() == null ? "" :
        // XmlUtil.formatXmlSource(wsRoutingRule
        // .getParameters()));
        refreshParameterEditor(serviceNameCombo.getText().trim());
        serviceParametersEditor.setContent(wsRoutingRule.getParameters() == null ? "" : XmlUtil.formatXmlSource(// $NON-NLS-1$
        wsRoutingRule.getParameters()));
        objectTypeText.setText(wsRoutingRule.getConcept());
        // xpathWidget1.setText(wsRoutingRule.getConcept());
        java.util.List<Line> lines = new ArrayList<Line>();
        for (WSRoutingRuleExpression wc : wsRoutingRule.getWsRoutingRuleExpressions()) {
            Line line = new Line(conditionsColumns, Util.convertRouteCondition(wc));
            lines.add(line);
        }
        conditionViewer.getViewer().setInput(lines);
        if (wsRoutingRule.getCondition() != null) {
            conditionText.setText(wsRoutingRule.getCondition());
        }
        this.refreshing = false;
        if (objectTypeText.getText().length() > 0 && !objectTypeText.getText().equals("*")) {
            // $NON-NLS-1$
            conditionViewer.setConceptName(objectTypeText.getText());
        }
        initParamterProposal(serviceNameCombo.getText());
    // initConditionProposal();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getSite().getShell(), Messages.errorMsgLabel, Messages.bind(Messages.errorMsgLabelX, e.getLocalizedMessage()));
    }
}
Also used : Line(com.amalto.workbench.models.Line) WSRoutingRule(com.amalto.workbench.webservices.WSRoutingRule) ArrayList(java.util.ArrayList) XtentisException(com.amalto.workbench.utils.XtentisException) WSRoutingRuleExpression(com.amalto.workbench.webservices.WSRoutingRuleExpression)

Example 3 with WSRoutingRuleExpression

use of com.amalto.workbench.webservices.WSRoutingRuleExpression in project tmdm-studio-se by Talend.

the class RoutingRuleMainPage method commit.

@Override
protected void commit() {
    try {
        if (this.refreshing) {
            return;
        }
        this.comitting = true;
        WSRoutingRule ws = (WSRoutingRule) (getXObject().getWsObject());
        ws.setDescription(descriptionText.getText());
        ws.setConcept(objectTypeText.getText());
        ws.setServiceJNDI(serviceNameCombo.getText().contains("/") ? serviceNameCombo.getText() : // $NON-NLS-1$//$NON-NLS-2$
        "amalto/local/service/" + serviceNameCombo.getText());
        // ws.setParameters("".equals(serviceParametersText.getText()) ? null : serviceParametersText.getText());
        String curServiceParameter = serviceParametersEditor.getContent().getContent();
        // $NON-NLS-1$
        ws.setParameters("".equals(curServiceParameter) ? null : curServiceParameter);
        serviceParametersEditor.clearExternalResources();
        ws.setSynchronous(isSynchronousButton.getSelection());
        ws.setDeactive(deactiveButton.getSelection());
        if (isSynchronousButton.getSelection()) {
            String orderStr = orderText.getText().trim();
            if (orderStr.isEmpty()) {
                // $NON-NLS-1$
                orderStr = "0";
            }
            try {
                int order = Integer.parseInt(orderStr);
                ws.setExecuteOrder(order);
            } catch (Exception e) {
            }
        } else {
            ws.setExecuteOrder(0);
        }
        java.util.List<Line> lines = (java.util.List<Line>) conditionViewer.getViewer().getInput();
        java.util.List<WSRoutingRuleExpression> wclist = new ArrayList<WSRoutingRuleExpression>();
        for (Line item : lines) {
            String[] values = new String[] { item.keyValues.get(0).value, item.keyValues.get(1).value, item.keyValues.get(2).value, item.keyValues.get(3).value };
            WSRoutingRuleExpression wc = Util.convertLineRoute(values);
            wclist.add(wc);
        }
        ws.getWsRoutingRuleExpressions().clear();
        ws.getWsRoutingRuleExpressions().addAll(wclist);
        // WSRoutingRuleExpressions refreshed by viewer
        ws.setCondition(conditionText.getText());
        this.comitting = false;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(this.getSite().getShell(), Messages.errorCommitLabel, Messages.bind(Messages.errorCommitLabelX, e.getLocalizedMessage()));
    }
}
Also used : ArrayList(java.util.ArrayList) WSString(com.amalto.workbench.webservices.WSString) Point(org.eclipse.swt.graphics.Point) XtentisException(com.amalto.workbench.utils.XtentisException) Line(com.amalto.workbench.models.Line) WSRoutingRule(com.amalto.workbench.webservices.WSRoutingRule) WSGetServicesList(com.amalto.workbench.webservices.WSGetServicesList) List(java.util.List) ArrayList(java.util.ArrayList) WSServicesList(com.amalto.workbench.webservices.WSServicesList) WSRoutingRuleExpression(com.amalto.workbench.webservices.WSRoutingRuleExpression)

Example 4 with WSRoutingRuleExpression

use of com.amalto.workbench.webservices.WSRoutingRuleExpression in project tmdm-studio-se by Talend.

the class UtilTest method testConvertLineRoute.

@Test
public void testConvertLineRoute() {
    // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    String[] values = { "Entity/Id", "Contains", "value", "name" };
    WSRoutingRuleExpression wr = Util.convertLineRoute(values);
    // $NON-NLS-1$
    assertEquals(wr.getXpath(), "Entity/Id");
    // $NON-NLS-1$
    assertEquals(wr.getWsOperator().value(), "CONTAINS");
    // $NON-NLS-1$
    assertEquals(wr.getValue(), "value");
    // $NON-NLS-1$
    assertEquals(wr.getName(), "name");
}
Also used : WSRoutingRuleExpression(com.amalto.workbench.webservices.WSRoutingRuleExpression) Test(org.junit.Test)

Example 5 with WSRoutingRuleExpression

use of com.amalto.workbench.webservices.WSRoutingRuleExpression in project tmdm-studio-se by Talend.

the class UtilTest method testConvertRouteCondition.

@Test
public void testConvertRouteCondition() {
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    WSRoutingRuleExpression wr = new WSRoutingRuleExpression("name", "value", WSRoutingRuleOperator.CONTAINS, "Entity/Id");
    String[] lines = Util.convertRouteCondition(wr);
    assertEquals(lines.length, 4);
    // $NON-NLS-1$
    assertEquals(lines[0], "Entity/Id");
    // $NON-NLS-1$
    assertEquals(lines[1], "Contains");
    // $NON-NLS-1$
    assertEquals(lines[2], "value");
    // $NON-NLS-1$
    assertEquals(lines[3], "name");
}
Also used : WSRoutingRuleExpression(com.amalto.workbench.webservices.WSRoutingRuleExpression) Test(org.junit.Test)

Aggregations

WSRoutingRuleExpression (com.amalto.workbench.webservices.WSRoutingRuleExpression)6 WSRoutingRule (com.amalto.workbench.webservices.WSRoutingRule)3 Line (com.amalto.workbench.models.Line)2 XtentisException (com.amalto.workbench.utils.XtentisException)2 WSRoutingRuleOperator (com.amalto.workbench.webservices.WSRoutingRuleOperator)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 WSGetServicesList (com.amalto.workbench.webservices.WSGetServicesList)1 WSServicesList (com.amalto.workbench.webservices.WSServicesList)1 WSString (com.amalto.workbench.webservices.WSString)1 List (java.util.List)1 Point (org.eclipse.swt.graphics.Point)1