Skip to content

Commit

Permalink
Update the collector record if already existing else create a new one. (
Browse files Browse the repository at this point in the history
  • Loading branch information
rvema authored and Tapabrata "Topo" Pal committed Oct 26, 2018
1 parent eb0966b commit 6f61b41
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,19 @@ public Collector createCollector(Collector collector) {
Collector existing = collectorRepository.findByName(collector.getName());
if (existing != null) {
collector.setId(existing.getId());
/*
* Since this is invoked by api it always needs to be enabled and online,
* additionally since this record is fetched from the database existing record
* needs to updated with these values.
* */
existing.setEnabled(true);
existing.setOnline(true);
existing.setLastExecuted(System.currentTimeMillis());
return collectorRepository.save(existing);
}
/*
* create a new collector record
* */
return collectorRepository.save(collector);
}

Expand Down

0 comments on commit 6f61b41

Please sign in to comment.