Search in sources :

Example 96 with IDatabaseConnection

use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.

the class TestDataSourceResource method delete.

private static void delete() {
    init();
    WebResource resource = client.resource(delete_url);
    IDatabaseConnection connection = createConnectionObject();
    String conn = (new JSONObject(connection)).toString();
    System.out.println(conn);
    try {
        Response result = resource.accept(MediaType.APPLICATION_JSON).entity(conn).post(Response.class);
        System.out.println(result);
    } catch (Exception ex) {
        System.out.println("Error in Delete");
    }
}
Also used : Response(javax.ws.rs.core.Response) JSONObject(org.json.JSONObject) WebResource(com.sun.jersey.api.client.WebResource) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection)

Example 97 with IDatabaseConnection

use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.

the class TestDataSourceResource method createConnectionObject.

private static IDatabaseConnection createConnectionObject() {
    IDatabaseConnection connection = new DatabaseConnection();
    connection.setAccessType(DatabaseAccessType.NATIVE);
    // connection.setDriverClass("org.hsqldb.jdbcDriver");
    // connection.setUrl("jdbc:hsqldb:hsql://localhost:9001/sampledata");
    connection.setUsername("pentaho_user");
    connection.setPassword("password");
    connection.setName(CONNECTION_NAME);
    return connection;
}
Also used : IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection)

Example 98 with IDatabaseConnection

use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.

the class TestDataSourceResource method getConnectionByName.

private static IDatabaseConnection getConnectionByName(String aConnecitonName) {
    ClientConfig clientConfig = new DefaultClientConfig();
    Client client = Client.create(clientConfig);
    IDatabaseConnection connection = null;
    WebResource resource = client.resource(getURL);
    try {
        connection = resource.type(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_XML).entity(aConnecitonName).get(DatabaseConnection.class);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return connection;
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) WebResource(com.sun.jersey.api.client.WebResource) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) Client(com.sun.jersey.api.client.Client)

Example 99 with IDatabaseConnection

use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.

the class TestDataSourceResource method add.

private static void add() {
    init();
    IDatabaseConnection connection = createConnectionObject();
    String conn = (new JSONObject(connection)).toString();
    System.out.println(conn);
    try {
        WebResource resource = client.resource(add_url);
        Response result = resource.accept(MediaType.APPLICATION_JSON).entity(conn).post(Response.class);
        System.out.println(result);
    } catch (Exception ex) {
        System.out.println("Error in Add");
    }
}
Also used : Response(javax.ws.rs.core.Response) JSONObject(org.json.JSONObject) WebResource(com.sun.jersey.api.client.WebResource) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection)

Aggregations

IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)99 Test (org.junit.Test)29 DatabaseConnection (org.pentaho.database.model.DatabaseConnection)29 ArrayList (java.util.ArrayList)18 Bindable (org.pentaho.ui.xul.stereotype.Bindable)15 RequestException (com.google.gwt.http.client.RequestException)14 Request (com.google.gwt.http.client.Request)13 RequestBuilder (com.google.gwt.http.client.RequestBuilder)13 RequestCallback (com.google.gwt.http.client.RequestCallback)13 Response (com.google.gwt.http.client.Response)13 ConnectionServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException)13 IDatasourceMgmtService (org.pentaho.platform.api.repository.datasource.IDatasourceMgmtService)11 DatasourceMgmtServiceException (org.pentaho.platform.api.repository.datasource.DatasourceMgmtServiceException)9 List (java.util.List)8 Response (javax.ws.rs.core.Response)8 Path (javax.ws.rs.Path)7 GET (javax.ws.rs.GET)6 Produces (javax.ws.rs.Produces)6 Facet (org.codehaus.enunciate.Facet)5 DatabaseDialectService (org.pentaho.database.service.DatabaseDialectService)5