Package org.fao.geonet.services.notifications.domain

Examples of org.fao.geonet.services.notifications.domain.NotificationTarget


        @SuppressWarnings("unchecked")
        List<Element> parameters = params.getChildren();
        for(Element parameter : parameters) {
            String identifier = parameter.getName().substring(parameter.getName().lastIndexOf('-') + 1);
            if(notificationTargets.containsKey(identifier)) {
                NotificationTarget notificationTarget = notificationTargets.get(identifier);
                notificationTarget = parameterToNotificationTarget(parameter, notificationTarget);
            }
            else {
                NotificationTarget notificationTarget = new NotificationTarget();
                notificationTarget.setId(identifier);
                notificationTarget = parameterToNotificationTarget(parameter, notificationTarget);
                notificationTargets.put(identifier, notificationTarget);
            }

        }
        final MetadataNotificationRepository notificationRepository = context.getBean(MetadataNotificationRepository.class);
        final MetadataNotifierRepository notifierRepository = context.getBean(MetadataNotifierRepository.class);

        for(NotificationTarget notificationTarget : notificationTargets.values()) {
            final MetadataNotifier metadataNotifier = new MetadataNotifier();
            metadataNotifier.setName(notificationTarget.getName());
            metadataNotifier.setUsername(notificationTarget.getUsername());
            metadataNotifier.setPassword(notificationTarget.getPassword());
            metadataNotifier.setUrl(notificationTarget.getUrl());
            metadataNotifier.setEnabled(notificationTarget.isEnabled());

            // insert
            if (!notificationTarget.isPreExisting() && StringUtils.isNotBlank(notificationTarget.getName())
                    && StringUtils.isNotBlank(notificationTarget.getUrl())) {

                notifierRepository.save(metadataNotifier);
            } else if(notificationTarget.isPreExisting()) {
                // pre-existing
                String id = notificationTarget.getId();
                // delete
                if(notificationTarget.getName() == null) {
                    int iid = Integer.parseInt(id);
                    notificationRepository.deleteAllWithNotifierId(iid);
                    notifierRepository.delete(iid);
                } else {
                    // update
View Full Code Here

TOP

Related Classes of org.fao.geonet.services.notifications.domain.NotificationTarget

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.