Search in sources :

Example 1 with LocationAndArtifactToInstall

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());
    }
}
Also used : LocationAndArtifactToInstall(se.light.assembly64.model.LocationAndArtifactToInstall) ArtifactDelta(se.light.assembly64.model.ArtifactDelta) LoggerFactory(org.slf4j.LoggerFactory) PoisonPill(se.light.assembly64.model.PoisonPill) HashMap(java.util.HashMap) PathService(se.light.assembly64.service.PathService) ArrayList(java.util.ArrayList) Support.getVersionAsInteger(se.light.assembly64.Support.getVersionAsInteger) ArtifactType(se.light.assembly64.model.ArtifactType) Map(java.util.Map) CancelableTask(se.light.assembly64.model.CancelableTask) Support.getExecutor(se.light.assembly64.Support.getExecutor) Logger(org.slf4j.Logger) BlockingQueue(java.util.concurrent.BlockingQueue) Artifact(se.light.assembly64.model.Artifact) ArtifactsService(se.light.assembly64.service.ArtifactsService) LocalStorageUtil(se.light.assembly64.util.LocalStorageUtil) File(java.io.File) UserService(se.light.assembly64.service.UserService) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ProgressControlWrapper(se.light.assembly64.fx.ProgressControlWrapper) List(java.util.List) LocationAndArtifactToInstall(se.light.assembly64.model.LocationAndArtifactToInstall) SettingsController(se.light.assembly64.fx.SettingsController) Optional(java.util.Optional) InstallationService(se.light.assembly64.service.InstallationService) LocationAndInstallationStatus(se.light.assembly64.model.LocationAndInstallationStatus) Optional(java.util.Optional) LocationAndInstallationStatus(se.light.assembly64.model.LocationAndInstallationStatus) File(java.io.File)

Aggregations

File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Support.getExecutor (se.light.assembly64.Support.getExecutor)1 Support.getVersionAsInteger (se.light.assembly64.Support.getVersionAsInteger)1 ProgressControlWrapper (se.light.assembly64.fx.ProgressControlWrapper)1 SettingsController (se.light.assembly64.fx.SettingsController)1 Artifact (se.light.assembly64.model.Artifact)1 ArtifactDelta (se.light.assembly64.model.ArtifactDelta)1 ArtifactType (se.light.assembly64.model.ArtifactType)1 CancelableTask (se.light.assembly64.model.CancelableTask)1 LocationAndArtifactToInstall (se.light.assembly64.model.LocationAndArtifactToInstall)1 LocationAndInstallationStatus (se.light.assembly64.model.LocationAndInstallationStatus)1