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