private void updateData(List<OctopusApplication> octopusApplications) { for (OctopusApplication application : octopusApplications) { List<EnvironmentComponent> compList = new ArrayList<>(); List<EnvironmentStatus> statusList = new ArrayList<>(); long startApp = System.currentTimeMillis(); List<ApplicationDeploymentHistoryItem> applicationDeploymentHistoryItems = octopusClient.getApplicationDeploymentHistory(application); LOGGER.info("history ==>" + applicationDeploymentHistoryItems.size()); compList.addAll(getEnvironmentComponent(applicationDeploymentHistoryItems)); statusList.addAll(getEnvironmentStatus(applicationDeploymentHistoryItems)); LOGGER.info("compList ==>" + compList.size()); LOGGER.info("statusList ==>" + statusList.size()); if (!compList.isEmpty()) { List<EnvironmentComponent> existingComponents = envComponentRepository.findByCollectorItemId(application.getId()); envComponentRepository.delete(existingComponents); envComponentRepository.save(compList); } if (!statusList.isEmpty()) { List<EnvironmentStatus> existingStatuses = environmentStatusRepository.findByCollectorItemId(application.getId()); environmentStatusRepository.delete(existingStatuses); environmentStatusRepository.save(statusList); } log(" " + application.getApplicationName(), startApp); } }
@Override public void collect(OctopusCollector collector) { long start = System.currentTimeMillis(); clean(collector); addNewApplications(octopusClient.getApplications(), collector); List<OctopusApplication> applications = enabledApplications(collector, octopusSettings.getUrl()); LOGGER.info("Enabled Applications ==>" + applications.size()); updateData(applications); log("Finished", start); }