use of site.model.Partner in project jprime by bgjug.
the class IndexController method getPartnerChunks.
private List<List<Partner>> getPartnerChunks(List<Partner> partners) {
List<List<Partner>> partnerChunks = new LinkedList<>();
int partnersCount = 0;
List<Partner> currentChunk = new LinkedList<>();
for (Partner partner : partners) {
currentChunk.add(partner);
partnersCount++;
if (partnersCount == PARTNERS_CHUNK_SIZE) {
partnerChunks.add(currentChunk);
partnersCount = 0;
currentChunk = new LinkedList<>();
}
}
if (partnersCount > 0) {
partnerChunks.add(currentChunk);
}
return partnerChunks;
}
use of site.model.Partner in project jprime by bgjug.
the class PartnerController method add.
@Transactional
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String add(@Valid final Partner partner, BindingResult bindingResult, @RequestParam("file") MultipartFile file) {
if (bindingResult.hasErrors()) {
System.out.println(bindingResult.getAllErrors());
return "/admin/partner/edit.jsp";
}
if (!file.isEmpty()) {
try {
byte[] bytes = file.getBytes();
partner.setLogo(thumbnailService.thumbImage(bytes, 180, 64));
} catch (Exception e) {
e.printStackTrace();
}
} else {
// empty file is it edit?
if (partner.getId() != null) {
Partner oldPartner = adminFacade.findOnePartner(partner.getId());
byte[] oldImage = oldPartner.getLogo();
partner.setLogo(oldImage);
}
}
this.adminFacade.savePartner(partner);
return "redirect:/admin/partner/view";
}
use of site.model.Partner in project jprime by bgjug.
the class PartnerController method edit.
@Transactional
@RequestMapping(value = "/edit/{itemId}", method = RequestMethod.GET)
public String edit(@PathVariable("itemId") Long itemId, Model model) {
Partner partner = adminFacade.findOnePartner(itemId);
model.addAttribute("partner", partner);
return "/admin/partner/edit.jsp";
}
Aggregations