Search in sources :

Example 1 with MondrianSchemaAnnotator

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));
}
Also used : MondrianSchemaAnnotator(org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 2 with MondrianSchemaAnnotator

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();
}
Also used : MondrianSchemaAnnotator(org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) BeforeClass(org.junit.BeforeClass)

Example 3 with MondrianSchemaAnnotator

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);
}
Also used : MondrianSchemaAnnotator(org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Matchers.anyString(org.mockito.Matchers.anyString) SystemSettings(org.pentaho.platform.engine.core.system.SystemSettings) PrintWriter(java.io.PrintWriter) Before(org.junit.Before)

Example 4 with MondrianSchemaAnnotator

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;
}
Also used : MondrianSchemaAnnotator(org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator) FileObject(org.apache.commons.vfs2.FileObject)

Example 5 with MondrianSchemaAnnotator

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);
}
Also used : MondrianSchemaAnnotator(org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) FileObject(org.apache.commons.vfs2.FileObject) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

MondrianSchemaAnnotator (org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator)6 InputStream (java.io.InputStream)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 FileObject (org.apache.commons.vfs2.FileObject)2 Test (org.junit.Test)2 MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)2 PrintWriter (java.io.PrintWriter)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 Matchers.anyString (org.mockito.Matchers.anyString)1 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)1 RepositoryException (org.pentaho.platform.api.repository.RepositoryException)1 SystemSettings (org.pentaho.platform.engine.core.system.SystemSettings)1