Search in sources :

Example 51 with ModelMap

use of org.springframework.ui.ModelMap in project esup-papercut by EsupPortail.

the class EsupPapercutPortletController method adminList.

@RequestMapping(params = "action=admin")
public ModelAndView adminList(@RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "sortFieldName", required = false) String sortFieldName, @RequestParam(value = "sortOrder", required = false) String sortOrder, RenderRequest request, RenderResponse response) {
    boolean isAdmin = isAdmin(request);
    boolean isManager = isManager(request);
    ModelMap model = new ModelMap();
    model.put("isAdmin", isAdmin);
    model.put("adminView", true);
    model.put("isManager", isManager);
    if (isAdmin || isManager) {
        String paperCutContext = request.getPreferences().getValue(PREF_PAPERCUT_CONTEXT, null);
        if (sortFieldName == null) {
            sortFieldName = "transactionDate";
            sortOrder = "desc";
        }
        if (size == null) {
            size = 10;
        }
        if (page != null || size != null) {
            int sizeNo = size == null ? 10 : size.intValue();
            final int firstResult = page == null ? 0 : (page.intValue() - 1) * sizeNo;
            model.put("payboxpapercuttransactionlogs", PayboxPapercutTransactionLog.findPayboxPapercutTransactionLogsByPaperCutContextEquals(paperCutContext, sortFieldName, sortOrder).setFirstResult(firstResult).setMaxResults(sizeNo).getResultList());
            float nrOfPages = (float) PayboxPapercutTransactionLog.countFindPayboxPapercutTransactionLogsByPaperCutContextEquals(paperCutContext) / sizeNo;
            model.put("maxPages", (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));
        } else {
            model.put("payboxpapercuttransactionlogs", PayboxPapercutTransactionLog.findPayboxPapercutTransactionLogsByPaperCutContextEquals(paperCutContext, sortFieldName, sortOrder).getResultList());
        }
        addDateTimeFormatPatterns(model);
        String sharedSessionId = response.getNamespace();
        EsupPapercutSessionObject objectShared = new EsupPapercutSessionObject();
        objectShared.setIsAdmin(true);
        objectShared.setPaperCutContext(paperCutContext);
        final PortletPreferences prefs = request.getPreferences();
        objectShared.setRequeteCumulMontants(prefs.getValue(PREF_CUMUL_MONTANT, "useOriginal"));
        objectShared.setRequeteCumulTransactions(prefs.getValue(PREF_CUMUL_TRANSACTIONS, "useOriginal"));
        objectShared.setRequeteMontantTransactions((String) prefs.getValue(PREF_MONTANT_TRANSACTIONS, "useOriginal"));
        objectShared.setRequeteNbTransactions((String) prefs.getValue(PREF_NB_TRANSCATIONS, "useOriginal"));
        PortletUtils.setSessionAttribute(request, sharedSessionId, objectShared, PortletSession.APPLICATION_SCOPE);
        model.put("sharedSessionId", sharedSessionId);
        model.put("active", "admin");
    }
    model.put("sortFieldName", sortFieldName);
    model.put("sortOrder", sortOrder);
    return new ModelAndView(getViewName(request, "history"), model);
}
Also used : EsupPapercutSessionObject(org.esupportail.papercut.domain.EsupPapercutSessionObject) ModelMap(org.springframework.ui.ModelMap) ModelAndView(org.springframework.web.portlet.ModelAndView) PortletPreferences(javax.portlet.PortletPreferences) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 52 with ModelMap

use of org.springframework.ui.ModelMap in project esup-papercut by EsupPortail.

the class EsupPapercutPortletController method myhistoryList.

@RequestMapping(params = "action=myhistory")
public ModelAndView myhistoryList(@RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "sortFieldName", required = false) String sortFieldName, @RequestParam(value = "sortOrder", required = false) String sortOrder, RenderRequest request) {
    String uid = getUid(request);
    String paperCutContext = request.getPreferences().getValue(PREF_PAPERCUT_CONTEXT, null);
    if (sortFieldName == null) {
        sortFieldName = "transactionDate";
        sortOrder = "desc";
    }
    if (size == null) {
        size = 10;
    }
    ModelMap model = new ModelMap();
    if (page != null || size != null) {
        int sizeNo = size == null ? 10 : size.intValue();
        final int firstResult = page == null ? 0 : (page.intValue() - 1) * sizeNo;
        model.put("payboxpapercuttransactionlogs", PayboxPapercutTransactionLog.findPayboxPapercutTransactionLogsByUidEqualsAndPaperCutContextEquals(uid, paperCutContext, sortFieldName, sortOrder).setFirstResult(firstResult).setMaxResults(sizeNo).getResultList());
        float nrOfPages = (float) PayboxPapercutTransactionLog.countFindPayboxPapercutTransactionLogsByUidEqualsAndPaperCutContextEquals(uid, paperCutContext) / sizeNo;
        model.put("maxPages", (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));
    } else {
        model.put("payboxpapercuttransactionlogs", PayboxPapercutTransactionLog.findPayboxPapercutTransactionLogsByUidEqualsAndPaperCutContextEquals(uid, paperCutContext, sortFieldName, sortOrder).getResultList());
    }
    addDateTimeFormatPatterns(model);
    model.put("isAdmin", isAdmin(request));
    model.put("isManager", isManager(request));
    model.put("active", "history");
    model.put("sortFieldName", sortFieldName);
    model.put("sortOrder", sortOrder);
    return new ModelAndView(getViewName(request, "history"), model);
}
Also used : ModelMap(org.springframework.ui.ModelMap) ModelAndView(org.springframework.web.portlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 53 with ModelMap

use of org.springframework.ui.ModelMap in project esup-papercut by EsupPortail.

the class EsupPapercutPortletController method renderStats.

@RequestMapping(params = "action=stats")
public ModelAndView renderStats(RenderRequest request, RenderResponse response) {
    boolean isAdmin = isAdmin(request);
    boolean isManager = isManager(request);
    ModelMap model = new ModelMap();
    if (isAdmin || isManager) {
        String paperCutContext = request.getPreferences().getValue(PREF_PAPERCUT_CONTEXT, null);
        String sharedSessionId = response.getNamespace();
        EsupPapercutSessionObject objectShared = new EsupPapercutSessionObject();
        objectShared.setIsAdmin(true);
        objectShared.setPaperCutContext(paperCutContext);
        model.put("sharedSessionId", sharedSessionId);
        model.put("sessionId", sharedSessionId);
        model.put("objectShared", objectShared);
        final PortletPreferences prefs = request.getPreferences();
        objectShared.setRequeteCumulMontants(prefs.getValue(PREF_CUMUL_MONTANT, "useOriginal"));
        objectShared.setRequeteCumulTransactions(prefs.getValue(PREF_CUMUL_TRANSACTIONS, "useOriginal"));
        objectShared.setRequeteMontantTransactions((String) prefs.getValue(PREF_MONTANT_TRANSACTIONS, "useOriginal"));
        objectShared.setRequeteNbTransactions((String) prefs.getValue(PREF_NB_TRANSCATIONS, "useOriginal"));
        PortletUtils.setSessionAttribute(request, sharedSessionId, objectShared, PortletSession.APPLICATION_SCOPE);
    }
    model.put("isAdmin", isAdmin);
    model.put("isManager", isManager);
    model.put("active", "stats");
    return new ModelAndView(getViewName(request, "stats"), model);
}
Also used : EsupPapercutSessionObject(org.esupportail.papercut.domain.EsupPapercutSessionObject) ModelMap(org.springframework.ui.ModelMap) ModelAndView(org.springframework.web.portlet.ModelAndView) PortletPreferences(javax.portlet.PortletPreferences) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ModelMap (org.springframework.ui.ModelMap)53 Test (org.junit.Test)23 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)23 ModelAndView (org.springframework.web.servlet.ModelAndView)11 RedirectAttributesModelMap (org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)6 ModelAndView (org.springframework.web.portlet.ModelAndView)5 Map (java.util.Map)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 IOException (java.io.IOException)3 Date (java.util.Date)3 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)3 HttpSessionRequiredException (org.springframework.web.HttpSessionRequiredException)3 NimbusClient (backtype.storm.utils.NimbusClient)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 PortletPreferences (javax.portlet.PortletPreferences)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2