Search in sources :

Example 6 with MondrianSchemaAnnotator

use of org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator in project pentaho-platform by pentaho.

the class MondrianCatalogRepositoryHelper method includeAnnotatedSchema.

private Map<String, InputStream> includeAnnotatedSchema(final Map<String, InputStream> values) {
    MondrianSchemaAnnotator annotator = PentahoSystem.get(MondrianSchemaAnnotator.class, ANNOTATOR_KEY, PentahoSessionHolder.getSession());
    try {
        if (annotator != null) {
            byte[] schemaBytes = IOUtils.toByteArray(values.get(SCHEMA_XML));
            byte[] annotationBytes = IOUtils.toByteArray(values.get(ANNOTATIONS_XML));
            values.put(SCHEMA_XML, new ByteArrayInputStream(schemaBytes));
            values.put(ANNOTATIONS_XML, new ByteArrayInputStream(annotationBytes));
            values.put("schema.annotated.xml", annotator.getInputStream(new ByteArrayInputStream(schemaBytes), new ByteArrayInputStream(annotationBytes)));
        }
    } catch (IOException e) {
        throw new RepositoryException(e);
    }
    return values;
}
Also used : MondrianSchemaAnnotator(org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator) ByteArrayInputStream(java.io.ByteArrayInputStream) RepositoryException(org.pentaho.platform.api.repository.RepositoryException) IOException(java.io.IOException)

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