Package com.sparc.knappsack.components.entities

Examples of com.sparc.knappsack.components.entities.Region


        if (bindingResult.hasErrors()) {
            redirectAttributes.addFlashAttribute("org.springframework.validation.BindingResult.domainRegionForm", bindingResult);
            redirectAttributes.addFlashAttribute("domainRegionForm", domainRegionForm);
        } else {

            Region region;
            if (domainRegionForm.getId() == null || domainRegionForm.getId() <= 0) {
                region = regionService.createRegion(domainRegionForm);
            } else {
                region = regionService.editRegion(domainRegionForm);
            }

            if (region != null && region.getId() != null && region.getId() > 0) {
                redirectAttributes.addFlashAttribute("updateSuccess", true);
            } else {
                log.info(String.format("Unable to save Region for domain: Domain Id: %s", domainRegionForm.getDomainId()));
                String[] codes = {"desktop.manager.domainRegions.generic.error"};
                ObjectError error = new ObjectError("domainRegionForm", codes, null, null);
View Full Code Here


            errors.rejectValue(NAME_FIELD, "domainRegionValidator.name.empty");
        }

        boolean domainRegionNameExists = domainService.doesDomainContainRegionWithName(form.getDomainId(), form.getName());
        if (isEdit && domainRegionNameExists) {
            Region region = regionService.get(form.getId());
            if (!region.getName().equals(form.getName())) {
                errors.rejectValue(NAME_FIELD, "domainRegionValidator.name.exists");
            }
        } else if (!ValidationUtils.doesFieldErrorExist(errors, NAME_FIELD) && domainRegionNameExists) {
            errors.rejectValue(NAME_FIELD, "domainRegionValidator.name.exists");
        }
View Full Code Here

        regionDao.add(region);
    }

    @Override
    public Region get(Long id) {
        Region region = null;

        if (id != null && id > 0) {
            region = regionDao.get(id);
        }
View Full Code Here

        return region;
    }

    @Override
    public void delete(Long id) {
        Region region = get(id);

        if (region != null) {
            Domain domain = domainService.getDomainForRegion(region);

            if (domain != null) {
View Full Code Here

        regionDao.update(region);
    }

    @Override
    public Region createRegion(DomainRegionForm regionForm) {
        Region region = null;

        if (regionForm != null) {
            Domain domain = domainService.get(regionForm.getDomainId());

            if (domain != null) {
                region = new Region();
                region.setName(regionForm.getName());
                region.getEmails().addAll(regionForm.getEmails());

                domain.getRegions().add(region);

                add(region);
            }
View Full Code Here

        return region;
    }

    @Override
    public Region editRegion(DomainRegionForm regionForm) {
        Region region = null;

        if (regionForm != null) {
            region = get(regionForm.getId());

            if (region != null) {
                region.setName(regionForm.getName());
                region.getEmails().clear();
                region.getEmails().addAll(regionForm.getEmails());

                update(region);
            }
        }
View Full Code Here

TOP

Related Classes of com.sparc.knappsack.components.entities.Region

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.