Search in sources :

Example 1 with Installer

use of org.phoenicis.scripts.Installer in project POL-POM-5 by PhoenicisOrg.

the class CLIController method installApp.

@Option
@LongSwitch("install")
@ShortSwitch("i")
@AllAvailableArguments
public void installApp(List<String> arguments) {
    final String typeName = arguments.get(0);
    final String typeId = typeName;
    final String categoryName = arguments.get(1);
    final String categoryId = typeId + "." + categoryName;
    final String appName = arguments.get(2);
    final String appId = categoryId + "." + appName;
    final String scriptName = arguments.get(3);
    final String scriptId = appId + "." + scriptName;
    final ScriptDTO scriptDTO = repositoryManager.getScript(Arrays.asList(typeId, categoryId, appId, scriptId));
    if (scriptDTO == null) {
        LOGGER.error("Requested app does not exist: " + arguments);
        return;
    }
    final StringBuilder executeBuilder = new StringBuilder();
    executeBuilder.append(String.format("TYPE_ID=\"%s\";\n", scriptDTO.getTypeId()));
    executeBuilder.append(String.format("CATEGORY_ID=\"%s\";\n", scriptDTO.getCategoryId()));
    executeBuilder.append(String.format("APPLICATION_ID=\"%s\";\n", scriptDTO.getApplicationId()));
    executeBuilder.append(String.format("SCRIPT_ID=\"%s\";\n", scriptDTO.getId()));
    executeBuilder.append(scriptDTO.getScript());
    executeBuilder.append("\n");
    scriptInterpreter.createInteractiveSession().eval(executeBuilder.toString(), result -> {
        Value installer = (Value) result;
        installer.as(Installer.class).go();
    }, Throwable::printStackTrace);
}
Also used : ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) Installer(org.phoenicis.scripts.Installer) Value(org.graalvm.polyglot.Value) ShortSwitch(com.github.jankroken.commandline.annotations.ShortSwitch) Option(com.github.jankroken.commandline.annotations.Option) LongSwitch(com.github.jankroken.commandline.annotations.LongSwitch) AllAvailableArguments(com.github.jankroken.commandline.annotations.AllAvailableArguments)

Example 2 with Installer

use of org.phoenicis.scripts.Installer in project POL-POM-5 by PlayOnLinux.

the class CLIController method installApp.

@Option
@LongSwitch("install")
@ShortSwitch("i")
@AllAvailableArguments
public void installApp(List<String> arguments) {
    final String typeName = arguments.get(0);
    final String typeId = typeName;
    final String categoryName = arguments.get(1);
    final String categoryId = typeId + "." + categoryName;
    final String appName = arguments.get(2);
    final String appId = categoryId + "." + appName;
    final String scriptName = arguments.get(3);
    final String scriptId = appId + "." + scriptName;
    final ScriptDTO scriptDTO = repositoryManager.getScript(Arrays.asList(typeId, categoryId, appId, scriptId));
    if (scriptDTO == null) {
        LOGGER.error("Requested app does not exist: " + arguments);
        return;
    }
    final StringBuilder executeBuilder = new StringBuilder();
    executeBuilder.append(String.format("TYPE_ID=\"%s\";\n", scriptDTO.getTypeId()));
    executeBuilder.append(String.format("CATEGORY_ID=\"%s\";\n", scriptDTO.getCategoryId()));
    executeBuilder.append(String.format("APPLICATION_ID=\"%s\";\n", scriptDTO.getApplicationId()));
    executeBuilder.append(String.format("SCRIPT_ID=\"%s\";\n", scriptDTO.getId()));
    executeBuilder.append(scriptDTO.getScript());
    executeBuilder.append("\n");
    scriptInterpreter.createInteractiveSession().eval(executeBuilder.toString(), result -> {
        Value installer = (Value) result;
        installer.as(Installer.class).go();
    }, Throwable::printStackTrace);
}
Also used : ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) Installer(org.phoenicis.scripts.Installer) Value(org.graalvm.polyglot.Value) ShortSwitch(com.github.jankroken.commandline.annotations.ShortSwitch) Option(com.github.jankroken.commandline.annotations.Option) LongSwitch(com.github.jankroken.commandline.annotations.LongSwitch) AllAvailableArguments(com.github.jankroken.commandline.annotations.AllAvailableArguments)

Example 3 with Installer

use of org.phoenicis.scripts.Installer in project POL-POM-5 by PlayOnLinux.

the class ApplicationInformationPanelSkin method installScript.

/**
 * Install the given script
 *
 * @param script The script to be installed
 */
private void installScript(ScriptDTO script) {
    final StringBuilder executeBuilder = new StringBuilder();
    executeBuilder.append(String.format("TYPE_ID=\"%s\";\n", script.getTypeId()));
    executeBuilder.append(String.format("CATEGORY_ID=\"%s\";\n", script.getCategoryId()));
    executeBuilder.append(String.format("APPLICATION_ID=\"%s\";\n", script.getApplicationId()));
    executeBuilder.append(String.format("SCRIPT_ID=\"%s\";\n", script.getId()));
    executeBuilder.append(script.getScript());
    executeBuilder.append("\n");
    getControl().getScriptInterpreter().createInteractiveSession().eval(executeBuilder.toString(), result -> {
        Value installer = (Value) result;
        installer.as(Installer.class).go();
    }, e -> Platform.runLater(() -> {
        // no exception if installation is cancelled
        if (!(e.getCause() instanceof InterruptedException)) {
            final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("The script ended unexpectedly")).withException(e).build();
            errorDialog.showAndWait();
        }
    }));
}
Also used : Installer(org.phoenicis.scripts.Installer) Value(org.graalvm.polyglot.Value) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog)

Example 4 with Installer

use of org.phoenicis.scripts.Installer in project POL-POM-5 by PhoenicisOrg.

the class ApplicationInformationPanelSkin method installScript.

/**
 * Install the given script
 *
 * @param script The script to be installed
 */
private void installScript(ScriptDTO script) {
    final StringBuilder executeBuilder = new StringBuilder();
    executeBuilder.append(String.format("TYPE_ID=\"%s\";\n", script.getTypeId()));
    executeBuilder.append(String.format("CATEGORY_ID=\"%s\";\n", script.getCategoryId()));
    executeBuilder.append(String.format("APPLICATION_ID=\"%s\";\n", script.getApplicationId()));
    executeBuilder.append(String.format("SCRIPT_ID=\"%s\";\n", script.getId()));
    executeBuilder.append(script.getScript());
    executeBuilder.append("\n");
    getControl().getScriptInterpreter().createInteractiveSession().eval(executeBuilder.toString(), result -> {
        Value installer = (Value) result;
        installer.as(Installer.class).go();
    }, e -> Platform.runLater(() -> {
        // no exception if installation is cancelled
        if (!(e.getCause() instanceof InterruptedException)) {
            final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("The script ended unexpectedly")).withException(e).build();
            errorDialog.showAndWait();
        }
    }));
}
Also used : Installer(org.phoenicis.scripts.Installer) Value(org.graalvm.polyglot.Value) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog)

Aggregations

Value (org.graalvm.polyglot.Value)4 Installer (org.phoenicis.scripts.Installer)4 AllAvailableArguments (com.github.jankroken.commandline.annotations.AllAvailableArguments)2 LongSwitch (com.github.jankroken.commandline.annotations.LongSwitch)2 Option (com.github.jankroken.commandline.annotations.Option)2 ShortSwitch (com.github.jankroken.commandline.annotations.ShortSwitch)2 ErrorDialog (org.phoenicis.javafx.dialogs.ErrorDialog)2 ScriptDTO (org.phoenicis.repository.dto.ScriptDTO)2