/src/main/java/org/atlasapi/equiv/OddJobRandomTaskModule.java

https://github.com/atlasapi/atlas · Java · 69 lines · 58 code · 11 blank · 0 comment · 0 complexity · cc236b91f5cee198694f20a8c5badc50 MD5 · raw file

  1. package org.atlasapi.equiv;
  2. import javax.annotation.PostConstruct;
  3. import org.atlasapi.equiv.update.tasks.ScheduleTaskProgressStore;
  4. import org.atlasapi.media.entity.Publisher;
  5. import org.atlasapi.persistence.audit.NoLoggingPersistenceAuditLog;
  6. import org.atlasapi.persistence.content.ContentResolver;
  7. import org.atlasapi.persistence.content.listing.ContentLister;
  8. import org.atlasapi.persistence.content.people.PersonStore;
  9. import org.atlasapi.persistence.lookup.mongo.MongoLookupEntryStore;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.context.annotation.Bean;
  12. import org.springframework.context.annotation.Configuration;
  13. import com.metabroadcast.common.persistence.mongo.DatabasedMongo;
  14. import com.metabroadcast.common.scheduling.RepetitionRules;
  15. import com.metabroadcast.common.scheduling.SimpleScheduler;
  16. import com.mongodb.ReadPreference;
  17. @Configuration
  18. public class OddJobRandomTaskModule {
  19. private @Autowired ContentLister lister;
  20. private @Autowired ContentResolver resolver;
  21. private @Autowired DatabasedMongo mongo;
  22. private @Autowired ScheduleTaskProgressStore progressStore;
  23. private @Autowired SimpleScheduler scheduler;
  24. private @Autowired PersonStore personStore;
  25. @PostConstruct
  26. public void setup() {
  27. scheduler.schedule(childRefUpdateTask(), RepetitionRules.NEVER);
  28. scheduler.schedule(personRefUpdateTask(), RepetitionRules.NEVER);
  29. scheduler.schedule(personLookupPopulationTask(), RepetitionRules.NEVER);
  30. scheduler.schedule(lookupRefUpdateTask(), RepetitionRules.NEVER);
  31. }
  32. @Bean
  33. public ChildRefUpdateController childRefUpdateTaskController() {
  34. return new ChildRefUpdateController(childRefUpdateTask(), resolver);
  35. }
  36. @Bean
  37. public ChildRefUpdateTask childRefUpdateTask() {
  38. return new ChildRefUpdateTask(lister, resolver, mongo, progressStore)
  39. .forPublishers(Publisher.all().toArray(new Publisher[]{}));
  40. }
  41. @Bean
  42. public PersonRefUpdateTask personRefUpdateTask() {
  43. return new PersonRefUpdateTask(lister, mongo, progressStore)
  44. .forPublishers(Publisher.RADIO_TIMES, Publisher.BBC, Publisher.PA);
  45. }
  46. @Bean
  47. public PersonLookupPopulationTask personLookupPopulationTask() {
  48. return new PersonLookupPopulationTask(mongo.collection("people"),
  49. new MongoLookupEntryStore(mongo.collection("peopleLookup"),
  50. new NoLoggingPersistenceAuditLog(),
  51. ReadPreference.primary()));
  52. }
  53. @Bean
  54. public LookupRefUpdateTask lookupRefUpdateTask() {
  55. return new LookupRefUpdateTask(mongo.collection("lookup"),
  56. mongo.collection("scheduling"));
  57. }
  58. }