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;
}
Aggregations