Search in sources :

Example 1 with ThinServiceInformation

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

the class DataServiceClient method getServiceInformation.

@Override
public List<IThinServiceInformation> getServiceInformation() throws SQLException {
    List<IThinServiceInformation> services = Lists.newArrayList();
    for (DataServiceMeta service : resolver.getDataServices(logErrors()::apply)) {
        TransMeta transMeta = service.getServiceTrans();
        try {
            transMeta.activateParameters();
            RowMetaInterface serviceFields = transMeta.getStepFields(service.getStepname());
            IThinServiceInformation serviceInformation = new ThinServiceInformation(service.getName(), service.isStreaming(), serviceFields);
            services.add(serviceInformation);
        } catch (Exception e) {
            String message = MessageFormat.format("Unable to get fields for service {0}, transformation: {1}", service.getName(), transMeta.getName());
            log.logError(message, e);
        }
    }
    return services;
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) TransMeta(org.pentaho.di.trans.TransMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) IThinServiceInformation(org.pentaho.di.trans.dataservice.jdbc.api.IThinServiceInformation) ThinServiceInformation(org.pentaho.di.trans.dataservice.jdbc.ThinServiceInformation) IThinServiceInformation(org.pentaho.di.trans.dataservice.jdbc.api.IThinServiceInformation) KettleException(org.pentaho.di.core.exception.KettleException) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Example 2 with ThinServiceInformation

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

the class DataServiceClient method getServiceInformation.

@Override
public ThinServiceInformation getServiceInformation(String name) throws SQLException {
    DataServiceMeta dataServiceMeta = resolver.getDataService(name);
    if (dataServiceMeta != null) {
        TransMeta transMeta = dataServiceMeta.getServiceTrans();
        try {
            transMeta.activateParameters();
            RowMetaInterface serviceFields = transMeta.getStepFields(dataServiceMeta.getStepname());
            return new ThinServiceInformation(dataServiceMeta.getName(), dataServiceMeta.isStreaming(), serviceFields);
        } catch (Exception e) {
            String message = MessageFormat.format("Unable to get fields for service {0}, transformation: {1}", dataServiceMeta.getName(), transMeta.getName());
            log.logError(message, e);
        }
    }
    return null;
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) TransMeta(org.pentaho.di.trans.TransMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ThinServiceInformation(org.pentaho.di.trans.dataservice.jdbc.ThinServiceInformation) IThinServiceInformation(org.pentaho.di.trans.dataservice.jdbc.api.IThinServiceInformation) KettleException(org.pentaho.di.core.exception.KettleException) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Example 3 with ThinServiceInformation

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

the class DataServiceClientTest method testGetServiceInformationByName.

@Test
public void testGetServiceInformationByName() throws Exception {
    when(transMeta.getStepFields(dataService.getStepname())).thenReturn(rowMetaInterface);
    ThinServiceInformation serviceInformation = client.getServiceInformation(DATA_SERVICE_NAME);
    verify(transMeta).activateParameters();
    assertThat(serviceInformation.getName(), equalTo(DATA_SERVICE_NAME));
    assertThat(serviceInformation.getServiceFields(), equalTo(rowMetaInterface));
}
Also used : ThinServiceInformation(org.pentaho.di.trans.dataservice.jdbc.ThinServiceInformation) Test(org.junit.Test) BaseTest(org.pentaho.di.trans.dataservice.BaseTest)

Example 4 with ThinServiceInformation

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

the class ListDataServicesServletTest method setUp.

@Before
public void setUp() throws Exception {
    servlet = new ListDataServicesServlet(client);
    servlet.setJettyMode(true);
    servlet.setup(transformationMap, null, null, null);
    when(request.getContextPath()).thenReturn(CONTEXT_PATH);
    StringWriter out = new StringWriter();
    ThinServiceInformation thinServiceInformation = new ThinServiceInformation(DATA_SERVICE_NAME, false, rowMetaInterface);
    when(response.getWriter()).thenReturn(new PrintWriter(out));
    when(rowMetaInterface.getMetaXML()).thenReturn("<rowMeta mock/>");
    when(client.getServiceInformation()).thenReturn(ImmutableList.of(thinServiceInformation));
    outputBuffer = out.getBuffer();
}
Also used : StringWriter(java.io.StringWriter) ThinServiceInformation(org.pentaho.di.trans.dataservice.jdbc.ThinServiceInformation) PrintWriter(java.io.PrintWriter) Before(org.junit.Before)

Aggregations

ThinServiceInformation (org.pentaho.di.trans.dataservice.jdbc.ThinServiceInformation)4 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 KettleException (org.pentaho.di.core.exception.KettleException)2 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)2 TransMeta (org.pentaho.di.trans.TransMeta)2 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)2 IThinServiceInformation (org.pentaho.di.trans.dataservice.jdbc.api.IThinServiceInformation)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Before (org.junit.Before)1 Test (org.junit.Test)1 BaseTest (org.pentaho.di.trans.dataservice.BaseTest)1