use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.
the class DatasourceAdminDialogController method edit.
@Bindable
public void edit() {
IDatasourceInfo dsInfo = datasourceAdminDialogModel.getSelectedDatasource();
if (dsInfo == null) {
showErrorDialog("datasourceAdminErrorDialog.SELECT_DATASOURCE", "datasourceAdminErrorDialog.SELECT_DATASOURCE_EDIT");
return;
}
String type = dsInfo.getType();
final String dsId = dsInfo.getId();
if (DSWUIDatasourceService.TYPE.equals(type)) {
dswService.getLogicalModels(dsId, new XulServiceCallback<List<LogicalModelSummary>>() {
@Override
public void success(List<LogicalModelSummary> retVal) {
for (LogicalModelSummary logicalModelSummary : retVal) {
if (!dsId.equals(logicalModelSummary.getDomainId())) {
continue;
}
entryPoint.showWizardEdit(logicalModelSummary.getDomainId(), logicalModelSummary.getModelId(), false, new DialogListener<Domain>() {
@Override
public void onDialogAccept(Domain returnValue) {
// TODO Auto-generated method stub
}
@Override
public void onDialogCancel() {
// TODO Auto-generated method stub
}
@Override
public void onDialogReady() {
// TODO Auto-generated method stub
}
@Override
public void onDialogError(String errorMessage) {
// TODO Auto-generated method stub
}
});
}
}
@Override
public void error(String message, Throwable error) {
// TODO Auto-generated method stub
}
});
} else if (JdbcDatasourceService.TYPE.equals(type)) {
entryPoint.showEditDatabaseDialog(adminDatasourceListener, dsId);
} else if (MondrianUIDatasourceService.TYPE.equals(type)) {
IDatasourceInfo datasourceInfo = datasourceAdminDialogModel.getSelectedDatasource();
entryPoint.showEditAnalysisDialog(adminDatasourceListener, datasourceInfo);
} else if (MetadataUIDatasourceService.TYPE.equals(type)) {
showErrorDialog("datasourceAdminErrorDialog.CANNOT_EDIT_HEADER", "datasourceAdminErrorDialog.CANNOT_EDIT_TEXT");
return;
}
}
use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.
the class DatasourceSelectionDialogController method removeDatasourceConfirm.
@Bindable
public void removeDatasourceConfirm() {
if (messageBundle != null) {
XulLabel removeDatasourceConfirmationDialogLabel = (XulLabel) removeDatasourceConfirmationDialog.getElementById("removeDatasourceConfirmationDialogLabel");
LogicalModelSummary logicalModelSummary = getDialogResult();
if (removeDatasourceConfirmationDialogLabel != null && logicalModelSummary != null) {
removeDatasourceConfirmationDialogLabel.setValue(messageBundle.getString(REMOVE_DS_MSG_ID, logicalModelSummary.getModelName()));
}
}
removeDatasourceConfirmationDialog.show();
}
use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.
the class DatasourceSelectionDialogController method internalInit.
private void internalInit() {
try {
// $NON-NLS-1$
datasourceListbox = (XulListbox) safeGetElementById(document, "datasourceListbox");
// $NON-NLS-1$
datasourceSelectionDialog = (XulDialog) safeGetElementById(document, "datasourceSelectionDialog");
removeDatasourceConfirmationDialog = (XulDialog) safeGetElementById(document, // $NON-NLS-1$
"removeDatasourceConfirmationDialog");
XulButton acceptButton = null;
try {
// $NON-NLS-1$
acceptButton = (XulButton) safeGetElementById(document, "datasourceSelectionDialog_accept");
} catch (Exception e) {
// this might not be available
}
// $NON-NLS-1$
addDatasourceButton = (XulButton) safeGetElementById(document, "addDatasource");
// $NON-NLS-1$
editDatasourceButton = (XulButton) safeGetElementById(document, "editDatasource");
// $NON-NLS-1$
removeDatasourceButton = (XulButton) safeGetElementById(document, "removeDatasource");
manager = UIDatasourceServiceManager.getInstance();
manager.getIds(new XulServiceCallback<List<IDatasourceInfo>>() {
@Override
public void success(List<IDatasourceInfo> infoList) {
DatasourceSelectionDialogController.this.datasourceInfos = infoList;
}
@Override
public void error(String message, Throwable error) {
}
});
bf.setBindingType(Binding.Type.ONE_WAY);
bf.createBinding(DatasourceSelectionDialogController.this.datasourceSelectionDialogModel, "logicalModelSummaries", datasourceListbox, // $NON-NLS-1$ //$NON-NLS-2$
"elements");
bf.setBindingType(Binding.Type.ONE_WAY);
// $NON-NLS-1$
bf.createBinding(// $NON-NLS-1$
datasourceListbox, // $NON-NLS-1$
"selectedIndex", DatasourceSelectionDialogController.this.datasourceSelectionDialogModel, // $NON-NLS-1$
"selectedIndex");
// setup binding to disable accept button until user selects a datasource
bf.setBindingType(Binding.Type.ONE_WAY);
if (acceptButton != null) {
BindingConvertor<Integer, Boolean> acceptButtonConvertor = new BindingConvertor<Integer, Boolean>() {
@Override
public Boolean sourceToTarget(final Integer value) {
return value > -1;
}
@Override
public Integer targetToSource(final Boolean value) {
throw new UnsupportedOperationException();
}
};
bf.createBinding(DatasourceSelectionDialogController.this.datasourceSelectionDialogModel, "selectedIndex", // $NON-NLS-1$
acceptButton, "!disabled", // $NON-NLS-1$
acceptButtonConvertor);
}
// setup binding to disable remove datasource button until user selects a datasource
bf.setBindingType(Binding.Type.ONE_WAY);
BindingConvertor<Integer, Boolean> removeDatasourceButtonConvertor = new BindingConvertor<Integer, Boolean>() {
@Override
public Boolean sourceToTarget(final Integer value) {
boolean active = false;
if (value > -1) {
LogicalModelSummary summary = (LogicalModelSummary) datasourceListbox.getSelectedItem();
if (datasourceInfos.size() > 0) {
for (int i = 0; i < datasourceInfos.size(); i++) {
IDatasourceInfo datasourceInfo = datasourceInfos.get(i);
if (datasourceInfo.getId().equals(summary.getDomainId())) {
active = datasourceInfo.isEditable();
break;
}
}
}
}
return active && administrator;
}
@Override
public Integer targetToSource(final Boolean value) {
throw new UnsupportedOperationException();
}
};
removeDatasourceButtonBinding = bf.createBinding(DatasourceSelectionDialogController.this.datasourceSelectionDialogModel, "selectedIndex", // $NON-NLS-1$
removeDatasourceButton, "!disabled", // $NON-NLS-1$
removeDatasourceButtonConvertor);
BindingConvertor<Integer, Boolean> editDatasourceButtonConvertor = new BindingConvertor<Integer, Boolean>() {
@Override
public Boolean sourceToTarget(final Integer value) {
boolean active = false;
if (value > -1) {
LogicalModelSummary summary = (LogicalModelSummary) datasourceListbox.getSelectedItem();
if (datasourceInfos.size() > 0) {
for (int i = 0; i < datasourceInfos.size(); i++) {
IDatasourceInfo datasourceInfo = datasourceInfos.get(i);
if (datasourceInfo.getId().equals(summary.getDomainId())) {
active = datasourceInfo.isEditable();
break;
}
}
}
}
return active && administrator;
}
@Override
public Integer targetToSource(final Boolean value) {
throw new UnsupportedOperationException();
}
};
editDatasourceButtonBinding = bf.createBinding(DatasourceSelectionDialogController.this.datasourceSelectionDialogModel, "selectedIndex", // $NON-NLS-1$
editDatasourceButton, "!disabled", // $NON-NLS-1$
editDatasourceButtonConvertor);
datasourceListbox.setSelectedIndex(-1);
// workaround for bug in some XulListbox implementations (doesn't fire event on setSelectedIndex call)
DatasourceSelectionDialogController.this.datasourceSelectionDialogModel.setSelectedIndex(-1);
} catch (Exception e) {
e.printStackTrace();
// $NON-NLS-1$
showMessagebox("Error", e.getLocalizedMessage());
}
}
use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.
the class DataSourceWizardServiceTest method testGetDSWDatasourceIds.
@Test
public void testGetDSWDatasourceIds() throws Exception {
Domain mockDomain = mock(Domain.class);
LogicalModelSummary mockLogicalModelSummary = mock(LogicalModelSummary.class);
List<LogicalModelSummary> mockLogicalModelSummaryList = new ArrayList<LogicalModelSummary>();
mockLogicalModelSummaryList.add(mockLogicalModelSummary);
List<LogicalModel> mockLogicalModelList = new ArrayList<LogicalModel>();
LogicalModel mockLogicalModel = mock(LogicalModel.class);
mockLogicalModelList.add(mockLogicalModel);
Object mockObject = mock(Object.class);
List<String> datasourceList = new ArrayList<String>();
datasourceList.add(mockLogicalModelSummary.getDomainId());
doReturn(mockLogicalModelSummaryList).when(dataSourceWizardService.dswService).getLogicalModels(null);
doReturn(mockDomain).when(dataSourceWizardService.modelerService).loadDomain(anyString());
doReturn(mockLogicalModelList).when(mockDomain).getLogicalModels();
doReturn(mockObject).when(mockLogicalModel).getProperty("AGILE_BI_GENERATED_SCHEMA");
List<String> response = dataSourceWizardService.getDSWDatasourceIds();
assertEquals(datasourceList, response);
verify(dataSourceWizardService, times(1)).getDSWDatasourceIds();
}
Aggregations