use of se.light.assembly64.model.LocationAndArtifactToInstall in project assembly64fx by freabemania.
the class Scheduler method addToQueue.
public void addToQueue(Integer installation, Artifact entry) {
File location = UserService.getInstance().getLocation(installation).asFile();
Optional<LocationAndArtifactToInstall> itemPossiblyAlreadyInList = workQueue.stream().filter(item -> item.getArtifact().getName().equals(entry.getName())).findFirst();
LocationAndInstallationStatus tmp = LocationAndInstallationStatus.builder().location(location).id(installation).build();
if (itemPossiblyAlreadyInList.isPresent()) {
LOGGER.info("Adding " + entry.getName() + " " + installation + " to already in queue");
ProgressControlWrapper.getInstance().addProgressSteps(countNofItems(tmp, entry));
itemPossiblyAlreadyInList.get().addLocationAndInstallationStatus(tmp);
} else if (currentlyInstalling.containsKey(entry.getName())) {
LOGGER.info("Adding " + entry.getName() + " to current worker");
ProgressControlWrapper.getInstance().addProgressSteps(countNofItems(tmp, entry));
currentlyInstalling.get(entry.getName()).addLocationAndInstallationStatus(tmp);
} else {
Optional<Artifact> first = artifactsService.getArtifactsDb().stream().filter(item -> item.isMarkedForUpdate() || item.isUpdating()).findFirst();
LocationAndInstallationStatus locationAndInstallation = LocationAndInstallationStatus.builder().location(location).id(installation).build();
if (!first.isPresent()) {
ProgressControlWrapper.getInstance().resetThreadIdMapping();
ProgressControlWrapper.getInstance().setProgressSteps(countNofItems(locationAndInstallation, entry));
} else {
ProgressControlWrapper.getInstance().addProgressSteps(countNofItems(locationAndInstallation, entry));
}
entry.setMarkedForUpdate(true);
// Main.resolveFXMain().refreshTree();
Support.refreshTree();
workQueue.offer(LocationAndArtifactToInstall.builder().artifact(entry).locationsAndInstallationStatus(LocationAndInstallationStatus.builder().location(location).id(installation).build()).build());
}
}
Aggregations