use of org.sagebionetworks.repo.model.storage.StorageUsageSummaryList in project Synapse-Repository-Services by Sage-Bionetworks.
the class StorageUsageServiceImplTest method testGetUsageForUserSameUser.
@Test
public void testGetUsageForUserSameUser() throws Exception {
StorageUsageSummaryList results = suService.getUsageForUser(userId, userId, dList);
Assert.assertNotNull(results);
}
use of org.sagebionetworks.repo.model.storage.StorageUsageSummaryList in project Synapse-Repository-Services by Sage-Bionetworks.
the class StorageLocationDAOImpl method getAggregatedUsageByUserInRange.
@Override
public StorageUsageSummaryList getAggregatedUsageByUserInRange(long beginIncl, long endExcl) {
if (beginIncl >= endExcl) {
String msg = "begin must be greater than end (begin = " + beginIncl;
msg += "; end = ";
msg += endExcl;
msg += ")";
throw new IllegalArgumentException(msg);
}
StorageUsageSummaryList summaryList = getAggregatedResults(COL_STORAGE_LOCATION_USER_ID, SELECT_AGGREGATED_USAGE_PART_1, SELECT_AGGREGATED_USAGE_PART_2, beginIncl, endExcl);
return summaryList;
}
use of org.sagebionetworks.repo.model.storage.StorageUsageSummaryList in project Synapse-Repository-Services by Sage-Bionetworks.
the class StorageLocationDAOImpl method getAggregatedResults.
/**
* Gets aggregated results. The results will be sorted in descending order.
* Gets the specific type of aggregations (sum, count, etc.)
* by passing in the appropriate SQL parts.
*/
private StorageUsageSummaryList getAggregatedResults(String column, String sqlPart1, String sqlPart2, long beginIncl, long endExcl) {
assert column != null;
assert sqlPart1 != null;
assert sqlPart2 != null;
assert beginIncl < endExcl;
List<String> columnList = new ArrayList<String>(1);
columnList.add(column);
String sql = getAggregateSql(sqlPart1, sqlPart2, columnList);
sql = sql + ORDER_BY_DESC_LIMIT;
MapSqlParameterSource paramMap = new MapSqlParameterSource();
paramMap.addValue(OFFSET_PARAM_NAME, beginIncl);
paramMap.addValue(LIMIT_PARAM_NAME, endExcl - beginIncl);
List<Map<String, Object>> rows = simpleJdbcTemplate.queryForList(sql, paramMap);
StorageUsageSummaryList summaryList = createEmptySummaryList(null);
List<StorageUsageSummary> summaries = summaryList.getSummaryList();
fillSummaryList(columnList, summaries, rows);
return summaryList;
}
use of org.sagebionetworks.repo.model.storage.StorageUsageSummaryList in project Synapse-Repository-Services by Sage-Bionetworks.
the class StorageLocationDAOImpl method getAggregatedResults.
/**
* Gets aggregated results. Gets the specific type of aggregations (sum, count, etc.)
* by passing in the appropriate SQL parts.
*/
private StorageUsageSummaryList getAggregatedResults(List<StorageUsageDimension> dimensionList, String sqlPart1, String sqlPart2) {
assert dimensionList != null;
assert sqlPart1 != null;
assert sqlPart2 != null;
StorageUsageSummaryList summaryList = createEmptySummaryList(null);
if (dimensionList.isEmpty()) {
return summaryList;
}
List<String> columnList = getGroupByColumns(dimensionList);
assert columnList.size() > 0 : "We should have returned otherwise.";
String sql = getAggregateSql(sqlPart1, sqlPart2, columnList);
List<Map<String, Object>> rows = simpleJdbcTemplate.queryForList(sql);
List<StorageUsageSummary> summaries = summaryList.getSummaryList();
fillSummaryList(columnList, summaries, rows);
return summaryList;
}
use of org.sagebionetworks.repo.model.storage.StorageUsageSummaryList in project Synapse-Repository-Services by Sage-Bionetworks.
the class StorageLocationDAOImpl method getAggregatedResultsForUser.
/**
* Gets aggregated results for user. Gets the specific type of aggregations (sum, count, etc.)
* by passing in the appropriate SQL parts.
*/
private StorageUsageSummaryList getAggregatedResultsForUser(String userId, List<StorageUsageDimension> dimensionList, String sqlPart1, String sqlPart2) throws DatastoreException, InvalidModelException {
assert userId != null;
assert dimensionList != null;
assert sqlPart1 != null;
assert sqlPart2 != null;
StorageUsageSummaryList summaryList = createEmptySummaryList(userId);
if (dimensionList.isEmpty()) {
return summaryList;
}
List<String> columnList = getGroupByColumns(dimensionList);
assert columnList.size() > 0 : "We should have returned otherwise.";
String sql = getAggregateSql(sqlPart1, sqlPart2, columnList);
MapSqlParameterSource paramMap = new MapSqlParameterSource();
Long userIdLong = KeyFactory.stringToKey(userId);
paramMap.addValue(COL_STORAGE_LOCATION_USER_ID, userIdLong);
List<Map<String, Object>> rows = simpleJdbcTemplate.queryForList(sql, paramMap);
List<StorageUsageSummary> summaries = summaryList.getSummaryList();
fillSummaryList(columnList, summaries, rows);
return summaryList;
}
Aggregations