use of org.iobserve.execution.actionscripts.AbstractActionScript in project iobserve-analysis by research-iobserve.
the class CLIEventListener method notifyUnsupportedActionsFound.
@Override
public void notifyUnsupportedActionsFound(final List<AbstractActionScript> unsupportedActions) {
final String unsupportedActionsDesc = unsupportedActions.stream().map(script -> script.getDescription()).collect(Collectors.joining("\n"));
if (!this.interactiveMode) {
throw new IllegalStateException("Could not execute all actions automatically, aborting.\n Not supported actions were:\n" + unsupportedActionsDesc);
}
CLIEventListener.LOGGER.info("The following actions can not be executed automatically:");
CLIEventListener.LOGGER.info(unsupportedActionsDesc);
CLIEventListener.LOGGER.info("You will be prompted to execute the tasks manually during the process. Do you want to continue?");
final Scanner scanner = new Scanner(System.in);
if (!scanner.nextBoolean()) {
scanner.close();
throw new RuntimeException("User aborted during adaptation execution.");
}
scanner.close();
}
use of org.iobserve.execution.actionscripts.AbstractActionScript in project iobserve-analysis by research-iobserve.
the class AdaptationExecution method execute.
@Override
protected void execute(final AdaptationData element) throws Exception {
AdaptationExecution.LOGGER.info("Executing adaptation");
element.setDeployablesFolderURI(this.deployablesFolderURI);
final List<AbstractActionScript> notAutoSupported = new ArrayList<>();
final List<AbstractActionScript> actionScripts = new ArrayList<>();
final ActionScriptFactory actionFactory = new ActionScriptFactory(element);
// TODO Finish, by adding execution. Maybe Async?
for (final Action action : element.getExecutionOrder()) {
final AbstractActionScript script = actionFactory.getExecutionScript(action);
actionScripts.add(script);
if (!script.isAutoExecutable()) {
notAutoSupported.add(script);
}
}
if (notAutoSupported.size() > 0) {
if (this.listener == null) {
final String unsupportedActionsDesc = notAutoSupported.stream().map(script -> script.getDescription()).collect(Collectors.joining("\n"));
throw new IllegalStateException("Could not execute all actions automatically, aborting.\n Not supported actions were:\n" + unsupportedActionsDesc);
}
this.listener.notifyUnsupportedActionsFound(notAutoSupported);
}
SystemEvaluation.enableEvaluation(element);
try {
actionScripts.forEach(script -> {
try {
script.execute();
} catch (final Exception e) {
if (this.listener == null) {
throw new IllegalStateException("Could not execute action script '" + script.getDescription() + "' automatically and no listener was present. Aborting!");
}
this.listener.notifyExecutionError(script, e);
}
});
} finally {
SystemEvaluation.disableEvaluation();
}
}
Aggregations