Search in sources :

Example 1 with APISearchResultDTO

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

the class SearchResultMappingUtil method fromAPIToAPIResultDTO.

/**
 * Get API result representation for content search.
 *
 * @param api API
 * @return APISearchResultDTO
 */
public static APISearchResultDTO fromAPIToAPIResultDTO(API api) {
    APISearchResultDTO apiResultDTO = new APISearchResultDTO();
    apiResultDTO.setId(api.getUUID());
    APIIdentifier apiId = api.getId();
    apiResultDTO.setName(apiId.getApiName());
    apiResultDTO.setVersion(apiId.getVersion());
    apiResultDTO.setProvider(APIUtil.replaceEmailDomainBack(apiId.getProviderName()));
    String context = api.getContextTemplate();
    if (context.endsWith("/" + RestApiConstants.API_VERSION_PARAM)) {
        context = context.replace("/" + RestApiConstants.API_VERSION_PARAM, "");
    }
    apiResultDTO.setContext(context);
    apiResultDTO.setContextTemplate(api.getContextTemplate());
    apiResultDTO.setType(SearchResultDTO.TypeEnum.API);
    apiResultDTO.setTransportType(api.getType());
    apiResultDTO.setDescription(api.getDescription());
    apiResultDTO.setStatus(api.getStatus());
    apiResultDTO.setThumbnailUri(api.getThumbnailUrl());
    apiResultDTO.setAdvertiseOnly(api.isAdvertiseOnly());
    return apiResultDTO;
}
Also used : APISearchResultDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APISearchResultDTO) APIIdentifier(org.wso2.carbon.apimgt.api.model.APIIdentifier)

Example 2 with APISearchResultDTO

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

the class SearchResultMappingUtil method fromAPIToAPIResultDTO.

/**
 * Get API result representation for content search
 * @param apiProduct API product
 * @return APISearchResultDTO
 */
public static APISearchResultDTO fromAPIToAPIResultDTO(APIProduct apiProduct) {
    APISearchResultDTO apiResultDTO = new APISearchResultDTO();
    apiResultDTO.setId(apiProduct.getUuid());
    APIProductIdentifier apiId = apiProduct.getId();
    apiResultDTO.setName(apiId.getName());
    apiResultDTO.setVersion(apiId.getVersion());
    apiResultDTO.setProvider(APIUtil.replaceEmailDomainBack(apiId.getProviderName()));
    String context = apiProduct.getContextTemplate();
    if (context.endsWith("/" + RestApiConstants.API_VERSION_PARAM)) {
        context = context.replace("/" + RestApiConstants.API_VERSION_PARAM, "");
    }
    apiResultDTO.setContext(context);
    apiResultDTO.setAvgRating(String.valueOf(apiProduct.getRating()));
    APIBusinessInformationDTO apiBusinessInformationDTO = new APIBusinessInformationDTO();
    apiBusinessInformationDTO.setBusinessOwner(apiProduct.getBusinessOwner());
    apiBusinessInformationDTO.setBusinessOwnerEmail(apiProduct.getBusinessOwnerEmail());
    apiBusinessInformationDTO.setTechnicalOwner(apiProduct.getTechnicalOwner());
    apiBusinessInformationDTO.setTechnicalOwnerEmail(apiProduct.getTechnicalOwnerEmail());
    apiResultDTO.setBusinessInformation(apiBusinessInformationDTO);
    apiResultDTO.setType(SearchResultDTO.TypeEnum.API);
    apiResultDTO.setTransportType(apiProduct.getType());
    apiResultDTO.setDescription(apiProduct.getDescription());
    apiResultDTO.setStatus(apiProduct.getState());
    apiResultDTO.setThumbnailUri(apiProduct.getThumbnailUrl());
    return apiResultDTO;
}
Also used : APIBusinessInformationDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.APIBusinessInformationDTO) APISearchResultDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.APISearchResultDTO) APIProductIdentifier(org.wso2.carbon.apimgt.api.model.APIProductIdentifier)

Example 3 with APISearchResultDTO

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

the class SearchResultMappingUtil method fromAPIToAPIResultDTO.

/**
 * Get API result representation for content search
 * @param api API
 * @return
 */
public static APISearchResultDTO fromAPIToAPIResultDTO(API api) {
    APISearchResultDTO apiResultDTO = new APISearchResultDTO();
    apiResultDTO.setId(api.getUUID());
    APIIdentifier apiId = api.getId();
    apiResultDTO.setName(apiId.getApiName());
    apiResultDTO.setVersion(apiId.getVersion());
    apiResultDTO.setProvider(APIUtil.replaceEmailDomainBack(apiId.getProviderName()));
    String context = api.getContextTemplate();
    if (context.endsWith("/" + RestApiConstants.API_VERSION_PARAM)) {
        context = context.replace("/" + RestApiConstants.API_VERSION_PARAM, "");
    }
    apiResultDTO.setContext(context);
    apiResultDTO.setAvgRating(String.valueOf(api.getRating()));
    APIBusinessInformationDTO apiBusinessInformationDTO = new APIBusinessInformationDTO();
    apiBusinessInformationDTO.setBusinessOwner(api.getBusinessOwner());
    apiBusinessInformationDTO.setBusinessOwnerEmail(api.getBusinessOwnerEmail());
    apiBusinessInformationDTO.setTechnicalOwner(api.getTechnicalOwner());
    apiBusinessInformationDTO.setTechnicalOwnerEmail(api.getTechnicalOwnerEmail());
    apiResultDTO.setBusinessInformation(apiBusinessInformationDTO);
    apiResultDTO.setType(SearchResultDTO.TypeEnum.API);
    apiResultDTO.setTransportType(api.getType());
    apiResultDTO.setDescription(api.getDescription());
    apiResultDTO.setStatus(api.getStatus());
    apiResultDTO.setThumbnailUri(api.getThumbnailUrl());
    return apiResultDTO;
}
Also used : APIBusinessInformationDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.APIBusinessInformationDTO) APISearchResultDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.APISearchResultDTO) APIIdentifier(org.wso2.carbon.apimgt.api.model.APIIdentifier)

Aggregations

APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)2 APIBusinessInformationDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.APIBusinessInformationDTO)2 APISearchResultDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.APISearchResultDTO)2 APIProductIdentifier (org.wso2.carbon.apimgt.api.model.APIProductIdentifier)1 APISearchResultDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APISearchResultDTO)1