|
|
|
@ -1,14 +1,8 @@
|
|
|
|
|
package org.gcube.resources.discovery.client.impl;
|
|
|
|
|
|
|
|
|
|
import static org.gcube.data.streams.dsl.Streams.*;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.gcube.data.streams.Stream;
|
|
|
|
|
import org.gcube.data.streams.exceptions.StreamSkipSignal;
|
|
|
|
|
import org.gcube.data.streams.exceptions.StreamStopSignal;
|
|
|
|
|
import org.gcube.data.streams.generators.Generator;
|
|
|
|
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
|
|
|
|
import org.gcube.resources.discovery.client.api.DiscoveryException;
|
|
|
|
|
import org.gcube.resources.discovery.client.api.InvalidResultException;
|
|
|
|
@ -71,31 +65,4 @@ public class DelegateClient<R> implements DiscoveryClient<R> {
|
|
|
|
|
|
|
|
|
|
return parsed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
* <p>
|
|
|
|
|
* Result parsing errors are only logged as long as they do results are successfully parsed. Otherwise, the
|
|
|
|
|
* client flags the parsing errors as likely due to the parser itself.
|
|
|
|
|
*/
|
|
|
|
|
public Stream<R> submitForStream(Query query) throws DiscoveryException {
|
|
|
|
|
|
|
|
|
|
Stream<String> unparsed = inner.submitForStream(query);
|
|
|
|
|
|
|
|
|
|
return pipe(unparsed).through(new ParsingGenerator());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//helper
|
|
|
|
|
private class ParsingGenerator implements Generator<String,R> {
|
|
|
|
|
|
|
|
|
|
public R yield(String result) throws StreamSkipSignal, StreamStopSignal {
|
|
|
|
|
try {
|
|
|
|
|
return parser.parse(result);
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e) {
|
|
|
|
|
throw new InvalidResultException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|