/** * fetches the available versions of a certain engine * @param engineId engine ID (e.g. "wine") * @param callback callback which will be executed with the fetched engine versions * @param errorCallback callback which will be executed if an error occurs */ public void fetchAvailableVersions(String engineId, Consumer<List<EngineSubCategoryDTO>> callback, Consumer<Exception> errorCallback) { this.getEngine(engineId, engine -> callback.accept(unSerialize(engine.getAvailableVersions())), errorCallback); }
@Bean public EnginesManager enginesSource() { return new EnginesManager(scriptsConfiguration.scriptInterpreter(), phoenicisGlobalConfiguration.objectMapper()); }
/** * fetches the available engines * @param repositoryDTO * @param callback * @param errorCallback callback which will be executed if an error occurs */ public void fetchAvailableEngines(RepositoryDTO repositoryDTO, Consumer<Map<String, Engine>> callback, Consumer<Exception> errorCallback) { final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); interactiveScriptSession.eval(this.createFetchScript(repositoryDTO), output -> callback.accept((Map<String, Engine>) output), errorCallback); }
this.enginesManager.fetchAvailableVersions(engineId, versions -> { this.versionsCache.put(engineId, versions); .withOwner(enginesView.getContent().getScene().getWindow()) .withResizable(true) .withYesCallback(() -> this.enginesManager.getEngine(engineDTO.getId(), engine -> { engine.install(engineDTO.getSubCategory(), engineDTO.getVersion()); .withOwner(enginesView.getContent().getScene().getWindow()) .withResizable(true) .withYesCallback(() -> this.enginesManager.getEngine(engineDTO.getId(), engine -> { engine.delete(engineDTO.getSubCategory(), engineDTO.getVersion()); if (this.enginesView.isSelected() && this.firstViewSelection) { this.repositoryManager.addCallbacks( repositoryDTO -> this.enginesManager.fetchAvailableEngines( repositoryDTO, engines -> this.populateView(repositoryDTO, engines),
public void runInContainer(ContainerDTO container, String command, Runnable doneCallback, Consumer<Exception> errorCallback) { // TODO: better way to get engine ID final String engineId = container.getEngine().toLowerCase(); this.enginesManager.getEngine(engineId, engine -> { engine.setWorkingContainer(container.getName()); engine.run(command, new String[0], container.getPath(), false, true, new HashMap<>()); doneCallback.run(); }, errorCallback); } }
private void populateView(RepositoryDTO repositoryDTO, Map<String, Engine> engines) { this.repositoryCache = repositoryDTO; this.enginesCache = engines; // show a waiting screen until the engines are loaded Platform.runLater(enginesView::showWait); // fetch all categories consisting of engines that are contained in the repository final List<CategoryDTO> categoryDTOS = repositoryDTO.getTypes().stream() .filter(type -> type.getId().equals("engines")) .flatMap(type -> type.getCategories().stream()) .collect(Collectors.toList()); Platform.runLater(() -> { // generate the necessary css for the engine categories setDefaultEngineIcons(categoryDTOS); }); // fetch the engine categories objects contained in the engine categories final Queue<EngineCategoryDTO> engineCategories = new ArrayDeque<>( enginesManager.getAvailableEngines(categoryDTOS)); // insert the missing engine subcategories into the engine categories fetchEngineSubcategories(engineCategories, ImmutableMap.of(), subcategoryMap -> { final List<EngineCategoryDTO> categories = subcategoryMap.entrySet().stream() .map(entry -> new EngineCategoryDTO.Builder(entry.getKey()) .withSubCategories(entry.getValue()) .build()) .collect(Collectors.toList()); Platform.runLater(() -> { // update the view enginesView.populate(categories, engines); }); }); }
final String engineId = engineCategory.getName().toLowerCase(); enginesManager.fetchAvailableVersions( engineId, versions -> {