Search in sources :

Example 16 with IApplicationContext

use of org.pentaho.platform.api.engine.IApplicationContext in project pentaho-platform by pentaho.

the class SessionCleanupListener method startup.

public boolean startup(IPentahoSession session) {
    IApplicationContext applicationContext = PentahoSystem.getApplicationContext();
    applicationContext.addEntryPointHandler(this);
    applicationContext.addExitPointHandler(this);
    return true;
}
Also used : IApplicationContext(org.pentaho.platform.api.engine.IApplicationContext)

Example 17 with IApplicationContext

use of org.pentaho.platform.api.engine.IApplicationContext in project pentaho-platform by pentaho.

the class PentahoReportConfiguration method lookupVariable.

@Override
protected String lookupVariable(final String property) {
    final IApplicationContext context = PentahoSystem.getApplicationContext();
    if (context != null) {
        final String contextParam = context.getProperty(property);
        if (contextParam != null) {
            return contextParam;
        }
    }
    final IParameterProvider globalParameters = PentahoSystem.getGlobalParameters();
    if (globalParameters != null) {
        final String globalParam = globalParameters.getStringParameter(property, null);
        if (globalParam != null) {
            return globalParam;
        }
    }
    final String systemSetting = PentahoSystem.getSystemSetting(property, null);
    if (systemSetting != null) {
        return systemSetting;
    }
    if (context != null) {
        if ("base-url".equals(property)) {
            // $NON-NLS-1$
            return context.getFullyQualifiedServerURL();
        }
    }
    return null;
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) IApplicationContext(org.pentaho.platform.api.engine.IApplicationContext)

Example 18 with IApplicationContext

use of org.pentaho.platform.api.engine.IApplicationContext in project data-access by pentaho.

the class SerializeServiceIT method testSerialize.

@Test
public void testSerialize() throws Exception {
    if (ModelerMessagesHolder.getMessages() == null) {
        ModelerMessagesHolder.setMessages(new SpoonModelerMessages());
    }
    try {
        KettleEnvironment.init();
        Props.init(Props.TYPE_PROPERTIES_EMPTY);
    } catch (Exception e) {
    // may already be initialized by another test
    }
    login("suzy", "", false);
    String solutionStorage = AgileHelper.getDatasourceSolutionStorage();
    String path = solutionStorage + RepositoryFile.SEPARATOR + "resources" + RepositoryFile.SEPARATOR + "metadata" + // $NON-NLS-1$  //$NON-NLS-2$
    RepositoryFile.SEPARATOR;
    String olapPath = null;
    IApplicationContext appContext = PentahoSystem.getApplicationContext();
    if (appContext != null) {
        path = PentahoSystem.getApplicationContext().getSolutionPath(path);
        olapPath = PentahoSystem.getApplicationContext().getSolutionPath(// $NON-NLS-1$  //$NON-NLS-2$
        "system" + RepositoryFile.SEPARATOR + "olap" + RepositoryFile.SEPARATOR);
    }
    // $NON-NLS-1$
    File olap1 = new File(olapPath + "datasources.xml");
    // $NON-NLS-1$
    File olap2 = new File(olapPath + "tmp_datasources.xml");
    FileUtils.copyFile(olap1, olap2);
    Domain domain = generateModel();
    ModelerService service = new ModelerService();
    ModelerWorkspace model = new ModelerWorkspace(new GwtModelerWorkspaceHelper());
    model.setModelName("ORDERS");
    model.setDomain(domain);
    model.getWorkspaceHelper().populateDomain(model);
    // $NON-NLS-1$
    service.serializeModels(domain, "test_file");
    Assert.assertEquals(domain.getLogicalModels().get(1).getProperty("MondrianCatalogRef"), model.getModelName());
}
Also used : GwtModelerWorkspaceHelper(org.pentaho.agilebi.modeler.gwt.GwtModelerWorkspaceHelper) SpoonModelerMessages(org.pentaho.agilebi.modeler.util.SpoonModelerMessages) Matchers.anyString(org.mockito.Matchers.anyString) IApplicationContext(org.pentaho.platform.api.engine.IApplicationContext) Domain(org.pentaho.metadata.model.Domain) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) File(java.io.File) ModelerService(org.pentaho.platform.dataaccess.datasource.wizard.service.impl.ModelerService) UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) DatasourceMgmtServiceException(org.pentaho.platform.api.repository.datasource.DatasourceMgmtServiceException) DataAccessException(org.springframework.dao.DataAccessException) DuplicateDatasourceException(org.pentaho.platform.api.repository.datasource.DuplicateDatasourceException) NonExistingDatasourceException(org.pentaho.platform.api.repository.datasource.NonExistingDatasourceException) ModelerWorkspace(org.pentaho.agilebi.modeler.ModelerWorkspace) Test(org.junit.Test)

Example 19 with IApplicationContext

use of org.pentaho.platform.api.engine.IApplicationContext in project data-access by pentaho.

the class CsvTransformGeneratorIT method init.

private void init() {
    if (!PentahoSystem.getInitializedOK()) {
        // $NON-NLS-1$
        IApplicationContext context = new StandaloneApplicationContext(SOLUTION_PATH, ".");
        PentahoSystem.init(context);
    }
}
Also used : IApplicationContext(org.pentaho.platform.api.engine.IApplicationContext) StandaloneApplicationContext(org.pentaho.platform.engine.core.system.StandaloneApplicationContext)

Example 20 with IApplicationContext

use of org.pentaho.platform.api.engine.IApplicationContext in project data-access by pentaho.

the class AgileHelperTest method setUp.

@Before
public void setUp() throws SQLException, ObjectFactoryException {
    Connection connection = mock(Connection.class);
    DataSource dataSource = mock(DataSource.class);
    when(dataSource.getConnection()).thenReturn(connection);
    final ICacheManager manager = mock(ICacheManager.class);
    when(manager.cacheEnabled(anyString())).thenReturn(true);
    when(manager.getFromRegionCache(anyString(), any())).thenReturn(dataSource);
    pentahoObjectFactory = mock(IPentahoObjectFactory.class);
    when(pentahoObjectFactory.objectDefined(anyString())).thenReturn(true);
    when(pentahoObjectFactory.get(this.anyClass(), anyString(), any(IPentahoSession.class))).thenAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return manager;
        }
    });
    PentahoSystem.registerObjectFactory(pentahoObjectFactory);
    IApplicationContext context = mock(IApplicationContext.class);
    when(context.getSolutionPath(anyString())).thenAnswer(new Answer<String>() {

        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            return (String) invocation.getArguments()[0];
        }
    });
    PentahoSystem.setApplicationContext(context);
}
Also used : IPentahoObjectFactory(org.pentaho.platform.api.engine.IPentahoObjectFactory) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Connection(java.sql.Connection) IApplicationContext(org.pentaho.platform.api.engine.IApplicationContext) DataSource(javax.sql.DataSource) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ICacheManager(org.pentaho.platform.api.engine.ICacheManager) Before(org.junit.Before)

Aggregations

IApplicationContext (org.pentaho.platform.api.engine.IApplicationContext)20 File (java.io.File)9 IOException (java.io.IOException)5 Before (org.junit.Before)5 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 Matchers.anyString (org.mockito.Matchers.anyString)3 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)3 OutputStream (java.io.OutputStream)2 IPentahoRequestContext (org.pentaho.platform.api.engine.IPentahoRequestContext)2 StandaloneApplicationContext (org.pentaho.platform.engine.core.system.StandaloneApplicationContext)2 PentahoEntityResolver (org.pentaho.platform.engine.services.solution.PentahoEntityResolver)2 PentahoURLRewriter (org.pentaho.platform.plugin.action.jfreereport.helper.PentahoURLRewriter)2 ReportProcessingException (org.pentaho.reporting.engine.classic.core.ReportProcessingException)2 YieldReportListener (org.pentaho.reporting.engine.classic.core.layout.output.YieldReportListener)2 StreamReportProcessor (org.pentaho.reporting.engine.classic.core.modules.output.table.base.StreamReportProcessor)2 AllItemsHtmlPrinter (org.pentaho.reporting.engine.classic.core.modules.output.table.html.AllItemsHtmlPrinter)2 HtmlOutputProcessor (org.pentaho.reporting.engine.classic.core.modules.output.table.html.HtmlOutputProcessor)2