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;
}
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;
}
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);
}
}
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);
}
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();
}
Aggregations