Search in sources :

Example 21 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-apimgt by wso2.

the class TierMappingUtil method fromTierListToDTO.

/**
 * Converts a List object of Tiers into a DTO
 *
 * @param tiers  a list of Tier objects
 * @param limit  max number of objects returned
 * @param offset starting index
 * @return TierListDTO object containing TierDTOs
 */
public static TierListDTO fromTierListToDTO(List<Policy> tiers, String tierLevel, int limit, int offset) {
    TierListDTO tierListDTO = new TierListDTO();
    List<TierDTO> tierDTOs = tierListDTO.getList();
    if (tierDTOs == null) {
        tierDTOs = new ArrayList<>();
        tierListDTO.setList(tierDTOs);
    }
    // identifying the proper start and end indexes
    int size = tiers.size();
    int start = offset < size && offset >= 0 ? offset : Integer.MAX_VALUE;
    int end = offset + limit - 1 <= size - 1 ? offset + limit - 1 : size - 1;
    for (int i = start; i <= end; i++) {
        Policy tier = tiers.get(i);
        tierDTOs.add(fromTierToDTO(tier, tierLevel));
    }
    tierListDTO.setCount(tierDTOs.size());
    return tierListDTO;
}
Also used : Policy(org.wso2.carbon.apimgt.core.models.policy.Policy) TierDTO(org.wso2.carbon.apimgt.rest.api.store.dto.TierDTO) TierListDTO(org.wso2.carbon.apimgt.rest.api.store.dto.TierListDTO)

Example 22 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-apimgt by wso2.

the class RatingMappingUtil method fromRatingDTOListToRatingListDTO.

/**
 * Constructs a RatingListDTO from a list of RatingDTO objects and other information
 *
 * @param avgRating     Average Rating of the API
 * @param userRating    User Rating for the API
 * @param offset        starting index
 * @param limit         maximum number of ratings to return
 * @param ratingList    List of RatingDTO Objects available for the API
 * @return a new RatingLIstDTO object
 */
public static RatingListDTO fromRatingDTOListToRatingListDTO(double avgRating, double userRating, Integer offset, Integer limit, List<RatingDTO> ratingList) {
    RatingListDTO ratingListDTO = new RatingListDTO();
    List<RatingDTO> ratingDTOs = ratingListDTO.getList();
    DecimalFormat decimalFormat = new DecimalFormat("#.#");
    ratingListDTO.setAvgRating(String.valueOf(decimalFormat.format(avgRating)));
    ratingListDTO.setUserRating(String.valueOf(decimalFormat.format(userRating)));
    if (ratingList == null) {
        ratingList = new ArrayList<>();
        ratingListDTO.setList(ratingList);
    }
    // add the required range of objects to be returned
    int start = offset < ratingList.size() && offset >= 0 ? offset : Integer.MAX_VALUE;
    int end = offset + limit - 1 <= ratingList.size() - 1 ? offset + limit - 1 : ratingList.size() - 1;
    for (int i = start; i <= end; i++) {
        ratingDTOs.add(ratingList.get(i));
    }
    ratingListDTO.setCount(ratingDTOs.size());
    return ratingListDTO;
}
Also used : DecimalFormat(java.text.DecimalFormat) RatingDTO(org.wso2.carbon.apimgt.rest.api.store.dto.RatingDTO) RatingListDTO(org.wso2.carbon.apimgt.rest.api.store.dto.RatingListDTO)

Example 23 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-apimgt by wso2.

the class ApplicationMappingUtil method fromApplicationsToDTO.

/**
 * Converts an Application[] array into a corresponding ApplicationListDTO
 *
 * @param applications array of Application objects
 * @param limit limit parameter
 * @param offset starting index
 * @return ApplicationListDTO object corresponding to Application[] array
 */
public static ApplicationListDTO fromApplicationsToDTO(List<Application> applications, int limit, int offset) {
    ApplicationListDTO applicationListDTO = new ApplicationListDTO();
    List<ApplicationInfoDTO> applicationInfoDTOs = applicationListDTO.getList();
    if (applicationInfoDTOs == null) {
        applicationInfoDTOs = new ArrayList<>();
        applicationListDTO.setList(applicationInfoDTOs);
    }
    // identifying the proper start and end indexes
    int start = offset < applications.size() && offset >= 0 ? offset : Integer.MAX_VALUE;
    int end = offset + limit - 1 <= applications.size() - 1 ? offset + limit - 1 : applications.size() - 1;
    for (int i = start; i <= end; i++) {
        applicationInfoDTOs.add(fromApplicationToInfoDTO(applications.get(i)));
    }
    applicationListDTO.setCount(applicationInfoDTOs.size());
    return applicationListDTO;
}
Also used : ApplicationInfoDTO(org.wso2.carbon.apimgt.rest.api.store.dto.ApplicationInfoDTO) ApplicationListDTO(org.wso2.carbon.apimgt.rest.api.store.dto.ApplicationListDTO)

Example 24 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-apimgt by wso2.

the class CommentMappingUtil method fromCommentListToDTO.

/**
 * Wraps a List of Comments to a CommentListDTO
 *
 * @param commentList list of comments
 * @param limit maximum comments to return
 * @param offset  starting position of the pagination
 * @return CommentListDTO
 */
public static CommentListDTO fromCommentListToDTO(List<Comment> commentList, int limit, int offset) {
    CommentListDTO commentListDTO = new CommentListDTO();
    List<CommentDTO> listOfCommentDTOs = new ArrayList<>();
    commentListDTO.setCount(commentList.size());
    int start = offset < commentList.size() && offset >= 0 ? offset : Integer.MAX_VALUE;
    int end = offset + limit - 1 <= commentList.size() - 1 ? offset + limit - 1 : commentList.size() - 1;
    for (int i = start; i <= end; i++) {
        listOfCommentDTOs.add(fromCommentToDTO(commentList.get(i)));
    }
    commentListDTO.setList(listOfCommentDTOs);
    return commentListDTO;
}
Also used : ArrayList(java.util.ArrayList) CommentDTO(org.wso2.carbon.apimgt.rest.api.store.dto.CommentDTO) CommentListDTO(org.wso2.carbon.apimgt.rest.api.store.dto.CommentListDTO)

Example 25 with Start

use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-apimgt by wso2.

the class ApiApiServiceImpl method apiCountOverTimeGet.

/**
 * Get list of API count information
 *
 * @param startTime Filter for start time stamp
 * @param endTime   Filter for end time stamp
 * @param createdBy Filter for created user
 * @param request   MSF4J request
 * @return API Count information
 * @throws NotFoundException When the particular resource does not exist in the system
 */
@Override
public Response apiCountOverTimeGet(String startTime, String endTime, String createdBy, Request request) throws NotFoundException {
    String username = RestApiUtil.getLoggedInUsername(request);
    try {
        log.debug("Retrieving APIs created over time. [From: {}  To: {} Created By: {}]", startTime, endTime, createdBy);
        Analyzer analyzer = RestApiUtil.getAnalyzer(username);
        ZoneId requestTimezone = RestApiUtil.getRequestTimeZone(startTime);
        List<APICount> apiCountList = analyzer.getAPICount(fromISO8601ToInstant(startTime), fromISO8601ToInstant(endTime), createdBy);
        APICountListDTO apiCountListDTO = AnalyticsMappingUtil.fromAPICountToListDTO(apiCountList, requestTimezone);
        return Response.ok().entity(apiCountListDTO).build();
    } catch (APIManagementException e) {
        String errorMessage = "Error while retrieving API created over time info";
        ErrorDTO errorDTO = RestApiUtil.getErrorDTO(e.getErrorHandler());
        log.error(errorMessage, e);
        return Response.status(e.getErrorHandler().getHttpStatusCode()).entity(errorDTO).build();
    }
}
Also used : APICount(org.wso2.carbon.apimgt.core.models.analytics.APICount) ZoneId(java.time.ZoneId) APIManagementException(org.wso2.carbon.apimgt.core.exception.APIManagementException) APICountListDTO(org.wso2.carbon.apimgt.rest.api.analytics.dto.APICountListDTO) ErrorDTO(org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO) Analyzer(org.wso2.carbon.apimgt.core.api.Analyzer)

Aggregations

SVGCoordinates (org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)57 ActivityInterface (org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)47 Test (org.testng.annotations.Test)17 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)17 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)17 Event (org.wso2.siddhi.core.event.Event)17 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)13 SVGDimension (org.wso2.carbon.bpel.ui.bpel2svg.SVGDimension)11 StreamEventPool (org.wso2.siddhi.core.event.stream.StreamEventPool)11 ArrayList (java.util.ArrayList)10 OMElement (org.apache.axiom.om.OMElement)10 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)10 Element (org.w3c.dom.Element)9 StreamCallback (org.wso2.siddhi.core.stream.output.StreamCallback)9 TopLevelNode (org.ballerinalang.model.tree.TopLevelNode)7 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)7 ZoneId (java.time.ZoneId)5 HashMap (java.util.HashMap)5 Analyzer (org.wso2.carbon.apimgt.core.api.Analyzer)5 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)5