1 |
43931
|
katerina.i
|
package eu.dnetlib.data.search.web.api;
|
2 |
|
|
|
3 |
|
|
import eu.dnetlib.api.data.SearchServiceException;
|
4 |
|
|
import eu.dnetlib.data.search.app.SearchServiceImpl;
|
5 |
44602
|
katerina.i
|
import eu.dnetlib.data.search.utils.SolrResultsFormatter;
|
6 |
43931
|
katerina.i
|
import eu.dnetlib.data.search.web.utils.RequestResponseHandler;
|
7 |
|
|
import eu.dnetlib.domain.data.SearchResult;
|
8 |
44602
|
katerina.i
|
import eu.dnetlib.functionality.index.cql.CqlTranslator;
|
9 |
|
|
import eu.dnetlib.functionality.index.cql.CqlTranslatorImpl;
|
10 |
43931
|
katerina.i
|
import org.apache.log4j.Logger;
|
11 |
|
|
import org.json.XML;
|
12 |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
13 |
|
|
import org.springframework.stereotype.Component;
|
14 |
44602
|
katerina.i
|
import org.z3950.zing.cql.CQLParseException;
|
15 |
43931
|
katerina.i
|
|
16 |
|
|
import javax.servlet.http.HttpServletRequest;
|
17 |
|
|
import javax.ws.rs.*;
|
18 |
43975
|
katerina.i
|
import javax.ws.rs.core.Context;
|
19 |
|
|
import javax.ws.rs.core.MediaType;
|
20 |
|
|
import javax.ws.rs.core.Response;
|
21 |
44602
|
katerina.i
|
import java.io.IOException;
|
22 |
|
|
import java.util.Arrays;
|
23 |
|
|
import java.util.List;
|
24 |
|
|
import java.util.Locale;
|
25 |
|
|
import java.util.Map;
|
26 |
43931
|
katerina.i
|
|
27 |
|
|
/**
|
28 |
|
|
* Created by kiatrop on 2/6/2016.
|
29 |
|
|
*/
|
30 |
|
|
|
31 |
|
|
@Component
|
32 |
|
|
@Path("/v2")
|
33 |
|
|
public class SearchApiService {
|
34 |
|
|
|
35 |
|
|
private static final Logger logger = Logger.getLogger(SearchApiService.class);
|
36 |
|
|
|
37 |
|
|
@Autowired
|
38 |
|
|
private SearchServiceImpl searchService = null;
|
39 |
|
|
|
40 |
|
|
@GET
|
41 |
44602
|
katerina.i
|
@Path("/api/resources")
|
42 |
|
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
43 |
|
|
public Response fetchResources(@QueryParam("query") String query,
|
44 |
|
|
@DefaultValue("1") @QueryParam("page") final int offset,
|
45 |
|
|
@DefaultValue("10") @QueryParam("size") final int limit,
|
46 |
|
|
@QueryParam("refine") @DefaultValue("false") final boolean refine,
|
47 |
|
|
@QueryParam("fields") final List<String> fields,
|
48 |
|
|
@QueryParam("fq") final List<String> fieldQueries,
|
49 |
|
|
@QueryParam("format") final String format,
|
50 |
|
|
@Context final HttpServletRequest request) {
|
51 |
|
|
String type = null;
|
52 |
|
|
if (format != null && !format.isEmpty() && format.equalsIgnoreCase("json")) {
|
53 |
|
|
type = MediaType.APPLICATION_JSON;
|
54 |
|
|
|
55 |
|
|
} else {
|
56 |
|
|
type = MediaType.APPLICATION_XML;
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
if(query == null || query.isEmpty()) {
|
60 |
|
|
return Response.status(Response.Status.BAD_REQUEST).
|
61 |
|
|
entity(APIResponseFormatter.compose400Message(type, "The 'query' parameter is required")).
|
62 |
|
|
type(type).build();
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
return getResponseByEntity(query, RequestResponseHandler.Entity.PUBLICATION, offset, limit, format, request, refine, fields, fieldQueries);
|
66 |
|
|
}
|
67 |
|
|
/*
|
68 |
|
|
@GET
|
69 |
43931
|
katerina.i
|
@Path("/api/publications")
|
70 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
71 |
|
|
public Response fetchPublications(@QueryParam("q") String keywords,
|
72 |
43975
|
katerina.i
|
@DefaultValue("1") @QueryParam("page") final int offset,
|
73 |
|
|
@DefaultValue("10") @QueryParam("size") final int limit,
|
74 |
|
|
@QueryParam("refine") @DefaultValue("false") final boolean refine,
|
75 |
|
|
@QueryParam("fields") final List<String> fields,
|
76 |
44602
|
katerina.i
|
@QueryParam("format") final String format,
|
77 |
43975
|
katerina.i
|
@Context final HttpServletRequest request) {
|
78 |
44602
|
katerina.i
|
|
79 |
|
|
String simpleQuery = createSimpleSearchQuery(RequestResponseHandler.Entity.PUBLICATION, keywords);
|
80 |
|
|
return getResponseByEntity(simpleQuery, RequestResponseHandler.Entity.PUBLICATION, offset, limit, format, request, refine, fields);
|
81 |
43931
|
katerina.i
|
|
82 |
|
|
}
|
83 |
|
|
|
84 |
44602
|
katerina.i
|
private String createSimpleSearchQuery(RequestResponseHandler.Entity entity, String keywords) {
|
85 |
|
|
StringBuilder queryBuilder = new StringBuilder();
|
86 |
|
|
enhanceQueryWithEntityType(queryBuilder,entity);
|
87 |
|
|
enhanceQueryWithKeywords(queryBuilder, keywords);
|
88 |
|
|
return queryBuilder.toString();
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
private void enhanceQueryWithKeywords(StringBuilder queryBuilder, String keywords) {
|
92 |
|
|
queryBuilder.append(' ').append(CQLQueryGeneration.Operator.AND).append(' ').append(keywords);
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
private String builtFullQuery(List<String> keywords, List<String> keywordOperators, RequestResponseHandler.Entity entity, HttpServletRequest request) {
|
96 |
44301
|
katerina.i
|
Map<String, String[]> parameterMap = request.getParameterMap();
|
97 |
44271
|
katerina.i
|
|
98 |
44301
|
katerina.i
|
Map<String, String[]> operators = new HashMap<String, String[]>();
|
99 |
|
|
Map<String, String[]> parameters = new HashMap<String, String[]>();
|
100 |
|
|
extractParameterNOperatorsValues(parameterMap, operators, parameters, entity);
|
101 |
44290
|
katerina.i
|
|
102 |
44301
|
katerina.i
|
return enhanceQuery(keywords, keywordOperators, operators, parameters, entity);
|
103 |
44271
|
katerina.i
|
}
|
104 |
|
|
|
105 |
44602
|
katerina.i
|
/* public static void buildFq(RequestResponseHandler.Entity entity, HttpServletRequest request, List<String> fields, List<FieldQuery> fieldQueries) {
|
106 |
|
|
Map<String, String[]> parameterMap = request.getParameterMap();
|
107 |
44290
|
katerina.i
|
|
108 |
44602
|
katerina.i
|
Map<String, String> indexParameterMap = entity.geIndexParameterMap();
|
109 |
|
|
Map<String, String> parameterOperatorMap = entity.getParameterOperatorMap();
|
110 |
|
|
//logger.debug(parameterOperatorMap.keySet());
|
111 |
|
|
|
112 |
|
|
for (String field:fields) {
|
113 |
|
|
logger.debug("field: " + field);
|
114 |
|
|
String parameter = indexParameterMap.get(field);
|
115 |
|
|
logger.debug("parameter: " + parameter);
|
116 |
|
|
if (indexParameterMap.get(field) != null ) {
|
117 |
|
|
String[] refineValues = request.getParameterValues(parameter);
|
118 |
|
|
String operatorParameter = parameterOperatorMap.get(parameter);
|
119 |
|
|
String operatorValue = null;
|
120 |
|
|
if (operatorParameter != null && !operatorParameter.trim().isEmpty()) {
|
121 |
|
|
operatorValue = request.getParameter(operatorParameter);
|
122 |
|
|
if (operatorValue == null || operatorValue.trim().isEmpty()) {
|
123 |
|
|
operatorValue = "AND";
|
124 |
|
|
}
|
125 |
|
|
fieldQueries.add(new FieldQuery(field, operatorValue, refineValues));
|
126 |
|
|
|
127 |
|
|
} else {
|
128 |
|
|
//TODO throw exception?
|
129 |
|
|
}
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
}
|
133 |
|
|
*/
|
134 |
|
|
|
135 |
|
|
/*
|
136 |
|
|
|
137 |
|
|
public static String createFqParameter(List<FieldQuery> fieldQueries) {
|
138 |
|
|
StringBuilder fq = new StringBuilder();
|
139 |
|
|
for (FieldQuery fieldQuery:fieldQueries) {
|
140 |
|
|
fq.append(fieldQuery.getIndexField());
|
141 |
|
|
if(fieldQuery.getValues() != null && fieldQuery.getValues().length == 0) {
|
142 |
|
|
for(int i=0; i< fieldQuery.getValues().length; i++) {
|
143 |
|
|
fq.append(":").append(fieldQuery.getValues()[i] + " ");
|
144 |
|
|
if(i < fieldQuery.getValues().length-1) {
|
145 |
|
|
fq.append(" " + fieldQuery.getOperator() + " ");
|
146 |
|
|
}
|
147 |
|
|
}
|
148 |
|
|
}
|
149 |
|
|
}
|
150 |
|
|
return fq.toString();
|
151 |
|
|
}
|
152 |
|
|
|
153 |
43931
|
katerina.i
|
@GET
|
154 |
44271
|
katerina.i
|
@Path("/api/publications/count")
|
155 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
156 |
44290
|
katerina.i
|
public Response fetchPublicationsCount(@QueryParam("q") String query) {
|
157 |
|
|
String fullQuery = builtQueryByEntity(query, RequestResponseHandler.Entity.PUBLICATION);
|
158 |
|
|
return getCount(fullQuery);
|
159 |
44271
|
katerina.i
|
}
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
@GET
|
163 |
43931
|
katerina.i
|
@Path("/api/publications/{publicationid}")
|
164 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
165 |
43931
|
katerina.i
|
public Response fetchPublicationsById(@PathParam("publicationid") String publicationid) {
|
166 |
44290
|
katerina.i
|
return getResponseByEntityId(RequestResponseHandler.Entity.PUBLICATION, publicationid);
|
167 |
43975
|
katerina.i
|
}
|
168 |
43931
|
katerina.i
|
|
169 |
44290
|
katerina.i
|
|
170 |
44301
|
katerina.i
|
@GET
|
171 |
43975
|
katerina.i
|
@Path("/api/datasets")
|
172 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
173 |
44301
|
katerina.i
|
public Response fetchDatasets(@QueryParam("q") List<String> keywords,
|
174 |
|
|
@QueryParam("op") final List<String> keywordOperators,
|
175 |
43975
|
katerina.i
|
@DefaultValue("1") @QueryParam("page") int offset,
|
176 |
|
|
@DefaultValue("10") @QueryParam("size") int limit,
|
177 |
|
|
@QueryParam("refine") @DefaultValue("false") boolean refine,
|
178 |
|
|
@QueryParam("fields") final List<String> fields,
|
179 |
44602
|
katerina.i
|
@QueryParam("format") final String format,
|
180 |
43975
|
katerina.i
|
@Context HttpServletRequest request) {
|
181 |
43931
|
katerina.i
|
|
182 |
44301
|
katerina.i
|
String fullQuery = builtFullQuery(keywords, keywordOperators, RequestResponseHandler.Entity.PUBLICATION, request);
|
183 |
44602
|
katerina.i
|
return getResponseByEntity(fullQuery, RequestResponseHandler.Entity.DATASET, offset, limit, format, request, refine, fields);
|
184 |
43931
|
katerina.i
|
}
|
185 |
44301
|
katerina.i
|
|
186 |
44271
|
katerina.i
|
@GET
|
187 |
|
|
@Path("/api/datasets/count")
|
188 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
189 |
44290
|
katerina.i
|
public Response fetchDatesetsCount(@QueryParam("q") String query) {
|
190 |
|
|
String fullQuery = builtQueryByEntity(query, RequestResponseHandler.Entity.DATASET);
|
191 |
|
|
return getCount(fullQuery);
|
192 |
44271
|
katerina.i
|
}
|
193 |
43931
|
katerina.i
|
|
194 |
|
|
@GET
|
195 |
|
|
@Path("/api/datasets/{datasetid}")
|
196 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
197 |
43931
|
katerina.i
|
public Response fetchDatasets(@PathParam("datasetid") String datasetid) {
|
198 |
44290
|
katerina.i
|
return getResponseByEntityId(RequestResponseHandler.Entity.DATASET, datasetid);
|
199 |
43931
|
katerina.i
|
}
|
200 |
|
|
|
201 |
44301
|
katerina.i
|
|
202 |
43931
|
katerina.i
|
@GET
|
203 |
43975
|
katerina.i
|
@Path("/api/projects")
|
204 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
205 |
44301
|
katerina.i
|
public Response fetchProjects(@QueryParam("q") List<String> keywords,
|
206 |
|
|
@QueryParam("op") final List<String> keywordOperators,
|
207 |
43975
|
katerina.i
|
@DefaultValue("1") @QueryParam("page") final int offset,
|
208 |
|
|
@DefaultValue("10") @QueryParam("size") final int limit,
|
209 |
|
|
@QueryParam("refine") @DefaultValue("false") final boolean refine,
|
210 |
44602
|
katerina.i
|
@QueryParam("format") final String format,
|
211 |
43975
|
katerina.i
|
@QueryParam("fields") final List<String> fields,
|
212 |
|
|
@Context final HttpServletRequest request) {
|
213 |
|
|
|
214 |
44301
|
katerina.i
|
String fullQuery = builtFullQuery(keywords, keywordOperators, RequestResponseHandler.Entity.PROJECT, request);
|
215 |
44602
|
katerina.i
|
return getResponseByEntity(fullQuery, RequestResponseHandler.Entity.PROJECT, offset, limit, format, request, refine, fields);
|
216 |
43975
|
katerina.i
|
}
|
217 |
|
|
|
218 |
44301
|
katerina.i
|
|
219 |
43975
|
katerina.i
|
@GET
|
220 |
44271
|
katerina.i
|
@Path("/api/projects/count")
|
221 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
222 |
44271
|
katerina.i
|
public Response fetchProjectsCount(@QueryParam("q") String query){
|
223 |
44290
|
katerina.i
|
String fullQuery = builtQueryByEntity(query, RequestResponseHandler.Entity.PROJECT);
|
224 |
|
|
return getCount(fullQuery);
|
225 |
44271
|
katerina.i
|
}
|
226 |
|
|
|
227 |
|
|
@GET
|
228 |
43931
|
katerina.i
|
@Path("/api/projects/{projectid}")
|
229 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
230 |
43931
|
katerina.i
|
public Response fetchProjects(@PathParam("projectid") String projectid) {
|
231 |
44290
|
katerina.i
|
return getResponseByEntityId(RequestResponseHandler.Entity.PROJECT, projectid);
|
232 |
43931
|
katerina.i
|
}
|
233 |
|
|
|
234 |
|
|
@GET
|
235 |
|
|
@Path("/api/projects/{projectId}/publications")
|
236 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
237 |
43931
|
katerina.i
|
public Response fetchProjectPublications(@PathParam("projectId") String projectId,
|
238 |
|
|
@DefaultValue("1") @QueryParam("page") int offset,
|
239 |
|
|
@DefaultValue("10") @QueryParam("size") int limit,
|
240 |
44602
|
katerina.i
|
@QueryParam("format") final String format,
|
241 |
43931
|
katerina.i
|
@Context HttpServletRequest request) {
|
242 |
|
|
|
243 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.PUBLICATION, "relprojectid", projectId);
|
244 |
44602
|
katerina.i
|
return getResponseByEntity(fullQuery, RequestResponseHandler.Entity.PUBLICATION, offset, limit, format, request, false, null);
|
245 |
43975
|
katerina.i
|
}
|
246 |
43931
|
katerina.i
|
|
247 |
43975
|
katerina.i
|
@GET
|
248 |
44290
|
katerina.i
|
@Path("/api/projects/{projectId}/publications/count")
|
249 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
250 |
44290
|
katerina.i
|
public Response fetchProjectPublicationsCount(@PathParam("projectId") String projectId) {
|
251 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.PUBLICATION, "relprojectid", projectId);
|
252 |
|
|
return getCount(fullQuery);
|
253 |
44290
|
katerina.i
|
}
|
254 |
|
|
|
255 |
|
|
@GET
|
256 |
43975
|
katerina.i
|
@Path("/api/projects/{projectId}/datasets")
|
257 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
258 |
43975
|
katerina.i
|
public Response fetchProjectDatasets(@PathParam("projectId") String projectId,
|
259 |
|
|
@DefaultValue("1") @QueryParam("page") int offset,
|
260 |
|
|
@DefaultValue("10") @QueryParam("size") int limit,
|
261 |
44602
|
katerina.i
|
@QueryParam("format") final String format,
|
262 |
43975
|
katerina.i
|
@Context HttpServletRequest request) {
|
263 |
43931
|
katerina.i
|
|
264 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.DATASET, "relprojectid", projectId);
|
265 |
44602
|
katerina.i
|
return getResponseByEntity(fullQuery, RequestResponseHandler.Entity.DATASET, offset, limit, format, request, false, null);
|
266 |
43931
|
katerina.i
|
}
|
267 |
|
|
|
268 |
44290
|
katerina.i
|
@GET
|
269 |
|
|
@Path("/api/projects/{projectId}/datasets/count")
|
270 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
271 |
44290
|
katerina.i
|
public Response fetchProjectDatasetsCount(@PathParam("projectId") String projectId,
|
272 |
|
|
@DefaultValue("1") @QueryParam("page") int offset,
|
273 |
|
|
@DefaultValue("10") @QueryParam("size") int limit,
|
274 |
|
|
@Context HttpServletRequest request) {
|
275 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.DATASET, "relprojectid", projectId);
|
276 |
|
|
return getCount(fullQuery);
|
277 |
44290
|
katerina.i
|
}
|
278 |
|
|
|
279 |
|
|
|
280 |
44301
|
katerina.i
|
|
281 |
43975
|
katerina.i
|
@GET
|
282 |
|
|
@Path("/api/datasources")
|
283 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
284 |
44301
|
katerina.i
|
public Response fetchDatasources(@QueryParam("q") List<String> keywords,
|
285 |
|
|
@QueryParam("op") final List<String> keywordOperators,
|
286 |
43975
|
katerina.i
|
@DefaultValue("1") @QueryParam("page") final int offset,
|
287 |
|
|
@DefaultValue("10") @QueryParam("size") final int limit,
|
288 |
|
|
@QueryParam("refine") @DefaultValue("false") final boolean refine,
|
289 |
|
|
@QueryParam("fields") final List<String> fields,
|
290 |
44602
|
katerina.i
|
@QueryParam("format") final String format,
|
291 |
43975
|
katerina.i
|
@Context final HttpServletRequest request) {
|
292 |
43931
|
katerina.i
|
|
293 |
44301
|
katerina.i
|
String fullQuery = builtFullQuery(keywords, keywordOperators, RequestResponseHandler.Entity.DATASOURCE, request);
|
294 |
44602
|
katerina.i
|
return getResponseByEntity(fullQuery, RequestResponseHandler.Entity.DATASOURCE, offset, limit, format, request, refine, fields);
|
295 |
43975
|
katerina.i
|
}
|
296 |
44301
|
katerina.i
|
|
297 |
44271
|
katerina.i
|
@GET
|
298 |
|
|
@Path("/api/datasources/count")
|
299 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
300 |
44271
|
katerina.i
|
public Response fetchDatasourcesCount(@QueryParam("q") String query){
|
301 |
44290
|
katerina.i
|
String fullQuery = builtQueryByEntity(query, RequestResponseHandler.Entity.DATASOURCE);
|
302 |
|
|
return getCount(fullQuery);
|
303 |
44271
|
katerina.i
|
}
|
304 |
43975
|
katerina.i
|
|
305 |
43931
|
katerina.i
|
@GET
|
306 |
|
|
@Path("/api/datasources/{datasourceid}")
|
307 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
308 |
44290
|
katerina.i
|
public Response fetchDatasources(@PathParam("datasourceid") String datasourceid) {
|
309 |
|
|
return getResponseByEntityId(RequestResponseHandler.Entity.DATASOURCE, datasourceid);
|
310 |
44271
|
katerina.i
|
}
|
311 |
44602
|
katerina.i
|
*/
|
312 |
44290
|
katerina.i
|
/*
|
313 |
44271
|
katerina.i
|
@Path("/api/datasources/{datasourceid}/publications")
|
314 |
44290
|
katerina.i
|
@Path("/api/datasources/{datasourceid}/publications/count")
|
315 |
|
|
Same for datasets.
|
316 |
43931
|
katerina.i
|
|
317 |
44290
|
katerina.i
|
NOT supported by schema. No such field as *reldatasourceid*.
|
318 |
|
|
To oercomethis collectedFrom and hostedBy are added in the other paths when needed
|
319 |
43931
|
katerina.i
|
|
320 |
44290
|
katerina.i
|
*/
|
321 |
|
|
|
322 |
44602
|
katerina.i
|
/*
|
323 |
43931
|
katerina.i
|
@GET
|
324 |
43975
|
katerina.i
|
@Path("/api/organizations")
|
325 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
326 |
44301
|
katerina.i
|
public Response fetchOrganisations(@QueryParam("q") List<String> keywords,
|
327 |
|
|
@QueryParam("op") final List<String> keywordOperators,
|
328 |
|
|
@DefaultValue("1") @QueryParam("page") final int offset,
|
329 |
|
|
@DefaultValue("10") @QueryParam("size") final int limit,
|
330 |
|
|
@QueryParam("refine") @DefaultValue("false") final boolean refine,
|
331 |
|
|
@QueryParam("fields") final List<String> fields,
|
332 |
44602
|
katerina.i
|
@QueryParam("format") final String format,
|
333 |
44301
|
katerina.i
|
@Context final HttpServletRequest request) {
|
334 |
43975
|
katerina.i
|
|
335 |
44301
|
katerina.i
|
String fullQuery = builtFullQuery(keywords, keywordOperators, RequestResponseHandler.Entity.ORGANIZATION, request);
|
336 |
44602
|
katerina.i
|
return getResponseByEntity(fullQuery, RequestResponseHandler.Entity.ORGANIZATION, offset, limit, format, request, refine, fields);
|
337 |
43931
|
katerina.i
|
}
|
338 |
|
|
|
339 |
44301
|
katerina.i
|
|
340 |
44271
|
katerina.i
|
@GET
|
341 |
|
|
@Path("/api/organizations/count")
|
342 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
343 |
44271
|
katerina.i
|
public Response fetchOrganizationsCount(@QueryParam("q") String query){
|
344 |
44290
|
katerina.i
|
String fullQuery = builtQueryByEntity(query, RequestResponseHandler.Entity.ORGANIZATION);
|
345 |
|
|
return getCount(fullQuery);
|
346 |
44271
|
katerina.i
|
}
|
347 |
43975
|
katerina.i
|
|
348 |
43931
|
katerina.i
|
@GET
|
349 |
43975
|
katerina.i
|
@Path("/api/organizations/{organizationid}")
|
350 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
351 |
43975
|
katerina.i
|
public Response fetchOrganizations(@PathParam("organizationid") String organizationid) {
|
352 |
44290
|
katerina.i
|
return getResponseByEntityId(RequestResponseHandler.Entity.ORGANIZATION, organizationid);
|
353 |
43975
|
katerina.i
|
}
|
354 |
|
|
|
355 |
|
|
@GET
|
356 |
|
|
@Path("/api/organizations/{organizationid}/datasources")
|
357 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
358 |
43975
|
katerina.i
|
public Response fetchOrganizationDatasources(@PathParam("organizationid") String organizationid,
|
359 |
|
|
@DefaultValue("1") @QueryParam("page") int offset,
|
360 |
|
|
@DefaultValue("10") @QueryParam("size") int limit,
|
361 |
44602
|
katerina.i
|
@QueryParam("format") final String format,
|
362 |
43975
|
katerina.i
|
@Context HttpServletRequest request) {
|
363 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.DATASOURCE, "relorganizationid", organizationid);
|
364 |
44602
|
katerina.i
|
return getResponseByEntity(fullQuery, RequestResponseHandler.Entity.DATASOURCE, offset, limit, format, request, false, null);
|
365 |
43975
|
katerina.i
|
}
|
366 |
|
|
|
367 |
44290
|
katerina.i
|
@GET
|
368 |
|
|
@Path("/api/organizations/{organizationid}/datasources/count")
|
369 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
370 |
44290
|
katerina.i
|
public Response fetchOrganizationDatasources(@PathParam("organizationid") String organizationid) {
|
371 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.DATASOURCE, "relorganizationid", organizationid);
|
372 |
|
|
return getCount(fullQuery);
|
373 |
44290
|
katerina.i
|
}
|
374 |
|
|
|
375 |
|
|
|
376 |
43975
|
katerina.i
|
@GET
|
377 |
44271
|
katerina.i
|
@Path("/api/organizations/{organizationid}/projects")
|
378 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
379 |
44271
|
katerina.i
|
public Response fetchOrganizationProjects(@PathParam("organizationid") String organizationid,
|
380 |
|
|
@DefaultValue("1") @QueryParam("page") int offset,
|
381 |
|
|
@DefaultValue("10") @QueryParam("size") int limit,
|
382 |
44602
|
katerina.i
|
@QueryParam("format") final String format,
|
383 |
44271
|
katerina.i
|
@Context HttpServletRequest request) {
|
384 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.PROJECT, "relprojectid", organizationid);
|
385 |
44602
|
katerina.i
|
return getResponseByEntity(fullQuery, RequestResponseHandler.Entity.PROJECT, offset, limit, format, request, false, null);
|
386 |
44271
|
katerina.i
|
}
|
387 |
|
|
|
388 |
44290
|
katerina.i
|
@GET
|
389 |
|
|
@Path("/api/organizations/{organizationid}/projects/count")
|
390 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
391 |
44290
|
katerina.i
|
public Response fetchOrganizationProjectsCount(@PathParam("organizationid") String organizationid) {
|
392 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.PROJECT, "relprojectid", organizationid);
|
393 |
|
|
return getCount(fullQuery);
|
394 |
44290
|
katerina.i
|
}
|
395 |
|
|
|
396 |
|
|
|
397 |
44301
|
katerina.i
|
|
398 |
44271
|
katerina.i
|
@GET
|
399 |
43975
|
katerina.i
|
@Path("/api/people")
|
400 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
401 |
44301
|
katerina.i
|
public Response fetchPeople(@QueryParam("q") List<String> keywords,
|
402 |
|
|
@QueryParam("op") final List<String> keywordOperators,
|
403 |
43975
|
katerina.i
|
@DefaultValue("1") @QueryParam("page") final int offset,
|
404 |
|
|
@DefaultValue("10") @QueryParam("size") final int limit,
|
405 |
|
|
@QueryParam("refine") @DefaultValue("false") final boolean refine,
|
406 |
|
|
@QueryParam("fields") final List<String> fields,
|
407 |
44602
|
katerina.i
|
@QueryParam("format") final String format,
|
408 |
43975
|
katerina.i
|
@Context final HttpServletRequest request) {
|
409 |
44301
|
katerina.i
|
|
410 |
|
|
String fullQuery = builtFullQuery(keywords, keywordOperators, RequestResponseHandler.Entity.PERSON, request);
|
411 |
44602
|
katerina.i
|
return getResponseByEntity(fullQuery, RequestResponseHandler.Entity.PERSON, offset, limit, format, request, refine, fields);
|
412 |
43975
|
katerina.i
|
}
|
413 |
|
|
|
414 |
44301
|
katerina.i
|
|
415 |
43975
|
katerina.i
|
@GET
|
416 |
44271
|
katerina.i
|
@Path("/api/people/count")
|
417 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
418 |
44271
|
katerina.i
|
public Response fetchPeopleCount(@QueryParam("q") String query){
|
419 |
44290
|
katerina.i
|
String fullQuery = builtQueryByEntity(query, RequestResponseHandler.Entity.PERSON);
|
420 |
|
|
return getCount(fullQuery);
|
421 |
44271
|
katerina.i
|
}
|
422 |
|
|
|
423 |
|
|
@GET
|
424 |
43931
|
katerina.i
|
@Path("/api/people/{personid}")
|
425 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
426 |
43931
|
katerina.i
|
public Response fetchPeople(@PathParam("personid") String personid) {
|
427 |
44290
|
katerina.i
|
return getResponseByEntityId(RequestResponseHandler.Entity.PERSON, personid);
|
428 |
43931
|
katerina.i
|
}
|
429 |
|
|
|
430 |
43975
|
katerina.i
|
@GET
|
431 |
|
|
@Path("/api/people/{personid}/publications")
|
432 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
433 |
43975
|
katerina.i
|
public Response fetchPeoplePublications(@PathParam("personid") String personid,
|
434 |
|
|
@DefaultValue("1") @QueryParam("page") final int offset,
|
435 |
|
|
@DefaultValue("10") @QueryParam("size") final int limit,
|
436 |
44602
|
katerina.i
|
@QueryParam("format") final String format,
|
437 |
43975
|
katerina.i
|
@Context final HttpServletRequest request) {
|
438 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.PUBLICATION, "relpersonid", personid);
|
439 |
44602
|
katerina.i
|
return getResponseByEntity(fullQuery, RequestResponseHandler.Entity.PUBLICATION, offset, limit, format, request, false, null);
|
440 |
43975
|
katerina.i
|
}
|
441 |
43931
|
katerina.i
|
|
442 |
43975
|
katerina.i
|
@GET
|
443 |
44290
|
katerina.i
|
@Path("/api/people/{personid}/publications/count")
|
444 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
445 |
44290
|
katerina.i
|
public Response fetchPeoplePublicationsCount(@PathParam("personid") String personid) {
|
446 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.PUBLICATION, "relpersonid", personid);
|
447 |
|
|
return getCount(fullQuery);
|
448 |
44290
|
katerina.i
|
}
|
449 |
|
|
|
450 |
|
|
|
451 |
|
|
@GET
|
452 |
43975
|
katerina.i
|
@Path("/api/people/{personid}/datasets")
|
453 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
454 |
43975
|
katerina.i
|
public Response fetchPeopleDatasets(@PathParam("personid") String personid,
|
455 |
|
|
@DefaultValue("1") @QueryParam("page") final int offset,
|
456 |
|
|
@DefaultValue("10") @QueryParam("size") final int limit,
|
457 |
44602
|
katerina.i
|
@QueryParam("format") final String format,
|
458 |
43975
|
katerina.i
|
@Context final HttpServletRequest request) {
|
459 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.DATASET, "relpersonid", personid);
|
460 |
44602
|
katerina.i
|
return getResponseByEntity(fullQuery, RequestResponseHandler.Entity.DATASET, offset, limit, format, request, false, null);
|
461 |
43975
|
katerina.i
|
}
|
462 |
|
|
|
463 |
44290
|
katerina.i
|
@GET
|
464 |
|
|
@Path("/api/people/{personid}/datasets/count")
|
465 |
44602
|
katerina.i
|
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
466 |
44290
|
katerina.i
|
public Response fetchPeopleDatasetsCount(@PathParam("personid") String personid) {
|
467 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(RequestResponseHandler.Entity.DATASET, "relpersonid", personid);
|
468 |
|
|
return getCount(fullQuery);
|
469 |
|
|
}
|
470 |
|
|
|
471 |
|
|
private String enhanceQuery(List<String> keywords, List<String> keywordOperators, Map<String, String[]> operatorTypeValues, Map<String, String[]> parameterTypeValues, RequestResponseHandler.Entity entity) {
|
472 |
44290
|
katerina.i
|
StringBuilder queryBuilder = new StringBuilder();
|
473 |
43975
|
katerina.i
|
|
474 |
44301
|
katerina.i
|
//There is always an entity
|
475 |
|
|
enhanceQueryWithEntityType(queryBuilder, entity);
|
476 |
|
|
|
477 |
|
|
enhanceQueryWithKeywords(queryBuilder, keywordOperators, keywords);
|
478 |
|
|
|
479 |
|
|
Map<String, String> parameterIndexMap = entity.getParameterIndexMap();
|
480 |
|
|
Map<String, String> parameterOperatorMap = entity.getParameterOperatorMap();
|
481 |
|
|
enhanceQueryWithParameters(queryBuilder, operatorTypeValues, parameterTypeValues, parameterIndexMap, parameterOperatorMap);
|
482 |
|
|
|
483 |
|
|
return queryBuilder.toString();
|
484 |
44290
|
katerina.i
|
}
|
485 |
44602
|
katerina.i
|
*/
|
486 |
|
|
@Deprecated
|
487 |
44301
|
katerina.i
|
private void enhanceQueryWithKeywords(StringBuilder queryBuilder, List<String> keywordOperators, List<String> keywords) {
|
488 |
|
|
if (keywordOperators != null && !keywordOperators.isEmpty()) {
|
489 |
|
|
if (keywords != null && !keywords.isEmpty()) {
|
490 |
|
|
if (keywordOperators.size() != keywords.size()) {
|
491 |
|
|
throw new IllegalArgumentException("Keywords and Operators are not matched");
|
492 |
|
|
}
|
493 |
|
|
} else {
|
494 |
|
|
throw new IllegalArgumentException("Keywords and Operators are not matched");
|
495 |
|
|
}
|
496 |
|
|
}
|
497 |
|
|
|
498 |
|
|
for(int i = 0; i < keywords.size(); i++) {
|
499 |
|
|
queryBuilder.append(' ').append(keywordOperators.get(i)).append(' ').append('(').append(keywords.get(i)).append(")");
|
500 |
|
|
}
|
501 |
|
|
}
|
502 |
|
|
|
503 |
|
|
private void enhanceQueryWithParameters(StringBuilder queryBuilder, Map<String, String[]> operators, Map<String, String[]> parameters, Map<String, String> parameterIndexMap, Map<String, String> parameterOperatorMap) {
|
504 |
|
|
if (parameterIndexMap != null && !parameterIndexMap.isEmpty()) {
|
505 |
|
|
if (parameterOperatorMap != null && !parameterOperatorMap.isEmpty()) {
|
506 |
|
|
for(String operatorType:operators.keySet()) {
|
507 |
|
|
//enhance messages with >, < ?? or maybe move all checks in the beginning?
|
508 |
|
|
if (operators.get(operatorType).length != parameters.get(parameterOperatorMap.get(operatorType)).length ) {
|
509 |
|
|
throw new IllegalArgumentException("Parameters and Operators are not matched");
|
510 |
|
|
}
|
511 |
|
|
|
512 |
|
|
String parameterName = parameterOperatorMap.get(operatorType);
|
513 |
|
|
|
514 |
|
|
for(int i = 0; i < operators.get(operatorType).length; i++) {
|
515 |
|
|
String indexField = parameterIndexMap.get(parameterOperatorMap.get(operatorType));
|
516 |
|
|
|
517 |
|
|
/*logger.debug("operator " + operatorType);
|
518 |
|
|
logger.debug("operator map get" + parameterOperatorMap.get(operatorType));
|
519 |
|
|
|
520 |
|
|
logger.debug("index map" + parameterIndexMap.keySet());
|
521 |
|
|
logger.debug("index map values" + parameterIndexMap.values());
|
522 |
|
|
|
523 |
|
|
logger.debug("index field " + indexField);*/
|
524 |
|
|
|
525 |
|
|
if (indexField != null) {
|
526 |
|
|
/* logger.debug(indexField + " " + operators.get(operatorType)[i] + " " + parameters.get(parameterName)[i]);*/
|
527 |
|
|
queryBuilder.append(' ').append(operators.get(operatorType)[i]).append('(').append(indexField).append(" = ").append(parameters.get(parameterName)[i]).append(")");
|
528 |
|
|
|
529 |
|
|
} else { //TODO check if needed
|
530 |
|
|
logger.debug("and here!");
|
531 |
|
|
logger.debug(" " + operators.get(operatorType)[i] + " " + parameters.get(operatorType)[i]);
|
532 |
|
|
queryBuilder.append(" " + operators.get(operatorType)[i] + " " + parameters.get(operatorType)[i]);
|
533 |
|
|
}
|
534 |
|
|
}
|
535 |
|
|
}
|
536 |
|
|
} else {
|
537 |
|
|
throw new IllegalArgumentException("Keywords and Operators are not matched");
|
538 |
|
|
}
|
539 |
|
|
|
540 |
|
|
}
|
541 |
|
|
}
|
542 |
|
|
|
543 |
44602
|
katerina.i
|
/*
|
544 |
44301
|
katerina.i
|
private boolean isFirstTerm(StringBuilder queryBuilder) {
|
545 |
|
|
return queryBuilder.toString().trim().equals("");
|
546 |
44602
|
katerina.i
|
}*/
|
547 |
44301
|
katerina.i
|
|
548 |
44290
|
katerina.i
|
public void builtEntityIdQuery(StringBuilder queryBuilder, RequestResponseHandler.Entity entity, String entityId){
|
549 |
|
|
enhanceQueryWithEntityType(queryBuilder, entity);
|
550 |
|
|
enhanceQueryWithEntityId(queryBuilder, entityId);
|
551 |
|
|
}
|
552 |
|
|
|
553 |
44301
|
katerina.i
|
public String builtEntity2EntityRelationQuery(RequestResponseHandler.Entity entity, String relationfield, String entityId){
|
554 |
|
|
StringBuilder queryBuilder = new StringBuilder();
|
555 |
44290
|
katerina.i
|
enhanceQueryWithEntityType(queryBuilder, entity);
|
556 |
|
|
enhanceQueryWithEntity2EntityId(queryBuilder, relationfield, entityId);
|
557 |
44301
|
katerina.i
|
return queryBuilder.toString();
|
558 |
44290
|
katerina.i
|
}
|
559 |
|
|
|
560 |
|
|
private void enhanceQueryWithEntity2EntityId(StringBuilder queryBuilder, String relationfield, String entityId) {
|
561 |
|
|
CQLQueryGeneration.appendTerm(queryBuilder, CQLQueryGeneration.Operator.AND, " " + relationfield + " ", CQLQueryGeneration.Operator.EXACT, entityId);
|
562 |
|
|
}
|
563 |
|
|
|
564 |
|
|
|
565 |
|
|
public void enhanceQueryWithEntityType(StringBuilder queryBuilder, RequestResponseHandler.Entity entity) {
|
566 |
|
|
queryBuilder.append(entity.getQueryPrefix());
|
567 |
|
|
}
|
568 |
|
|
|
569 |
|
|
public void enhanceQueryWithEntityId(StringBuilder queryBuilder, String entityId) {
|
570 |
|
|
CQLQueryGeneration.appendTerm(queryBuilder, CQLQueryGeneration.Operator.AND, "objidentifier", CQLQueryGeneration.Operator.EXACT, entityId);
|
571 |
|
|
}
|
572 |
|
|
|
573 |
44271
|
katerina.i
|
public String builtQueryByEntity(String query, RequestResponseHandler.Entity entity) {
|
574 |
43975
|
katerina.i
|
StringBuilder queryBuilder = new StringBuilder();
|
575 |
|
|
queryBuilder.append(entity.getQueryPrefix());
|
576 |
|
|
|
577 |
|
|
if (query != null && !query.trim().isEmpty()) {
|
578 |
|
|
CQLQueryGeneration.appendSimpleTerm(queryBuilder, CQLQueryGeneration.Operator.AND, "(" + query + ")");
|
579 |
43931
|
katerina.i
|
}
|
580 |
43975
|
katerina.i
|
|
581 |
|
|
return queryBuilder.toString();
|
582 |
43931
|
katerina.i
|
}
|
583 |
|
|
|
584 |
44301
|
katerina.i
|
public void extractParameterNOperatorsValues(Map<String, String[]> parameterMap, Map<String, String[]> operatorTypeValues, Map<String, String[]> parameterTypeValues, RequestResponseHandler.Entity entity) {
|
585 |
44271
|
katerina.i
|
for (String parameter:parameterMap.keySet()) {
|
586 |
44301
|
katerina.i
|
Map<String, String> parameterIndexMap = entity.getParameterIndexMap();
|
587 |
|
|
Map<String, String> parameterOperatorMap = entity.getParameterOperatorMap();
|
588 |
44271
|
katerina.i
|
|
589 |
44301
|
katerina.i
|
if (parameterOperatorMap.get(parameter) != null) {
|
590 |
44271
|
katerina.i
|
operatorTypeValues.put(parameter, parameterMap.get(parameter));
|
591 |
|
|
|
592 |
44301
|
katerina.i
|
} else if (parameterIndexMap.get(parameter) != null) {
|
593 |
44271
|
katerina.i
|
parameterTypeValues.put(parameter, parameterMap.get(parameter));
|
594 |
|
|
|
595 |
44301
|
katerina.i
|
} else if (!parameter.equals("q") && !parameter.equals("op") && !parameter.equals("size") && !parameter.equals("page") && !parameter.equals("fields") && !parameter.equals("refine")){
|
596 |
44271
|
katerina.i
|
throw new IllegalArgumentException("The parameter " + parameter + " is not supported.");
|
597 |
|
|
}
|
598 |
|
|
|
599 |
|
|
if (parameterTypeValues.get(parameter) == null) {
|
600 |
|
|
logger.debug("parameterTypeValues is null");
|
601 |
|
|
} else {
|
602 |
|
|
logger.debug("parameterTypeValues " + Arrays.asList(parameterTypeValues.get(parameter)));
|
603 |
|
|
}
|
604 |
|
|
|
605 |
|
|
}
|
606 |
|
|
|
607 |
|
|
//TODO make checks per type????
|
608 |
44301
|
katerina.i
|
if (operatorTypeValues.size() != parameterTypeValues.size()) {
|
609 |
|
|
throw new IllegalArgumentException("Parameters and Operators do not match.");
|
610 |
44271
|
katerina.i
|
}
|
611 |
|
|
}
|
612 |
44301
|
katerina.i
|
/*
|
613 |
|
|
*//* For each parameter get the values and the operators *//*
|
614 |
|
|
public void extractParameterOperatorsNValues(Map<String, String[]> requestParameterMap, Map<String, String[]> keywordOperatorValueMap, Map<String, String[]> keywordValuesMap,
|
615 |
|
|
Map<String, String[]> operatorValueMap, Map<String, String[]> parameterValuesMap, RequestResponseHandler.Entity entity) {
|
616 |
44271
|
katerina.i
|
|
617 |
44301
|
katerina.i
|
for (String parameter:requestParameterMap.keySet()) {
|
618 |
|
|
Map<String, String> parameterIndexMap = entity.getParameterIndexMap();
|
619 |
|
|
Map<String, String> parameterOperatoMap = entity.getParameterOperatorMap();
|
620 |
|
|
|
621 |
|
|
if (parameterOperatoMap.get(parameter) != null) {
|
622 |
|
|
operatorValueMap.put(parameter, requestParameterMap.get(parameter));
|
623 |
|
|
|
624 |
|
|
} else if (parameterIndexMap.get(parameter) != null) {
|
625 |
|
|
parameterValuesMap.put(parameter, requestParameterMap.get(parameter));
|
626 |
|
|
|
627 |
|
|
} else if (parameter.equals("q")) {
|
628 |
|
|
keywordValuesMap.put("q", requestParameterMap.get("q"));
|
629 |
|
|
|
630 |
|
|
} else if (parameter.equals("op")) {
|
631 |
|
|
keywordOperatorValueMap.put("op", requestParameterMap.get("op"));
|
632 |
|
|
|
633 |
|
|
} else if (!parameter.equals("size") && !parameter.equals("page") && !parameter.equals("fields") && !parameter.equals("refine")){
|
634 |
|
|
throw new IllegalArgumentException("The parameter " + parameter + " is not supported.");
|
635 |
|
|
}
|
636 |
|
|
|
637 |
|
|
if (parameterValuesMap.get(parameter) == null) {
|
638 |
|
|
logger.debug("parameterTypeValues is null");
|
639 |
|
|
} else {
|
640 |
|
|
logger.debug("parameterTypeValues " + Arrays.asList(parameterValuesMap.get(parameter)));
|
641 |
|
|
}
|
642 |
|
|
}
|
643 |
|
|
|
644 |
|
|
if ((operatorValueMap.size() != parameterValuesMap.size()) || (keywordOperatorValueMap.size() != keywordValuesMap.size())) {
|
645 |
|
|
throw new IllegalArgumentException("Operators do not match parameters.");
|
646 |
|
|
}
|
647 |
|
|
}*/
|
648 |
|
|
|
649 |
44290
|
katerina.i
|
private Response getCount(String query) {
|
650 |
44271
|
katerina.i
|
try {
|
651 |
44290
|
katerina.i
|
SearchResult searchResult = searchService.search(query, null, Locale.getDefault().toString(), 0, 0);
|
652 |
|
|
return Response.status(Response.Status.OK).entity(ResponseFormatter.createCountMeta(query.replace("\"", "\\\""), searchResult.getTotal())).build();
|
653 |
44271
|
katerina.i
|
|
654 |
|
|
} catch (SearchServiceException sse) {
|
655 |
44290
|
katerina.i
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ResponseFormatter.compose500Message("Fail to fetch count for query " + query.replace("\"", "\\\"") + ".", sse.getMessage())).build();
|
656 |
|
|
}
|
657 |
|
|
}
|
658 |
|
|
|
659 |
44602
|
katerina.i
|
/* TODO remove?
|
660 |
44290
|
katerina.i
|
private Response getCountByEntity2EntityRelation(String query, RequestResponseHandler.Entity entity, String relationfield, String entityId) {
|
661 |
44301
|
katerina.i
|
String fullQuery = builtEntity2EntityRelationQuery(entity, relationfield, entityId);
|
662 |
44290
|
katerina.i
|
|
663 |
|
|
try {
|
664 |
44301
|
katerina.i
|
SearchResult searchResult = searchService.search(fullQuery, null, Locale.getDefault().toString(), 0, 0);
|
665 |
|
|
return Response.status(Response.Status.OK).entity(ResponseFormatter.createCountMeta(fullQuery.replace("\"", "\\\""), searchResult.getTotal())).build();
|
666 |
44290
|
katerina.i
|
|
667 |
|
|
} catch (SearchServiceException sse) {
|
668 |
44271
|
katerina.i
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ResponseFormatter.compose500Message("Fail to fetch count for query " + fullQuery.replace("\"", "\\\"") + ".", sse.getMessage())).build();
|
669 |
|
|
}
|
670 |
44602
|
katerina.i
|
} */
|
671 |
44271
|
katerina.i
|
|
672 |
44290
|
katerina.i
|
private Response getResponseByEntityId(RequestResponseHandler.Entity entity, String entityId) {
|
673 |
43931
|
katerina.i
|
try {
|
674 |
44290
|
katerina.i
|
StringBuilder queryBuilder = new StringBuilder();
|
675 |
|
|
builtEntityIdQuery(queryBuilder, entity, entityId);
|
676 |
|
|
String fullQuery = queryBuilder.toString();
|
677 |
43931
|
katerina.i
|
|
678 |
44290
|
katerina.i
|
SearchResult searchResult = searchService.search(fullQuery, null, Locale.getDefault().toString(), 1, 1);
|
679 |
|
|
|
680 |
43931
|
katerina.i
|
if (searchResult.getSearchResults() == null || searchResult.getSearchResults().isEmpty() ||
|
681 |
|
|
searchResult.getSearchResults().size() == 0 || searchResult.getSearchResults().get(0) == null) {
|
682 |
|
|
return Response.status(Response.Status.NOT_FOUND).entity(
|
683 |
43975
|
katerina.i
|
ResponseFormatter.compose404Message("404 - " + entity +" with id "
|
684 |
|
|
+ entityId + " not found.")).type(MediaType.APPLICATION_JSON).build();
|
685 |
43931
|
katerina.i
|
}
|
686 |
|
|
|
687 |
43975
|
katerina.i
|
return Response.status(Response.Status.OK).entity(ResponseFormatter.createEntityResponse(entity, XML.toJSONObject(searchResult.getSearchResults().get(0)).toString())).type(MediaType.APPLICATION_JSON).build();
|
688 |
43931
|
katerina.i
|
|
689 |
|
|
} catch (SearchServiceException sse) {
|
690 |
43975
|
katerina.i
|
logger.error("Fail to fetch "+ entity + " with id " + entityId, sse);
|
691 |
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ResponseFormatter.compose500Message("Fail to fetch " + entity + " with id " + entityId, sse.getMessage())).build();
|
692 |
43931
|
katerina.i
|
}
|
693 |
|
|
}
|
694 |
|
|
|
695 |
44602
|
katerina.i
|
private Response getResponseByEntity(String fullQuery, RequestResponseHandler.Entity entity, int offset, int limit, String format, HttpServletRequest request, boolean refine, List<String> refineFields, List<String> fieldQueries) {
|
696 |
43975
|
katerina.i
|
try {
|
697 |
44301
|
katerina.i
|
|
698 |
44602
|
katerina.i
|
SearchResult solrResults = searchService.newSearch(fullQuery, Locale.getDefault().toString(), refineFields, fieldQueries, offset, limit, format);
|
699 |
44301
|
katerina.i
|
|
700 |
43975
|
katerina.i
|
return Response.status(Response.Status.OK).entity(ResponseFormatter.createEntitiesResponse(request, entity, fullQuery.replace("\"", "\\\""),
|
701 |
44602
|
katerina.i
|
solrResults.getSearchResults().toString(), solrResults.getTotal()+"", offset+"", limit+"", refine, SolrResultsFormatter.jsonList2Json(solrResults.getBrowseResults()))).type(MediaType.APPLICATION_JSON).build();
|
702 |
43931
|
katerina.i
|
|
703 |
43975
|
katerina.i
|
} catch (SearchServiceException sse) {
|
704 |
|
|
logger.error("Fail to get " + entity.getPlural() , sse);
|
705 |
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
|
706 |
|
|
entity(ResponseFormatter.compose500Message("Fail to fetch " + entity.getPlural(), sse.getMessage())).type(MediaType.APPLICATION_JSON).build();
|
707 |
|
|
}
|
708 |
43931
|
katerina.i
|
}
|
709 |
|
|
|
710 |
44301
|
katerina.i
|
private void formatRefineResults(StringBuilder refineBuilder, SearchResult refineResults) {
|
711 |
43975
|
katerina.i
|
int i = 0;
|
712 |
44301
|
katerina.i
|
for (String json: refineResults.getBrowseResults()) {
|
713 |
|
|
if (i == (refineResults.getBrowseResults().size() - 1)) {
|
714 |
|
|
refineBuilder.append(json);
|
715 |
|
|
} else {
|
716 |
|
|
refineBuilder.append(json).append(",");
|
717 |
43975
|
katerina.i
|
}
|
718 |
|
|
i++;
|
719 |
|
|
}
|
720 |
43931
|
katerina.i
|
}
|
721 |
|
|
|
722 |
43975
|
katerina.i
|
|
723 |
44602
|
katerina.i
|
/*
|
724 |
43931
|
katerina.i
|
public static void main(String[] args) {
|
725 |
|
|
String json = " {\"result\":{\"xmlns:oaf\":\"http://namespace.openaire.eu/oaf\",\"xmlns:xsi\":\"http://www.w3.o" +
|
726 |
|
|
"rg/2001/XMLSchema-instance\",\"header\":{\"dri:dateOfCollection\":\"2016-05-20T03:34:07Z\",\"dri:dateOfTransformation\":\"\",\"counters\":{\"counter_dedup\":{\"value\":2},\"counter_doi\":{\"value\":2},\"counter_authorship\":{\"va" +
|
727 |
|
|
"lue\":1},\"counter_authorship_inferred\":{\"value\":1}},\"dri:objIdentifier\":\"dedup_wf_001::0f5604702b32f59d9789573113279e69\"},\"metadata\":{\"oaf:entity\":{\"oaf:result\":{\"datainfo\":{\"provenanceaction\":{\"schemename\"" +
|
728 |
|
|
":\"dnet:provenanceActions\",\"classname\":\"sysimport:dedup\",\"schemeid\":\"dnet:provenanceActions\",\"classid\":\"sysimport:dedup\"},\"trust\":0.9,\"inferenceprovenance\":\"dedup-similarity-result\",\"deletedbyinference\":fal" +
|
729 |
|
|
"se,\"inferred\":true},\"rels\":{\"rel\":{\"to\":{\"content\":\"dedup_wf_001::884d8c367553a8de98ec90ece1b1be4a\",\"scheme\":\"dnet:person_result_relations\",\"class\":\"hasAuthor\",\"type\":\"person\"},\"provenanceaction\":\"sysimpor" +
|
730 |
|
|
"t:crosswalk:repository\",\"trust\":0.9,\"inferenceprovenance\":\"\",\"ranking\":1,\"inferred\":true,\"fullname\":\"Krafft, Alexander\"}},\"subject\":[{\"content\":\"Clinic for Obstetrics\",\"schemename\":\"dnet:result_subject\",\"c" +
|
731 |
|
|
"lassname\":\"keyword\",\"schemeid\":\"dnet:result_subject\",\"classid\":\"keyword\"},{\"content\":\"610 Medicine & health\",\"schemename\":\"dnet:result_subject\",\"classname\":\"keyword\",\"schemeid\":\"dnet:result_subject\",\"class" +
|
732 |
|
|
"id\":\"keyword\"},{\"content\":\"News\",\"schemename\":\"dnet:result_subject\",\"classname\":\"keyword\",\"schemeid\":\"dnet:result_subject\",\"classid\":\"keyword\"}],\"collectedfrom\":[{\"id\":\"opendoar____::0efe32849d230d7f53049d" +
|
733 |
|
|
"dc4a4b0c60\",\"name\":\"Zurich Open Repository and Archive\"},{\"id\":\"opendoar____::8b6dd7db9af49e67306feb59a8bdc52c\",\"name\":\"Europe PubMed Central\"}],\"children\":{\"result\":[{\"title\":{\"content\":\"Iron supplementat" +
|
734 |
|
|
"ion in pregnancy\",\"schemename\":\"dnet:dataCite_title\",\"classname\":\"main title\",\"schemeid\":\"dnet:dataCite_title\",\"classid\":\"main title\"},\"resulttype\":{\"schemename\":\"dnet:result_typologies\",\"classname\":\"publi" +
|
735 |
|
|
"cation\",\"schemeid\":\"dnet:result_typologies\",\"classid\":\"publication\"},\"dateofacceptance\":\"1981-09-01\",\"objidentifier\":\"od_______908::f27f9e68f0b9f510ebf572ba295344e1\"},{\"title\":{\"content\":\"Iron supplementat" +
|
736 |
|
|
"ion in pregnancy\",\"schemename\":\"dnet:dataCite_title\",\"classname\":\"main title\",\"schemeid\":\"dnet:dataCite_title\",\"classid\":\"main title\"},\"resulttype\":{\"schemename\":\"dnet:result_typologies\",\"classname\":\"publi" +
|
737 |
|
|
"cation\",\"schemeid\":\"dnet:result_typologies\",\"classid\":\"publication\"},\"dateofacceptance\":\"2013-01-01\",\"publisher\":\"BMJ Publishing Group\",\"objidentifier\":\"od_______885::0f5604702b32f59d9789573113279e69\"}],\"i" +
|
738 |
|
|
"nstance\":[{\"webresource\":{\"url\":\"http://europepmc.org/articles/PMC2306130\"},\"id\":\"opendoar____::8b6dd7db9af49e67306feb59a8bdc52c\",\"licence\":{\"schemename\":\"dnet:access_modes\",\"classname\":\"Open Access\",\"sche" +
|
739 |
|
|
"meid\":\"dnet:access_modes\",\"classid\":\"OPEN\"},\"hostedby\":{\"id\":\"opendoar____::8b6dd7db9af49e67306feb59a8bdc52c\",\"name\":\"Europe PubMed Central\"},\"instancetype\":{\"schemename\":\"dnet:publication_resource\",\"class" +
|
740 |
|
|
"name\":\"Article\",\"schemeid\":\"dnet:publication_resource\",\"classid\":\"0001\"}},{\"webresource\":{\"url\":\"http://www.zora.uzh.ch/87059/1/30_13_Krafft_2013bmj_f4399_full.pdf\"},\"id\":\"opendoar____::0efe32849d230d7f530" +
|
741 |
|
|
"49ddc4a4b0c60\",\"licence\":{\"schemename\":\"dnet:access_modes\",\"classname\":\"Open Access\",\"schemeid\":\"dnet:access_modes\",\"classid\":\"OPEN\"},\"hostedby\":{\"id\":\"opendoar____::0efe32849d230d7f53049ddc4a4b0c60\",\"name" +
|
742 |
|
|
"\":\"Zurich Open Repository and Archive\"},\"instancetype\":{\"schemename\":\"dnet:publication_resource\",\"classname\":\"Article\",\"schemeid\":\"dnet:publication_resource\",\"classid\":\"0001\"}}]},\"pid\":[{\"content\":\"10.5167" +
|
743 |
|
|
"/uzh-87059\",\"schemename\":\"dnet:pid_types\",\"classname\":\"doi\",\"schemeid\":\"dnet:pid_types\",\"classid\":\"doi\"},{\"content\":\"PMC2306130\",\"schemename\":\"dnet:pid_types\",\"classname\":\"pmc\",\"schemeid\":\"dnet:pid_types\"," +
|
744 |
|
|
"\"classid\":\"pmc\"},{\"content\":\"10.1136/bmj.f4399\",\"schemename\":\"dnet:pid_types\",\"classname\":\"doi\",\"schemeid\":\"dnet:pid_types\",\"classid\":\"doi\"}],\"resourcetype\":{\"schemename\":\"\",\"classname\":\"\",\"schemeid\":\"\",\"c" +
|
745 |
|
|
"lassid\":\"\"},\"format\":\"\",\"dateofacceptance\":\"2013-01-01\",\"embargoenddate\":\"\",\"version\":\"\",\"size\":\"\",\"publisher\":\"BMJ Publishing Group\",\"country\":{\"schemename\":\"\",\"classname\":\"\",\"schemeid\":\"\",\"classid\":\"\"},\"" +
|
746 |
|
|
"metadataversionnumber\":\"\",\"title\":{\"content\":\"Iron supplementation in pregnancy\",\"schemename\":\"dnet:dataCite_title\",\"classname\":\"main title\",\"schemeid\":\"dnet:dataCite_title\",\"classid\":\"main title\"},\"result" +
|
747 |
|
|
"type\":{\"schemename\":\"dnet:result_typologies\",\"classname\":\"publication\",\"schemeid\":\"dnet:result_typologies\",\"classid\":\"publication\"},\"source\":\"Krafft, Alexander (2013). Iron supplementation in pregnancy. Br" +
|
748 |
|
|
"itish Medical Journal, 347:f4399.\",\"contributor\":\"\",\"description\":\"\",\"originalId\":[\"oai:europepmc.org:1052305\",\"oai:www.zora.uzh.ch:87059\"],\"lastmetadataupdate\":\"\",\"relevantdate\":{\"schemename\":\"\",\"classnam" +
|
749 |
|
|
"e\":\"\",\"schemeid\":\"\",\"classid\":\"\"},\"device\":\"\",\"bestlicense\":{\"schemename\":\"dnet:access_modes\",\"classname\":\"Open Access\",\"schemeid\":\"dnet:access_modes\",\"classid\":\"OPEN\"},\"language\":{\"schemename\":\"dnet:langu" +
|
750 |
|
|
"ages\",\"classname\":\"English\",\"schemeid\":\"dnet:languages\",\"classid\":\"eng\"},\"storagedate\":\"\",\"fulltext\":\"\"},\"xsi:schemaLocation\":\"http://namespace.openaire.eu/oaf https://www.openaire.eu/schema/0.2/oaf-0.2.xs" +
|
751 |
|
|
"d\"}},\"xmlns:dri\":\"http://www.driver-repository.eu/namespace/dri\"}}";
|
752 |
|
|
|
753 |
|
|
String s = "{\"result\":{\"xmlns:oaf\":\"http://namespace.openaire.eu/oaf\",\"xmlns:xsi\":\"http://www.w3.org/2001" +
|
754 |
|
|
"/XMLSchema-instance\",\"header\":{\"dri:dateOfCollection\":\"2014-04-10T13:35:33Z\",\"dri:dateOfTransformation\":\"\",\"counters\":{\"counter_dedup\":{\"value\":2},\"counter_authorship\":{\"value\":1},\"counter_authorship_infer" +
|
755 |
|
|
"red\":{\"value\":1}},\"dri:objIdentifier\":\"dedup_wf_001::4d934888dee33a62dece6fa36192c710\"},\"metadata\":{\"oaf:entity\":{\"oaf:result\":{\"datainfo\":{\"provenanceaction\":{\"schemename\":\"dnet:provenanceActions\",\"classn" +
|
756 |
|
|
"ame\":\"sysimport:dedup\",\"schemeid\":\"dnet:provenanceActions\",\"classid\":\"sysimport:dedup\"},\"trust\":0.9,\"inferenceprovenance\":\"dedup-similarity-result\",\"deletedbyinference\":false,\"inferred\":true},\"rels\":{\"rel\"" +
|
757 |
|
|
":{\"to\":{\"content\":\"od______1232::d4f9cea02c7762da24cd71ea0b9791de\",\"scheme\":\"dnet:person_result_relations\",\"class\":\"hasAuthor\",\"type\":\"person\"},\"provenanceaction\":\"sysimport:crosswalk:repository\",\"trust\":0" +
|
758 |
|
|
".9,\"inferenceprovenance\":\"\",\"ranking\":1,\"inferred\":true,\"fullname\":\"Anonymous\"}},\"subject\":{\"content\":\"Señoríos-Legislación\",\"schemename\":\"dnet:result_subject\",\"classname\":\"keyword\",\"schemeid\":\"dnet:result" +
|
759 |
|
|
"_subject\",\"classid\":\"keyword\"},\"collectedfrom\":[{\"id\":\"opendoar____::e53a0a2978c28872a4505bdb51db06dc\",\"name\":\"Biblioteca Virtual del Patrimonio Bibliográfico (Virtual Library of Bibliographical Heritage)\"" +
|
760 |
|
|
"},{\"id\":\"opendoar____::7aee26c309def8c5a2a076eb250b8f36\",\"name\":\"Biblioteca Virtual de Aragón\"}],\"children\":{\"result\":[{\"title\":{\"content\":\"Discurso sobre los señoríos : necesidad y justicia del decreto de" +
|
761 |
|
|
" Cortes de 6 de Agosto de 1811 y ventaja que debe causar a la Nación\",\"schemename\":\"dnet:dataCite_title\",\"classname\":\"main title\",\"schemeid\":\"dnet:dataCite_title\",\"classid\":\"main title\"},\"resulttype\":{\"sch" +
|
762 |
|
|
"emename\":\"dnet:result_typologies\",\"classname\":\"publication\",\"schemeid\":\"dnet:result_typologies\",\"classid\":\"publication\"},\"dateofacceptance\":\"1820-01-01\",\"objidentifier\":\"od______2719::bc2326a31763719dc5ebd" +
|
763 |
|
|
"38f16a25404\"},{\"title\":{\"content\":\"Discurso sobre los señoríos : necesidad y justicia del decreto de Cortes de 6 de Agosto de 1811 y ventaja que debe causar a la Nación\",\"schemename\":\"dnet:dataCite_title\"," +
|
764 |
|
|
"\"classname\":\"main title\",\"schemeid\":\"dnet:dataCite_title\",\"classid\":\"main title\"},\"resulttype\":{\"schemename\":\"dnet:result_typologies\",\"classname\":\"publication\",\"schemeid\":\"dnet:result_typologies\",\"classid\"" +
|
765 |
|
|
":\"publication\"},\"dateofacceptance\":\"1820-01-01\",\"objidentifier\":\"od______1232::4d934888dee33a62dece6fa36192c710\"}],\"instance\":[{\"webresource\":[{\"url\":\"http://bvpb.mcu.es/es/consulta/registro.cmd?id=403864\"" +
|
766 |
|
|
"},{\"url\":\"http://bvpb.mcu.es/es/catalogo_imagenes/grupo.cmd?path=2755\"}],\"id\":\"opendoar____::e53a0a2978c28872a4505bdb51db06dc\",\"licence\":{\"schemename\":\"dnet:access_modes\",\"classname\":\"Open Access\",\"schemei" +
|
767 |
|
|
"d\":\"dnet:access_modes\",\"classid\":\"OPEN\"},\"hostedby\":{\"id\":\"opendoar____::e53a0a2978c28872a4505bdb51db06dc\",\"name\":\"Biblioteca Virtual del Patrimonio Bibliográfico (Virtual Library of Bibliographical Herita" +
|
768 |
|
|
"ge)\"},\"instancetype\":{\"schemename\":\"dnet:publication_resource\",\"classname\":\"Book\",\"schemeid\":\"dnet:publication_resource\",\"classid\":\"0002\"}},{\"webresource\":{\"url\":\"http://bibliotecavirtual.aragon.es/bva/i18" +
|
769 |
|
|
"n/consulta/registro.cmd?id=2878\"},\"id\":\"opendoar____::7aee26c309def8c5a2a076eb250b8f36\",\"licence\":{\"schemename\":\"dnet:access_modes\",\"classname\":\"Open Access\",\"schemeid\":\"dnet:access_modes\",\"classid\":\"OPEN\"" +
|
770 |
|
|
"},\"hostedby\":{\"id\":\"opendoar____::7aee26c309def8c5a2a076eb250b8f36\",\"name\":\"Biblioteca Virtual de Aragón\"},\"instancetype\":{\"schemename\":\"dnet:publication_resource\",\"classname\":\"Book\",\"schemeid\":\"dnet:publi" +
|
771 |
|
|
"cation_resource\",\"classid\":\"0002\"}}]},\"pid\":{\"schemename\":\"\",\"classname\":\"\",\"schemeid\":\"\",\"classid\":\"\"},\"resourcetype\":{\"schemename\":\"\",\"classname\":\"\",\"schemeid\":\"\",\"classid\":\"\"},\"format\":\"\",\"dateofaccepta" +
|
772 |
|
|
"nce\":\"1820-01-01\",\"embargoenddate\":\"\",\"version\":\"\",\"size\":\"\",\"country\":{\"schemename\":\"\",\"classname\":\"\",\"schemeid\":\"\",\"classid\":\"\"},\"publisher\":\"\",\"metadataversionnumber\":\"\",\"title\":{\"content\":\"Discurso sob" +
|
773 |
|
|
"re los señoríos : necesidad y justicia del decreto de Cortes de 6 de Agosto de 1811 y ventaja que debe causar a la Nación\",\"schemename\":\"dnet:dataCite_title\",\"classname\":\"main title\",\"schemeid\":\"dnet:dataC" +
|
774 |
|
|
"ite_title\",\"classid\":\"main title\"},\"resulttype\":{\"schemename\":\"dnet:result_typologies\",\"classname\":\"publication\",\"schemeid\":\"dnet:result_typologies\",\"classid\":\"publication\"},\"source\":\"\",\"contributor\":\"Impr" +
|
775 |
|
|
"enta de Heras, imp.\",\"description\":\"\",\"originalId\":[\"oai:bvpb.mcu.es:403864\",\"oai:bibliotecavirtual.aragon.es:2878\"],\"lastmetadataupdate\":\"\",\"relevantdate\":{\"schemename\":\"\",\"classname\":\"\",\"schemeid\":\"\",\"cl" +
|
776 |
|
|
"assid\":\"\"},\"device\":\"\",\"bestlicense\":{\"schemename\":\"dnet:access_modes\",\"classname\":\"Open Access\",\"schemeid\":\"dnet:access_modes\",\"classid\":\"OPEN\"},\"language\":{\"schemename\":\"dnet:languages\",\"classname\":\"Span" +
|
777 |
|
|
"ish\",\"schemeid\":\"dnet:languages\",\"classid\":\"esl/spa\"},\"storagedate\":\"\",\"fulltext\":\"\"},\"xsi:schemaLocation\":\"http://namespace.openaire.eu/oaf https://www.openaire.eu/schema/0.2/oaf-0.2.xsd\"}},\"xmlns:dri\":\"h" +
|
778 |
|
|
"ttp://www.driver-repository.eu/namespace/dri\"}}\n";
|
779 |
|
|
|
780 |
|
|
JSONObject finalOject = new JSONObject();
|
781 |
|
|
finalOject.put("dri:objIdentifier", new JSONObject(json).getJSONObject("result").getJSONObject("header").getString("dri:objIdentifier"));
|
782 |
|
|
finalOject.put("content", new JSONObject(new JSONObject(json).getJSONObject("result").getJSONObject("metadata").getJSONObject("oaf:entity").getJSONObject("oaf:result"),
|
783 |
|
|
new String[]{"title", "description", "language", "bestlicense", "pid", "rels"}));
|
784 |
|
|
|
785 |
|
|
System.out.println(finalOject);
|
786 |
|
|
|
787 |
|
|
JSONObject jsonObject = new JSONObject(s).getJSONObject("result").getJSONObject("metadata").getJSONObject("oaf:entity").getJSONObject("oaf:result");
|
788 |
|
|
System.out.println("title --> " + jsonObject.getJSONObject("title").getString("content"));
|
789 |
|
|
System.out.println("pid --> " + jsonObject.getJSONArray("pid"));
|
790 |
|
|
|
791 |
|
|
JSONObject newJsonObject1 = new JSONObject(jsonObject, new String[]{"title", "description", "language", "bestlicense", "pid", "rels"});
|
792 |
|
|
|
793 |
44602
|
katerina.i
|
}
|
794 |
|
|
*/
|
795 |
43931
|
katerina.i
|
|
796 |
44602
|
katerina.i
|
public static void main(String[] args) throws IOException, CQLParseException {
|
797 |
|
|
CqlTranslator translator = new CqlTranslatorImpl();
|
798 |
|
|
System.out.println(translator.toLucene("relfundinglevel0_id = ec__________::EC::FP7"));
|
799 |
|
|
}
|
800 |
43931
|
katerina.i
|
|
801 |
|
|
}
|