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);
}
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);
}
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);
}
Aggregations