Revision 47231
Added by Alessia Bardi almost 7 years ago
EHRIGraphQLClient.java | ||
---|---|---|
4 | 4 |
import java.io.InputStreamReader; |
5 | 5 |
import java.net.URI; |
6 | 6 |
import java.net.URISyntaxException; |
7 |
import java.util.List;
|
|
7 |
import java.util.Iterator;
|
|
8 | 8 |
|
9 | 9 |
import com.google.common.collect.Iterables; |
10 | 10 |
import com.google.common.collect.Lists; |
... | ... | |
33 | 33 |
|
34 | 34 |
private static final Log log = LogFactory.getLog(EHRIGraphQLClient.class); |
35 | 35 |
|
36 |
public List<String> collect(final String baseURL, final String graphQLQuery) throws URISyntaxException, IOException, CollectorServiceException {
|
|
36 |
public Iterator<String> collect(final String baseURL, final String graphQLQuery) throws URISyntaxException, IOException, CollectorServiceException {
|
|
37 | 37 |
/* |
38 | 38 |
The curl equivalent: |
39 | 39 |
curl --header X-Stream:true \ |
... | ... | |
67 | 67 |
} |
68 | 68 |
} |
69 | 69 |
|
70 |
protected List<String> getIdentifiers(final InputStreamReader input){
|
|
70 |
protected Iterator<String> getIdentifiers(final InputStreamReader input){
|
|
71 | 71 |
JsonObject jsonObject = new JsonParser().parse(input).getAsJsonObject(); |
72 | 72 |
JsonArray items = jsonObject.getAsJsonObject("data").getAsJsonObject("topLevelDocumentaryUnits").getAsJsonArray("items"); |
73 | 73 |
log.debug(items); |
74 |
return Lists.newArrayList(Iterables.transform(items, jelem -> jelem.getAsJsonObject().get("id").getAsString())); |
|
74 |
return Lists.newArrayList(Iterables.transform(items, jelem -> jelem.getAsJsonObject().get("id").getAsString())).iterator();
|
|
75 | 75 |
} |
76 | 76 |
|
77 | 77 |
} |
Also available in: Unified diff
Let's use Iterators instead of Lists