Search in sources :

Example 1 with DatasourceInfo

use of org.pentaho.platform.dataaccess.datasource.DatasourceInfo in project data-access by pentaho.

the class XMLToDatasourceInfoConverter method getDatasourceInfoList.

private List<IDatasourceInfo> getDatasourceInfoList(Element element) {
    List<IDatasourceInfo> datasourceInfoList = new ArrayList<IDatasourceInfo>();
    NodeList nodeList = element.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Element ele = (Element) nodeList.item(i);
        boolean editable = Boolean.parseBoolean(getNodeValueByTagName(ele, "editable"));
        boolean removable = Boolean.parseBoolean(getNodeValueByTagName(ele, "removable"));
        boolean importable = Boolean.parseBoolean(getNodeValueByTagName(ele, "importable"));
        boolean exportable = Boolean.parseBoolean(getNodeValueByTagName(ele, "exportable"));
        IDatasourceInfo info = new DatasourceInfo(getName(ele), getId(ele), getType(ele), editable, removable, importable, exportable);
        datasourceInfoList.add(info);
    }
    return datasourceInfoList;
}
Also used : IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo) DatasourceInfo(org.pentaho.platform.dataaccess.datasource.DatasourceInfo) NodeList(com.google.gwt.xml.client.NodeList) Element(com.google.gwt.xml.client.Element) ArrayList(java.util.ArrayList) IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)

Example 2 with DatasourceInfo

use of org.pentaho.platform.dataaccess.datasource.DatasourceInfo in project data-access by pentaho.

the class JSUIDatasourceService method getIds.

@Override
public final void getIds(XulServiceCallback<List<IDatasourceInfo>> callback) {
    List<IDatasourceInfo> datasourceInfoList = new ArrayList<IDatasourceInfo>();
    JsArray<JavaScriptObject> infos = getDelegateIds(this.datasourceServiceObject);
    for (int i = 0; i < infos.length(); i++) {
        JSDatasourceInfo info = new JSDatasourceInfo(infos.get(i));
        datasourceInfoList.add(new DatasourceInfo(info.getName(), info.getName(), info.getType(), info.isEditable(), info.isRemovable(), info.isImportable(), info.isExportable()));
    }
    callback.success(datasourceInfoList);
}
Also used : IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo) DatasourceInfo(org.pentaho.platform.dataaccess.datasource.DatasourceInfo) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ArrayList(java.util.ArrayList) IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)

Example 3 with DatasourceInfo

use of org.pentaho.platform.dataaccess.datasource.DatasourceInfo in project data-access by pentaho.

the class JdbcDatasourceService method getIds.

@Override
public void getIds(final XulServiceCallback<List<IDatasourceInfo>> callback) {
    RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, getMetadataBaseURL() + "getDatasourcePermissions");
    requestBuilder.setHeader("Content-Type", "application/json");
    try {
        requestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
                callback.error(exception.getMessage(), exception);
            }

            public void onResponseReceived(Request request, Response response) {
                if (response.getText().equals("EDIT")) {
                    String cacheBuster = "?ts=" + new java.util.Date().getTime();
                    RequestBuilder listConnectionBuilder = new RequestBuilder(RequestBuilder.GET, getBaseURL() + "list" + cacheBuster);
                    listConnectionBuilder.setHeader("Content-Type", "application/json");
                    try {
                        listConnectionBuilder.sendRequest(null, new RequestCallback() {

                            @Override
                            public void onError(Request request, Throwable exception) {
                                callback.error(exception.getMessage(), exception);
                            }

                            @Override
                            public void onResponseReceived(Request request, Response response) {
                                AutoBean<IDatabaseConnectionList> bean = AutoBeanCodex.decode(connectionAutoBeanFactory, IDatabaseConnectionList.class, response.getText());
                                List<IDatabaseConnection> connections = bean.as().getDatabaseConnections();
                                List<IDatasourceInfo> datasourceInfos = new ArrayList<IDatasourceInfo>();
                                for (IDatabaseConnection connection : connections) {
                                    // check attributes to make sure we only return "standard" connections which can be managed
                                    Map<String, String> attributes = connection.getAttributes();
                                    if (attributes.containsKey(ATTRIBUTE_STANDARD_CONNECTION)) {
                                        if (attributes.get(ATTRIBUTE_STANDARD_CONNECTION).equals(Boolean.FALSE.toString())) {
                                            continue;
                                        }
                                    }
                                    datasourceInfos.add(new DatasourceInfo(connection.getName(), connection.getName(), TYPE, editable, removable, importable, exportable));
                                }
                                callback.success(datasourceInfos);
                            }
                        });
                    } catch (RequestException e) {
                        callback.error(e.getMessage(), e);
                    }
                }
            }
        });
    } catch (RequestException e) {
        callback.error(e.getMessage(), e);
    }
}
Also used : IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo) DatasourceInfo(org.pentaho.platform.dataaccess.datasource.DatasourceInfo) RequestBuilder(com.google.gwt.http.client.RequestBuilder) Request(com.google.gwt.http.client.Request) ArrayList(java.util.ArrayList) IDatabaseConnectionList(org.pentaho.ui.database.event.IDatabaseConnectionList) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) RequestCallback(com.google.gwt.http.client.RequestCallback) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)

Aggregations

ArrayList (java.util.ArrayList)3 DatasourceInfo (org.pentaho.platform.dataaccess.datasource.DatasourceInfo)3 IDatasourceInfo (org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)3 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 Request (com.google.gwt.http.client.Request)1 RequestBuilder (com.google.gwt.http.client.RequestBuilder)1 RequestCallback (com.google.gwt.http.client.RequestCallback)1 RequestException (com.google.gwt.http.client.RequestException)1 Response (com.google.gwt.http.client.Response)1 Element (com.google.gwt.xml.client.Element)1 NodeList (com.google.gwt.xml.client.NodeList)1 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)1 IDatabaseConnectionList (org.pentaho.ui.database.event.IDatabaseConnectionList)1