Search in sources :

Example 6 with Alert

use of org.plos.ned_client.model.Alert in project wombat by PLOS.

the class AlertService method createAlertForSubject.

/**
 * Create a new JSON alert object for the subject in that journal.
 *
 * @param journalKey The journal key.
 * @param subjectName The subject to create alert for.
 * @return JSON alert object.
 */
private Alert createAlertForSubject(String journalKey, String subjectName) {
    AlertQuery query = new AlertQuery();
    query.setFilterJournals(ImmutableList.of(journalKey));
    query.setFilterSubjectsDisjunction(ImmutableList.of(subjectName));
    Alert alert = new Alert();
    alert.setSource(ALERT_SOURCE);
    alert.setFrequency(ALERT_FREQUENCY);
    alert.setName(ALERT_NAME);
    alert.setQuery(gson.toJson(query));
    return alert;
}
Also used : AlertQuery(org.ambraproject.wombat.model.AlertQuery) Alert(org.plos.ned_client.model.Alert)

Example 7 with Alert

use of org.plos.ned_client.model.Alert in project wombat by PLOS.

the class AlertService method addSearchAlert.

public void addSearchAlert(String authId, String name, String query, String frequency) throws IOException {
    String userId = userApi.getUserIdFromAuthId(authId);
    Alert alert = createAlertForSearch(name, query, frequency);
    userApi.postObject(ApiAddress.builder("individuals").addToken(userId).addToken("alerts").build(), alert);
}
Also used : Alert(org.plos.ned_client.model.Alert)

Aggregations

Alert (org.plos.ned_client.model.Alert)7 AlertQuery (org.ambraproject.wombat.model.AlertQuery)4 ApiAddress (org.ambraproject.wombat.service.remote.ApiAddress)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Gson (com.google.gson.Gson)1 TypeToken (com.google.gson.reflect.TypeToken)1 IOException (java.io.IOException)1 Type (java.lang.reflect.Type)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 UserApi (org.ambraproject.wombat.service.remote.UserApi)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 MultiValueMap (org.springframework.util.MultiValueMap)1