Search in sources :

Example 1 with NotificationResource

use of org.apache.airavata.registry.core.experiment.catalog.resources.NotificationResource in project airavata by apache.

the class NotificationRegistry method getNotification.

public Notification getNotification(String notificationId) throws RegistryException {
    NotificationResource notificationResource = new NotificationResource();
    NotificationResource resource = (NotificationResource) notificationResource.get(ResourceType.NOTIFICATION, notificationId);
    if (resource != null) {
        return ThriftDataModelConversion.getNotification(resource);
    }
    return null;
}
Also used : NotificationResource(org.apache.airavata.registry.core.experiment.catalog.resources.NotificationResource)

Example 2 with NotificationResource

use of org.apache.airavata.registry.core.experiment.catalog.resources.NotificationResource in project airavata by apache.

the class NotificationRegistry method deleteNotification.

public void deleteNotification(String notificationId) throws RegistryException {
    NotificationResource notificationResource = new NotificationResource();
    notificationResource.remove(ResourceType.NOTIFICATION, notificationId);
}
Also used : NotificationResource(org.apache.airavata.registry.core.experiment.catalog.resources.NotificationResource)

Example 3 with NotificationResource

use of org.apache.airavata.registry.core.experiment.catalog.resources.NotificationResource in project airavata by apache.

the class NotificationRegistry method updateNotification.

public void updateNotification(Notification notification) throws RegistryException {
    NotificationResource notificationResource = new NotificationResource();
    notificationResource.setNotificationId(notification.getNotificationId());
    notificationResource.setGatewayId(notification.getGatewayId());
    notificationResource.setTitle(notification.getTitle());
    notificationResource.setNotificationMessage(notification.getNotificationMessage());
    notificationResource.setPriority(notification.getPriority().toString());
    if (notification.getPublishedTime() != 0)
        notificationResource.setPublishedTime(new Timestamp(notification.getPublishedTime()));
    if (notification.getExpirationTime() != 0)
        notificationResource.setExpirationTime(new Timestamp(notification.getExpirationTime()));
    if (notification.getCreationTime() != 0)
        notificationResource.setCreationTime(new Timestamp(notification.getCreationTime()));
    else
        notificationResource.setCreationTime(new Timestamp(System.currentTimeMillis()));
    notificationResource.save();
}
Also used : NotificationResource(org.apache.airavata.registry.core.experiment.catalog.resources.NotificationResource) Timestamp(java.sql.Timestamp)

Example 4 with NotificationResource

use of org.apache.airavata.registry.core.experiment.catalog.resources.NotificationResource in project airavata by apache.

the class NotificationRegistry method getAllGatewayNotifications.

public List<Notification> getAllGatewayNotifications(String gatewayId) throws RegistryException {
    List<Notification> notifications = new ArrayList<>();
    NotificationResource notificationResource = new NotificationResource();
    List<ExperimentCatResource> resources = notificationResource.getAllNotifications(gatewayId);
    if (resources != null && !resources.isEmpty()) {
        for (ExperimentCatResource e : resources) {
            notifications.add(ThriftDataModelConversion.getNotification((NotificationResource) e));
        }
    }
    Collections.sort(notifications, (o1, o2) -> (o2.getCreationTime() - o1.getCreationTime()) > 0 ? 1 : -1);
    return notifications;
}
Also used : NotificationResource(org.apache.airavata.registry.core.experiment.catalog.resources.NotificationResource) Notification(org.apache.airavata.model.workspace.Notification) ExperimentCatResource(org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource)

Aggregations

NotificationResource (org.apache.airavata.registry.core.experiment.catalog.resources.NotificationResource)4 Timestamp (java.sql.Timestamp)1 Notification (org.apache.airavata.model.workspace.Notification)1 ExperimentCatResource (org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource)1