Search in sources :

Example 36 with DataServiceMeta

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

the class EmbeddedMetaStoreFactory method getElements.

@Override
public List<DataServiceMeta> getElements() throws MetaStoreException {
    List<DataServiceMeta> elements = super.getElements();
    for (DataServiceMeta dataServiceMeta : elements) {
        dataServiceMeta.setServiceTrans(transMeta);
        saveToCache(dataServiceMeta);
    }
    return elements;
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta)

Example 37 with DataServiceMeta

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

the class EmbeddedMetaStoreFactory method loadElement.

@Override
public DataServiceMeta loadElement(String name) throws MetaStoreException {
    DataServiceMeta dataServiceMeta = super.loadElement(name);
    if (dataServiceMeta != null) {
        dataServiceMeta.setServiceTrans(transMeta);
        saveToCache(dataServiceMeta);
    }
    return dataServiceMeta;
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta)

Example 38 with DataServiceMeta

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

the class SynchronizationListener method onStepChange.

@Override
public void onStepChange(TransMeta transMeta, StepMeta oldMeta, StepMeta newMeta) {
    if (Objects.equal(oldMeta.getName(), newMeta.getName())) {
        return;
    }
    try {
        DataServiceMeta dataService = delegate.getDataServiceByStepName(transMeta, oldMeta.getName());
        if (dataService != null) {
            dataService.setStepname(newMeta.getName());
            delegate.save(dataService);
        }
    } catch (MetaStoreException e) {
        delegate.getLogChannel().logError(e.getMessage(), e);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta)

Example 39 with DataServiceMeta

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

the class ServiceCacheTest method setUp.

@Before
public void setUp() throws Exception {
    rowMeta = new RowMeta();
    rowMeta.addValueMeta(new ValueMetaString("ID"));
    rowMeta.addValueMeta(new ValueMetaInteger("A"));
    rowMeta.addValueMeta(new ValueMetaInteger("B"));
    when(factory.getCache("MOCK_SERVICE")).thenReturn(Optional.of(cache));
    when(factory.getCache(serviceCache, "MOCK_SERVICE")).thenReturn(cache);
    serviceStep = serviceTrans.findRunThread(SERVICE_STEP);
    TransMeta transMeta = serviceTrans.getTransMeta();
    dataServiceMeta = new DataServiceMeta(transMeta);
    dataServiceMeta.setName("MOCK_SERVICE");
    dataServiceMeta.setStepname(SERVICE_STEP);
    when(transMeta.getXML(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean())).thenReturn("<transformation/>");
    when(transMeta.getStepFields(SERVICE_STEP)).thenReturn(rowMeta);
    when(factory.getExecutorService()).thenReturn(MoreExecutors.sameThreadExecutor());
    serviceCacheOpt = when(mock(PushDownOptimizationMeta.class).getType()).thenReturn(mock(ServiceCache.class)).getMock();
    otherOpt = when(mock(PushDownOptimizationMeta.class).getType()).thenReturn(mock(PushDownType.class)).getMock();
    dataServiceMeta.setPushDownOptimizationMeta(ImmutableList.of(serviceCacheOpt, otherOpt));
    when(cache.getConfiguration(CompleteConfiguration.class)).thenReturn(config);
    when(config.getExpiryPolicyFactory()).thenReturn(expiryFactory);
    when(expiryFactory.create()).thenReturn(expiryPolicy);
    when(expiryPolicy.getExpiryForAccess()).thenReturn(duration);
    when(duration.getDurationAmount()).thenReturn(DEFAULT_TTL);
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) TransMeta(org.pentaho.di.trans.TransMeta) PushDownType(org.pentaho.di.trans.dataservice.optimization.PushDownType) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) Before(org.junit.Before)

Example 40 with DataServiceMeta

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

the class ParameterGenerationTest method testInit.

@Test
public void testInit() throws DuplicateParamException {
    DataServiceMeta dataService = mock(DataServiceMeta.class);
    PushDownOptimizationMeta pdo = new PushDownOptimizationMeta();
    pdo.setName(OPT_NAME);
    pdo.setStepName(OPT_STEP);
    when(transMeta.findStep(OPT_STEP)).thenReturn(null, stepMeta);
    when(serviceProvider.getService(stepMeta)).thenReturn(null, service);
    // Step not found
    paramGen.init(transMeta, dataService, pdo);
    // Service not found
    paramGen.init(transMeta, dataService, pdo);
    // Okay
    paramGen.init(transMeta, dataService, pdo);
    verify(transMeta, times(2)).addParameterDefinition(eq(PARAM_NAME), eq(""), anyString());
    verify(transMeta).addParameterDefinition(eq(PARAM_NAME), eq(EXPECTED_DEFAULT), anyString());
    doThrow(DuplicateParamException.class).when(transMeta).addParameterDefinition(eq(PARAM_NAME), eq(EXPECTED_DEFAULT), anyString());
    // Exception should be silently caught
    paramGen.init(transMeta, dataService, pdo);
    verify(transMeta, atLeast(3)).activateParameters();
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) Test(org.junit.Test)

Aggregations

DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)52 Test (org.junit.Test)29 TransMeta (org.pentaho.di.trans.TransMeta)16 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)9 KettleException (org.pentaho.di.core.exception.KettleException)8 DataServiceContext (org.pentaho.di.trans.dataservice.DataServiceContext)6 DataServiceDelegate (org.pentaho.di.trans.dataservice.ui.DataServiceDelegate)6 StepMeta (org.pentaho.di.trans.step.StepMeta)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Before (org.junit.Before)4 RowMeta (org.pentaho.di.core.row.RowMeta)4 DataServiceResolver (org.pentaho.di.trans.dataservice.resolvers.DataServiceResolver)4 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)4 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)4 MetastoreLocator (org.pentaho.osgi.metastore.locator.api.MetastoreLocator)4 ModelAnnotationGroup (org.pentaho.agilebi.modeler.models.annotations.ModelAnnotationGroup)3 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)3 File (java.io.File)2 IOException (java.io.IOException)2 URL (java.net.URL)2