72788: Feedback processed: Javadoc, moved service > util, config comment

This commit is contained in:
Marie Verdonck
2020-09-04 12:26:18 +02:00
parent c88b6ef2e7
commit 88fbb77aa5
7 changed files with 130 additions and 13 deletions

View File

@@ -15,6 +15,9 @@ package org.dspace.app.rest.model;
*/
public class UsageReportPointDsoTotalVisitsRest extends UsageReportPointRest {
/**
* Type of dso a UsageReport is being requested of (e.g. item, bitstream, ...)
*/
private String type;
@Override
@@ -22,6 +25,11 @@ public class UsageReportPointDsoTotalVisitsRest extends UsageReportPointRest {
return this.type;
}
/**
* Sets the type of this {@link UsageReportPointRest} object, should be type of dso concerned (e.g. item, bitstream, ...)
*
* @param type Type of dso a {@link UsageReportRest} object is being requested of (e.g. item, bitstream, ...)
*/
public void setType(String type) {
this.type = type;
}

View File

@@ -24,30 +24,69 @@ public class UsageReportPointRest extends BaseObjectRest<String> {
protected String label;
private Map<String, Integer> values;
/**
* Returns the category of this Rest object, {@link #CATEGORY}
*
* @return The category of this Rest object, {@link #CATEGORY}
*/
@Override
public String getCategory() {
return CATEGORY;
}
/**
* Return controller class responsible for this Rest object
*
* @return Controller class responsible for this Rest object
*/
@Override
public Class getController() {
return StatisticsRestController.class;
}
/**
* Returns the type of this {@link UsageReportPointRest} object
*
* @return Type of this {@link UsageReportPointRest} object
*/
@Override
public String getType() {
return NAME;
}
/**
* Returns the values of this {@link UsageReportPointRest} object, containing the amount of views
*
* @return The values of this {@link UsageReportPointRest} object, containing the amount of views
*/
public Map<String, Integer> getValues() {
return values;
}
/**
* Returns the id of this {@link UsageReportPointRest} object, of the form: type of UsageReport_dso uuid
*
* @return The id of this {@link UsageReportPointRest} object, of the form: type of UsageReport_dso uuid
*/
public String getId() {
return id;
}
/**
* Set the id of this {@link UsageReportPointRest} object, of the form: type of UsageReport_dso uuid
*
* @param id The id of this {@link UsageReportPointRest} object, of the form: type of UsageReport_dso uuid
*/
public void setId(String id) {
this.id = id;
}
/**
* Add a value pair to this {@link UsageReportPointRest} object's values
*
* @param key Key of new value pair
* @param value Value of new value pair
*/
public void addValue(String key, Integer value) {
if (values == null) {
values = new HashMap<>();
@@ -55,14 +94,29 @@ public class UsageReportPointRest extends BaseObjectRest<String> {
values.put(key, value);
}
/**
* Sets all values of this {@link UsageReportPointRest} object
*
* @param values All values of this {@link UsageReportPointRest} object
*/
public void setValues(Map<String, Integer> values) {
this.values = values;
}
/**
* Returns label of this {@link UsageReportPointRest} object, e.g. the dso's name
*
* @return Label of this {@link UsageReportPointRest} object, e.g. the dso's name
*/
public String getLabel() {
return label;
}
/**
* Sets the label of this {@link UsageReportPointRest} object, e.g. the dso's name
*
* @param label Label of this {@link UsageReportPointRest} object, e.g. the dso's name
*/
public void setLabel(String label) {
this.label = label;
}

View File

@@ -26,26 +26,69 @@ public class UsageReportRest extends BaseObjectRest<String> {
private String reportType;
private List<UsageReportPointRest> points;
/**
* Returns the category of this Rest object, {@link #CATEGORY}
*
* @return The category of this Rest object, {@link #CATEGORY}
*/
@Override
public String getCategory() {
return CATEGORY;
}
/**
* Return controller class responsible for this Rest object
*
* @return Controller class responsible for this Rest object
*/
@Override
public Class getController() {
return StatisticsRestController.class;
}
/**
* Returns the type of this {@link UsageReportRest} object
*
* @return Type of this {@link UsageReportRest} object
*/
@Override
public String getType() {
return NAME;
}
/**
* Returns the report type of this UsageReport, options listed in
* {@link org.dspace.app.rest.utils.UsageReportUtils}, e.g.
* {@link org.dspace.app.rest.utils.UsageReportUtils#TOTAL_VISITS_REPORT_ID}
*
* @return The report type of this UsageReport, options listed in
* {@link org.dspace.app.rest.utils.UsageReportUtils}, e.g.
* {@link org.dspace.app.rest.utils.UsageReportUtils#TOTAL_VISITS_REPORT_ID}
*/
public String getReportType() {
return reportType;
}
/**
* Sets the report type of this UsageReport, options listed in
* {@link org.dspace.app.rest.utils.UsageReportUtils}, e.g.
* {@link org.dspace.app.rest.utils.UsageReportUtils#TOTAL_VISITS_REPORT_ID}
*
* @param reportType The report type of this UsageReport, options listed in
* {@link org.dspace.app.rest.utils.UsageReportUtils}, e.g.
* {@link org.dspace.app.rest.utils.UsageReportUtils#TOTAL_VISITS_REPORT_ID}
*/
public void setReportType(String reportType) {
this.reportType = reportType;
}
/**
* Returns the list of {@link UsageReportPointRest} objects attached to this {@link UsageReportRest} object, or
* empty list if none
*
* @return The list of {@link UsageReportPointRest} objects attached to this {@link UsageReportRest} object, or
* empty list if none
*/
public List<UsageReportPointRest> getPoints() {
if (points == null) {
points = new ArrayList<>();
@@ -53,6 +96,11 @@ public class UsageReportRest extends BaseObjectRest<String> {
return points;
}
/**
* Adds a {@link UsageReportPointRest} object to this {@link UsageReportRest} object
*
* @param point {@link UsageReportPointRest} to add to this {@link UsageReportRest} object
*/
public void addPoint(UsageReportPointRest point) {
if (points == null) {
points = new ArrayList<>();
@@ -60,6 +108,11 @@ public class UsageReportRest extends BaseObjectRest<String> {
points.add(point);
}
/**
* Set all {@link UsageReportPointRest} objects on this {@link UsageReportRest} object
*
* @param points All {@link UsageReportPointRest} objects on this {@link UsageReportRest} object
*/
public void setPoints(List<UsageReportPointRest> points) {
this.points = points;
}

View File

@@ -20,6 +20,7 @@ import org.dspace.app.rest.SearchRestMethod;
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
import org.dspace.app.rest.model.StatisticsSupportRest;
import org.dspace.app.rest.model.UsageReportRest;
import org.dspace.app.rest.utils.UsageReportUtils;
import org.dspace.core.Context;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@@ -31,7 +32,7 @@ import org.springframework.stereotype.Component;
public class StatisticsRestRepository extends DSpaceRestRepository<UsageReportRest, String> {
@Autowired
private UsageReportService usageReportService;
private UsageReportUtils usageReportUtils;
public StatisticsSupportRest getStatisticsSupport() {
return new StatisticsSupportRest();
@@ -45,7 +46,7 @@ public class StatisticsRestRepository extends DSpaceRestRepository<UsageReportRe
UsageReportRest usageReportRest = null;
try {
usageReportRest = usageReportService.createUsageReport(context, uuidObject, reportId);
usageReportRest = usageReportUtils.createUsageReport(context, uuidObject, reportId);
} catch (ParseException | SolrServerException | IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
@@ -59,7 +60,7 @@ public class StatisticsRestRepository extends DSpaceRestRepository<UsageReportRe
UUID uuid = UUID.fromString(StringUtils.substringAfterLast(uri, "/"));
List<UsageReportRest> usageReportsOfItem = null;
try {
usageReportsOfItem = usageReportService.getUsageReportsOfDSO(obtainContext(), uuid);
usageReportsOfItem = usageReportUtils.getUsageReportsOfDSO(obtainContext(), uuid);
} catch (SQLException | ParseException | SolrServerException | IOException e) {
throw new RuntimeException(e.getMessage(), e);
}

View File

@@ -5,7 +5,7 @@
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.repository;
package org.dspace.app.rest.utils;
import java.io.IOException;
import java.sql.SQLException;
@@ -22,7 +22,7 @@ import org.dspace.app.rest.model.UsageReportPointCountryRest;
import org.dspace.app.rest.model.UsageReportPointDateRest;
import org.dspace.app.rest.model.UsageReportPointDsoTotalVisitsRest;
import org.dspace.app.rest.model.UsageReportRest;
import org.dspace.app.rest.utils.DSpaceObjectUtils;
import org.dspace.app.rest.repository.AbstractDSpaceRestRepository;
import org.dspace.content.Bitstream;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
@@ -47,7 +47,7 @@ import org.springframework.stereotype.Component;
* @author Maria Verdonck (Atmire) on 08/06/2020
*/
@Component
public class UsageReportService extends AbstractDSpaceRestRepository {
public class UsageReportUtils extends AbstractDSpaceRestRepository {
@Autowired
private DSpaceObjectUtils dspaceObjectUtil;

View File

@@ -9,11 +9,11 @@ package org.dspace.app.rest;
import static org.apache.commons.codec.CharEncoding.UTF_8;
import static org.apache.commons.io.IOUtils.toInputStream;
import static org.dspace.app.rest.repository.UsageReportService.TOP_CITIES_REPORT_ID;
import static org.dspace.app.rest.repository.UsageReportService.TOP_COUNTRIES_REPORT_ID;
import static org.dspace.app.rest.repository.UsageReportService.TOTAL_DOWNLOADS_REPORT_ID;
import static org.dspace.app.rest.repository.UsageReportService.TOTAL_VISITS_PER_MONTH_REPORT_ID;
import static org.dspace.app.rest.repository.UsageReportService.TOTAL_VISITS_REPORT_ID;
import static org.dspace.app.rest.utils.UsageReportUtils.TOP_CITIES_REPORT_ID;
import static org.dspace.app.rest.utils.UsageReportUtils.TOP_COUNTRIES_REPORT_ID;
import static org.dspace.app.rest.utils.UsageReportUtils.TOTAL_DOWNLOADS_REPORT_ID;
import static org.dspace.app.rest.utils.UsageReportUtils.TOTAL_VISITS_PER_MONTH_REPORT_ID;
import static org.dspace.app.rest.utils.UsageReportUtils.TOTAL_VISITS_REPORT_ID;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.not;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
@@ -37,8 +37,8 @@ import org.dspace.app.rest.model.UsageReportPointDsoTotalVisitsRest;
import org.dspace.app.rest.model.UsageReportPointRest;
import org.dspace.app.rest.model.ViewEventRest;
import org.dspace.app.rest.repository.StatisticsRestRepository;
import org.dspace.app.rest.repository.UsageReportService;
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
import org.dspace.app.rest.utils.UsageReportUtils;
import org.dspace.authorize.service.AuthorizeService;
import org.dspace.builder.BitstreamBuilder;
import org.dspace.builder.CollectionBuilder;
@@ -64,7 +64,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
/**
* Integration test to test the /api/statistics/usagereports/ endpoints, see {@link UsageReportService} and
* Integration test to test the /api/statistics/usagereports/ endpoints, see {@link UsageReportUtils} and
* {@link StatisticsRestRepository}
*
* @author Maria Verdonck (Atmire) on 10/06/2020

View File

@@ -42,4 +42,5 @@ usage-statistics.authorization.admin.workflow=true
#usage-statistics.bots.case-insensitive = false
# Set to true if the statistics core is sharded into a core per year, defaults to false
# If you are sharding your statistics index each year by running "dspace stats-util -s", you should set this to "true"
usage-statistics.shardedByYear = false