Package com.sparc.knappsack.models

Examples of com.sparc.knappsack.models.SystemNotificationModel


            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 {
View Full Code Here


        List<SystemNotificationModel> models = new ArrayList<SystemNotificationModel>();

        List<SystemNotification> systemNotifications = getAll(filterByDate);
        if (systemNotifications != null) {
            for (SystemNotification systemNotification : systemNotifications) {
                SystemNotificationModel model = createSystemNotificationModel(systemNotification);

                if (model != null) {
                    models.add(model);
                }
            }
View Full Code Here

        for (SystemNotification systemNotification : systemNotificationDao.getAllForAllPages()) {
            if (filterByDate) {
                Date startDate = systemNotification.getStartDate();
                Date endDate = systemNotification.getEndDate();
                if (isDateInDateRange(currentDate, startDate, endDate)) {
                    SystemNotificationModel model = createSystemNotificationModel(systemNotification);
                    if (!models.contains(model)) {
                        models.add(model);
                    }
                }
            } else {
                SystemNotificationModel model = createSystemNotificationModel(systemNotification);
                if (!models.contains(model)) {
                    models.add(model);
                }
            }
        }
View Full Code Here

    public boolean doesEntityExist(Long id) {
        return get(id) != null;
    }

    private SystemNotificationModel createSystemNotificationModel(SystemNotification systemNotification) {
        SystemNotificationModel model = null;
        if (systemNotification != null) {
            model = new SystemNotificationModel();

            model.setId(systemNotification.getId());
            model.setStartDate(systemNotification.getStartDate());
            model.setEndDate(systemNotification.getEndDate());
            model.setMessage(systemNotification.getMessage());
            model.setNotificationType(systemNotification.getNotificationType());
            model.setNotificationSeverity(systemNotification.getNotificationSeverity());
            model.setAllPages(systemNotification.isAllPages());
        }
        return model;
    }
View Full Code Here

    @Test
    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

        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

        assertEquals(updatedSystemNotification.getNotificationSeverity(), updateModel.getNotificationSeverity());
    }

    @Test
    public void editSystemNotification_Failure_Test() {
        assertNull(systemNotificationService.editSystemNotification(new SystemNotificationModel()));
        assertNull(systemNotificationService.editSystemNotification(null));
    }
View Full Code Here

        return systemNotification;
    }

    private SystemNotificationModel createSystemNotificationModel(Long id, boolean allPages, Date startDate, Date endDate, String message, SystemNotificationType notificationType, SystemNotificationSeverity notificationSeverity) {
        SystemNotificationModel model = new SystemNotificationModel();
        if (id != null && id > 0) {
            model.setId(id);
        }
        model.setAllPages(allPages);
        model.setStartDate(startDate);
        model.setEndDate(endDate);
        model.setMessage(message);
        model.setNotificationType(notificationType);
        model.setNotificationSeverity(notificationSeverity);

        return model;
    }
View Full Code Here

TOP

Related Classes of com.sparc.knappsack.models.SystemNotificationModel

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.