develop #1
|
@ -57,20 +57,20 @@ public class DashboardController {
|
||||||
@PathVariable("repoId") String repoId,
|
@PathVariable("repoId") String repoId,
|
||||||
@RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException {
|
@RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException {
|
||||||
|
|
||||||
List<AggregationInfo> aggregationDetails = repositoryService.getRepositoryAggregations(repoId, 0, size);
|
List<AggregationInfo> aggregationInfo = repositoryService.getRepositoryAggregations(repoId, 0, size);
|
||||||
CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary();
|
CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary();
|
||||||
collectionMonitorSummary.setAggregationDetails(aggregationDetails);
|
collectionMonitorSummary.setAggregationInfo(aggregationInfo);
|
||||||
size = 0;
|
size = 0;
|
||||||
do {
|
do {
|
||||||
aggregationDetails = repositoryService.getRepositoryAggregations(repoId, size, size + 50);
|
aggregationInfo = repositoryService.getRepositoryAggregations(repoId, size, size + 50);
|
||||||
for (AggregationInfo aggregationDetail : aggregationDetails) {
|
for (AggregationInfo aggregationDetail : aggregationInfo) {
|
||||||
if (aggregationDetail.isIndexedVersion()) {
|
if (aggregationDetail.isIndexedVersion()) {
|
||||||
collectionMonitorSummary.setLastIndexedVersion(aggregationDetail);
|
collectionMonitorSummary.setLastIndexedVersion(aggregationDetail);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size += 30;
|
size += 30;
|
||||||
} while (aggregationDetails.size() != 0 && collectionMonitorSummary.getLastIndexedVersion() == null);
|
} while (aggregationInfo.size() != 0 && collectionMonitorSummary.getLastIndexedVersion() == null);
|
||||||
|
|
||||||
return collectionMonitorSummary;
|
return collectionMonitorSummary;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.domain;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class AggregationDetails{
|
|
||||||
|
|
||||||
|
|
||||||
private String aggregationStage;
|
|
||||||
private Date date;
|
|
||||||
private int numberOfRecords;
|
|
||||||
private String collectionMode;
|
|
||||||
private Boolean indexedVersion;
|
|
||||||
|
|
||||||
public AggregationDetails() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAggregationStage() {
|
|
||||||
return aggregationStage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCollectionMode() {
|
|
||||||
return collectionMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCollectionMode(String collectionMode) {
|
|
||||||
this.collectionMode = collectionMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAggregationStage(String aggregationStage) {
|
|
||||||
this.aggregationStage = aggregationStage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDate(Date date) {
|
|
||||||
this.date = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNumberOfRecords() {
|
|
||||||
return numberOfRecords;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNumberOfRecords(int numberOfRecords) {
|
|
||||||
this.numberOfRecords = numberOfRecords;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getYear() {
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTime(getDate());
|
|
||||||
return String.valueOf(calendar.get(Calendar.YEAR));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getIndexedVersion() {
|
|
||||||
return indexedVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIndexedVersion(Boolean indexedVersion) {
|
|
||||||
this.indexedVersion = indexedVersion;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,23 +5,23 @@ import eu.dnetlib.enabling.datasources.common.AggregationInfo;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CollectionMonitorSummary {
|
public class CollectionMonitorSummary {
|
||||||
private List<AggregationInfo> aggregationDetails;
|
private List<AggregationInfo> aggregationInfo;
|
||||||
|
|
||||||
private AggregationInfo lastIndexedVersion;
|
private AggregationInfo lastIndexedVersion;
|
||||||
|
|
||||||
public CollectionMonitorSummary(){}
|
public CollectionMonitorSummary(){}
|
||||||
|
|
||||||
public CollectionMonitorSummary(List<AggregationInfo> aggregationDetails, AggregationInfo lastIndexedVersion) {
|
public CollectionMonitorSummary(List<AggregationInfo> aggregationInfo, AggregationInfo lastIndexedVersion) {
|
||||||
this.aggregationDetails = aggregationDetails;
|
this.aggregationInfo = aggregationInfo;
|
||||||
this.lastIndexedVersion = lastIndexedVersion;
|
this.lastIndexedVersion = lastIndexedVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AggregationInfo> getAggregationDetails() {
|
public List<AggregationInfo> getAggregationInfo() {
|
||||||
return aggregationDetails;
|
return aggregationInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAggregationDetails(List<AggregationInfo> aggregationDetails) {
|
public void setAggregationInfo(List<AggregationInfo> aggregationInfo) {
|
||||||
this.aggregationDetails = aggregationDetails;
|
this.aggregationInfo = aggregationInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AggregationInfo getLastIndexedVersion() {
|
public AggregationInfo getLastIndexedVersion() {
|
||||||
|
|
|
@ -44,11 +44,11 @@ public class DashboardServiceImpl implements DashboardService {
|
||||||
|
|
||||||
//TODO getRepositoryAggregations returns only the 20 more recent items. Is it positive that we will find an indexed version there?
|
//TODO getRepositoryAggregations returns only the 20 more recent items. Is it positive that we will find an indexed version there?
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
List<AggregationInfo> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(), 0, 20);
|
List<AggregationInfo> aggregationInfoList = repositoryService.getRepositoryAggregations(repository.getId(), 0, 20);
|
||||||
for (AggregationInfo aggregationDetails : aggregationDetailsList) {
|
for (AggregationInfo aggregationInfo : aggregationInfoList) {
|
||||||
if (aggregationDetails.isIndexedVersion()) {
|
if (aggregationInfo.isIndexedVersion()) {
|
||||||
repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords());
|
repositorySummaryInfo.setRecordsCollected(aggregationInfo.getNumberOfRecords());
|
||||||
repositorySummaryInfo.setLastIndexedVersion(DateUtils.toDate(aggregationDetails.getDate()));
|
repositorySummaryInfo.setLastIndexedVersion(DateUtils.toDate(aggregationInfo.getDate()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,14 +101,13 @@ public class Converter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AggregationInfo> toAggregationHistory(String aggregationHistoryResponse) throws JSONException {
|
public List<AggregationInfo> toAggregationHistory(String aggregationHistoryResponse) throws JSONException {
|
||||||
List<AggregationInfo> aggregationDetailsList = new ArrayList<>();
|
List<AggregationInfo> aggregationInfoList = new ArrayList<>();
|
||||||
JSONArray aggregationInfo = new JSONObject(aggregationHistoryResponse).getJSONArray("aggregationInfo");
|
JSONArray aggregationInfo = new JSONObject(aggregationHistoryResponse).getJSONArray("aggregationInfo");
|
||||||
|
|
||||||
for (int i = 0; i < aggregationInfo.length(); i++)
|
for (int i = 0; i < aggregationInfo.length(); i++)
|
||||||
// aggregationDetailsList.add(toAggregationDetails(aggregationInfo.getJSONObject(i)));
|
aggregationInfoList.add(objectMapper.convertValue(aggregationInfo.getJSONObject(i), AggregationInfo.class));
|
||||||
aggregationDetailsList.add(objectMapper.convertValue(aggregationInfo.getJSONObject(i), AggregationInfo.class));
|
|
||||||
|
|
||||||
return aggregationDetailsList;
|
return aggregationInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Timezone> toTimezones(List<String> timezones) {
|
public List<Timezone> toTimezones(List<String> timezones) {
|
||||||
|
@ -138,20 +137,5 @@ public class Converter {
|
||||||
return Double.valueOf(number);
|
return Double.valueOf(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AggregationDetails toAggregationDetails(JSONObject aggregationObject) throws JSONException {
|
|
||||||
|
|
||||||
AggregationDetails aggregationDetails = new AggregationDetails();
|
|
||||||
|
|
||||||
if (aggregationObject.has("collectionMode"))
|
|
||||||
aggregationDetails.setCollectionMode(aggregationObject.get("collectionMode").toString());
|
|
||||||
if (aggregationObject.has("indexedVersion"))
|
|
||||||
aggregationDetails.setIndexedVersion(Boolean.parseBoolean(aggregationObject.get("indexedVersion").toString()));
|
|
||||||
|
|
||||||
aggregationDetails.setAggregationStage(aggregationObject.get("aggregationStage").toString());
|
|
||||||
aggregationDetails.setDate(DateUtils.toDate(aggregationObject.get("date").toString()));
|
|
||||||
aggregationDetails.setNumberOfRecords(Integer.parseInt(aggregationObject.get("numberOfRecords").toString()));
|
|
||||||
|
|
||||||
return aggregationDetails;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue