Search in sources :

Example 1 with OperationPolicyDTO

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

the class OperationPolicyMappingUtil method fromDTOToOperationPolicy.

public static OperationPolicy fromDTOToOperationPolicy(OperationPolicyDTO operationPolicyDTO) {
    OperationPolicy operationPolicy = new OperationPolicy();
    operationPolicy.setPolicyName(operationPolicyDTO.getPolicyName());
    operationPolicy.setPolicyId(operationPolicyDTO.getPolicyId());
    operationPolicy.setParameters(operationPolicyDTO.getParameters());
    return operationPolicy;
}
Also used : OperationPolicy(org.wso2.carbon.apimgt.api.model.OperationPolicy)

Example 2 with OperationPolicyDTO

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

the class OperationPolicyMappingUtil method fromOperationPolicyToDTO.

public static OperationPolicyDTO fromOperationPolicyToDTO(OperationPolicy operationPolicy) {
    OperationPolicyDTO dto = new OperationPolicyDTO();
    dto.setPolicyName(operationPolicy.getPolicyName());
    dto.setPolicyId(operationPolicy.getPolicyId());
    dto.setOrder(operationPolicy.getOrder());
    dto.setParameters(operationPolicy.getParameters());
    return dto;
}
Also used : OperationPolicyDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicyDTO)

Example 3 with OperationPolicyDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicyDTO 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 4 with OperationPolicyDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicyDTO 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)

Example 5 with OperationPolicyDTO

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

the class OperationPolicyMappingUtil method fromDTOListToOperationPolicyList.

public static List<OperationPolicy> fromDTOListToOperationPolicyList(List<OperationPolicyDTO> operationPolicyDTOList) {
    List<OperationPolicy> operationPolicyList = new ArrayList<>();
    for (OperationPolicyDTO operationPolicyDto : operationPolicyDTOList) {
        OperationPolicy operationPolicy = fromDTOToOperationPolicy(operationPolicyDto);
        operationPolicyList.add(operationPolicy);
    }
    return operationPolicyList;
}
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

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