Search in sources :

Example 81 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project OpenAttestation by OpenAttestation.

the class WLMDataController method deleteOEMData.

public ModelAndView deleteOEMData(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.deleteOEMData >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    int selectedPage;
    try {
        selectedPage = Integer.parseInt(req.getParameter("selectedPageNo"));
        OEMDataVO dataVONew = new OEMDataVO();
        dataVONew.setOemName(req.getParameter("oemName"));
        //dataVONew.setOemDescription(req.getParameter("inputDec"));
        boolean updateDone = oemClientService.deleteOEM(dataVONew, getWhitelistService(req));
        if (updateDone) {
            Map<Integer, List<OEMDataVO>> mapOfData = getPartitionListOfAllOEM(req);
            if (selectedPage > mapOfData.size()) {
                selectedPage = mapOfData.size();
            }
            responseView.addObject("OEMDataVo", mapOfData.get(selectedPage));
            responseView.addObject("noOfPages", mapOfData.size());
            responseView.addObject("result", updateDone);
        }
    } catch (Exception e) {
        log.error("Error Wile Deleting OEM Data. Root cause " + e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
    }
    log.info("WLMDataController.deleteOEMData <<<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) List(java.util.List) FileUploadException(org.apache.commons.fileupload.FileUploadException) WLMPortalException(com.intel.mountwilson.common.WLMPortalException) OEMDataVO(com.intel.mountwilson.datamodel.OEMDataVO)

Example 82 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project OpenAttestation by OpenAttestation.

the class WLMDataController method getViewOSForPageNo.

@SuppressWarnings("unchecked")
public ModelAndView getViewOSForPageNo(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.getViewOSForPageNo >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        HttpSession session = req.getSession();
        Map<Integer, List<MLEDataVO>> map = (Map<Integer, List<MLEDataVO>>) session.getAttribute("OSList");
        responseView.addObject("OSDataVo", map.get(Integer.parseInt(req.getParameter("pageNo"))));
    } catch (Exception e) {
        log.error(e.toString());
        e.printStackTrace();
        responseView.addObject("OSDataVo", "");
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
        return responseView;
    }
    responseView.addObject("result", true);
    responseView.addObject("message", "");
    log.info("WLMDataController.getViewOSForPageNo <<");
    return responseView;
}
Also used : JSONView(com.intel.mountwilson.util.JSONView) HttpSession(javax.servlet.http.HttpSession) ModelAndView(org.springframework.web.servlet.ModelAndView) MLEDataVO(com.intel.mountwilson.datamodel.MLEDataVO) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) FileUploadException(org.apache.commons.fileupload.FileUploadException) WLMPortalException(com.intel.mountwilson.common.WLMPortalException)

Example 83 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project OpenAttestation by OpenAttestation.

the class WLMDataController method updateOSData.

/**
	 * Method to Update previously add OS Data into a REST Services.
	 * 
	 *@param req (HttpServletRequest Object)
	 * @param res (HttpServletResponse Object)
	 * @return
	 */
public ModelAndView updateOSData(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.updateOSData >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    int selectedPage;
    try {
        //Get Current select page no used in pagination.
        selectedPage = Integer.parseInt(req.getParameter("selectedPageNo"));
        //Get updated OS data from req object and create OSDataVO Object from it.
        OSDataVO dataVONew = new OSDataVO();
        dataVONew.setOsName(req.getParameter("osName"));
        dataVONew.setOsVersion(req.getParameter("osVer"));
        dataVONew.setOsDescription(req.getParameter("inputDec"));
        //Calling into Service Layer(OSClientServiceImpl) to update OS Data.
        boolean updateDone = osClientService.updateOSInfo(dataVONew, getWhitelistService(req));
        // Once OS data is updated, get List of all OS for a current page to show while pagination.  
        if (updateDone) {
            //Get map view of OS data from Services based on there page no.
            Map<Integer, List<OSDataVO>> mapOfData = getPartitionListOfAllOS(req);
            responseView.addObject("OSDataVo", mapOfData.get(selectedPage));
            responseView.addObject("noOfPages", mapOfData.size());
            responseView.addObject("result", updateDone);
        } else {
            log.error("Error Wile Editing OS Data. Api Client return false.");
            responseView.addObject("result", false);
            responseView.addObject("message", "Error Wile Editing OS Data. Api Client return false.");
        }
    } catch (WLMPortalException e) {
        log.error("Error Wile Editing OS Data. Root cause " + e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
    }
    log.info("WLMDataController.updateOSData <<<");
    return responseView;
}
Also used : WLMPortalException(com.intel.mountwilson.common.WLMPortalException) JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) List(java.util.List) OSDataVO(com.intel.mountwilson.datamodel.OSDataVO)

Example 84 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project pinpoint by naver.

the class ScatterChartController method selectScatterData.

private ModelAndView selectScatterData(String applicationName, Range range, int xGroupUnit, int yGroupUnit, int limit, boolean backwardDirection, int version) {
    ModelAndView mv = null;
    if (version == 1) {
        final ScatterData scatterData = scatter.selectScatterData(applicationName, range, xGroupUnit, yGroupUnit, limit, backwardDirection);
        boolean requestComplete = scatterData.getDotSize() < limit;
        mv = createScatterDataV1(scatterData, requestComplete);
    } else {
        mv = new ModelAndView();
    }
    mv.addObject("currentServerTime", new ServerTime().getCurrentServerTime());
    mv.addObject("from", range.getFrom());
    mv.addObject("to", range.getTo());
    return mv;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) ServerTime(com.navercorp.pinpoint.web.view.ServerTime) ScatterData(com.navercorp.pinpoint.web.scatter.ScatterData)

Example 85 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project pinpoint by naver.

the class ScatterChartController method selectFilterScatterData.

private ModelAndView selectFilterScatterData(String applicationName, Range range, int xGroupUnit, int yGroupUnit, int limit, boolean backwardDirection, String filterText, int version) {
    final LimitedScanResult<List<TransactionId>> limitedScanResult = flow.selectTraceIdsFromApplicationTraceIndex(applicationName, range, limit, backwardDirection);
    final List<TransactionId> transactionIdList = limitedScanResult.getScanData();
    logger.trace("submitted transactionId count={}", transactionIdList.size());
    boolean requestComplete = transactionIdList.size() < limit;
    Collections.sort(transactionIdList, TransactionIdComparator.INSTANCE);
    Filter filter = filterBuilder.build(filterText);
    ModelAndView mv;
    if (version == 1) {
        ScatterData scatterData = scatter.selectScatterData(transactionIdList, applicationName, range, xGroupUnit, yGroupUnit, filter);
        if (logger.isDebugEnabled()) {
            logger.debug("getScatterData range scan(limited:{}, backwardDirection:{}) from ~ to:{} ~ {}, limited:{}, filterDataSize:{}", limit, backwardDirection, DateUtils.longToDateStr(range.getFrom()), DateUtils.longToDateStr(range.getTo()), DateUtils.longToDateStr(limitedScanResult.getLimitedTime()), transactionIdList.size());
        }
        mv = createScatterDataV1(scatterData, requestComplete);
    } else {
        mv = new ModelAndView();
    }
    mv.addObject("currentServerTime", new ServerTime().getCurrentServerTime());
    mv.addObject("from", range.getFrom());
    mv.addObject("to", range.getTo());
    return mv;
}
Also used : Filter(com.navercorp.pinpoint.web.filter.Filter) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) ServerTime(com.navercorp.pinpoint.web.view.ServerTime) ScatterData(com.navercorp.pinpoint.web.scatter.ScatterData) TransactionId(com.navercorp.pinpoint.common.util.TransactionId)

Aggregations

ModelAndView (org.springframework.web.servlet.ModelAndView)1576 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)669 Test (org.junit.jupiter.api.Test)195 Test (org.junit.Test)188 HashMap (java.util.HashMap)166 ArrayList (java.util.ArrayList)140 RedirectView (org.springframework.web.servlet.view.RedirectView)90 Map (java.util.Map)85 List (java.util.List)69 IOException (java.io.IOException)62 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)60 Date (java.util.Date)57 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)49 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)49 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)47 GetMapping (org.springframework.web.bind.annotation.GetMapping)45 HandlerMethod (org.springframework.web.method.HandlerMethod)45 IPerson (org.apereo.portal.security.IPerson)43 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)35