Search in sources :

Example 1 with GlobalPolicyListDTO

use of org.wso2.carbon.apimgt.internal.service.dto.GlobalPolicyListDTO in project carbon-apimgt by wso2.

the class SubscriptionValidationDataUtil method fromGlobalPolicyToGlobalPolicyListDTO.

/**
 * Converts a list of global policy objects into a global policy list DTO object.
 *
 * @param globalPolicies list of global policy objects
 * @return global policy list DTO
 */
public static GlobalPolicyListDTO fromGlobalPolicyToGlobalPolicyListDTO(List<GlobalPolicy> globalPolicies) {
    GlobalPolicyListDTO globalPolicyListDTO = new GlobalPolicyListDTO();
    if (globalPolicies != null) {
        for (GlobalPolicy globalPolicy : globalPolicies) {
            GlobalPolicyDTO globalPolicyDTO = new GlobalPolicyDTO();
            globalPolicyDTO.setId(globalPolicy.getId());
            globalPolicyDTO.setName(globalPolicy.getName());
            globalPolicyDTO.setTenantId(globalPolicy.getTenantId());
            globalPolicyDTO.setTenantDomain(globalPolicy.getTenantDomain());
            globalPolicyDTO.setSiddhiQuery(globalPolicy.getSiddhiQuery());
            globalPolicyDTO.setKeyTemplate(globalPolicy.getKeyTemplate());
            globalPolicyListDTO.getList().add(globalPolicyDTO);
        }
        globalPolicyListDTO.setCount(globalPolicies.size());
    } else {
        globalPolicyListDTO.setCount(0);
    }
    return globalPolicyListDTO;
}
Also used : GlobalPolicyListDTO(org.wso2.carbon.apimgt.internal.service.dto.GlobalPolicyListDTO) GlobalPolicyDTO(org.wso2.carbon.apimgt.internal.service.dto.GlobalPolicyDTO) GlobalPolicy(org.wso2.carbon.apimgt.api.model.subscription.GlobalPolicy)

Aggregations

GlobalPolicy (org.wso2.carbon.apimgt.api.model.subscription.GlobalPolicy)1 GlobalPolicyDTO (org.wso2.carbon.apimgt.internal.service.dto.GlobalPolicyDTO)1 GlobalPolicyListDTO (org.wso2.carbon.apimgt.internal.service.dto.GlobalPolicyListDTO)1