use of org.pentaho.metadata.model.InlineEtlPhysicalModel in project data-access by pentaho.
the class DSWDatasourceServiceImpl method loadBusinessData.
public BusinessData loadBusinessData(String domainId, String modelId) throws DatasourceServiceException {
Domain domain = getMetadataDomainRepository().getDomain(domainId);
List<List<String>> data = null;
if (domain.getPhysicalModels().get(0) instanceof InlineEtlPhysicalModel) {
InlineEtlPhysicalModel model = (InlineEtlPhysicalModel) domain.getPhysicalModels().get(0);
String relativePath = PentahoSystem.getSystemSetting("file-upload-defaults/relative-path", // $NON-NLS-1$
String.valueOf(CsvTransformGenerator.DEFAULT_RELATIVE_UPLOAD_FILE_PATH));
String csvFileLoc = PentahoSystem.getApplicationContext().getSolutionPath(relativePath);
data = DatasourceServiceHelper.getCsvDataSample(csvFileLoc + model.getFileLocation(), model.getHeaderPresent(), model.getDelimiter(), model.getEnclosure(), 5);
} else {
SqlPhysicalModel model = (SqlPhysicalModel) domain.getPhysicalModels().get(0);
String query = model.getPhysicalTables().get(0).getTargetTable();
SerializedResultSet resultSet = DatasourceServiceHelper.getSerializeableResultSet(model.getDatasource().getDatabaseName(), query, 5, PentahoSessionHolder.getSession());
data = resultSet.getData();
}
return new BusinessData(domain, data);
}
use of org.pentaho.metadata.model.InlineEtlPhysicalModel in project data-access by pentaho.
the class InMemoryDSWDatasourceServiceImpl method loadBusinessData.
public BusinessData loadBusinessData(String domainId, String modelId) throws DatasourceServiceException {
Domain domain = getMetadataDomainRepository().getDomain(domainId);
List<List<String>> data = null;
if (domain.getPhysicalModels().get(0) instanceof InlineEtlPhysicalModel) {
InlineEtlPhysicalModel model = (InlineEtlPhysicalModel) domain.getPhysicalModels().get(0);
data = DatasourceInMemoryServiceHelper.getCsvDataSample(model.getFileLocation(), model.getHeaderPresent(), model.getDelimiter(), model.getEnclosure(), 5);
} else {
SqlPhysicalModel model = (SqlPhysicalModel) domain.getPhysicalModels().get(0);
String query = model.getPhysicalTables().get(0).getTargetTable();
SerializedResultSet resultSet = DatasourceInMemoryServiceHelper.getSerializeableResultSet(model.getDatasource().getDatabaseName(), query, 5, null);
data = resultSet.getData();
}
return new BusinessData(domain, data);
}
Aggregations