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;
}
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;
}
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());
}
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);
}
}
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);
}
Aggregations