use of com.amalto.workbench.webservices.WSStoredProcedure 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.WSStoredProcedure in project tmdm-studio-se by Talend.
the class StoredProcedureMainPage method refreshData.
// createCharacteristicsContent
@Override
protected void refreshData() {
if (this.comitting) {
return;
}
this.refreshing = true;
WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
String s;
// $NON-NLS-1$
s = wsStoredProcedure.getDescription() == null ? "" : wsStoredProcedure.getDescription();
if (!s.equals(descriptionText.getText())) {
descriptionText.setText(s);
}
Document doc = new Document(wsStoredProcedure.getProcedure());
procedureViewer.setDocument(doc);
refreshCacheBtn.setSelection(wsStoredProcedure.isRefreshCache() != null && wsStoredProcedure.isRefreshCache() ? true : false);
initDataClusterCombo();
this.refreshing = false;
}
use of com.amalto.workbench.webservices.WSStoredProcedure in project tmdm-studio-se by Talend.
the class StoredProcedureMainPage method createCharacteristicsContent.
@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
try {
WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
// description
Label descriptionLabel = toolkit.createLabel(charComposite, Messages.StoredProcedureMainPage_4, SWT.NULL);
descriptionLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
// $NON-NLS-1$
descriptionText = toolkit.createText(charComposite, "", SWT.BORDER);
descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
// $NON-NLS-1$
descriptionText.setText(wsStoredProcedure.getDescription() == null ? "" : wsStoredProcedure.getDescription());
descriptionText.addModifyListener(this);
// Procedure
Group storedProcedureGroup = new Group(charComposite, SWT.SHADOW_NONE);
storedProcedureGroup.setText(Messages.StoredProcedureMainPage_5);
storedProcedureGroup.setLayout(new GridLayout(1, true));
storedProcedureGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
((GridData) storedProcedureGroup.getLayoutData()).minimumHeight = 100;
procedureViewer = new SourceViewer(storedProcedureGroup, new VerticalRuler(10), SWT.V_SCROLL);
procedureViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
procedureViewer.addTextListener(this);
WidgetUtils.initRedoUndo(procedureViewer);
refreshCacheBtn = toolkit.createButton(charComposite, Messages.StoredProcedureMainPage_6, SWT.CHECK);
refreshCacheBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
refreshCacheBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
markDirty();
}
public void widgetDefaultSelected(SelectionEvent e) {
markDirty();
}
});
/**
**********************************************************
* Execute Stored Procedure
***********************************************************
*/
createCompDropTarget();
Composite resultsGroup = this.getNewSectionComposite(Messages.StoredProcedureMainPage_7);
resultsGroup.setLayout(new GridLayout(4, false));
// data cluster
Hyperlink dataClusterLink = toolkit.createHyperlink(resultsGroup, Messages.StoredProcedureMainPage_8, SWT.NULL);
dataClusterLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
dataClusterLink.addHyperlinkListener(new IHyperlinkListener() {
public void linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent e) {
}
public void linkExited(org.eclipse.ui.forms.events.HyperlinkEvent e) {
}
public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) {
if (!isLocalInput()) {
TreeParent serverRoot = StoredProcedureMainPage.this.getXObject().getServerRoot();
TreeObject iaObject = new TreeObject(StoredProcedureMainPage.this.dataClusterCombo.getText(), serverRoot, TreeObject.DATA_CLUSTER, new WSDataClusterPK(StoredProcedureMainPage.this.dataClusterCombo.getText()), null);
(new EditXObjectAction(iaObject, StoredProcedureMainPage.this.getSite().getPage())).run();
}
}
});
dataClusterCombo = new Combo(resultsGroup, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
dataClusterCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, false, false, 1, 1));
Button executeButton = new Button(resultsGroup, SWT.PUSH);
executeButton.setText(Messages.StoredProcedureMainPage_9);
executeButton.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
executeProcedure();
}
public void mouseDoubleClick(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
}
});
resultsLabel = toolkit.createLabel(resultsGroup, // $NON-NLS-1$
" ", SWT.NULL);
resultsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 1, 1));
resultsViewer = new TableViewer(resultsGroup);
resultsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
((GridData) resultsViewer.getControl().getLayoutData()).heightHint = 300;
resultsViewer.setContentProvider(new ArrayContentProvider());
resultsViewer.setLabelProvider(new XMLTableLabelProvider());
resultsViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
resultsViewer.setSelection(event.getSelection());
new ResultsViewAction(StoredProcedureMainPage.this.getSite().getShell(), resultsViewer).run();
}
});
hookContextMenu();
refreshData();
dataClusterCombo.select(0);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of com.amalto.workbench.webservices.WSStoredProcedure in project tmdm-studio-se by Talend.
the class StoredProcedureMainPage method commit.
@Override
protected void commit() {
if (this.refreshing) {
return;
}
this.comitting = true;
WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
wsStoredProcedure.setDescription(descriptionText.getText());
wsStoredProcedure.setProcedure(procedureViewer.getDocument().get());
wsStoredProcedure.setRefreshCache(refreshCacheBtn.getSelection());
this.comitting = false;
}
use of com.amalto.workbench.webservices.WSStoredProcedure in project tmdm-studio-se by Talend.
the class StoredProcedureMainPage method executeProcedure.
protected void executeProcedure() {
boolean checkMissingJar = MissingJarService.getInstance().checkMissingJar(true);
if (!checkMissingJar) {
return;
}
BusyIndicator.showWhile(this.getPartControl().getDisplay(), new Runnable() {
public void run() {
WSDataClusterPK dcpk = null;
if (!"[ALL]".equals(dataClusterCombo.getText())) {
dcpk = new WSDataClusterPK(dataClusterCombo.getText());
}
try {
String proc = procedureViewer.getDocument().get();
// read parameters
int number = 0;
while (true) {
// $NON-NLS-1$//$NON-NLS-2$
Pattern p = Pattern.compile(".*[^\\\\]%" + number + "[^\\d]*.*", Pattern.DOTALL);
Matcher m = p.matcher(proc);
if (!m.matches()) {
break;
} else {
++number;
}
}
String[] ps = null;
if (number > 0) {
// transfer current parameters to new array
ps = new String[number];
for (int i = 0; i < number; i++) {
if (i < currentParameters.size()) {
ps[i] = currentParameters.get(i);
} else {
// $NON-NLS-1$
ps[i] = "";
}
}
// call parameters window
QueryParametersDialog dialog = new QueryParametersDialog(StoredProcedureMainPage.this.getSite().getShell(), ps);
dialog.setBlockOnOpen(true);
dialog.open();
if (dialog.getButtonPressed() == QueryParametersDialog.BUTTON_CANCEL) {
return;
}
ps = dialog.getParameters();
// Apply parameters
for (int i = 0; i < ps.length; i++) {
// transfer parameters back into current parameters
if (i < currentParameters.size()) {
currentParameters.set(i, ps[i]);
} else {
currentParameters.add(ps[i]);
}
}
}
// perform call
TMDMService service = getMDMService();
if (service != null) {
WSStoredProcedure wsStoredProcedure = (WSStoredProcedure) (getXObject().getWsObject());
service.putStoredProcedure(new WSPutStoredProcedure(wsStoredProcedure));
WSStringArray array = service.executeStoredProcedure(new WSExecuteStoredProcedure(currentParameters, dcpk, new WSStoredProcedurePK(wsStoredProcedure.getName())));
List<String> results = array.getStrings();
resultsLabel.setText(Messages.StoredProcedureMainPage_15 + results.size() + Messages.StoredProcedureMainPage_16);
resultsViewer.setInput(results);
}
} catch (Exception ex) {
if (!Util.handleConnectionException(StoredProcedureMainPage.this.getSite().getShell(), ex, null)) {
String message = ex.getMessage();
Set<String> messages = getMessages(message);
StringBuilder builder = new StringBuilder();
for (String currentMessage : messages) {
builder.append(currentMessage + '\n');
}
MessageDialog.openError(StoredProcedureMainPage.this.getSite().getShell(), Messages._Error, builder.toString());
}
}
}
});
}
Aggregations