use of org.pentaho.platform.dataaccess.datasource.beans.SerializedResultSet in project data-access by pentaho.
the class InMemoryDSWDatasourceServiceImpl method doPreview.
public SerializedResultSet doPreview(String connectionName, String query, String previewLimit) throws DatasourceServiceException {
SerializedResultSet returnResultSet;
try {
executeQuery(connectionName, query, previewLimit);
returnResultSet = DatasourceInMemoryServiceHelper.getSerializeableResultSet(connectionName, query, Integer.parseInt(previewLimit), null);
} catch (QueryValidationException e) {
logger.error(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0009_QUERY_VALIDATION_FAILED", e.getLocalizedMessage()), // $NON-NLS-1$
e);
throw new DatasourceServiceException(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0009_QUERY_VALIDATION_FAILED", e.getLocalizedMessage()), // $NON-NLS-1$
e);
}
return returnResultSet;
}
use of org.pentaho.platform.dataaccess.datasource.beans.SerializedResultSet in project data-access by pentaho.
the class InMemoryDSWDatasourceServiceImpl method generateQueryDomain.
@Override
public QueryDatasourceSummary generateQueryDomain(String name, String query, DatabaseConnection connection, DatasourceDTO datasourceDTO) throws DatasourceServiceException {
ModelerWorkspace modelerWorkspace = new ModelerWorkspace(new GwtModelerWorkspaceHelper(), getGeoContext());
ModelerService modelerService = new ModelerService();
modelerWorkspace.setModelName(name);
try {
Boolean securityEnabled = (getPermittedRoleList() != null && getPermittedRoleList().size() > 0) || (getPermittedUserList() != null && getPermittedUserList().size() > 0);
SerializedResultSet resultSet = DatasourceInMemoryServiceHelper.getSerializeableResultSet(connection.getName(), query, Integer.parseInt("10"), null);
SQLModelGenerator sqlModelGenerator = new SQLModelGenerator(name, connection.getName(), connection.getDatabaseType().getShortName(), resultSet.getColumnTypes(), resultSet.getColumns(), query, securityEnabled, getPermittedRoleList(), getPermittedUserList(), getDefaultAcls(), "joe");
Domain domain = sqlModelGenerator.generate();
modelerWorkspace.setDomain(domain);
modelerWorkspace.getWorkspaceHelper().autoModelFlat(modelerWorkspace);
modelerWorkspace.setModelName(datasourceDTO.getDatasourceName());
modelerWorkspace.getWorkspaceHelper().populateDomain(modelerWorkspace);
domain.getLogicalModels().get(0).setProperty("datasourceModel", serializeModelState(datasourceDTO));
domain.getLogicalModels().get(0).setProperty("DatasourceType", "SQL-DS");
QueryDatasourceSummary summary = new QueryDatasourceSummary();
modelerService.serializeModels(domain, modelerWorkspace.getModelName());
summary.setDomain(domain);
return summary;
} catch (SQLModelGeneratorException smge) {
logger.error(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0016_UNABLE_TO_GENERATE_MODEL", smge.getLocalizedMessage()), smge);
throw new DatasourceServiceException(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0015_UNABLE_TO_GENERATE_MODEL"), // $NON-NLS-1$
smge);
} catch (QueryValidationException e) {
logger.error(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0009_QUERY_VALIDATION_FAILED", e.getLocalizedMessage()), // $NON-NLS-1$
e);
throw new DatasourceServiceException(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0009_QUERY_VALIDATION_FAILED", e.getLocalizedMessage()), // $NON-NLS-1$
e);
} catch (ModelerException e) {
logger.error(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0016_UNABLE_TO_GENERATE_MODEL", e.getLocalizedMessage()), e);
throw new DatasourceServiceException(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0015_UNABLE_TO_GENERATE_MODEL"), // $NON-NLS-1$
e);
} catch (Exception e) {
logger.error(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0016_UNABLE_TO_GENERATE_MODEL", e.getLocalizedMessage()), e);
throw new DatasourceServiceException(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0015_UNABLE_TO_GENERATE_MODEL"), // $NON-NLS-1$
e);
}
}
use of org.pentaho.platform.dataaccess.datasource.beans.SerializedResultSet in project data-access by pentaho.
the class DSWDatasourceServiceImplTest method testDoPreview_NullQuery.
@Test(expected = DatasourceServiceException.class)
public void testDoPreview_NullQuery() throws DatasourceServiceException {
doReturn(true).when(dswService).hasDataAccessPermission();
SerializedResultSet result = dswService.doPreview(CONNECTION_NAME, null, PREVIEW_LIMIT);
try {
verify(dswService).executeQuery("[connection 接続 <;>!@#$%^&*()_-=+.,]", VALID_QUERY, PREVIEW_LIMIT);
} catch (Exception e) {
e.printStackTrace();
}
assertNotNull(result);
assertArrayEquals(columns, result.getColumns());
assertArrayEquals(columnTypes, result.getColumnTypes());
}
use of org.pentaho.platform.dataaccess.datasource.beans.SerializedResultSet in project data-access by pentaho.
the class DatasourceInMemoryServiceHelperTest method testGetSerializeableResultSet.
@Test
public void testGetSerializeableResultSet() throws DatasourceServiceException, SQLException {
SerializedResultSet rs = DatasourceInMemoryServiceHelper.getSerializeableResultSet(GENERIC_CONN_DRIVER_CLASS, SAMPLE_VALID_QUERY, 10, null);
assertNotNull(rs);
verify(sqlConnection).close();
}
use of org.pentaho.platform.dataaccess.datasource.beans.SerializedResultSet in project data-access by pentaho.
the class DSWDatasourceServiceImplTest method testDoPreview.
@Test
public void testDoPreview() throws DatasourceServiceException {
doReturn(true).when(dswService).hasDataAccessPermission();
SerializedResultSet result = dswService.doPreview(CONNECTION_NAME, VALID_QUERY, PREVIEW_LIMIT);
try {
verify(dswService).executeQuery("[connection 接続 <;>!@#$%^&*()_-=+.,]", VALID_QUERY, PREVIEW_LIMIT);
} catch (Exception e) {
e.printStackTrace();
}
assertNotNull(result);
assertArrayEquals(columns, result.getColumns());
assertArrayEquals(columnTypes, result.getColumnTypes());
}
Aggregations