use of org.pentaho.platform.dataaccess.datasource.wizard.models.DatasourceModel in project data-access by pentaho.
the class GwtDatasourceEditorEntryPoint method showEditDatabaseDialog.
public void showEditDatabaseDialog(final DialogListener dialogListener, final String databaseName) {
String cacheBuster = String.valueOf(new java.util.Date().getTime());
String url = ConnectionController.getServiceURL("get", new String[][] { { "name", databaseName }, { "ts", cacheBuster } });
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
builder.setHeader("Accept", "application/json");
try {
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
Window.alert(exception.toString());
}
@SuppressWarnings("deprecation")
public void onResponseReceived(Request request, Response response) {
IDatabaseConnection conn = null;
if (response.getStatusCode() == Response.SC_OK) {
AutoBean<IDatabaseConnection> bean = AutoBeanCodex.decode(connectionAutoBeanFactory, IDatabaseConnection.class, response.getText());
conn = bean.as();
}
ConnectionController connectionController = wizard.getConnectionController();
connectionController.init();
DatasourceModel datasourceModel = connectionController.getDatasourceModel();
if (datasourceModel == null) {
datasourceModel = new DatasourceModel();
}
datasourceModel.setSelectedRelationalConnection(conn);
// This is important for edit mode of datasource model
datasourceModel.setEditing(true);
connectionController.setDatasourceModel(datasourceModel);
connectionController.showEditConnectionDialog(dialogListener, conn);
}
});
} catch (Exception e) {
Window.alert("Cannot edit datasource");
}
}
use of org.pentaho.platform.dataaccess.datasource.wizard.models.DatasourceModel in project data-access by pentaho.
the class DSWDatasourceServiceImplTest method testDeSerializeModelStateValidString.
@Test
public void testDeSerializeModelStateValidString() throws Exception {
PentahoSystem.registerObjectFactory(new TestObjectFactory());
DatasourceModel datasourceModel = spy(new DatasourceModel());
doReturn("testdatasource").when(datasourceModel).generateTableName();
datasourceModel.setDatasourceName("testDatasource");
datasourceModel.setDatasourceType(DatasourceType.CSV);
DatasourceDTO dto = DatasourceDTO.generateDTO(datasourceModel);
assertNotNull(dto);
String serializedDTO = dswService.serializeModelState(dto);
dswService.deSerializeModelState(serializedDTO);
}
use of org.pentaho.platform.dataaccess.datasource.wizard.models.DatasourceModel in project data-access by pentaho.
the class GwtDatasourceEditorEntryPoint method showDatabaseDialog.
public void showDatabaseDialog(final DialogListener<IDatabaseConnection> listener) {
ConnectionController connectionController = wizard.getConnectionController();
connectionController.init();
DatasourceModel datasourceModel = connectionController.getDatasourceModel();
if (datasourceModel == null) {
datasourceModel = new DatasourceModel();
}
connectionController.setDatasourceModel(datasourceModel);
connectionController.showAddConnectionDialog(listener);
}
Aggregations