Project

General

Profile

« Previous | Next » 

Revision 50920

using lambdas

View differences:

modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/virtuoso/VirtuosoReadAPI.java
3 3
import java.io.OutputStream;
4 4
import java.util.Iterator;
5 5
import java.util.List;
6
import javax.annotation.Nullable;
7 6

  
8
import com.google.common.base.Function;
9 7
import com.google.common.collect.Iterators;
10 8
import com.google.common.collect.Lists;
11 9
import org.apache.commons.logging.Log;
12 10
import org.apache.commons.logging.LogFactory;
13
import org.apache.jena.query.*;
11
import org.apache.jena.query.Query;
12
import org.apache.jena.query.QueryExecutionFactory;
13
import org.apache.jena.query.QueryFactory;
14
import org.apache.jena.query.ResultSet;
14 15
import org.apache.jena.rdf.model.Model;
15 16
import org.apache.jena.riot.RDFDataMgr;
16 17
import org.apache.jena.riot.RDFFormat;
......
56 57
		Query query = QueryFactory.create(queryForGraphs);
57 58
		final QueryEngineHTTP serviceRequest = QueryExecutionFactory.createServiceRequest(sparqlUrl, query);
58 59
		ResultSet graphs = serviceRequest.execSelect();
59
		Iterator<String> s = Iterators.transform(graphs, new Function<QuerySolution, String>() {
60
			@Nullable
61
			@Override
62
			public String apply(@Nullable final QuerySolution qs) {
63
				return qs.getResource("g").getURI();
64
			}
65
		});
60
		Iterator<String> s = Iterators.transform(graphs, qs -> qs.getResource("g").getURI());
66 61
		List<String> res = Lists.newArrayList(s);
67 62
		serviceRequest.close();
68 63
		return res;
......
79 74
		final QueryEngineHTTP serviceRequest =
80 75
				QueryExecutionFactory.createServiceRequest(sparqlUrl, QueryFactory.create(q));
81 76
		ResultSet subjects = serviceRequest.execSelect();
82
		Iterator<String> s = Iterators.transform(subjects, new Function<QuerySolution, String>() {
83
			@Nullable
84
			@Override
85
			public String apply(@Nullable final QuerySolution qs) {
86
				return qs.getResource("s").getURI();
87
			}
88
		});
77
		Iterator<String> s = Iterators.transform(subjects, qs -> qs.getResource("s").getURI());
89 78
		List<String> res = Lists.newArrayList(s);
90 79
		serviceRequest.close();
91 80
		return res;

Also available in: Unified diff