Revision 49935
Added by Panagiotis Kanakakis over 6 years ago
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/utils/Converter.java | ||
---|---|---|
239 | 239 |
|
240 | 240 |
public static List<AggregationDetails> getAggregationHistoryFromJson(JSONObject repositoryObject) throws JSONException { |
241 | 241 |
|
242 |
if( repositoryObject.get("aggregationHistory").toString().equals("[]")) |
|
242 |
if( repositoryObject.get("aggregationHistory").toString().equals("[]") || |
|
243 |
repositoryObject.get("aggregationHistory")!= null) |
|
243 | 244 |
return null; |
244 | 245 |
|
246 |
|
|
245 | 247 |
JSONArray rs = new JSONArray(repositoryObject.get("aggregationHistory").toString()); |
246 | 248 |
List<AggregationDetails> aggregationDetailsList = new ArrayList<>(); |
247 | 249 |
for(int i=0;i<rs.length();i++) |
... | ... | |
253 | 255 |
|
254 | 256 |
AggregationDetails aggregationDetails = new AggregationDetails(); |
255 | 257 |
aggregationDetails.setAggregationStage(aggregationObject.get("aggregationStage").toString()); |
256 |
aggregationDetails.setCollectionMode(aggregationObject.get("collectionMode").toString()); |
|
258 |
//aggregationDetails.setCollectionMode(aggregationObject.get("collectionMode").toString());
|
|
257 | 259 |
aggregationDetails.setDate(convertStringToDate(aggregationObject.get("date").toString())); |
258 | 260 |
aggregationDetails.setNumberOfRecords(Integer.parseInt(aggregationObject.get("numberOfRecords").toString())); |
259 | 261 |
return aggregationDetails; |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApi.java | ||
---|---|---|
18 | 18 |
@RequestMapping(value = "/testAggregations", method = RequestMethod.GET, |
19 | 19 |
produces = MediaType.APPLICATION_JSON_VALUE) |
20 | 20 |
@ResponseBody |
21 |
Aggregations testAggregations() throws JSONException;
|
|
21 |
List<String> testAggregations() throws JSONException;
|
|
22 | 22 |
|
23 | 23 |
@RequestMapping(value = "/getCountries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) |
24 | 24 |
@ResponseBody |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApiImpl.java | ||
---|---|---|
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
@Override |
69 |
public Aggregations testAggregations() throws JSONException {
|
|
69 |
public List<String> testAggregations() throws JSONException {
|
|
70 | 70 |
|
71 | 71 |
int page = 0; |
72 | 72 |
int size = 1000; |
... | ... | |
77 | 77 |
.build().expand(page,size).encode(); |
78 | 78 |
|
79 | 79 |
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class); |
80 |
List<String> ids = new ArrayList<>(); |
|
80 | 81 |
while(!rs.equals("[]")){ |
82 |
|
|
83 |
ids.addAll(getIdsWithNonEmptyAggregations(rs)); |
|
81 | 84 |
|
82 |
Aggregations aggregations = getFirstNonEmptyAggregation(rs); |
|
83 |
if(aggregations != null) |
|
84 |
return aggregations; |
|
85 |
LOGGER.debug("Checked " + (page+1)*size + " records!"); |
|
85 | 86 |
|
86 |
LOGGER.debug("Checked " + page*size + " records!"); |
|
87 |
|
|
88 | 87 |
page+=1; |
89 | 88 |
uriComponents = UriComponentsBuilder |
90 | 89 |
.fromHttpUrl(baseAddress + "/ds/list/") |
... | ... | |
93 | 92 |
rs = restTemplate.getForObject(uriComponents.toUri(), String.class); |
94 | 93 |
} |
95 | 94 |
|
96 |
return null;
|
|
95 |
return ids;
|
|
97 | 96 |
} |
98 | 97 |
|
99 |
private Aggregations getFirstNonEmptyAggregation(String rs) throws JSONException {
|
|
98 |
private List<String> getIdsWithNonEmptyAggregations(String rs) throws JSONException {
|
|
100 | 99 |
|
101 | 100 |
JSONArray ids = new JSONArray(rs); |
101 |
List<String> agg_ids = new ArrayList<>(); |
|
102 | 102 |
for(int i=0;i<ids.length();i++){ |
103 | 103 |
String id = ids.getString(i); |
104 | 104 |
Aggregations aggregations = getRepositoryAggregations(id); |
105 | 105 |
if(aggregations.getAggregationHistory() != null) |
106 |
return aggregations;
|
|
106 |
agg_ids.add(id);
|
|
107 | 107 |
} |
108 |
return null;
|
|
108 |
return agg_ids;
|
|
109 | 109 |
} |
110 | 110 |
|
111 | 111 |
@Override |
... | ... | |
221 | 221 |
JSONObject repository = new JSONObject(rs); |
222 | 222 |
|
223 | 223 |
Aggregations aggregations = new Aggregations(); |
224 |
|
|
225 |
aggregations.setAggregationHistory(Converter.getAggregationHistoryFromJson(repository)); |
|
226 |
aggregations.setLastCollection(Converter.getLastCollectionFromJson(repository)); |
|
227 |
aggregations.setLastTransformation(Converter.getLastTransformationFromJson(repository)); |
|
228 |
return aggregations; |
|
224 |
|
|
225 |
try{ |
|
226 |
aggregations.setAggregationHistory(Converter.getAggregationHistoryFromJson(repository)); |
|
227 |
aggregations.setLastCollection(Converter.getLastCollectionFromJson(repository)); |
|
228 |
aggregations.setLastTransformation(Converter.getLastTransformationFromJson(repository)); |
|
229 |
return aggregations; |
|
230 |
}catch (JSONException e){ |
|
231 |
LOGGER.debug("JSON aggregation exception " ,e); |
|
232 |
throw e; |
|
233 |
} |
|
234 |
|
|
229 | 235 |
} |
230 | 236 |
|
231 | 237 |
@Override |
modules/uoa-repository-manager-service/src/main/resources/application-context.xml | ||
---|---|---|
9 | 9 |
http://www.springframework.org/schema/context/spring-context-4.0.xsd |
10 | 10 |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> |
11 | 11 |
|
12 |
<import resource="classpath:META-INF/cxf/cxf.xml"/> |
|
13 |
<!--<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>--> |
|
14 |
<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml"/> |
|
12 |
<!-- <import resource="classpath:META-INF/cxf/cxf.xml"/>--> |
|
13 |
<!--<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml"/> |
|
15 | 14 |
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> |
16 | 15 |
<import resource="classpath*:/cxf.xml"/> |
17 | 16 |
<import resource="classpath*:/eu/dnetlib/repos/ehcacher/springContext-repos-ehcacher.xml"/> |
... | ... | |
24 | 23 |
<import resource="classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml"/> |
25 | 24 |
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/> |
26 | 25 |
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"/> |
27 |
<import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/> |
|
26 |
<import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/>-->
|
|
28 | 27 |
<context:property-placeholder location="classpath*:/eu/**/application.properties" /> |
29 | 28 |
<tx:annotation-driven transaction-manager="txManager"/> |
30 | 29 |
|
Also available in: Unified diff
1. Test aggregation method.
2. Bug fix on convertion from json to interface object.