use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.
the class DataSourceWizardServiceTest method testGetDSWDatasourceIdsError.
@Test
public void testGetDSWDatasourceIdsError() throws Exception {
LogicalModelSummary mockLogicalModelSummary = mock(LogicalModelSummary.class);
List<LogicalModelSummary> mockLogicalModelSummaryList = new ArrayList<LogicalModelSummary>();
mockLogicalModelSummaryList.add(mockLogicalModelSummary);
doReturn(mockLogicalModelSummaryList).when(dataSourceWizardService.dswService).getLogicalModels(null);
RuntimeException mockException = mock(RuntimeException.class);
doThrow(mockException).when(dataSourceWizardService.modelerService).loadDomain(anyString());
List<String> response = dataSourceWizardService.getDSWDatasourceIds();
assertEquals(null, response);
verify(dataSourceWizardService, times(1)).getDSWDatasourceIds();
}
use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.
the class DatasourceSelectionDialogController method removeDatasourceAccept.
@Bindable
public void removeDatasourceAccept() {
if (removeDatasourceButton.isDisabled()) {
return;
}
removeDatasourceButton.setDisabled(true);
LogicalModelSummary logicalModelSummary = getDialogResult();
datasourceService.deleteLogicalModel(logicalModelSummary.getDomainId(), logicalModelSummary.getModelId(), new XulServiceCallback<Boolean>() {
public void error(String message, Throwable error) {
// $NON-NLS-1$
showMessagebox("Error", error.getLocalizedMessage());
removeDatasourceButton.setDisabled(false);
}
public void success(Boolean retVal) {
refreshDatasources(null, null);
removeDatasourceConfirmationDialog.hide();
removeDatasourceButton.setDisabled(false);
}
});
}
use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.
the class DSWDatasourceServiceImpl method getLogicalModels.
public List<LogicalModelSummary> getLogicalModels(String context) throws DatasourceServiceException {
if (!hasDataAccessViewPermission()) {
// $NON-NLS-1$
logger.error(Messages.getErrorString("DatasourceServiceImpl.ERROR_0001_PERMISSION_DENIED"));
throw new DatasourceServiceException(Messages.getErrorString(// $NON-NLS-1$
"DatasourceServiceImpl.ERROR_0001_PERMISSION_DENIED"));
}
List<LogicalModelSummary> logicalModelSummaries = new ArrayList<LogicalModelSummary>();
for (String domainId : getMetadataDomainRepository().getDomainIds()) {
Domain domain;
try {
domain = getMetadataDomainRepository().getDomain(domainId);
} catch (Exception e) {
logger.error(Messages.getErrorString("DatasourceServiceImpl.ERROR_0022_UNABLE_TO_PROCESS_LOGICAL_MODEL", domainId), e);
continue;
}
String locale = LocaleHelper.getLocale().toString();
String[] locales = new String[domain.getLocales().size()];
for (int i = 0; i < domain.getLocales().size(); i++) {
locales[i] = domain.getLocales().get(i).getCode();
}
locale = LocaleHelper.getClosestLocale(locale, locales);
for (LogicalModel model : domain.getLogicalModels()) {
String vis = (String) model.getProperty(LM_PROP_VISIBLE);
if (vis != null) {
String[] visibleContexts = vis.split(",");
boolean visibleToContext = false;
for (String c : visibleContexts) {
if (StringUtils.isNotEmpty(c.trim()) && c.trim().equals(context)) {
visibleToContext = true;
break;
}
}
if (!visibleToContext) {
continue;
}
}
logicalModelSummaries.add(new LogicalModelSummary(domainId, model.getId(), model.getName(locale)));
}
}
return logicalModelSummaries;
}
use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.
the class InMemoryDSWDatasourceServiceImpl method getLogicalModels.
public List<LogicalModelSummary> getLogicalModels(String context) throws DatasourceServiceException {
List<LogicalModelSummary> logicalModelSummaries = new ArrayList<LogicalModelSummary>();
for (String domainId : getMetadataDomainRepository().getDomainIds()) {
Domain domain = getMetadataDomainRepository().getDomain(domainId);
String locale = LocaleHelper.getLocale().toString();
String[] locales = new String[domain.getLocales().size()];
for (int i = 0; i < domain.getLocales().size(); i++) {
locales[i] = domain.getLocales().get(i).getCode();
}
locale = LocaleHelper.getClosestLocale(locale, locales);
for (LogicalModel model : domain.getLogicalModels()) {
String vis = (String) model.getProperty("visible");
if (vis != null) {
String[] visibleContexts = vis.split(",");
boolean visibleToContext = false;
for (String c : visibleContexts) {
if (context.equals(c.trim())) {
visibleToContext = true;
break;
}
}
if (!visibleToContext) {
continue;
}
}
logicalModelSummaries.add(new LogicalModelSummary(domainId, model.getId(), model.getName().getString(locale)));
}
}
return logicalModelSummaries;
}
use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.
the class DSWDatasourceServiceImplTest method testGetLogicalModels_NullContext.
private void testGetLogicalModels_NullContext(String context) throws DatasourceServiceException {
doReturn(true).when(dswService).hasDataAccessPermission();
doReturn(true).when(dswService).hasDataAccessViewPermission();
List<LogicalModelSummary> models = dswService.getLogicalModels(context);
assertNotNull(models);
for (LogicalModelSummary logicalModelSummary : models) {
assertEquals(domain2Models.getId(), logicalModelSummary.getDomainId());
}
}
Aggregations