Search in sources :

Example 1 with InlineEtlPhysicalModel

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);
}
Also used : BusinessData(org.pentaho.platform.dataaccess.datasource.beans.BusinessData) InlineEtlPhysicalModel(org.pentaho.metadata.model.InlineEtlPhysicalModel) SerializedResultSet(org.pentaho.platform.dataaccess.datasource.beans.SerializedResultSet) List(java.util.List) ArrayList(java.util.ArrayList) Domain(org.pentaho.metadata.model.Domain) SqlPhysicalModel(org.pentaho.metadata.model.SqlPhysicalModel)

Example 2 with InlineEtlPhysicalModel

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);
}
Also used : BusinessData(org.pentaho.platform.dataaccess.datasource.beans.BusinessData) InlineEtlPhysicalModel(org.pentaho.metadata.model.InlineEtlPhysicalModel) SerializedResultSet(org.pentaho.platform.dataaccess.datasource.beans.SerializedResultSet) ArrayList(java.util.ArrayList) List(java.util.List) Domain(org.pentaho.metadata.model.Domain) SqlPhysicalModel(org.pentaho.metadata.model.SqlPhysicalModel)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 Domain (org.pentaho.metadata.model.Domain)2 InlineEtlPhysicalModel (org.pentaho.metadata.model.InlineEtlPhysicalModel)2 SqlPhysicalModel (org.pentaho.metadata.model.SqlPhysicalModel)2 BusinessData (org.pentaho.platform.dataaccess.datasource.beans.BusinessData)2 SerializedResultSet (org.pentaho.platform.dataaccess.datasource.beans.SerializedResultSet)2