use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.WorkflowInfoDTO in project carbon-apimgt by wso2.
the class WorkflowsApiServiceImpl method workflowsExternalWorkflowRefGet.
/**
* This is used to get the workflow pending request according to ExternalWorkflowReference
*
* @param externalWorkflowRef is the unique identifier for workflow request
* @return
*/
@Override
public Response workflowsExternalWorkflowRefGet(String externalWorkflowRef, MessageContext messageContext) throws APIManagementException {
WorkflowInfoDTO workflowinfoDTO;
try {
Workflow workflow;
String status = "CREATED";
String tenantDomain = RestApiCommonUtil.getLoggedInUserTenantDomain();
APIAdmin apiAdmin = new APIAdminImpl();
workflow = apiAdmin.getworkflowReferenceByExternalWorkflowReferenceID(externalWorkflowRef, status, tenantDomain);
workflowinfoDTO = WorkflowMappingUtil.fromWorkflowsToInfoDTO(workflow);
return Response.ok().entity(workflowinfoDTO).build();
} catch (APIManagementException e) {
RestApiUtil.handleInternalServerError("Error while retrieving workflow request by the " + "external workflow reference. ", e, log);
}
return null;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.WorkflowInfoDTO in project carbon-apimgt by wso2.
the class WorkflowMappingUtil method fromWorkflowsToInfoDTO.
public static WorkflowInfoDTO fromWorkflowsToInfoDTO(Workflow workflow) {
WorkflowInfoDTO workflowInfoDTO = new WorkflowInfoDTO();
if (workflow.getWorkflowType().equals("AM_APPLICATION_CREATION")) {
workflowInfoDTO.setWorkflowType(WorkflowInfoDTO.WorkflowTypeEnum.APPLICATION_CREATION);
} else if (workflow.getWorkflowType().equals("AM_SUBSCRIPTION_CREATION")) {
workflowInfoDTO.setWorkflowType(WorkflowInfoDTO.WorkflowTypeEnum.SUBSCRIPTION_CREATION);
} else if (workflow.getWorkflowType().equals("AM_USER_SIGNUP")) {
workflowInfoDTO.setWorkflowType(WorkflowInfoDTO.WorkflowTypeEnum.USER_SIGNUP);
} else if (workflow.getWorkflowType().equals("AM_APPLICATION_REGISTRATION_PRODUCTION")) {
workflowInfoDTO.setWorkflowType(WorkflowInfoDTO.WorkflowTypeEnum.APPLICATION_REGISTRATION_PRODUCTION);
} else if (workflow.getWorkflowType().equals("AM_APPLICATION_REGISTRATION_SANDBOX")) {
workflowInfoDTO.setWorkflowType(WorkflowInfoDTO.WorkflowTypeEnum.APPLICATION_REGISTRATION_SANDBOX);
} else if (workflow.getWorkflowType().equals("AM_API_STATE")) {
workflowInfoDTO.setWorkflowType(WorkflowInfoDTO.WorkflowTypeEnum.API_STATE);
} else if (workflow.getWorkflowType().equals("AM_API_PRODUCT_STATE")) {
workflowInfoDTO.setWorkflowType(WorkflowInfoDTO.WorkflowTypeEnum.API_PRODUCT_STATE);
}
workflowInfoDTO.setWorkflowStatus(WorkflowInfoDTO.WorkflowStatusEnum.valueOf(workflow.getStatus().toString()));
workflowInfoDTO.setCreatedTime(workflow.getCreatedTime());
workflowInfoDTO.setUpdatedTime(workflow.getUpdatedTime());
workflowInfoDTO.setReferenceId(workflow.getExternalWorkflowReference());
workflowInfoDTO.setDescription(workflow.getWorkflowDescription());
workflowInfoDTO.setProperties(workflow.getProperties());
return workflowInfoDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.WorkflowInfoDTO in project carbon-apimgt by wso2.
the class WorkflowMappingUtil method fromWorkflowsToDTO.
public static WorkflowListDTO fromWorkflowsToDTO(Workflow[] workflows, int limit, int offset) {
WorkflowListDTO workflowListDTO = new WorkflowListDTO();
List<WorkflowInfoDTO> workflowInfoDTOs = workflowListDTO.getList();
if (workflowInfoDTOs == null) {
workflowInfoDTOs = new ArrayList<>();
workflowListDTO.setList(workflowInfoDTOs);
}
// identifying the proper start and end indexes
int start = offset < workflows.length && offset >= 0 ? offset : Integer.MAX_VALUE;
int end = offset + limit - 1 <= workflows.length - 1 ? offset + limit - 1 : workflows.length - 1;
for (int i = start; i <= end; i++) {
workflowInfoDTOs.add(fromWorkflowsToInfoDTO(workflows[i]));
}
workflowListDTO.setCount(workflowInfoDTOs.size());
return workflowListDTO;
}
Aggregations