Package com.sparc.knappsack.components.entities

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


        if (bindingResult.hasErrors()) {
            redirectAttributes.addFlashAttribute("org.springframework.validation.BindingResult.systemNotificationForm", bindingResult);
            redirectAttributes.addFlashAttribute("systemNotificationForm", systemNotificationForm);
            return "redirect:/manager/system?notifUpdateSuccess=false";
        }
        SystemNotification returnedSystemNotification = null;

        //Map form to model
        SystemNotificationModel systemNotificationModel = new SystemNotificationModel();
        systemNotificationModel.setId(systemNotificationForm.getId());
        systemNotificationModel.setStartDate(systemNotificationForm.getStartDate());
        systemNotificationModel.setEndDate(systemNotificationForm.getEndDate());
        systemNotificationModel.setMessage(systemNotificationForm.getMessage());
        systemNotificationModel.setAllPages(systemNotificationForm.isAllPages());
        systemNotificationModel.setNotificationType(systemNotificationForm.getNotificationType());
        systemNotificationModel.setNotificationSeverity(systemNotificationForm.getNotificationSeverity());

        boolean success = false;

        try {
            //Check if editing or not
            if (systemNotificationModel.getId() != null && systemNotificationModel.getId() > 0) {
                returnedSystemNotification = systemNotificationService.editSystemNotification(systemNotificationModel);
                if (returnedSystemNotification != null) {
                    success = true;
                }
            } else {
                returnedSystemNotification = systemNotificationService.addSystemNotification(systemNotificationModel);
                if (returnedSystemNotification != null && returnedSystemNotification.getId() != null && returnedSystemNotification.getId() > 0) {
                    success = true;
                }
            }
        } catch (Exception ex) {
            log.info("Error updating systemNotification.", ex);
View Full Code Here


        save(systemNotification);
    }

    @Override
    public SystemNotification get(Long id) {
        SystemNotification systemNotification = null;
        if (id != null && id > 0) {
            systemNotification = systemNotificationDao.get(id);
        }
        return systemNotification;
    }
View Full Code Here

        }
    }

    @Override
    public void delete(Long id) {
        SystemNotification systemNotification = get(id);
        if (systemNotification != null) {
            delete(systemNotification);
        }
    }
View Full Code Here

    }

    @Override
    public SystemNotification addSystemNotification(SystemNotificationModel systemNotificationModel) {
        if (systemNotificationModel != null) {
            SystemNotification systemNotification = new SystemNotification();
            systemNotification.setStartDate(systemNotificationModel.getStartDate());
            systemNotification.setEndDate(systemNotificationModel.getEndDate());
            systemNotification.setMessage(StringUtils.trim(systemNotificationModel.getMessage()));
            systemNotification.setAllPages(systemNotificationModel.isAllPages());
            systemNotification.setNotificationType(systemNotificationModel.getNotificationType());
            systemNotification.setNotificationSeverity(systemNotificationModel.getNotificationSeverity());

            save(systemNotification);

            return systemNotification;
        }
View Full Code Here

    }

    @Override
    public SystemNotification editSystemNotification(SystemNotificationModel systemNotificationModel) {
        if (systemNotificationModel != null) {
            SystemNotification systemNotification = get(systemNotificationModel.getId());
            if (systemNotification != null) {
                systemNotification.setStartDate(systemNotificationModel.getStartDate());
                systemNotification.setEndDate(systemNotificationModel.getEndDate());
                systemNotification.setMessage(StringUtils.trim(systemNotificationModel.getMessage()));
                systemNotification.setAllPages(systemNotificationModel.isAllPages());
                systemNotification.setNotificationType(systemNotificationModel.getNotificationType());
                systemNotification.setNotificationSeverity(systemNotificationModel.getNotificationSeverity());

                save(systemNotification);

                return systemNotification;
            }
View Full Code Here

    @Test
    public void delete_Success_Test() {
        Calendar futureDate = Calendar.getInstance();
        futureDate.add(Calendar.DATE, 1);
        SystemNotification systemNotification = createSystemNotification(true, new Date(), futureDate.getTime(), "test message", SystemNotificationType.MAINTENANCE, SystemNotificationSeverity.INFO);

        assertTrue(systemNotificationService.doesEntityExist(systemNotification.getId()));
        systemNotificationService.delete(systemNotification.getId());
        assertFalse(systemNotificationService.doesEntityExist(systemNotification.getId()));
    }
View Full Code Here

    @Test
    public void update_Success_Test() {
        Calendar futureDate = Calendar.getInstance();
        futureDate.add(Calendar.DATE, 1);
        SystemNotification systemNotification = createSystemNotification(true, new Date(), futureDate.getTime(), "test message", SystemNotificationType.MAINTENANCE, SystemNotificationSeverity.INFO);
        assertTrue(systemNotificationService.doesEntityExist(systemNotification.getId()));

        Date updatedStartDate = systemNotification.getStartDate();
        updatedStartDate.setTime(updatedStartDate.getTime() + 1000);

        Date updatedEndDate = systemNotification.getEndDate();
        updatedEndDate.setTime(updatedEndDate.getTime() + 1000);

        systemNotification.setAllPages(!systemNotification.isAllPages());
        systemNotification.setStartDate(updatedStartDate);
        systemNotification.setEndDate(updatedEndDate);
        systemNotification.setMessage("updated message");
        systemNotification.setNotificationSeverity(SystemNotificationSeverity.ERROR);

        systemNotificationService.update(systemNotification);

        SystemNotification updatedSystemNotification = systemNotificationService.get(systemNotification.getId());

        assertNotNull(updatedSystemNotification);
        assertEquals(updatedSystemNotification.getStartDate(), systemNotification.getStartDate());
        assertEquals(updatedSystemNotification.getEndDate(), systemNotification.getEndDate());
        assertEquals(updatedSystemNotification.isAllPages(), systemNotification.isAllPages());
        assertEquals(updatedSystemNotification.getMessage(), systemNotification.getMessage());
        assertEquals(updatedSystemNotification.getNotificationType(), systemNotification.getNotificationType());
        assertEquals(updatedSystemNotification.getNotificationSeverity(), systemNotification.getNotificationSeverity());
    }
View Full Code Here

    public void addSystemNotification_Success_Test() {
        Calendar futureDate = Calendar.getInstance();
        futureDate.add(Calendar.DATE, 1);
        SystemNotificationModel model = createSystemNotificationModel(null, true, new Date(), futureDate.getTime(), "test message", SystemNotificationType.MAINTENANCE, SystemNotificationSeverity.INFO);

        SystemNotification systemNotification = systemNotificationService.addSystemNotification(model);
        assertNotNull(systemNotification);
        assertNotNull(systemNotification.getId());
    }
View Full Code Here

    @Test
    public void editSystemNotification_Success_Test() {
        Calendar futureDate = Calendar.getInstance();
        futureDate.add(Calendar.DATE, 1);
        SystemNotification systemNotification = createSystemNotification(true, new Date(), futureDate.getTime(), "test message", SystemNotificationType.MAINTENANCE, SystemNotificationSeverity.INFO);
        assertNotNull(systemNotification);
        assertNotNull(systemNotification.getId());

        Date updatedStartDate = systemNotification.getStartDate();
        updatedStartDate.setTime(updatedStartDate.getTime() + 1000);

        Date updatedEndDate = systemNotification.getEndDate();
        updatedEndDate.setTime(updatedEndDate.getTime() + 1000);

        SystemNotificationModel updateModel = createSystemNotificationModel(systemNotification.getId(), !systemNotification.isAllPages(), updatedStartDate, updatedEndDate, "updated message", SystemNotificationType.MAINTENANCE, SystemNotificationSeverity.ERROR);

        SystemNotification updatedSystemNotification = systemNotificationService.editSystemNotification(updateModel);
        assertNotNull(updatedSystemNotification);
        assertEquals(updatedSystemNotification.getStartDate(), updateModel.getStartDate());
        assertEquals(updatedSystemNotification.getEndDate(), updateModel.getEndDate());
        assertEquals(updatedSystemNotification.isAllPages(), updateModel.isAllPages());
        assertEquals(updatedSystemNotification.getMessage(), updateModel.getMessage());
        assertEquals(updatedSystemNotification.getNotificationType(), updateModel.getNotificationType());
        assertEquals(updatedSystemNotification.getNotificationSeverity(), updateModel.getNotificationSeverity());
    }
View Full Code Here

    @Test
    public void getAllModels_noFilterDate_Success() {
        Calendar futureDate = Calendar.getInstance();
        futureDate.add(Calendar.DATE, 1);
        SystemNotification systemNotification1 = createSystemNotification(true, new Date(), futureDate.getTime(), "test message", SystemNotificationType.MAINTENANCE, SystemNotificationSeverity.INFO);
        SystemNotification systemNotification2 = createSystemNotification(true, new Date(), futureDate.getTime(), "test message", SystemNotificationType.MAINTENANCE, SystemNotificationSeverity.INFO);

        List<SystemNotificationModel> systemNotifications = systemNotificationService.getAllModels(false);
        assertNotNull(systemNotifications);
        assertEquals(systemNotifications.size(), 2);
    }
View Full Code Here

TOP

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

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.