Search in sources :

Example 1 with OEMDataVO

use of com.intel.mountwilson.datamodel.OEMDataVO in project OpenAttestation by OpenAttestation.

the class WLMDataController method updateOEMData.

public ModelAndView updateOEMData(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.updateOEMData >>");
    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.updateOEMInfo(dataVONew, getWhitelistService(req));
        if (updateDone) {
            Map<Integer, List<OEMDataVO>> mapOfData = getPartitionListOfAllOEM(req);
            responseView.addObject("OEMDataVo", mapOfData.get(selectedPage));
            responseView.addObject("noOfPages", mapOfData.size());
            responseView.addObject("result", updateDone);
        }
    } catch (Exception e) {
        log.error("Error Wile Editing OEM Data. Root cause " + e.getMessage());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
    }
    log.info("WLMDataController.updateOEMData <<<");
    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 2 with OEMDataVO

use of com.intel.mountwilson.datamodel.OEMDataVO in project OpenAttestation by OpenAttestation.

the class WLMDataController method addOEMData.

public ModelAndView addOEMData(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.addOEMData>>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    try {
        OEMDataVO dataVONew = new OEMDataVO();
        dataVONew.setOemName(req.getParameter("oemName"));
        dataVONew.setOemDescription(req.getParameter("oemDescription"));
        System.out.println("New OEM data >>> " + dataVONew.toString());
        responseView.addObject("result", oemClientService.addOEMInfo(dataVONew, getWhitelistService(req)));
    } catch (WLMPortalException e) {
        log.error("Error Wile Adding OEM Data. Root cause " + e.getStackTrace());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
    }
    log.info("WLMDataController.addOEMData <<<");
    return responseView;
}
Also used : WLMPortalException(com.intel.mountwilson.common.WLMPortalException) JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) OEMDataVO(com.intel.mountwilson.datamodel.OEMDataVO)

Example 3 with OEMDataVO

use of com.intel.mountwilson.datamodel.OEMDataVO 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 4 with OEMDataVO

use of com.intel.mountwilson.datamodel.OEMDataVO in project OpenAttestation by OpenAttestation.

the class WLMDataController method getPartitionListOfAllOEM.

/**
	 * Method to get a Map View for all OEM data from REST Services according to there page no.
	 * Return data is used in pagination.
	 * 
	 * @param req object of HttpServletRequest
	 * @return
	 * @throws WLMPortalException
	 */
private Map<Integer, List<OEMDataVO>> getPartitionListOfAllOEM(HttpServletRequest req) throws WLMPortalException {
    Map<Integer, List<OEMDataVO>> map = new HashMap<Integer, List<OEMDataVO>>();
    //Get List of all OEM.
    List<OEMDataVO> dataVOs = oemClientService.getAllOEM(getWhitelistService(req));
    int no_row_per_page = WLMPConfig.getConfiguration().getInt("mtwilson.wlmp.pagingSize");
    //Divide List of all OEM into a subList based on the value of host per page. 
    List<List<OEMDataVO>> list = Lists.partition(dataVOs, no_row_per_page);
    int i = 1;
    for (List<OEMDataVO> listForMap : list) {
        map.put(i, listForMap);
        i++;
    }
    //setting map into session attribute;
    HttpSession session = req.getSession();
    session.setAttribute("OEMList", map);
    return map;
}
Also used : HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) ArrayList(java.util.ArrayList) List(java.util.List) OEMDataVO(com.intel.mountwilson.datamodel.OEMDataVO)

Example 5 with OEMDataVO

use of com.intel.mountwilson.datamodel.OEMDataVO in project OpenAttestation by OpenAttestation.

the class WLMDataController method getHostOSForBios.

public ModelAndView getHostOSForBios(HttpServletRequest req, HttpServletResponse res) {
    log.info("WLMDataController.getHostOSForBios >>");
    ModelAndView responseView = new ModelAndView(new JSONView());
    List<OEMDataVO> list = null;
    try {
        list = oemClientService.getAllOEM(getWhitelistService(req));
        responseView.addObject("result", true);
    } catch (WLMPortalException e) {
        log.error("Error While getting Host OS Data for BIOS. Root cause " + e.getStackTrace());
        responseView.addObject("result", false);
        responseView.addObject("message", e.getMessage());
    }
    responseView.addObject("HostList", list);
    responseView.addObject("message", "");
    log.info("WLMDataController.getHostOSForBios <<<");
    return responseView;
}
Also used : WLMPortalException(com.intel.mountwilson.common.WLMPortalException) JSONView(com.intel.mountwilson.util.JSONView) ModelAndView(org.springframework.web.servlet.ModelAndView) OEMDataVO(com.intel.mountwilson.datamodel.OEMDataVO)

Aggregations

OEMDataVO (com.intel.mountwilson.datamodel.OEMDataVO)6 WLMPortalException (com.intel.mountwilson.common.WLMPortalException)4 JSONView (com.intel.mountwilson.util.JSONView)4 ArrayList (java.util.ArrayList)4 ModelAndView (org.springframework.web.servlet.ModelAndView)4 List (java.util.List)3 FileUploadException (org.apache.commons.fileupload.FileUploadException)2 OemData (com.intel.mtwilson.datatypes.OemData)1 HashMap (java.util.HashMap)1 HttpSession (javax.servlet.http.HttpSession)1