use of org.wso2.carbon.apimgt.api.model.LifeCycleEvent in project carbon-apimgt by wso2.
the class ApiMgtDAO method getLifeCycleEvents.
public List<LifeCycleEvent> getLifeCycleEvents(String uuid) throws APIManagementException {
Connection connection = null;
PreparedStatement prepStmt = null;
ResultSet rs = null;
String sqlQuery = SQLConstants.GET_LIFECYCLE_EVENT_SQL;
int apiOrApiProductId = getAPIID(uuid);
List<LifeCycleEvent> events = new ArrayList<LifeCycleEvent>();
try {
connection = APIMgtDBUtil.getConnection();
prepStmt = connection.prepareStatement(sqlQuery);
prepStmt.setInt(1, apiOrApiProductId);
rs = prepStmt.executeQuery();
while (rs.next()) {
LifeCycleEvent event = new LifeCycleEvent();
String oldState = rs.getString("PREVIOUS_STATE");
// event.setOldStatus(oldState != null ? APIStatus.valueOf(oldState) : null);
event.setOldStatus(oldState);
// event.setNewStatus(APIStatus.valueOf(rs.getString("NEW_STATE")));
event.setNewStatus(rs.getString("NEW_STATE"));
event.setUserId(rs.getString("USER_ID"));
event.setDate(rs.getTimestamp("EVENT_DATE"));
events.add(event);
}
Collections.sort(events, (o1, o2) -> o1.getDate().compareTo(o2.getDate()));
} catch (SQLException e) {
handleException("Error when executing the SQL : " + sqlQuery, e);
} finally {
APIMgtDBUtil.closeAllConnections(prepStmt, connection, rs);
}
return events;
}
use of org.wso2.carbon.apimgt.api.model.LifeCycleEvent in project carbon-apimgt by wso2.
the class APIMappingUtil method fromLifecycleHistoryModelToDTO.
/**
* Return the REST API DTO representation of API Lifecycle history information.
*
* @param lifeCycleEvents API lifecycle history information
* @return REST API DTO representation of API Lifecycle history information
*/
public static LifecycleHistoryDTO fromLifecycleHistoryModelToDTO(List<LifeCycleEvent> lifeCycleEvents) {
LifecycleHistoryDTO historyDTO = new LifecycleHistoryDTO();
historyDTO.setCount(lifeCycleEvents.size());
for (LifeCycleEvent event : lifeCycleEvents) {
LifecycleHistoryItemDTO historyItemDTO = new LifecycleHistoryItemDTO();
historyItemDTO.setPostState(event.getNewStatus());
historyItemDTO.setPreviousState(event.getOldStatus());
historyItemDTO.setUser(event.getUserId());
String updatedTime = RestApiCommonUtil.getRFC3339Date(event.getDate());
historyItemDTO.setUpdatedTime(updatedTime);
historyDTO.getList().add(historyItemDTO);
}
return historyDTO;
}
Aggregations