use of com.thinkbiganalytics.jobrepo.query.model.JobStatusCountResult in project kylo by Teradata.
the class JobStatusTransform method ensureDateFromPeriodExists.
/**
* Enusre that the list contains a date matching Now - the Period. if not add it to the collection
*/
public static void ensureDateFromPeriodExists(List<JobStatusCount> jobStatusCounts, Period period) {
// add in the very first date relative to the period if it doesnt exist with a count of 0
if (jobStatusCounts != null && !jobStatusCounts.isEmpty()) {
// get the first min date in the result set
Date firstDateInResultSet = jobStatusCounts.stream().map(jobStatusCount -> jobStatusCount.getDate()).min(Date::compareTo).get();
Date firstDate = DateUtils.truncate(DateTimeUtil.getNowUTCTime().minus(period).toDate(), Calendar.DATE);
boolean containsFirstDate = jobStatusCounts.stream().anyMatch(jobStatusCount -> jobStatusCount.getDate().equals(firstDate));
if (!containsFirstDate) {
JobStatusCount first = jobStatusCounts.get(0);
JobStatusCount min = new JobStatusCountResult(first);
min.setDate(firstDate);
min.setCount(new Long(0));
jobStatusCounts.add(min);
}
}
}
use of com.thinkbiganalytics.jobrepo.query.model.JobStatusCountResult in project kylo by Teradata.
the class JobStatusTransform method jobStatusCount.
public static JobStatusCount jobStatusCount(com.thinkbiganalytics.metadata.api.jobrepo.job.JobStatusCount domain) {
JobStatusCount count = new JobStatusCountResult();
count.setCount(domain.getCount());
if (domain.getDate() != null) {
count.setDate(domain.getDate().toDate());
}
count.setFeedName(domain.getFeedName());
count.setFeedId(domain.getFeedId());
count.setStatus(domain.getStatus());
return count;
}
Aggregations