PentahoPlatformExporter extends ZipExportProcessor { protected void exportMondrianSchemas() { log.debug( "export mondrian schemas" ); List<MondrianCatalog> catalogs = getMondrianCatalogService().listCatalogs( getSession(), false ); for ( MondrianCatalog catalog : catalogs ) { Map<String, InputStream> files = getMondrianCatalogRepositoryHelper().getModrianSchemaFiles( catalog.getName() ); ExportManifestMondrian mondrian = new ExportManifestMondrian(); for ( String fileName : files.keySet() ) { String path = ANALYSIS_PATH_IN_ZIP + catalog.getName() + "/" + fileName; ZipEntry zipEntry = new ZipEntry( new ZipEntry( ExportFileNameEncoder.encodeZipPathName( path ) ) ); InputStream inputStream = files.get( fileName ); if ( fileName.equals( "schema.annotated.xml" ) ) { continue; } else if ( MondrianVfs.ANNOTATIONS_XML.equals( fileName ) ) { mondrian.setAnnotationsFile( path ); } else { mondrian.setCatalogName( catalog.getName() ); boolean xmlaEnabled = parseXmlaEnabled( catalog.getDataSourceInfo() ); mondrian.setXmlaEnabled( xmlaEnabled ); mondrian.setFile( path ); Parameters mondrianParameters = new Parameters(); mondrianParameters.put( "Provider", "mondrian" ); mondrianParameters.put( "DataSource", StringEscapeUtils.unescapeXml( catalog.getJndi() ) ); mondrianParameters.put( "EnableXmla", Boolean.toString( xmlaEnabled ) ); StreamSupport.stream( catalog.getConnectProperties().spliterator(), false ) .filter( p -> !mondrianParameters.containsKey( p.getKey() ) ) .forEach( p -> mondrianParameters.put( p.getKey(), StringEscapeUtils.unescapeXml( p.getValue() ) ) ); mondrian.setParameters( mondrianParameters ); } try { zos.putNextEntry( zipEntry ); IOUtils.copy( inputStream, zos ); } catch ( IOException e ) { log.warn( e.getMessage(), e ); } finally { IOUtils.closeQuietly( inputStream ); try { zos.closeEntry(); } catch ( IOException e ) { } } } if ( mondrian.getCatalogName() != null && mondrian.getFile() != null ) { getExportManifest().addMondrian( mondrian ); } } } PentahoPlatformExporter( IUnifiedRepository repository ); File performExport(); @Override File performExport( RepositoryFile exportRepositoryFile ); IScheduler getScheduler(); void setScheduler( IScheduler scheduler ); IMetadataDomainRepository getMetadataDomainRepository(); void setMetadataDomainRepository( IMetadataDomainRepository metadataDomainRepository ); IDatasourceMgmtService getDatasourceMgmtService(); void setDatasourceMgmtService( IDatasourceMgmtService datasourceMgmtService ); MondrianCatalogRepositoryHelper getMondrianCatalogRepositoryHelper(); void setMondrianCatalogRepositoryHelper(
    MondrianCatalogRepositoryHelper mondrianCatalogRepositoryHelper ); IMondrianCatalogService getMondrianCatalogService(); void setMondrianCatalogService(
    IMondrianCatalogService mondrianCatalogService ); IUserSettingService getUserSettingService(); void setUserSettingService( IUserSettingService userSettingService ); static final String ROOT; static final String DATA_SOURCES_PATH_IN_ZIP; static final String METADATA_PATH_IN_ZIP; static final String ANALYSIS_PATH_IN_ZIP; static final String CONNECTIONS_PATH_IN_ZIP; static final String METASTORE; static final String METASTORE_BACKUP_EXT; }
@Test public void testExportMondrianSchemas() throws Exception { final String catalogName = "test"; String dataSourceInfo = "EnableXmla=\"true\""; executeExportMondrianSchemasForDataSourceInfo( catalogName, dataSourceInfo ); verify( exportManifest ).addMondrian( any( ExportManifestMondrian.class ) ); verify( mondrianCatalogRepositoryHelper ).getModrianSchemaFiles( anyString() ); assertEquals( catalogName, exportManifest.getMondrianList().get( 0 ).getCatalogName() ); assertTrue( exportManifest.getMondrianList().get( 0 ).isXmlaEnabled() ); verify( exporterSpy.zos ).putNextEntry( any( ZipEntry.class ) ); }