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()));
}
}
}
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()));
}
}
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()));
}
}
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;
}
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);
}
Aggregations