Search in sources :

Example 1 with PushDownOptimizationMeta

use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta in project pdi-dataservice-server-plugin by pentaho.

the class ParameterGenerationController method runAutoGenerate.

public void runAutoGenerate() throws XulException {
    DataServiceModel dialogModel = model.getDialogModel();
    try {
        AutoOptimizationService autoOptimizationService = factory.createAutoOptimizationService();
        Collection<PushDownOptimizationMeta> found = autoOptimizationService.apply(dialogModel.getDataService());
        if (dialogModel.addAll(found)) {
            model.updateParameterMap();
        }
        info(getString(PKG, "ParameterGenerationController.AutoGen.Title"), getString(PKG, "ParameterGenerationController.AutoGen.Message", found.size()));
    } catch (Exception e) {
        String message = getString(PKG, "ParameterGenerationController.AutoGen.Error");
        getLogChannel().logError(message, e);
        error(getString(PKG, "ParameterGenerationController.AutoGen.Title"), message);
    }
}
Also used : DataServiceModel(org.pentaho.di.trans.dataservice.ui.model.DataServiceModel) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) AutoOptimizationService(org.pentaho.di.trans.dataservice.optimization.AutoOptimizationService) BaseMessages.getString(org.pentaho.di.i18n.BaseMessages.getString) XulException(org.pentaho.ui.xul.XulException)

Example 2 with PushDownOptimizationMeta

use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta in project pdi-dataservice-server-plugin by pentaho.

the class ParameterGenerationController method addParameter.

public void addParameter() throws XulException {
    PushDownOptimizationMeta meta = new PushDownOptimizationMeta();
    ParameterGeneration parameterGeneration = factory.createPushDown();
    meta.setType(parameterGeneration);
    meta.setStepName(getStepMenuList().getSelectedItem());
    XulPromptBox promptBox = createPromptBox();
    promptBox.setTitle(getString(PKG, "ParameterGenerationController.Create.Title"));
    promptBox.setMessage(getString(PKG, "ParameterGenerationController.Create.Message"));
    ParameterEditor editor = new ParameterEditor(parameterGeneration);
    promptBox.addDialogCallback(editor);
    if (promptBox.open() == 0 && editor.modified) {
        model.add(meta);
        model.setSelectedParameter(parameterGeneration.getParameterName());
    }
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) XulPromptBox(org.pentaho.ui.xul.components.XulPromptBox) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)

Example 3 with PushDownOptimizationMeta

use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta in project pdi-dataservice-server-plugin by pentaho.

the class ParameterGenerationModel method setEnabled.

public void setEnabled(boolean enabled) {
    PushDownOptimizationMeta meta = getSelectedOptimization();
    if (meta != null) {
        boolean previous = meta.isEnabled();
        meta.setEnabled(enabled);
        firePropertyChange("enabled", previous, enabled);
    }
}
Also used : PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)

Example 4 with PushDownOptimizationMeta

use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta in project pdi-dataservice-server-plugin by pentaho.

the class ServiceCacheController method initBindings.

public void initBindings(DataServiceModel model) {
    PushDownOptimizationMeta meta = locateServiceCacheMeta(model);
    ServiceCache serviceCache = (ServiceCache) meta.getType();
    BindingFactory bindingFactory = getBindingFactory();
    XulRadio normalModeRadio = getElementById("regular-type-radio");
    XulTab serviceCacheTab = getElementById("service-cache-tab");
    XulCheckbox serviceCacheCheckBox = getElementById("service-cache-checkbox");
    XulTextbox serviceCacheTextBox = getElementById("service-cache-ttl");
    bindingFactory.setBindingType(Binding.Type.ONE_WAY);
    serviceCacheCheckBox.setChecked(meta.isEnabled());
    serviceCacheTab.setVisible(!model.isStreaming());
    try {
        serviceCacheTextBox.setValue(serviceCache.getConfiguredTimeToLive());
    } catch (Exception e) {
        getLogChannel().logError("Unable to set default TTL", e);
    }
    bindingFactory.createBinding(serviceCacheTextBox, "value", serviceCache, "timeToLive");
    bindingFactory.createBinding(serviceCacheCheckBox, "checked", meta, "enabled");
    bindingFactory.createBinding(serviceCacheCheckBox, "checked", serviceCacheTextBox, "disabled", not());
    bindingFactory.createBinding(normalModeRadio, "selected", serviceCacheTab, "visible");
}
Also used : XulCheckbox(org.pentaho.ui.xul.components.XulCheckbox) XulRadio(org.pentaho.ui.xul.components.XulRadio) ServiceCache(org.pentaho.di.trans.dataservice.optimization.cache.ServiceCache) XulTextbox(org.pentaho.ui.xul.components.XulTextbox) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) XulTab(org.pentaho.ui.xul.components.XulTab) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory)

Example 5 with PushDownOptimizationMeta

use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta in project pdi-dataservice-server-plugin by pentaho.

the class ServiceCacheController method locateServiceCacheMeta.

/**
 * Locate or create a pushdown optimization for service cache. Only one should exist, others will be removed if found.
 *
 * @param model Data Service model to update
 * @return The ONLY Optimization Meta with a Service Cache type
 */
protected PushDownOptimizationMeta locateServiceCacheMeta(DataServiceModel model) {
    List<PushDownOptimizationMeta> cacheOptimizations = model.getPushDownOptimizations(factory.getType());
    PushDownOptimizationMeta meta;
    if (cacheOptimizations.isEmpty()) {
        meta = new PushDownOptimizationMeta();
        meta.setStepName(model.getServiceStep());
        meta.setType(factory.createPushDown());
        model.add(meta);
    } else {
        meta = cacheOptimizations.get(0);
    }
    if (cacheOptimizations.size() > 1) {
        model.removeAll(cacheOptimizations.subList(1, cacheOptimizations.size()));
    }
    return meta;
}
Also used : PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)

Aggregations

PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)41 Test (org.junit.Test)23 ParameterGeneration (org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration)10 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)8 SQL (org.pentaho.di.core.sql.SQL)7 IMetaStore (org.pentaho.metastore.api.IMetaStore)7 Matchers.anyString (org.mockito.Matchers.anyString)5 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 DataOutputStream (java.io.DataOutputStream)3 Set (java.util.Set)3 RowProducer (org.pentaho.di.trans.RowProducer)3 PushDownType (org.pentaho.di.trans.dataservice.optimization.PushDownType)3 DataServiceModel (org.pentaho.di.trans.dataservice.ui.model.DataServiceModel)3 XulException (org.pentaho.ui.xul.XulException)3 Shell (org.eclipse.swt.widgets.Shell)2 Before (org.junit.Before)2 InOrder (org.mockito.InOrder)2 KettleException (org.pentaho.di.core.exception.KettleException)2