use of org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator in project pentaho-platform by pentaho.
the class MondrianVfsTest method testAnnotationsAreApplied.
@Test
public void testAnnotationsAreApplied() throws Exception {
MondrianSchemaAnnotator mondrianSchemaAnnotator = new MondrianSchemaAnnotator() {
@Override
public InputStream getInputStream(final InputStream inputStream, final InputStream annotationsInputStream) {
return IOUtils.toInputStream(appliedContent);
}
};
assertEquals(appliedContent, runCatalogTest("/annotated", mondrianSchemaAnnotator, true));
}
use of org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator in project pentaho-platform by pentaho.
the class MondrianCatalogRepositoryHelperIT method setUpClass.
@BeforeClass
public static void setUpClass() throws Exception {
MicroPlatform platform = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/solution");
platform.defineInstance("inlineModeling", new MondrianSchemaAnnotator() {
@Override
public InputStream getInputStream(final InputStream schemaInputStream, final InputStream annotationsInputStream) {
return new java.io.SequenceInputStream(schemaInputStream, annotationsInputStream);
}
});
platform.start();
}
use of org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator in project pentaho-platform by pentaho.
the class MondrianCatalogHelperIT method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(olapService.getConnection(any(String.class), any(IPentahoSession.class))).thenReturn(olapConn);
when(rolapConn.getSchema()).thenReturn(mondrianSchema);
when(rolapConn.getCacheControl(any(PrintWriter.class))).thenReturn(mondrianCacheControl);
when(olapConn.unwrap(Connection.class)).thenReturn(rolapConn);
booter = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/solution");
booter.define(IPasswordService.class, KettlePasswordService.class, Scope.GLOBAL);
booter.define(IDatabaseConnection.class, DatabaseConnection.class, Scope.GLOBAL);
booter.define(IDatabaseDialectService.class, DatabaseDialectService.class, Scope.GLOBAL);
booter.define(IAclAwareMondrianCatalogService.class, MondrianCatalogHelper.class, Scope.GLOBAL);
booter.define(ICacheManager.class, CacheManager.class, Scope.GLOBAL);
booter.define(IUserRoleListService.class, TestUserRoleListService.class, Scope.GLOBAL);
booter.defineInstance(IUnifiedRepository.class, repo);
booter.defineInstance(IOlapService.class, olapService);
booter.defineInstance("inlineModeling", new MondrianSchemaAnnotator() {
@Override
public InputStream getInputStream(final InputStream schemaInputStream, final InputStream annotationsInputStream) {
return schemaInputStream;
}
});
booter.setSettingsProvider(new SystemSettings());
booter.start();
cacheMgr = PentahoSystem.getCacheManager(null);
helper = (MondrianCatalogHelper) PentahoSystem.get(IAclAwareMondrianCatalogService.class);
}
use of org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator in project pentaho-platform by pentaho.
the class MondrianVfs method findFile.
public FileObject findFile(FileObject arg0, String catalog, FileSystemOptions arg2) throws FileSystemException {
// Resolves mondrian:/<catalog> to /etc/mondrian/<catalog>/schema.xml
// removes mondrian:
catalog = catalog.substring(catalog.indexOf(":") + 1);
FileObject schemaFile = getCatalogFileObject(catalog, SCHEMA_XML);
FileObject annotationsFile = getCatalogFileObject(catalog, ANNOTATIONS_XML);
MondrianSchemaAnnotator annotator = getAnnotator();
if (annotationsFile.exists() && annotator != null) {
return new MondrianFileObject(schemaFile, annotationsFile, annotator);
}
return schemaFile;
}
use of org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator in project pentaho-platform by pentaho.
the class MondrianFileObjectTest method testAppliesAllAnnotators.
@Test
public void testAppliesAllAnnotators() throws Exception {
FileObject schemaFile = FileObjectTestHelper.mockFile("schemaFile", true);
FileObject annotationsFile = FileObjectTestHelper.mockFile("annotationsFile", true);
MondrianSchemaAnnotator mondrianSchemaAnnotator = new MondrianSchemaAnnotator() {
@Override
public InputStream getInputStream(final InputStream schemaInputStream, final InputStream annotationsInputStream) {
try {
return new ByteArrayInputStream((IOUtils.toString(annotationsInputStream) + " - " + IOUtils.toString(schemaInputStream)).getBytes());
} catch (IOException e) {
fail(e.getMessage());
return null;
}
}
};
MondrianFileObject mondrianFileObject = new MondrianFileObject(schemaFile, annotationsFile, mondrianSchemaAnnotator);
String actual = IOUtils.toString(mondrianFileObject.getContent().getInputStream());
assertEquals("annotationsFile - schemaFile", actual);
}
Aggregations