Search in sources :

Example 1 with APIOperationPoliciesDTO

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

the class OperationPolicyMappingUtil method fromOperationPolicyListToDTO.

public static APIOperationPoliciesDTO fromOperationPolicyListToDTO(List<OperationPolicy> operationPolicyList) {
    APIOperationPoliciesDTO dto = new APIOperationPoliciesDTO();
    List<OperationPolicyDTO> request = new ArrayList<>();
    List<OperationPolicyDTO> response = new ArrayList<>();
    List<OperationPolicyDTO> fault = new ArrayList<>();
    for (OperationPolicy op : operationPolicyList) {
        OperationPolicyDTO policyDTO = fromOperationPolicyToDTO(op);
        if (APIConstants.OPERATION_SEQUENCE_TYPE_REQUEST.equals(op.getDirection())) {
            request.add(policyDTO);
        } else if (APIConstants.OPERATION_SEQUENCE_TYPE_RESPONSE.equals(op.getDirection())) {
            response.add(policyDTO);
        } else if (APIConstants.OPERATION_SEQUENCE_TYPE_FAULT.equals(op.getDirection())) {
            fault.add(policyDTO);
        }
    }
    dto.setRequest(request);
    dto.setResponse(response);
    dto.setFault(fault);
    return dto;
}
Also used : APIOperationPoliciesDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIOperationPoliciesDTO) OperationPolicyDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicyDTO) OperationPolicy(org.wso2.carbon.apimgt.api.model.OperationPolicy) ArrayList(java.util.ArrayList)

Example 2 with APIOperationPoliciesDTO

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

the class OperationPolicyMappingUtil method fromDTOToAPIOperationPoliciesList.

public static List<OperationPolicy> fromDTOToAPIOperationPoliciesList(APIOperationPoliciesDTO apiOperationPoliciesDTO) {
    List<OperationPolicy> operationPoliciesList = new ArrayList<>();
    if (apiOperationPoliciesDTO != null) {
        List<OperationPolicyDTO> request = apiOperationPoliciesDTO.getRequest();
        List<OperationPolicyDTO> response = apiOperationPoliciesDTO.getResponse();
        List<OperationPolicyDTO> fault = apiOperationPoliciesDTO.getFault();
        int requestCount = 1;
        int responseCount = 1;
        int faultCount = 1;
        for (OperationPolicyDTO op : request) {
            OperationPolicy operationPolicy = fromDTOToOperationPolicy(op);
            operationPolicy.setDirection(APIConstants.OPERATION_SEQUENCE_TYPE_REQUEST);
            operationPolicy.setOrder(requestCount);
            operationPoliciesList.add(operationPolicy);
            requestCount += 1;
        }
        for (OperationPolicyDTO op : response) {
            OperationPolicy operationPolicy = fromDTOToOperationPolicy(op);
            operationPolicy.setDirection(APIConstants.OPERATION_SEQUENCE_TYPE_RESPONSE);
            operationPolicy.setOrder(responseCount);
            operationPoliciesList.add(operationPolicy);
            responseCount += 1;
        }
        for (OperationPolicyDTO op : fault) {
            OperationPolicy operationPolicy = fromDTOToOperationPolicy(op);
            operationPolicy.setDirection(APIConstants.OPERATION_SEQUENCE_TYPE_FAULT);
            operationPolicy.setOrder(faultCount);
            operationPoliciesList.add(operationPolicy);
            faultCount += 1;
        }
    }
    return operationPoliciesList;
}
Also used : OperationPolicyDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicyDTO) OperationPolicy(org.wso2.carbon.apimgt.api.model.OperationPolicy) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 OperationPolicy (org.wso2.carbon.apimgt.api.model.OperationPolicy)2 OperationPolicyDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicyDTO)2 APIOperationPoliciesDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIOperationPoliciesDTO)1