use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.LifecycleStateCheckItemsDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method fromLifecycleModelToDTO.
/**
* Return the REST API DTO representation of API Lifecycle state information.
*
* @param apiLCData API lifecycle state information
* @return REST API DTO representation of API Lifecycle state information
*/
public static LifecycleStateDTO fromLifecycleModelToDTO(Map<String, Object> apiLCData, boolean apiOlderVersionExist) {
LifecycleStateDTO lifecycleStateDTO = new LifecycleStateDTO();
String currentState = (String) apiLCData.get(APIConstants.LC_STATUS);
lifecycleStateDTO.setState(currentState);
String[] nextStates = (String[]) apiLCData.get(APIConstants.LC_NEXT_STATES);
if (nextStates != null) {
List<LifecycleStateAvailableTransitionsDTO> transitionDTOList = new ArrayList<>();
for (String state : nextStates) {
LifecycleStateAvailableTransitionsDTO transitionDTO = new LifecycleStateAvailableTransitionsDTO();
transitionDTO.setEvent(state);
// todo: Set target state properly
transitionDTO.setTargetState("");
transitionDTOList.add(transitionDTO);
}
lifecycleStateDTO.setAvailableTransitions(transitionDTOList);
}
List checkListItems = (List) apiLCData.get(APIConstants.LC_CHECK_ITEMS);
if (checkListItems != null) {
List<LifecycleStateCheckItemsDTO> checkItemsDTOList = new ArrayList<>();
for (Object checkListItemObj : checkListItems) {
CheckListItem checkListItem = (CheckListItem) checkListItemObj;
if (!apiOlderVersionExist && (checkListItem.getName().equals(APIConstants.DEPRECATE_CHECK_LIST_ITEM) || checkListItem.getName().equals(APIConstants.RESUBSCRIBE_CHECK_LIST_ITEM))) {
continue;
}
LifecycleStateCheckItemsDTO checkItemsDTO = new LifecycleStateCheckItemsDTO();
checkItemsDTO.setName(checkListItem.getName());
checkItemsDTO.setValue(Boolean.getBoolean(checkListItem.getValue()));
// todo: Set targets properly
checkItemsDTO.setRequiredStates(new ArrayList<>());
checkItemsDTOList.add(checkItemsDTO);
}
lifecycleStateDTO.setCheckItems(checkItemsDTOList);
}
return lifecycleStateDTO;
}
Aggregations