Search in sources :

Example 71 with Transactional

use of javax.transaction.Transactional 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";
}
Also used : Partner(site.model.Partner) Transactional(javax.transaction.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 72 with Transactional

use of javax.transaction.Transactional in project jprime by bgjug.

the class TicketsController method register.

/**
 * User submitted the form.
 */
@Transactional
@RequestMapping(value = "/tickets/epay", method = RequestMethod.POST)
public String register(Model model, @Valid final Registrant registrant, BindingResult bindingResult, HttpServletRequest request) throws Exception {
    boolean invalidCaptcha = false;
    if (registrant.getCaptcha() == null || !registrant.getCaptcha().equals(request.getSession().getAttribute(CaptchaController.SESSION_PARAM_CAPTCHA_IMAGE))) {
        bindingResult.rejectValue("captcha", "invalid");
        invalidCaptcha = true;
    }
    if (bindingResult.hasErrors() || invalidCaptcha) {
        return TICKETS_REGISTER_JSP;
    }
    // check empty users, server side validation
    List<Visitor> toBeRemoved = registrant.getVisitors().stream().filter(v -> v.getEmail() == null || v.getEmail().isEmpty() || v.getName() == null || v.getName().isEmpty()).collect(Collectors.toList());
    registrant.getVisitors().removeAll(toBeRemoved);
    registrant.getVisitors().forEach(visitor -> visitor.setStatus(VisitorStatus.REQUESTING));
    if (!registrant.isCompany()) {
        handlePersonalRegistrant(registrant);
    }
    registrant.setPaymentType(Registrant.PaymentType.BANK_TRANSFER);
    Registrant savedRegistrant = registrantFacade.save(registrant);
    model.addAttribute("tags", userFacade.findAllTags());
    InvoiceData invoiceData = buildInvoiceData(savedRegistrant);
    byte[] pdf = invoiceExporter.exportInvoice(invoiceData, registrant.isCompany());
    sendPDF(savedRegistrant, generatePdfFilename(registrant, invoiceData.getSinglePriceWithVAT()), pdf);
    return result("ok", model);
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) MessagingException(javax.mail.MessagingException) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) BindingResult(org.springframework.validation.BindingResult) MailService(site.facade.MailService) Controller(org.springframework.stereotype.Controller) InvoiceExporter(site.controller.invoice.InvoiceExporter) Valid(javax.validation.Valid) HttpServletRequest(javax.servlet.http.HttpServletRequest) Model(org.springframework.ui.Model) Calendar(java.util.Calendar) Visitor(site.model.Visitor) Qualifier(org.springframework.beans.factory.annotation.Qualifier) UserService(site.facade.UserService) Transactional(javax.transaction.Transactional) Registrant(site.model.Registrant) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) Collectors(java.util.stream.Collectors) InvoiceData(site.controller.invoice.InvoiceData) List(java.util.List) Logger(org.apache.logging.log4j.Logger) RegistrantService(site.facade.RegistrantService) LogManager(org.apache.logging.log4j.LogManager) VisitorStatus(site.model.VisitorStatus) Visitor(site.model.Visitor) InvoiceData(site.controller.invoice.InvoiceData) Registrant(site.model.Registrant) Transactional(javax.transaction.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 73 with Transactional

use of javax.transaction.Transactional in project jprime by bgjug.

the class AdminSpeakerController method add.

@Transactional
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String add(@Valid final Speaker speaker, BindingResult bindingResult, @RequestParam("file") MultipartFile file, Model model) {
    if (bindingResult.hasErrors()) {
        model.addAttribute("branches", Branch.values());
        return "/admin/speaker/edit.jsp";
    }
    if (!file.isEmpty()) {
        try {
            byte[] bytes = file.getBytes();
            speaker.setPicture(thumbnailService.thumbImage(bytes, 280, 326));
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        // empty file is it edit?
        if (speaker.getId() != null) {
            Speaker oldSpeaker = adminFacade.findOneSpeaker(speaker.getId());
            byte[] oldImage = oldSpeaker.getPicture();
            speaker.setPicture(oldImage);
        }
    }
    this.adminFacade.saveSpeaker(speaker);
    return "redirect:/admin/speaker/view";
}
Also used : Speaker(site.model.Speaker) Transactional(javax.transaction.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 74 with Transactional

use of javax.transaction.Transactional in project jprime by bgjug.

the class AdminSpeakerController method edit.

@Transactional
@RequestMapping(value = "/edit/{itemId}", method = RequestMethod.GET)
public String edit(@PathVariable("itemId") Long itemId, Model model) {
    Speaker speaker = adminFacade.findOneSpeaker(itemId);
    model.addAttribute("speaker", speaker);
    model.addAttribute("branches", Branch.values());
    return "/admin/speaker/edit.jsp";
}
Also used : Speaker(site.model.Speaker) Transactional(javax.transaction.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 75 with Transactional

use of javax.transaction.Transactional in project openlmis-stockmanagement by OpenLMIS.

the class StockCardTemplateService method saveOrUpdate.

/**
 * Save or update stock card template by facility type id and program id.
 *
 * @param templateDto object to save or update.
 * @return the saved or updated object.
 */
@Transactional
public StockCardTemplateDto saveOrUpdate(StockCardTemplateDto templateDto) {
    checkProgramAndFacilityTypeIdNotNull(templateDto);
    checkFieldsDuplication(templateDto);
    StockCardTemplate template = templateDto.toModel(findAllFieldsFrom(cardFieldsRepo).collect(toList()), findAllFieldsFrom(lineItemFieldsRepo).collect(toList()));
    StockCardTemplate found = templateRepository.findByProgramIdAndFacilityTypeId(template.getProgramId(), template.getFacilityTypeId());
    if (found != null) {
        template.setId(found.getId());
        templateRepository.delete(found);
    } else {
        programFacilityTypeExistenceService.checkProgramAndFacilityTypeExist(template.getProgramId(), template.getFacilityTypeId());
    }
    return StockCardTemplateDto.from(templateRepository.save(template));
}
Also used : StockCardTemplate(org.openlmis.stockmanagement.domain.template.StockCardTemplate) Transactional(javax.transaction.Transactional)

Aggregations

Transactional (javax.transaction.Transactional)299 Test (org.junit.Test)99 PostResult (org.collectiveone.common.dto.PostResult)29 ArrayList (java.util.ArrayList)24 UserDO (org.neusoft.neubbs.entity.UserDO)21 Timestamp (java.sql.Timestamp)18 TopicDO (org.neusoft.neubbs.entity.TopicDO)18 Initiative (org.collectiveone.modules.initiatives.Initiative)16 GetResult (org.collectiveone.common.dto.GetResult)15 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)13 TopicReplyDO (org.neusoft.neubbs.entity.TopicReplyDO)13 HashMap (java.util.HashMap)12 Date (java.util.Date)11 AppUser (org.collectiveone.modules.users.AppUser)11 UUID (java.util.UUID)10 RolesAllowed (javax.annotation.security.RolesAllowed)10 PeerReviewedAssignation (org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 IOException (java.io.IOException)9 TopicContentDO (org.neusoft.neubbs.entity.TopicContentDO)9