Examples of OrganizationForm


Examples of com.sparc.knappsack.forms.OrganizationForm

    private Errors errors;
    private OrganizationForm organizationForm;

    @Before
    public void setup() {
        organizationForm = new OrganizationForm();
        errors = new BeanPropertyBindingResult(organizationForm, "organizationForm");
        ReflectionTestUtils.setField(validator, "emailPattern", EMAIL_PATTERN);

    }
View Full Code Here

Examples of com.sparc.knappsack.forms.OrganizationForm

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @RequestMapping(value = "/manager/addOrg", method = RequestMethod.GET)
    public String addOrganization(Model model) {

        if(!model.containsAttribute("organization")) {
            model.addAttribute("organization", new OrganizationForm());
        }
        model.addAttribute("storageConfigurations", storageConfigurationService.getAll());

        return "manager/manageOrganizationTH";
    }
View Full Code Here

Examples of com.sparc.knappsack.forms.OrganizationForm

        checkRequiredEntity(organizationService, id);
        Organization existingOrg = organizationService.get(id);

        if (existingOrg != null) {
            if (!model.containsAttribute("organization")) {
                OrganizationForm orgForm = new OrganizationForm();
                orgForm.setEditing(true);
                orgForm.setName(existingOrg.getName());
                orgForm.setId(existingOrg.getId());
                orgForm.setStorageConfigurationId(existingOrg.getOrgStorageConfig().getStorageConfigurations().get(0).getId());
                orgForm.setStoragePrefix(existingOrg.getOrgStorageConfig().getPrefix());

                if (existingOrg.getCustomBranding() != null) {
                    AppFile logo = existingOrg.getCustomBranding().getLogo();
                    if (logo != null) {
                        MockMultipartFile logoMultipartFile = new MockMultipartFile(logo.getName(), logo.getName(), logo.getType(), new byte[0]);
                        orgForm.setLogo(logoMultipartFile);
                    }
                    orgForm.setEmailHeader(existingOrg.getCustomBranding().getEmailHeader());
                    orgForm.setEmailFooter(existingOrg.getCustomBranding().getEmailFooter());
                    orgForm.setSubdomain(existingOrg.getCustomBranding().getSubdomain());
                }

                model.addAttribute("organization", orgForm);
            } else {
                ((OrganizationForm) model.asMap().get("organization")).setStorageConfigurationId(existingOrg.getOrgStorageConfig().getStorageConfigurations().get(0).getId());
View Full Code Here

Examples of com.sparc.knappsack.forms.OrganizationForm

    @RequestMapping(value = "/manager/uploadOrg", method = RequestMethod.POST)
    public String uploadOrganization(HttpServletRequest request, Model model, @ModelAttribute("organization") @Validated OrganizationForm organizationForm, BindingResult bindingResult) {

        if (bindingResult.hasErrors()) {
            if(!model.containsAttribute("organization")) {
                model.addAttribute("organization", new OrganizationForm());
            }
            model.addAttribute("storageConfigurations", storageConfigurationService.getAll());
            model.addAttribute("organization", organizationForm);
            if (organizationForm.isEditing()) {
                return editOrganization(request, model, organizationForm.getId());
View Full Code Here

Examples of com.sparc.knappsack.forms.OrganizationForm

        return OrganizationForm.class.isAssignableFrom(aClass);
    }

    @Override
    public void validate(Object o, Errors errors) {
        OrganizationForm organizationForm = (OrganizationForm) o;
        if (organizationForm.getName() == null || "".equals(organizationForm.getName().trim())) {
            errors.rejectValue(NAME_FIELD, "organizationValidator.emptyName");
        }

        if ((organizationForm.getStorageConfigurationId() == null || organizationForm.getStorageConfigurationId() <= 0) && !organizationForm.isEditing()) {
            errors.rejectValue(STORAGE_CONFIGURATION_ID_FIELD, "organizationValidator.emptyStorageConfigurationId");
        }

        if (!organizationForm.isEditing() && (organizationForm.getStoragePrefix() == null || "".equals(organizationForm.getStoragePrefix().trim()))) {
            errors.rejectValue(STORAGE_PREFIX_FIELD, "organizationValidator.emptyPrefix");
        }

        Organization organization = organizationService.getByName(organizationForm.getName());
        if (organization != null && !organization.getId().equals(organizationForm.getId())) {
            errors.rejectValue(NAME_FIELD, "organizationValidator.nameEquals");
        }

        if (!organizationForm.isEditing()) {
            OrgStorageConfig orgStorageConfig = orgStorageConfigService.getByPrefix(organizationForm.getStoragePrefix());
            if (orgStorageConfig != null && !orgStorageConfig.getOrganization().getId().equals(organizationForm.getId())) {
                errors.rejectValue(STORAGE_PREFIX_FIELD, "organizationValidator.prefix");
            }
        }

        if(organizationForm.getSubdomain() != null && !organizationForm.getSubdomain().isEmpty()) {
            CustomBranding customBranding = customBrandingService.getBySubdomain(organizationForm.getSubdomain());
            if(customBranding != null && !organization.getCustomBranding().getId().equals(customBranding.getId())) {
                errors.rejectValue(SUBDOMAIN_FIELD, "organizationValidator.subdomain");
            }
        }

        if (organizationForm.getLogo() != null) {
            BufferedImage bufferedImage = imageValidator.createBufferedImage(organizationForm.getLogo());

            boolean logoErrorExists = false;

            if (!imageValidator.isValidImageSize(organizationForm.getLogo(), MAX_IMAGE_BYTES /*Bytes: 800 KB*/)) {
                errors.rejectValue(LOGO_FIELD, "organizationValidator.logo.invalidSize", new Object[]{MAX_IMAGE_BYTES * 0.0009765625 /*Convert bytes to KiloBytes*/}, "");
                logoErrorExists = true;
            }

            if (!imageValidator.isValidImageType(organizationForm.getLogo())) {
                errors.rejectValue(LOGO_FIELD, "organizationValidator.logo.invalidType");
                logoErrorExists = true;
            }

            if (bufferedImage == null || !imageValidator.isValidMaxDimensions(bufferedImage, 150, 50)) {
                errors.rejectValue(LOGO_FIELD, "organizationValidator.logo.invalidDimensions", new Object[]{Long.toString(150), Long.toString(50)}, "");
                logoErrorExists = true;
            }

            if (logoErrorExists) {
                organizationForm.setLogo(null);
            }
        }
    }
View Full Code Here

Examples of com.sparc.knappsack.forms.OrganizationForm

    public void deleteStorageConfigWithOrganization() {
        StorageConfiguration storageConfiguration = getStorageConfiguration();
        storageConfigurationService.add(storageConfiguration);
        storageConfiguration = storageConfigurationService.getByName(storageConfiguration.getName());

        OrganizationForm organizationForm = new OrganizationForm();
        organizationForm.setStorageConfigurationId(storageConfiguration.getId());
        organizationForm.setStoragePrefix("test");
        organizationForm.setName("Test Organization");

        organizationService.createOrganization(organizationForm);

        storageConfigurationService.delete(storageConfiguration.getId());
        storageConfiguration = storageConfigurationService.getByName(storageConfiguration.getName());
View Full Code Here

Examples of com.sparc.knappsack.forms.OrganizationForm

    @Autowired
    private UserService userService;

    @Test
    public void updateTest() {
        OrganizationForm organizationForm = getOrganizationForm();

        organizationService.createOrganization(organizationForm);
        Organization organization = organizationService.getByName("Test Organization");
        organization.setName("New Organization");
        organizationService.update(organization);
View Full Code Here

Examples of com.sparc.knappsack.forms.OrganizationForm

        assertNotNull(organization);
    }

    @Test
    public void createOrganizationTest() {
        OrganizationForm organizationForm = getOrganizationForm();

        organizationService.createOrganization(organizationForm);
        Organization organization = organizationService.getByName("Test Organization");
        assertNotNull(organization);
    }
View Full Code Here

Examples of com.sparc.knappsack.forms.OrganizationForm

        assertNotNull(organization);
    }

    @Test
    public void editOrganizationTest() {
        OrganizationForm organizationForm = getOrganizationForm();

        organizationService.createOrganization(organizationForm);
        Organization organization = organizationService.getByName("Test Organization");

        OrganizationForm newOrganizationForm = new OrganizationForm();
        newOrganizationForm.setName("Test Organization 2");
        newOrganizationForm.setId(organization.getId());
        organizationService.editOrganization(newOrganizationForm);
        Organization updatedOrganization = organizationService.getByName("Test Organization 2");
        assertNotNull(updatedOrganization);
        assertEquals(organization.getId(), updatedOrganization.getId());
    }
View Full Code Here

Examples of com.sparc.knappsack.forms.OrganizationForm

    }

    @Test
    public void modelToEntityMappingTest() {

        OrganizationForm organizationForm = getOrganizationForm();

        organizationService.createOrganization(organizationForm);
        Organization organization = organizationService.getByName("Test Organization");

        OrganizationModel newOrganizationModel = new OrganizationModel();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.