Search in sources :

Example 1 with MediationInfoDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.MediationInfoDTO in project carbon-apimgt by wso2.

the class MediationMappingUtil method fromMediationInfoToDTO.

/**
 * Converts an Mediation object into MediationInfoDTO
 *
 * @param mediation Mediation object
 * @return MediationInfoDTO object corresponding to the given Mediation object
 */
public static MediationInfoDTO fromMediationInfoToDTO(Mediation mediation) {
    MediationInfoDTO mediationInfoDTO = new MediationInfoDTO();
    mediationInfoDTO.setId(mediation.getUuid());
    mediationInfoDTO.setName(mediation.getName());
    mediationInfoDTO.setType(MediationInfoDTO.TypeEnum.valueOf(mediation.getType().toUpperCase()));
    return mediationInfoDTO;
}
Also used : MediationInfoDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.MediationInfoDTO)

Example 2 with MediationInfoDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.MediationInfoDTO in project carbon-apimgt by wso2.

the class MediationMappingUtil method fromMediationListToDTO.

/**
 * Converts a List mediation objects into a DTO
 *
 * @param mediation a list of mediation objects
 * @param limit     max number of objects returned
 * @param offset    starting index
 * @return MediationListDTO object containing MediationInfoDTO
 */
public static MediationListDTO fromMediationListToDTO(List<Mediation> mediation, int offset, int limit) {
    MediationListDTO mediationListDTO = new MediationListDTO();
    List<MediationInfoDTO> mediationDTOs = mediationListDTO.getList();
    if (mediationDTOs == null) {
        mediationDTOs = new ArrayList<>();
        mediationListDTO.setList(mediationDTOs);
    }
    // identifying the proper start and end indexes
    int size = mediation.size();
    int start = offset < size && offset >= 0 ? offset : Integer.MAX_VALUE;
    int end = offset + limit - 1 <= size - 1 ? offset + limit - 1 : size - 1;
    for (int i = start; i <= end; i++) {
        mediationDTOs.add(fromMediationInfoToDTO(mediation.get(i)));
    }
    mediationListDTO.setCount(mediationDTOs.size());
    return mediationListDTO;
}
Also used : MediationInfoDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.MediationInfoDTO) MediationListDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.MediationListDTO)

Example 3 with MediationInfoDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.MediationInfoDTO in project carbon-apimgt by wso2.

the class MediationMappingUtil method fromMediationInfoToDTO.

/**
 * Converts an Mediation object into MediationInfoDTO
 *
 * @param mediation Mediation object
 * @return MediationInfoDTO object corresponding to the given Mediation object
 */
public static MediationInfoDTO fromMediationInfoToDTO(Mediation mediation) {
    MediationInfoDTO mediationInfoDTO = new MediationInfoDTO();
    mediationInfoDTO.setId(mediation.getUuid());
    mediationInfoDTO.setName(mediation.getName());
    mediationInfoDTO.setType(MediationInfoDTO.TypeEnum.valueOf(mediation.getType().toUpperCase()));
    return mediationInfoDTO;
}
Also used : MediationInfoDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.MediationInfoDTO)

Example 4 with MediationInfoDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.MediationInfoDTO in project carbon-apimgt by wso2.

the class MediationMappingUtil method fromMediationListToDTO.

/**
 * Converts a List mediation objects into a DTO
 *
 * @param mediation a list of mediation objects
 * @param limit     max number of objects returned
 * @param offset    starting index
 * @return TierListDTO object containing TierDTOs
 */
public static MediationListDTO fromMediationListToDTO(List<Mediation> mediation, int offset, int limit) {
    MediationListDTO mediationListDTO = new MediationListDTO();
    List<MediationInfoDTO> mediationDTOs = mediationListDTO.getList();
    if (mediationDTOs == null) {
        mediationDTOs = new ArrayList<>();
        mediationListDTO.setList(mediationDTOs);
    }
    // identifying the proper start and end indexes
    int size = mediation.size();
    int start = offset < size && offset >= 0 ? offset : Integer.MAX_VALUE;
    int end = offset + limit - 1 <= size - 1 ? offset + limit - 1 : size - 1;
    for (int i = start; i <= end; i++) {
        mediationDTOs.add(fromMediationInfoToDTO(mediation.get(i)));
    }
    mediationListDTO.setCount(mediationDTOs.size());
    return mediationListDTO;
}
Also used : MediationInfoDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.MediationInfoDTO) MediationListDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.MediationListDTO)

Aggregations

MediationInfoDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.MediationInfoDTO)2 MediationInfoDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.MediationInfoDTO)2 MediationListDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.MediationListDTO)1 MediationListDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.MediationListDTO)1