Search in sources :

Example 66 with DataNode

use of org.pentaho.platform.api.repository2.unified.data.node.DataNode in project pentaho-platform by pentaho.

the class MondrianCatalogHelper method appendCatalogsSection.

@VisibleForTesting
protected void appendCatalogsSection(IUnifiedRepository unifiedRepository, String etcMondrian, RepositoryFile etcMondrianFolder, StringBuffer datasourcesXML) {
    // $NON-NLS-1$
    datasourcesXML.append("<Catalogs>\n");
    // Creates <Catalogs> from the "/etc/mondrian/<catalog>/metadata" nodes.
    /*
       * IPentahoSession pentahoSession = PentahoSessionHolder.getSession(); String tenantEtcFolder = null;
       * if(pentahoSession != null) { String tenantId = (String)
       * pentahoSession.getAttribute(IPentahoSession.TENANT_ID_KEY); tenantEtcFolder =
       * ServerRepositoryPaths.getTenantEtcFolderPath(tenantId); } else { tenantEtcFolder =
       * ServerRepositoryPaths.getTenantEtcFolderPath(); }
       */
    List<RepositoryFile> mondrianCatalogs = unifiedRepository.getChildren(etcMondrianFolder.getId());
    for (RepositoryFile catalog : mondrianCatalogs) {
        String catalogName = catalog.getName();
        RepositoryFile metadata = unifiedRepository.getFile(etcMondrian + RepositoryFile.SEPARATOR + catalogName + RepositoryFile.SEPARATOR + // $NON-NLS-1$
        "metadata");
        if (metadata != null) {
            DataNode metadataNode = unifiedRepository.getDataForRead(metadata.getId(), NodeRepositoryFileData.class).getNode();
            // $NON-NLS-1$
            String datasourceInfo = metadataNode.getProperty("datasourceInfo").getString();
            // $NON-NLS-1$
            String definition = metadataNode.getProperty("definition").getString();
            datasourcesXML.append(// $NON-NLS-1$ //$NON-NLS-2$
            "<Catalog name=\"" + Encode.forXml(catalogName) + "\">\n");
            datasourcesXML.append("<DataSourceInfo>" + Encode.forXml(datasourceInfo) + // $NON-NLS-1$
            "</DataSourceInfo>\n");
            datasourcesXML.append(// $NON-NLS-1$ //$NON-NLS-2$
            "<Definition>" + Encode.forXml(definition) + "</Definition>\n");
            // $NON-NLS-1$
            datasourcesXML.append("</Catalog>\n");
        } else {
            logger.warn(// $NON-NLS-1$
            Messages.getInstance().getString("MondrianCatalogHelper.WARN_META_DATA_IS_NULL"));
        }
    }
    // $NON-NLS-1$
    datasourcesXML.append("</Catalogs>\n");
}
Also used : DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

DataNode (org.pentaho.platform.api.repository2.unified.data.node.DataNode)63 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)22 Test (org.junit.Test)17 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)17 DataProperty (org.pentaho.platform.api.repository2.unified.data.node.DataProperty)15 DataNodeRef (org.pentaho.platform.api.repository2.unified.data.node.DataNodeRef)11 Matchers.anyString (org.mockito.Matchers.anyString)7 Date (java.util.Date)6 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)6 ArrayList (java.util.ArrayList)5 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)5 ITenant (org.pentaho.platform.api.mt.ITenant)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 NotePadMeta (org.pentaho.di.core.NotePadMeta)4 KettleException (org.pentaho.di.core.exception.KettleException)4 JobMeta (org.pentaho.di.job.JobMeta)4 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)4 StringObjectId (org.pentaho.di.repository.StringObjectId)4 Properties (java.util.Properties)3