Skip to content

Commit

Permalink
starting getparser implementation (JabRef#8539)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielPortods committed Apr 15, 2022
1 parent 254b85e commit ff068a2
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collections;

import org.jabref.logic.importer.FetcherException;
import org.jabref.logic.importer.Parser;
import org.jabref.logic.importer.SearchBasedParserFetcher;
import org.jabref.logic.importer.fetcher.transformers.DefaultQueryTransformer;
import org.jabref.logic.importer.util.JsonReader;
import org.jabref.logic.util.BuildInfo;

import kong.unirest.json.JSONArray;
import kong.unirest.json.JSONObject;
import org.apache.http.client.utils.URIBuilder;
import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode;

Expand All @@ -25,7 +29,19 @@ public String getName() {

@Override
public Parser getParser() {
return null;
return inputStream -> {
JSONObject response = JsonReader.toJsonObject(inputStream);
if (response.isEmpty()) {
return Collections.emptyList();
}

JSONArray results = response.getJSONArray("Result");
if (results.isEmpty()) {
return Collections.emptyList();
}

return null;
};
}

@Override
Expand Down

0 comments on commit ff068a2

Please sign in to comment.