1 package com.quantum.wizards;
3 import java.sql.SQLException;
5 import com.quantum.adapters.DatabaseAdapter;
6 import com.quantum.model.Bookmark;
7 import com.quantum.model.Column;
8 import com.quantum.model.ConnectionException;
9 import com.quantum.model.Entity;
10 import com.quantum.model.NotConnectedException;
11 import com.quantum.sql.SQLResults;
12 import com.quantum.sql.TableRow;
13 import com.quantum.view.ViewHelper;
14 import com.quantum.view.tableview.TableAdapter;
16 import org.eclipse.jface.wizard.WizardPage;
22 public abstract class BaseSQLPage extends WizardPage implements SQLPage {
24 protected TableRow row;
25 protected TableAdapter adapter;
27 public BaseSQLPage(String pageName) {
30 public boolean performFinish() {
32 Bookmark bookmark = this.adapter.getBookmark();
33 bookmark.addQuery(getQueryText());
34 SQLResults sqlResults = ViewHelper.tryGetResults(getShell(),
35 bookmark.getConnection(), getQueryText());
36 return sqlResults.isError() ? false : true;
37 } catch (ConnectionException e) {
43 protected abstract String getQueryText();
44 protected void appendColumn(StringBuffer whereClause, Entity entity, String columnName, DatabaseAdapter adapter, String value) {
46 if (adapter != null && entity != null && getColumn(entity, columnName) != null) {
47 Column column = getColumn(entity, columnName);
48 whereClause.append(adapter.quote(value, column.getType(), column.getTypeName()));
50 whereClause.append(value);
57 * @throws NotConnectedException
58 * @throws SQLException
60 protected Column getColumn(Entity entity, String columnName) {
62 return entity == null ? null : entity.getColumn(columnName);
63 } catch (NotConnectedException e) {
65 } catch (SQLException e) {
69 public void init(TableRow row, TableAdapter adapter) {
71 this.adapter = adapter;