use of org.wso2.carbon.apimgt.core.models.analytics.ApplicationCount in project carbon-apimgt by wso2.
the class AnalyticsMappingUtilTestCase method fromApplicationCountToListDTOTest.
@Test
public void fromApplicationCountToListDTOTest() {
List<ApplicationCount> applicationCountList = new ArrayList<>();
applicationCountList.add(SampleTestObjectCreator.createRandomApplicationCountObject());
applicationCountList.add(SampleTestObjectCreator.createRandomApplicationCountObject());
applicationCountList.add(SampleTestObjectCreator.createRandomApplicationCountObject());
ApplicationCountListDTO applicationCountListDTO = AnalyticsMappingUtil.fromApplicationCountToListDTO(applicationCountList, ZoneOffset.UTC);
Assert.assertEquals(applicationCountList.size(), applicationCountListDTO.getList().size());
for (int i = 0; i < applicationCountList.size(); i++) {
Assert.assertEquals(epochToISO8601DateTime(applicationCountList.get(i).getTimestamp(), ZoneOffset.UTC), applicationCountListDTO.getList().get(i).getTime());
}
}
use of org.wso2.carbon.apimgt.core.models.analytics.ApplicationCount in project carbon-apimgt by wso2.
the class ApplicationApiServiceImpl method applicationCountOverTimeGet.
/**
* Get list of Application count information
*
* @param startTime Filter for start time stamp
* @param endTime Filter for end time stamp
* @param createdBy Filter for application creator
* @param request MSF4J request
* @return Application count over time
* @throws NotFoundException When the particular resource does not exist in the system
*/
@Override
public Response applicationCountOverTimeGet(String startTime, String endTime, String createdBy, Request request) throws NotFoundException {
String username = RestApiUtil.getLoggedInUsername(request);
try {
log.debug("Retrieving applications created over time. [From: {} to: {} Created By: {}]", startTime, endTime, createdBy);
Analyzer analyzer = RestApiUtil.getAnalyzer(username);
ZoneId requestTimezone = RestApiUtil.getRequestTimeZone(startTime);
List<ApplicationCount> applicationCountList = analyzer.getApplicationCount(fromISO8601ToInstant(startTime), fromISO8601ToInstant(endTime), createdBy);
ApplicationCountListDTO applicationCountListDTO = AnalyticsMappingUtil.fromApplicationCountToListDTO(applicationCountList, requestTimezone);
return Response.ok().entity(applicationCountListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving application created over time info";
ErrorDTO errorDTO = RestApiUtil.getErrorDTO(e.getErrorHandler());
log.error(errorMessage, e);
return Response.status(e.getErrorHandler().getHttpStatusCode()).entity(errorDTO).build();
}
}
use of org.wso2.carbon.apimgt.core.models.analytics.ApplicationCount in project carbon-apimgt by wso2.
the class AnalyticsMappingUtil method fromApplicationCountToDTO.
private static ApplicationCountDTO fromApplicationCountToDTO(ApplicationCount applicationCount, ZoneId zoneId) {
ApplicationCountDTO applicationCountDTO = new ApplicationCountDTO();
applicationCountDTO.setTime(epochToISO8601DateTime(applicationCount.getTimestamp(), zoneId));
applicationCountDTO.setCount(applicationCount.getCount());
return applicationCountDTO;
}
Aggregations