Search in sources :

Example 1 with APIExternalStoreDTO

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

the class ExternalStoreMappingUtil method fromAPIExternalStoreToDTO.

/**
 * Converts APIStore object to APIExternalStoreDTO object.
 *
 * @param apiStore API Store
 * @return APIExternalStoreDTO
 */
public static APIExternalStoreDTO fromAPIExternalStoreToDTO(APIStore apiStore) {
    APIExternalStoreDTO apiExternalStoreDTO = new APIExternalStoreDTO();
    apiExternalStoreDTO.setId(apiStore.getName());
    if (apiStore.getLastUpdated() != null) {
        Date lastUpdateDate = apiStore.getLastUpdated();
        Timestamp timeStamp = new Timestamp(lastUpdateDate.getTime());
        apiExternalStoreDTO.setLastUpdatedTime(String.valueOf(timeStamp));
    }
    return apiExternalStoreDTO;
}
Also used : Timestamp(java.sql.Timestamp) Date(java.util.Date) APIExternalStoreDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIExternalStoreDTO)

Example 2 with APIExternalStoreDTO

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

the class ExternalStoreMappingUtil method fromAPIExternalStoreCollectionToDTO.

/**
 * Converts list of APIStore object into APIExternalStoreListDTO object.
 *
 * @param externalStoreCollection a collection of APIStore objects
 * @return APIExternalStoreListDTO object containing APIExternalStoreDTOs
 */
public static APIExternalStoreListDTO fromAPIExternalStoreCollectionToDTO(Collection<APIStore> externalStoreCollection) {
    APIExternalStoreListDTO apiExternalStoreListDTO = new APIExternalStoreListDTO();
    List<APIExternalStoreDTO> apiExternalStoreDTOS = apiExternalStoreListDTO.getList();
    if (externalStoreCollection == null) {
        externalStoreCollection = new HashSet<>();
    }
    for (APIStore externalStore : externalStoreCollection) {
        apiExternalStoreDTOS.add(fromAPIExternalStoreToDTO(externalStore));
    }
    apiExternalStoreListDTO.setList(apiExternalStoreDTOS);
    apiExternalStoreListDTO.setCount(apiExternalStoreDTOS.size());
    return apiExternalStoreListDTO;
}
Also used : APIExternalStoreListDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIExternalStoreListDTO) APIExternalStoreDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIExternalStoreDTO) APIStore(org.wso2.carbon.apimgt.api.model.APIStore)

Aggregations

APIExternalStoreDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIExternalStoreDTO)2 Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 APIStore (org.wso2.carbon.apimgt.api.model.APIStore)1 APIExternalStoreListDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIExternalStoreListDTO)1