Search in sources :

Example 1 with WSRoutingRule

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

the class EditXObjectAction method run.

@Override
public void run() {
    try {
        super.run();
        if (xobject == null || !xobject.isXObject()) {
            return;
        }
        // Access to server and get port
        TMDMService service = Util.getMDMService(new URL(xobject.getEndpointAddress()), xobject.getUsername(), xobject.getPassword());
        switch(xobject.getType()) {
            case TreeObject.DATA_MODEL:
                WSDataModel wsDataModel = service.getDataModel(new WSGetDataModel((WSDataModelPK) xobject.getWsKey()));
                xobject.setWsObject(wsDataModel);
                // XSDEditorUtil.openDataModel(xobject, false);
                return;
            case TreeObject.VIEW:
                WSView wsView = service.getView(new WSGetView((WSViewPK) xobject.getWsKey()));
                xobject.setWsObject(wsView);
                break;
            case TreeObject.DATA_CLUSTER:
                WSDataCluster wsDataCluster = service.getDataCluster(new WSGetDataCluster((WSDataClusterPK) xobject.getWsKey()));
                xobject.setWsObject(wsDataCluster);
                break;
            case TreeObject.STORED_PROCEDURE:
                WSStoredProcedure wsStoredProcedure = service.getStoredProcedure(new WSGetStoredProcedure((WSStoredProcedurePK) xobject.getWsKey()));
                xobject.setWsObject(wsStoredProcedure);
                break;
            case TreeObject.ROUTING_RULE:
                WSRoutingRule wsRoutingRule = service.getRoutingRule(new WSGetRoutingRule((WSRoutingRulePK) xobject.getWsKey()));
                xobject.setWsObject(wsRoutingRule);
                break;
            case TreeObject.TRANSFORMER:
                WSTransformerV2 wsTranformer = service.getTransformerV2(new WSGetTransformerV2((WSTransformerV2PK) xobject.getWsKey()));
                xobject.setWsObject(wsTranformer);
                break;
            case TreeObject.MENU:
                WSMenu wsMenu = service.getMenu(new WSGetMenu((WSMenuPK) xobject.getWsKey()));
                xobject.setWsObject(wsMenu);
                break;
            case TreeObject.SERVICE_CONFIGURATION:
                break;
            case TreeObject.JOB_REGISTRY:
                // System.out.println("JOB_REGISTRY "+ xobject.getDisplayName());
                break;
            case TreeObject.JOB:
                // System.out.println("JOB "+ xobject.getDisplayName()+" "+xobject.getWsKey());
                xobject.setWsObject(xobject.getDisplayName());
                break;
            case TreeObject.ROLE:
                if (exAdapter != null) {
                    exAdapter.run(service, xobject);
                }
                break;
            case TreeObject.RESOURCES:
            case TreeObject.CUSTOM_TYPE:
            case TreeObject.DATA_MODEL_RESOURCE:
            case TreeObject.DATA_MODEL_TYPES_RESOURCE:
            case TreeObject.CUSTOM_TYPES_RESOURCE:
            case TreeObject.PICTURES_RESOURCE:
                break;
            default:
                MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages.EditXObjectAction_ErrorMsg1, IConstants.TALEND, xobject.getType()));
                return;
        }
        if (page == null) {
            this.page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        }
        this.page.openEditor(new XObjectEditorInput(xobject, xobject.getDisplayName()), // $NON-NLS-1$
        "com.amalto.workbench.editors.XObjectEditor");
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        if (!Util.handleConnectionException(getShell(), e, Messages.EditXObjectAction_ErrorMsg2)) {
            MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages.EditXObjectAction_ErrorMsg2, e.getLocalizedMessage()));
        }
    }
}
Also used : WSGetStoredProcedure(com.amalto.workbench.webservices.WSGetStoredProcedure) WSMenuPK(com.amalto.workbench.webservices.WSMenuPK) WSGetTransformerV2(com.amalto.workbench.webservices.WSGetTransformerV2) WSStoredProcedurePK(com.amalto.workbench.webservices.WSStoredProcedurePK) XObjectEditorInput(com.amalto.workbench.providers.XObjectEditorInput) URL(java.net.URL) WSView(com.amalto.workbench.webservices.WSView) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataCluster(com.amalto.workbench.webservices.WSDataCluster) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) TMDMService(com.amalto.workbench.webservices.TMDMService) WSRoutingRule(com.amalto.workbench.webservices.WSRoutingRule) WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure) WSGetView(com.amalto.workbench.webservices.WSGetView) WSGetMenu(com.amalto.workbench.webservices.WSGetMenu) WSRoutingRulePK(com.amalto.workbench.webservices.WSRoutingRulePK) WSGetRoutingRule(com.amalto.workbench.webservices.WSGetRoutingRule) WSMenu(com.amalto.workbench.webservices.WSMenu) WSDataModel(com.amalto.workbench.webservices.WSDataModel) WSGetDataCluster(com.amalto.workbench.webservices.WSGetDataCluster) WSTransformerV2(com.amalto.workbench.webservices.WSTransformerV2) WSTransformerV2PK(com.amalto.workbench.webservices.WSTransformerV2PK) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK) WSViewPK(com.amalto.workbench.webservices.WSViewPK)

Example 2 with WSRoutingRule

use of com.amalto.workbench.webservices.WSRoutingRule 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 WSRoutingRule

use of com.amalto.workbench.webservices.WSRoutingRule 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 WSRoutingRule

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

the class RoutingRuleTest method initWSObject.

private WSRoutingRule initWSObject() {
    WSRoutingRule rule = new WSRoutingRule();
    // $NON-NLS-1$
    rule.setName("ruleNameA");
    // $NON-NLS-1$
    rule.setConcept("concept");
    // $NON-NLS-1$
    rule.setCondition("condition");
    rule.setDeactive(true);
    // $NON-NLS-1$
    rule.setDescription("description");
    // $NON-NLS-1$
    rule.setParameters("parameters");
    // $NON-NLS-1$
    rule.setServiceJNDI("serviceJNDI");
    rule.setSynchronous(false);
    for (int i = 0; i < operators.size(); i++) {
        WSRoutingRuleExpression exp = new WSRoutingRuleExpression();
        // $NON-NLS-1$
        exp.setName("expression" + i);
        // $NON-NLS-1$
        exp.setValue("value" + i);
        // $NON-NLS-1$
        exp.setXpath("xpath" + i);
        WSRoutingRuleOperator o1 = WSRoutingRuleOperator.valueOf(operators.get(i));
        exp.setWsOperator(o1);
        rule.getWsRoutingRuleExpressions().add(exp);
    }
    return rule;
}
Also used : WSRoutingRule(com.amalto.workbench.webservices.WSRoutingRule) WSRoutingRuleOperator(com.amalto.workbench.webservices.WSRoutingRuleOperator) WSRoutingRuleExpression(com.amalto.workbench.webservices.WSRoutingRuleExpression)

Example 5 with WSRoutingRule

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

the class RoutingRuleTest method testHash.

@Test
public void testHash() {
    IHashValueCalculator wsCalculator = new WSRoutingRuleHVCalculator();
    IHashValueCalculator eobjCalculator = new EObjRoutingRuleHVCalculator();
    WSRoutingRule wsRule = initWSObject();
    WSRoutingRuleE eobjRule = initEObjRule();
    long wsHash = wsCalculator.calculateHash(wsRule);
    long eobjHash = eobjCalculator.calculateHash(eobjRule);
    assertEquals(wsHash, eobjHash);
}
Also used : WSRoutingRuleHVCalculator(org.talend.mdm.repository.core.hash.routingrule.WSRoutingRuleHVCalculator) IHashValueCalculator(org.talend.mdm.commmon.util.hash.IHashValueCalculator) EObjRoutingRuleHVCalculator(org.talend.mdm.repository.core.hash.routingrule.EObjRoutingRuleHVCalculator) WSRoutingRule(com.amalto.workbench.webservices.WSRoutingRule) WSRoutingRuleE(org.talend.mdm.repository.model.mdmserverobject.WSRoutingRuleE) Test(org.junit.Test)

Aggregations

WSRoutingRule (com.amalto.workbench.webservices.WSRoutingRule)7 TMDMService (com.amalto.workbench.webservices.TMDMService)3 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)3 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)3 WSDataModel (com.amalto.workbench.webservices.WSDataModel)3 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)3 WSGetDataCluster (com.amalto.workbench.webservices.WSGetDataCluster)3 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)3 WSGetMenu (com.amalto.workbench.webservices.WSGetMenu)3 WSGetRoutingRule (com.amalto.workbench.webservices.WSGetRoutingRule)3 WSGetStoredProcedure (com.amalto.workbench.webservices.WSGetStoredProcedure)3 WSGetTransformerV2 (com.amalto.workbench.webservices.WSGetTransformerV2)3 WSGetView (com.amalto.workbench.webservices.WSGetView)3 WSMenu (com.amalto.workbench.webservices.WSMenu)3 WSMenuPK (com.amalto.workbench.webservices.WSMenuPK)3 WSRoutingRuleExpression (com.amalto.workbench.webservices.WSRoutingRuleExpression)3 WSRoutingRulePK (com.amalto.workbench.webservices.WSRoutingRulePK)3 WSStoredProcedure (com.amalto.workbench.webservices.WSStoredProcedure)3 WSStoredProcedurePK (com.amalto.workbench.webservices.WSStoredProcedurePK)3 WSTransformerV2 (com.amalto.workbench.webservices.WSTransformerV2)3