Search in sources :

Example 1 with ApplicationInfoDTO

use of org.wso2.carbon.apimgt.rest.api.store.dto.ApplicationInfoDTO in project carbon-apimgt by wso2.

the class ApplicationMappingUtil method fromApplicationsToDTO.

/**
 * Converts an Application[] array into a corresponding ApplicationListDTO
 *
 * @param applications array of Application objects
 * @param limit limit parameter
 * @param offset starting index
 * @return ApplicationListDTO object corresponding to Application[] array
 */
public static ApplicationListDTO fromApplicationsToDTO(List<Application> applications, int limit, int offset) {
    ApplicationListDTO applicationListDTO = new ApplicationListDTO();
    List<ApplicationInfoDTO> applicationInfoDTOs = applicationListDTO.getList();
    if (applicationInfoDTOs == null) {
        applicationInfoDTOs = new ArrayList<>();
        applicationListDTO.setList(applicationInfoDTOs);
    }
    // identifying the proper start and end indexes
    int start = offset < applications.size() && offset >= 0 ? offset : Integer.MAX_VALUE;
    int end = offset + limit - 1 <= applications.size() - 1 ? offset + limit - 1 : applications.size() - 1;
    for (int i = start; i <= end; i++) {
        applicationInfoDTOs.add(fromApplicationToInfoDTO(applications.get(i)));
    }
    applicationListDTO.setCount(applicationInfoDTOs.size());
    return applicationListDTO;
}
Also used : ApplicationInfoDTO(org.wso2.carbon.apimgt.rest.api.store.dto.ApplicationInfoDTO) ApplicationListDTO(org.wso2.carbon.apimgt.rest.api.store.dto.ApplicationListDTO)

Example 2 with ApplicationInfoDTO

use of org.wso2.carbon.apimgt.rest.api.store.dto.ApplicationInfoDTO in project carbon-apimgt by wso2.

the class ApplicationMappingUtil method fromApplicationToInfoDTO.

public static ApplicationInfoDTO fromApplicationToInfoDTO(Application application) {
    ApplicationInfoDTO applicationInfoDTO = new ApplicationInfoDTO();
    applicationInfoDTO.setApplicationId(application.getId());
    applicationInfoDTO.setThrottlingTier(application.getPolicy().getPolicyName());
    applicationInfoDTO.setDescription(application.getDescription());
    applicationInfoDTO.setLifeCycleStatus(application.getStatus());
    applicationInfoDTO.setName(application.getName());
    applicationInfoDTO.setSubscriber(application.getCreatedUser());
    return applicationInfoDTO;
}
Also used : ApplicationInfoDTO(org.wso2.carbon.apimgt.rest.api.store.dto.ApplicationInfoDTO)

Aggregations

ApplicationInfoDTO (org.wso2.carbon.apimgt.rest.api.store.dto.ApplicationInfoDTO)2 ApplicationListDTO (org.wso2.carbon.apimgt.rest.api.store.dto.ApplicationListDTO)1