use of org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog in project pentaho-platform by pentaho.
the class PentahoPlatformExporterTest method executeExportMondrianSchemasForDataSourceInfo.
private void executeExportMondrianSchemasForDataSourceInfo(String catalogName, String dataSourceInfo) throws IOException {
PentahoSystem.registerObject(mondrianCatalogService);
exporterSpy.setMondrianCatalogRepositoryHelper(mondrianCatalogRepositoryHelper);
List<MondrianCatalog> catalogs = new ArrayList<>();
MondrianCatalog catalog = new MondrianCatalog(catalogName, dataSourceInfo, null, null);
catalogs.add(catalog);
when(mondrianCatalogService.listCatalogs(any(IPentahoSession.class), anyBoolean())).thenReturn(catalogs);
Map<String, InputStream> inputMap = new HashMap<>();
InputStream is = mock(InputStream.class);
when(is.read(any((new byte[] {}).getClass()))).thenReturn(-1);
inputMap.put(catalogName, is);
when(mondrianCatalogRepositoryHelper.getModrianSchemaFiles(catalogName)).thenReturn(inputMap);
exporterSpy.zos = mock(ZipOutputStream.class);
exporterSpy.exportMondrianSchemas();
}
use of org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog in project pentaho-platform by pentaho.
the class MDXBaseComponentTest method shouldAddSolutionPrefixIfFileExistsInRepository.
@Test
@SuppressWarnings("unchecked")
public void shouldAddSolutionPrefixIfFileExistsInRepository() throws ObjectFactoryException, DBDatasourceServiceException {
mdxBaseComponent.setActionDefinition(connAction);
when(connAction.getMdxConnectionString()).thenReturn(IActionInput.NULL_INPUT);
when(connAction.getConnectionProps()).thenReturn(IActionInput.NULL_INPUT);
when(connAction.getConnection()).thenReturn(IActionInput.NULL_INPUT);
when(connAction.getJndi()).thenReturn(new ActionInputConstant("", null));
when(connAction.getLocation()).thenReturn(new ActionInputConstant("", null));
when(connAction.getRole()).thenReturn(IActionInput.NULL_INPUT);
when(connAction.getCatalog()).thenReturn(IActionInput.NULL_INPUT);
when(connAction.getUserId()).thenReturn(IActionInput.NULL_INPUT);
when(connAction.getPassword()).thenReturn(IActionInput.NULL_INPUT);
when(connAction.getCatalogResource()).thenReturn(catalogResource);
when(catalogResource.getName()).thenReturn("catalog name");
PentahoSystem.registerObject(mdxConnection);
PentahoSystem.registerPrimaryObjectFactory(objFactory);
PentahoSessionHolder.setSession(session);
when(objFactory.get(any(Class.class), anyString(), any(IPentahoSession.class))).thenReturn(mdxConnection);
IDBDatasourceService datasourceService = mock(IDBDatasourceService.class);
when(objFactory.objectDefined("IDBDatasourceService")).thenReturn(true);
when(objFactory.get(any(Class.class), eq("IDBDatasourceService"), any(IPentahoSession.class))).thenReturn(datasourceService);
DataSource dataSource = mock(DataSource.class);
when(datasourceService.getDataSource(anyString())).thenReturn(dataSource);
mdxBaseComponent.setRuntimeContext(runtimeContext);
when(runtimeContext.getResourceDefintion("catalog name")).thenReturn(catalogActionSeqRes);
when(catalogActionSeqRes.getSourceType()).thenReturn(IActionSequenceResource.URL_RESOURCE);
MondrianCatalog mc = mock(MondrianCatalog.class);
doReturn(mc).when(mdxBaseComponent).getMondrianCatalog(anyString());
// using the same prepared environment for several checks...
// if file exists in repository, then the "solution:" prefix should be added
when(catalogActionSeqRes.getAddress()).thenReturn("fileName");
doReturn(true).when(mdxBaseComponent).fileExistsInRepository("fileName");
mdxBaseComponent.getConnectionOrig();
verify(mdxBaseComponent).getMondrianCatalog("solution:fileName");
verify(mdxBaseComponent, times(1)).fileExistsInRepository(anyString());
// if file exists in repository, then the "solution:" prefix should NOT be added,
// and the file therefore should be read from file system further
when(catalogActionSeqRes.getAddress()).thenReturn("fileName");
doReturn(false).when(mdxBaseComponent).fileExistsInRepository("fileName");
mdxBaseComponent.getConnectionOrig();
verify(mdxBaseComponent).getMondrianCatalog("fileName");
verify(mdxBaseComponent, times(2)).fileExistsInRepository(anyString());
// if filename already starts from "solution:" prefix,
// then no need to check file existence in repository
when(catalogActionSeqRes.getAddress()).thenReturn("solution:fileName");
mdxBaseComponent.getConnectionOrig();
verify(mdxBaseComponent, times(2)).fileExistsInRepository(anyString());
// same here: if the resource is http link, then no need to check it in repository
when(catalogActionSeqRes.getAddress()).thenReturn("http:fileName");
mdxBaseComponent.getConnectionOrig();
verify(mdxBaseComponent, times(2)).fileExistsInRepository(anyString());
}
use of org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog in project pentaho-platform by pentaho.
the class UserConsoleResource method getMondrianCatalogs.
/**
* Return the list of mondrian cubes in the platform
*
* @return list of cubes
*/
@GET
@Path("/cubes")
@Facet(name = "Unsupported")
@Produces({ APPLICATION_JSON, APPLICATION_XML })
public List<Cube> getMondrianCatalogs() {
ArrayList<Cube> cubes = new ArrayList<Cube>();
IMondrianCatalogService catalogService = PentahoSystem.get(IMondrianCatalogService.class, "IMondrianCatalogService", UserConsoleService.getPentahoSession());
List<MondrianCatalog> catalogs = catalogService.listCatalogs(UserConsoleService.getPentahoSession(), true);
for (MondrianCatalog cat : catalogs) {
for (MondrianCube cube : cat.getSchema().getCubes()) {
cubes.add(new Cube(cat.getName(), cube.getName(), cube.getId()));
}
}
return cubes;
}
use of org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog in project data-access by pentaho.
the class ModelerServiceIT method testRemoveCatalogDuringSerializeModels.
@Test
public void testRemoveCatalogDuringSerializeModels() throws Exception {
when(policy.isAllowed(anyString())).thenReturn(Boolean.TRUE);
when(pluginResourceLoader.getPluginSetting((Class) anyObject(), anyString(), anyString())).thenReturn(SimpleDataAccessPermissionHandler.class.getName());
MondrianCatalog mockCatalog = mock(MondrianCatalog.class);
when(mondrianCatalogService.getCatalog(anyString(), (IPentahoSession) anyObject())).thenReturn(mockCatalog);
modelerService.serializeModels(domain, TEST_CATALOG_NAME);
// verify removeCatalog is called
verify(mondrianCatalogService, times(1)).removeCatalog(anyString(), (IPentahoSession) anyObject());
}
use of org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog in project data-access by pentaho.
the class AnalysisService method getAnalysisDatasourceIds.
public List<String> getAnalysisDatasourceIds() {
List<String> analysisIds = new ArrayList<String>();
List<MondrianCatalog> mockMondrianCatalogList = mondrianCatalogService.listCatalogs(getSession(), false);
Set<String> ids = metadataDomainRepository.getDomainIds();
for (MondrianCatalog mondrianCatalog : mockMondrianCatalogList) {
String domainId = mondrianCatalog.getName() + METADATA_EXT;
if (!ids.contains(domainId)) {
analysisIds.add(mondrianCatalog.getName());
}
}
return analysisIds;
}
Aggregations