Search in sources :

Example 1 with OperationPolicySpecAttributeDTO

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

the class OperationPolicyMappingUtil method fromOperationPolicySpecAttributesToDTO.

public static OperationPolicySpecAttributeDTO fromOperationPolicySpecAttributesToDTO(OperationPolicySpecAttribute specAttribute) {
    OperationPolicySpecAttributeDTO specAttributeDTO = new OperationPolicySpecAttributeDTO();
    specAttributeDTO.setName(specAttribute.getName());
    specAttributeDTO.setDisplayName(specAttribute.getDisplayName());
    specAttributeDTO.setDescription(specAttribute.getDescription());
    specAttributeDTO.setType(specAttribute.getType().toString());
    specAttributeDTO.setValidationRegex(specAttribute.getValidationRegex());
    specAttributeDTO.setRequired(specAttribute.isRequired());
    specAttributeDTO.setDefaultValue(specAttribute.getDefaultValue());
    if (specAttribute.getType().equals(OperationPolicySpecAttribute.AttributeType.Enum)) {
        specAttributeDTO.setAllowedValues(specAttribute.getAllowedValues());
    }
    return specAttributeDTO;
}
Also used : OperationPolicySpecAttributeDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicySpecAttributeDTO)

Example 2 with OperationPolicySpecAttributeDTO

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

the class OperationPolicyMappingUtil method fromOperationPolicyDataToDTO.

public static OperationPolicyDataDTO fromOperationPolicyDataToDTO(OperationPolicyData policyData) {
    OperationPolicyDataDTO policyDataDTO = new OperationPolicyDataDTO();
    OperationPolicySpecification policySpecification = policyData.getSpecification();
    policyDataDTO.setId(policyData.getPolicyId());
    policyDataDTO.setMd5(policyData.getMd5Hash());
    policyDataDTO.setIsAPISpecific(policyData.isApiSpecificPolicy());
    policyDataDTO.setName(policySpecification.getName());
    policyDataDTO.setDisplayName(policySpecification.getDisplayName());
    policyDataDTO.setDescription(policySpecification.getDescription());
    policyDataDTO.setSupportedGateways(policySpecification.getSupportedGateways());
    policyDataDTO.setSupportedApiTypes(policySpecification.getSupportedApiTypes());
    policyDataDTO.setApplicableFlows(policySpecification.getApplicableFlows());
    policyDataDTO.setMultipleAllowed(policySpecification.isMultipleAllowed());
    policyDataDTO.setCategory(policySpecification.getCategory().toString());
    if (policySpecification.getPolicyAttributes() != null) {
        List<OperationPolicySpecAttributeDTO> specAttributeDtoList = new ArrayList<>();
        for (OperationPolicySpecAttribute specAttribute : policySpecification.getPolicyAttributes()) {
            OperationPolicySpecAttributeDTO specAttributeDTO = fromOperationPolicySpecAttributesToDTO(specAttribute);
            specAttributeDtoList.add(specAttributeDTO);
        }
        policyDataDTO.setPolicyAttributes(specAttributeDtoList);
    }
    return policyDataDTO;
}
Also used : OperationPolicySpecAttribute(org.wso2.carbon.apimgt.api.model.OperationPolicySpecAttribute) ArrayList(java.util.ArrayList) OperationPolicySpecAttributeDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicySpecAttributeDTO) OperationPolicyDataDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicyDataDTO) OperationPolicySpecification(org.wso2.carbon.apimgt.api.model.OperationPolicySpecification)

Aggregations

OperationPolicySpecAttributeDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicySpecAttributeDTO)2 ArrayList (java.util.ArrayList)1 OperationPolicySpecAttribute (org.wso2.carbon.apimgt.api.model.OperationPolicySpecAttribute)1 OperationPolicySpecification (org.wso2.carbon.apimgt.api.model.OperationPolicySpecification)1 OperationPolicyDataDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicyDataDTO)1