mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-04-23 08:00:56 -04:00
Implement library build
This commit is contained in:
@@ -10,6 +10,9 @@ import io.xpipe.beacon.ServerException;
|
||||
import io.xpipe.beacon.exchange.ReadInfoExchange;
|
||||
import io.xpipe.core.source.DataSourceId;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class DataSourceImpl implements DataSource {
|
||||
|
||||
public static DataSource get(DataSourceId ds) {
|
||||
@@ -34,6 +37,28 @@ public abstract class DataSourceImpl implements DataSource {
|
||||
return source[0];
|
||||
}
|
||||
|
||||
public static DataSource wrap(URL url, String type, Map<String,String> config) {
|
||||
final DataSource[] source = new DataSource[1];
|
||||
new XPipeApiConnector() {
|
||||
@Override
|
||||
protected void handle(BeaconClient sc) throws ClientException, ServerException, ConnectorException {
|
||||
var req = ReadInfoExchange.Request.builder().sourceId(ds).build();
|
||||
ReadInfoExchange.Response res = performSimpleExchange(sc, req);
|
||||
switch (res.getType()) {
|
||||
case TABLE -> {
|
||||
var data = res.getTableData();
|
||||
source[0] = new DataTableImpl(res.getSourceId(), data.getRowCount(), data.getDataType());
|
||||
}
|
||||
case STRUCTURE -> {
|
||||
}
|
||||
case RAW -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
return source[0];
|
||||
}
|
||||
|
||||
private final DataSourceId sourceId;
|
||||
|
||||
public DataSourceImpl(DataSourceId sourceId) {
|
||||
|
||||
Reference in New Issue
Block a user