Search in sources :

Example 1 with ScrapeJobImpl

use of org.apache.plc4x.java.scraper.ScrapeJobImpl in project plc4x by apache.

the class ScraperConfigurationTriggeredImpl method getJobs.

public static List<ScrapeJob> getJobs(List<JobConfigurationImpl> jobConfigurations, Map<String, String> sources) throws ScraperConfigurationException {
    List<ScrapeJob> scrapeJobs = new ArrayList<>();
    for (JobConfiguration jobConfiguration : jobConfigurations) {
        if (jobConfiguration.getTriggerConfig() != null) {
            logger.info("Assuming job as triggered job because triggerConfig has been set");
            scrapeJobs.add(new TriggeredScrapeJobImpl(jobConfiguration.getName(), jobConfiguration.getTriggerConfig(), getSourcesForAliases(jobConfiguration.getSources(), sources), jobConfiguration.getFields()));
        } else {
            if (jobConfiguration.getScrapeRate() != null) {
                logger.info("Assuming job as classic job because triggerConfig has NOT been set but scrapeRate has.");
                scrapeJobs.add(new ScrapeJobImpl(jobConfiguration.getName(), jobConfiguration.getScrapeRate(), getSourcesForAliases(jobConfiguration.getSources(), sources), jobConfiguration.getFields()));
            } else {
                logger.info("Job has lack of trigger/scheduled config");
                throw new ScraperConfigurationException(String.format("Job %s was intended to be o triggered annotation, but no triggerConfig-Field could be found. Canceling!", jobConfiguration.getName()));
            }
        }
    }
    return scrapeJobs;
}
Also used : ScrapeJob(org.apache.plc4x.java.scraper.ScrapeJob) TriggeredScrapeJobImpl(org.apache.plc4x.java.scraper.triggeredscraper.TriggeredScrapeJobImpl) ScrapeJobImpl(org.apache.plc4x.java.scraper.ScrapeJobImpl) ScraperConfigurationException(org.apache.plc4x.java.scraper.exception.ScraperConfigurationException) ArrayList(java.util.ArrayList) TriggeredScrapeJobImpl(org.apache.plc4x.java.scraper.triggeredscraper.TriggeredScrapeJobImpl) JobConfiguration(org.apache.plc4x.java.scraper.config.JobConfiguration)

Aggregations

ArrayList (java.util.ArrayList)1 ScrapeJob (org.apache.plc4x.java.scraper.ScrapeJob)1 ScrapeJobImpl (org.apache.plc4x.java.scraper.ScrapeJobImpl)1 JobConfiguration (org.apache.plc4x.java.scraper.config.JobConfiguration)1 ScraperConfigurationException (org.apache.plc4x.java.scraper.exception.ScraperConfigurationException)1 TriggeredScrapeJobImpl (org.apache.plc4x.java.scraper.triggeredscraper.TriggeredScrapeJobImpl)1