develop #1
|
@ -57,20 +57,20 @@ public class DashboardController {
|
|||
@PathVariable("repoId") String repoId,
|
||||
@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.setAggregationDetails(aggregationDetails);
|
||||
collectionMonitorSummary.setAggregationInfo(aggregationInfo);
|
||||
size = 0;
|
||||
do {
|
||||
aggregationDetails = repositoryService.getRepositoryAggregations(repoId, size, size + 50);
|
||||
for (AggregationInfo aggregationDetail : aggregationDetails) {
|
||||
aggregationInfo = repositoryService.getRepositoryAggregations(repoId, size, size + 50);
|
||||
for (AggregationInfo aggregationDetail : aggregationInfo) {
|
||||
if (aggregationDetail.isIndexedVersion()) {
|
||||
collectionMonitorSummary.setLastIndexedVersion(aggregationDetail);
|
||||
break;
|
||||
}
|
||||
}
|
||||
size += 30;
|
||||
} while (aggregationDetails.size() != 0 && collectionMonitorSummary.getLastIndexedVersion() == null);
|
||||
} while (aggregationInfo.size() != 0 && collectionMonitorSummary.getLastIndexedVersion() == null);
|
||||
|
||||
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;
|
||||
|
||||
public class CollectionMonitorSummary {
|
||||
private List<AggregationInfo> aggregationDetails;
|
||||
private List<AggregationInfo> aggregationInfo;
|
||||
|
||||
private AggregationInfo lastIndexedVersion;
|
||||
|
||||
public CollectionMonitorSummary(){}
|
||||
|
||||
public CollectionMonitorSummary(List<AggregationInfo> aggregationDetails, AggregationInfo lastIndexedVersion) {
|
||||
this.aggregationDetails = aggregationDetails;
|
||||
public CollectionMonitorSummary(List<AggregationInfo> aggregationInfo, AggregationInfo lastIndexedVersion) {
|
||||
this.aggregationInfo = aggregationInfo;
|
||||
this.lastIndexedVersion = lastIndexedVersion;
|
||||
}
|
||||
|
||||
public List<AggregationInfo> getAggregationDetails() {
|
||||
return aggregationDetails;
|
||||
public List<AggregationInfo> getAggregationInfo() {
|
||||
return aggregationInfo;
|
||||
}
|
||||
|
||||
public void setAggregationDetails(List<AggregationInfo> aggregationDetails) {
|
||||
this.aggregationDetails = aggregationDetails;
|
||||
public void setAggregationInfo(List<AggregationInfo> aggregationInfo) {
|
||||
this.aggregationInfo = aggregationInfo;
|
||||
}
|
||||
|
||||
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?
|
||||
long start = System.currentTimeMillis();
|
||||
List<AggregationInfo> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(), 0, 20);
|
||||
for (AggregationInfo aggregationDetails : aggregationDetailsList) {
|
||||
if (aggregationDetails.isIndexedVersion()) {
|
||||
repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords());
|
||||
repositorySummaryInfo.setLastIndexedVersion(DateUtils.toDate(aggregationDetails.getDate()));
|
||||
List<AggregationInfo> aggregationInfoList = repositoryService.getRepositoryAggregations(repository.getId(), 0, 20);
|
||||
for (AggregationInfo aggregationInfo : aggregationInfoList) {
|
||||
if (aggregationInfo.isIndexedVersion()) {
|
||||
repositorySummaryInfo.setRecordsCollected(aggregationInfo.getNumberOfRecords());
|
||||
repositorySummaryInfo.setLastIndexedVersion(DateUtils.toDate(aggregationInfo.getDate()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,14 +101,13 @@ public class Converter {
|
|||
}
|
||||
|
||||
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");
|
||||
|
||||
for (int i = 0; i < aggregationInfo.length(); i++)
|
||||
// aggregationDetailsList.add(toAggregationDetails(aggregationInfo.getJSONObject(i)));
|
||||
aggregationDetailsList.add(objectMapper.convertValue(aggregationInfo.getJSONObject(i), AggregationInfo.class));
|
||||
aggregationInfoList.add(objectMapper.convertValue(aggregationInfo.getJSONObject(i), AggregationInfo.class));
|
||||
|
||||
return aggregationDetailsList;
|
||||
return aggregationInfoList;
|
||||
}
|
||||
|
||||
public List<Timezone> toTimezones(List<String> timezones) {
|
||||
|
@ -138,20 +137,5 @@ public class Converter {
|
|||
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