Revision 49935
Added by Panagiotis Kanakakis over 6 years ago
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 |
Also available in: Unified diff
1. Test aggregation method.
2. Bug fix on convertion from json to interface object.