use of org.pentaho.agilebi.modeler.geo.GeoContext in project data-access by pentaho.
the class MultitableDatasourceService method serializeJoins.
public IDatasourceSummary serializeJoins(MultiTableDatasourceDTO dto, IDatabaseConnection connection) throws DatasourceServiceException {
try {
ModelerService modelerService = new ModelerService();
modelerService.initKettle();
DSWDatasourceServiceImpl datasourceService = new DSWDatasourceServiceImpl();
GeoContext geoContext = datasourceService.getGeoContext();
DatabaseMeta databaseMeta = this.getDatabaseMeta(connection);
MultiTableModelerSource multiTable = new MultiTableModelerSource(databaseMeta, dto.getSchemaModel(), dto.getDatasourceName(), dto.getSelectedTables(), geoContext);
Domain domain = multiTable.generateDomain(dto.isDoOlap());
String modelState = serializeModelState(dto);
for (LogicalModel lm : domain.getLogicalModels()) {
lm.setProperty("datasourceModel", modelState);
lm.setProperty("DatasourceType", "MULTI-TABLE-DS");
// BISERVER-6450 - add security settings to the logical model
applySecurity(lm);
}
modelerService.serializeModels(domain, dto.getDatasourceName(), dto.isDoOlap());
QueryDatasourceSummary summary = new QueryDatasourceSummary();
summary.setDomain(domain);
return summary;
} catch (Exception e) {
logger.error("Error serializing joins", e);
throw new DatasourceServiceException(e);
}
}
use of org.pentaho.agilebi.modeler.geo.GeoContext in project data-access by pentaho.
the class DatasourceServiceHelperTest method testGetGeoContext.
@Test
public void testGetGeoContext() throws Exception {
try {
KettleEnvironment.init();
Props.init(Props.TYPE_PROPERTIES_EMPTY);
} catch (Exception e) {
// may already be initialized by another test
}
GeoContext geo = DatasourceServiceHelper.getGeoContext();
assertEquals("Geography", geo.getDimensionName());
assertEquals(6, geo.size());
assertNotNull(geo.getLocationRole());
// make sure they are in the same order as entered in the props file
String rolesCsv = "continent, country, state, city, postal_code";
String[] tokens = rolesCsv.split(",");
for (int i = 0; i < tokens.length; i++) {
assertEquals(tokens[i].trim(), geo.getGeoRole(i).getName());
}
}
use of org.pentaho.agilebi.modeler.geo.GeoContext in project data-access by pentaho.
the class ModelerDialog method xulLoaded.
public void xulLoaded(GwtXulRunner gwtXulRunner) {
container = gwtXulRunner.getXulDomContainers().get(0);
container.addEventHandler(this);
BogoPojo bogo = new BogoPojo();
service.gwtWorkaround(bogo, new XulServiceCallback<BogoPojo>() {
public void success(BogoPojo retVal) {
}
public void error(String message, Throwable error) {
}
});
datasourceService = new DSWDatasourceServiceGwtImpl();
// connectionService = new ConnectionServiceGwtImpl();
csvService = (ICsvDatasourceServiceAsync) GWT.create(ICsvDatasourceService.class);
if (wizard == null) {
wizard = new EmbeddedWizard(false);
wizard.setDatasourceService(datasourceService);
// wizard.setConnectionService(connectionService);
wizard.setCsvDatasourceService(csvService);
wizard.init(null);
}
messages = new GwtModelerMessages((ResourceBundle) container.getResourceBundles().get(0));
try {
ModelerMessagesHolder.setMessages(messages);
} catch (Exception ignored) {
// Messages may have been set earlier, ignore.
}
IModelerWorkspaceHelper workspacehelper = model.getWorkspaceHelper();
controller = new ModelerController(model);
controller.setWorkspaceHelper(workspacehelper);
// controller.setMessages(messages);
final BindingFactory bf = new GwtBindingFactory(container.getDocumentRoot());
controller.setBindingFactory(bf);
container.addEventHandler(controller);
try {
controller.init();
} catch (ModelerException e) {
e.printStackTrace();
}
bf.setBindingType(Binding.Type.ONE_WAY);
bf.createBinding(model, "valid", "modeler_dialog_accept", "disabled", new BindingConvertor<Boolean, Boolean>() {
@Override
public Boolean sourceToTarget(Boolean value) {
return !value;
}
@Override
public Boolean targetToSource(Boolean value) {
return !value;
}
});
bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
// go get the geocontext from the server. Prop forms are initialized after this call returns as they
// may need them to create the UI
datasourceService.getGeoContext(new XulServiceCallback<GeoContext>() {
public void success(GeoContext geoContext) {
model.setGeoContext(geoContext);
ModelerUiHelper.configureControllers(container, model, bf, controller, new ColResolverController());
ModelerDialog.this.constructorListener.asyncConstructorDone(ModelerDialog.this);
}
public void error(String s, Throwable throwable) {
throwable.printStackTrace();
// put in a stub to ensure the rest of the dialog works
model.setGeoContext(new GeoContext());
ModelerUiHelper.configureControllers(container, model, bf, controller, new ColResolverController());
ModelerDialog.this.constructorListener.asyncConstructorDone(ModelerDialog.this);
}
});
}
use of org.pentaho.agilebi.modeler.geo.GeoContext in project data-access by pentaho.
the class DataAccessServiceTestBase method setUp.
@Before
public void setUp() throws Exception {
platform = new MicroPlatform();
metadataRepository = mock(IMetadataDomainRepository.class);
platform.defineInstance(IMetadataDomainRepository.class, metadataRepository);
importer = mock(IPlatformImporter.class);
platform.defineInstance(IPlatformImporter.class, importer);
policy = mock(IAuthorizationPolicy.class);
platform.defineInstance(IAuthorizationPolicy.class, policy);
catalogService = mock(IAclAwareMondrianCatalogService.class);
platform.defineInstance(IMondrianCatalogService.class, catalogService);
permissionHandler = mock(IDataAccessPermissionHandler.class);
platform.defineInstance(IDataAccessPermissionHandler.class, permissionHandler);
userRoleListService = mock(IUserRoleListService.class);
platform.defineInstance(IUserRoleListService.class, userRoleListService);
pluginResourceLoader = mock(IPluginResourceLoader.class);
platform.defineInstance(IPluginResourceLoader.class, pluginResourceLoader);
mondrianCatalogService = mock(IMondrianCatalogService.class);
platform.defineInstance(IMondrianCatalogService.class, mondrianCatalogService);
final IUnifiedRepository unifiedRepository = new FileSystemBackedUnifiedRepository("target/test-classes/solution1");
platform.defineInstance(IUnifiedRepository.class, unifiedRepository);
platform.defineInstance(String.class, "admin");
config = new GeoContextPropertiesProvider(getGeoProps());
GeoContext geo = GeoContextFactory.create(config);
platform.start();
acl.setOwner("owner");
acl.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
modelerService = new ModelerService();
datasourceService = mock(DSWDatasourceServiceImpl.class);
when(datasourceService.getGeoContext()).thenReturn(geo);
modelerService.setDatasourceService(datasourceService);
domain = getDomain();
}
use of org.pentaho.agilebi.modeler.geo.GeoContext in project data-access by pentaho.
the class InMemoryDSWDatasourceServiceImpl method getGeoContext.
public GeoContext getGeoContext() throws DatasourceServiceException {
try {
Properties props = new Properties();
props.load(new FileInputStream(new File("target/test-classes/geoContextSample.properties")));
GeoContext geo = GeoContextFactory.create(new GeoContextPropertiesProvider(props));
return geo;
} catch (ModelerException e) {
throw new DatasourceServiceException(e);
} catch (FileNotFoundException e) {
throw new DatasourceServiceException(e);
} catch (IOException e) {
// To change body of catch statement use File | Settings | File Templates.
e.printStackTrace();
}
return null;
}
Aggregations