Search in sources :

Example 6 with LogicalModelSummary

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;
    }
}
Also used : LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary) List(java.util.List) Domain(org.pentaho.metadata.model.Domain) IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 7 with LogicalModelSummary

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();
}
Also used : LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary) XulLabel(org.pentaho.ui.xul.components.XulLabel) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 8 with LogicalModelSummary

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());
    }
}
Also used : BindingConvertor(org.pentaho.ui.xul.binding.BindingConvertor) XulException(org.pentaho.ui.xul.XulException) RequestException(com.google.gwt.http.client.RequestException) LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary) XulButton(org.pentaho.ui.xul.components.XulButton) ArrayList(java.util.ArrayList) List(java.util.List) IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)

Example 9 with LogicalModelSummary

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();
}
Also used : LogicalModel(org.pentaho.metadata.model.LogicalModel) LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Domain(org.pentaho.metadata.model.Domain) Test(org.junit.Test)

Aggregations

LogicalModelSummary (org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary)9 ArrayList (java.util.ArrayList)5 Domain (org.pentaho.metadata.model.Domain)4 LogicalModel (org.pentaho.metadata.model.LogicalModel)3 Bindable (org.pentaho.ui.xul.stereotype.Bindable)3 List (java.util.List)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 IDatasourceInfo (org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)2 RequestException (com.google.gwt.http.client.RequestException)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 ModelerException (org.pentaho.agilebi.modeler.ModelerException)1 DomainAlreadyExistsException (org.pentaho.metadata.repository.DomainAlreadyExistsException)1 DomainIdNullException (org.pentaho.metadata.repository.DomainIdNullException)1 DomainStorageException (org.pentaho.metadata.repository.DomainStorageException)1 SQLModelGeneratorException (org.pentaho.metadata.util.SQLModelGeneratorException)1 CsvTransformGeneratorException (org.pentaho.platform.dataaccess.datasource.wizard.models.CsvTransformGeneratorException)1 ConnectionServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException)1 DatasourceServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)1