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