Search in sources :

Example 1 with MagicCommandType

use of com.twosigma.beakerx.kernel.magic.command.MagicCommandType in project beakerx by twosigma.

the class KernelTest method initMagicCommands.

private void initMagicCommands() {
    this.magicCommandTypes = new ArrayList<>();
    this.magicCommandTypes.addAll(Lists.newArrayList(new MagicCommandType(JavaScriptMagicCommand.JAVASCRIPT, "", new JavaScriptMagicCommand()), new MagicCommandType(JSMagicCommand.JAVASCRIPT, "", new JSMagicCommand()), new MagicCommandType(HtmlMagicCommand.HTML, "", new HtmlMagicCommand()), new MagicCommandType(HtmlAliasMagicCommand.HTML, "", new HtmlAliasMagicCommand()), new MagicCommandType(BashMagicCommand.BASH, "", new BashMagicCommand()), new MagicCommandType(LsMagicCommand.LSMAGIC, "", new LsMagicCommand(this.magicCommandTypes)), new MagicCommandType(ClasspathAddRepoMagicCommand.CLASSPATH_CONFIG_RESOLVER, "repoName repoURL", new ClasspathAddRepoMagicCommand(this)), new MagicCommandType(ClasspathAddJarMagicCommand.CLASSPATH_ADD_JAR, "<jar path>", new ClasspathAddJarMagicCommand(this)), new MagicCommandType(ClasspathAddMvnMagicCommand.CLASSPATH_ADD_MVN, "<group name version>", new ClasspathAddMvnMagicCommand(mavenResolverParam, this)), new MagicCommandType(ClassPathAddMvnCellMagicCommand.CLASSPATH_ADD_MVN_CELL, "<group name version>", new ClassPathAddMvnCellMagicCommand(mavenResolverParam, this)), addClasspathReset(this), addDynamic(this), addMagicCommandWhichThrowsException(), new MagicCommandType(ClasspathShowMagicCommand.CLASSPATH_SHOW, "", new ClasspathShowMagicCommand(this)), new MagicCommandType(AddStaticImportMagicCommand.ADD_STATIC_IMPORT, "<classpath>", new AddStaticImportMagicCommand(this)), new MagicCommandType(AddImportMagicCommand.IMPORT, "<classpath>", new AddImportMagicCommand(this)), new MagicCommandType(UnImportMagicCommand.UNIMPORT, "<classpath>", new UnImportMagicCommand(this)), new MagicCommandType(TimeLineModeMagicCommand.TIME_LINE, "", new TimeLineModeMagicCommand(this)), new MagicCommandType(TimeCellModeMagicCommand.TIME_CELL, "", new TimeCellModeMagicCommand(this)), new MagicCommandType(TimeItLineModeMagicCommand.TIMEIT_LINE, "", new TimeItLineModeMagicCommand(this)), new MagicCommandType(TimeItCellModeMagicCommand.TIMEIT_CELL, "", new TimeItCellModeMagicCommand(this)), new MagicCommandType(LoadMagicMagicCommand.LOAD_MAGIC, "", new LoadMagicMagicCommand(this))));
}
Also used : ClasspathAddMvnMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddMvnMagicCommand) UnImportMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.UnImportMagicCommand) ClasspathAddRepoMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddRepoMagicCommand) AddImportMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.AddImportMagicCommand) HtmlAliasMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.HtmlAliasMagicCommand) HtmlMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.HtmlMagicCommand) TimeLineModeMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.TimeLineModeMagicCommand) TimeItLineModeMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.TimeItLineModeMagicCommand) JavaScriptMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.JavaScriptMagicCommand) TimeItCellModeMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.TimeItCellModeMagicCommand) LoadMagicMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.LoadMagicMagicCommand) AddStaticImportMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.AddStaticImportMagicCommand) BashMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.BashMagicCommand) ClassPathAddMvnCellMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.ClassPathAddMvnCellMagicCommand) MagicCommandType(com.twosigma.beakerx.kernel.magic.command.MagicCommandType) JSMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.JSMagicCommand) ClasspathShowMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathShowMagicCommand) TimeCellModeMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.TimeCellModeMagicCommand) ClasspathAddJarMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddJarMagicCommand) LsMagicCommand(com.twosigma.beakerx.kernel.magic.command.functionality.LsMagicCommand)

Example 2 with MagicCommandType

use of com.twosigma.beakerx.kernel.magic.command.MagicCommandType in project beakerx by twosigma.

the class SQL method registerCustomMagicCommands.

private void registerCustomMagicCommands() {
    registerMagicCommandType(new MagicCommandType(DATASOURCES, "<jdbc:[dbEngine]:[subsubprotocol:][databaseName]>", new DataSourcesMagicCommand(this)));
    registerMagicCommandType(new MagicCommandType(DEFAULT_DATASOURCE, "<sourceName=jdbc:[dbEngine]:[subsubprotocol:][databaseName]>", new DefaultDataSourcesMagicCommand(this)));
}
Also used : DefaultDataSourcesMagicCommand(com.twosigma.beakerx.sql.magic.command.DefaultDataSourcesMagicCommand) DataSourcesMagicCommand(com.twosigma.beakerx.sql.magic.command.DataSourcesMagicCommand) DefaultDataSourcesMagicCommand(com.twosigma.beakerx.sql.magic.command.DefaultDataSourcesMagicCommand) MagicCommandType(com.twosigma.beakerx.kernel.magic.command.MagicCommandType)

Example 3 with MagicCommandType

use of com.twosigma.beakerx.kernel.magic.command.MagicCommandType in project beakerx by twosigma.

the class SQLKernelTest method getMagicCommandTypes.

@Override
public List<MagicCommandType> getMagicCommandTypes() {
    List<MagicCommandType> magicCommands = super.getMagicCommandTypes();
    magicCommands.add(new MagicCommandType(DATASOURCES, "<jdbc:[dbEngine]:[subsubprotocol:][databaseName]>", new DataSourcesMagicCommand(this)));
    magicCommands.add(new MagicCommandType(DEFAULT_DATASOURCE, "<sourceName=jdbc:[dbEngine]:[subsubprotocol:][databaseName]>", new DefaultDataSourcesMagicCommand(this)));
    return magicCommands;
}
Also used : MagicCommandType(com.twosigma.beakerx.kernel.magic.command.MagicCommandType)

Example 4 with MagicCommandType

use of com.twosigma.beakerx.kernel.magic.command.MagicCommandType in project beakerx by twosigma.

the class LoadMagicMagicCommand method execute.

@Override
public MagicCommandOutcomeItem execute(MagicCommandExecutionParam param) {
    String command = param.getCommand();
    String[] split = splitPath(command);
    if (split.length != 2) {
        return new MagicCommandOutput(ERROR, WRONG_FORMAT_MSG + LOAD_MAGIC);
    }
    String clazzName = split[1];
    try {
        Class<?> aClass = this.kernel.loadClass(clazzName);
        Object instance = aClass.newInstance();
        if (instance instanceof MagicCommandFunctionality) {
            MagicCommandFunctionality commandFunctionality = (MagicCommandFunctionality) instance;
            kernel.registerMagicCommandType(new MagicCommandType(commandFunctionality.getMagicCommandName(), "", commandFunctionality));
            return new MagicCommandOutput(OK, "Magic command " + commandFunctionality.getMagicCommandName() + " was successfully added.");
        } else {
            return new MagicCommandOutput(ERROR, "Magic command have to implement " + MagicCommandFunctionality.class + " interface.");
        }
    } catch (Exception e) {
        return new MagicCommandOutput(ERROR, e.toString());
    }
}
Also used : MagicCommandOutput(com.twosigma.beakerx.kernel.magic.command.outcome.MagicCommandOutput) MagicCommandFunctionality(com.twosigma.beakerx.kernel.magic.command.MagicCommandFunctionality) MagicCommandType(com.twosigma.beakerx.kernel.magic.command.MagicCommandType)

Aggregations

MagicCommandType (com.twosigma.beakerx.kernel.magic.command.MagicCommandType)4 MagicCommandFunctionality (com.twosigma.beakerx.kernel.magic.command.MagicCommandFunctionality)1 AddImportMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.AddImportMagicCommand)1 AddStaticImportMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.AddStaticImportMagicCommand)1 BashMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.BashMagicCommand)1 ClassPathAddMvnCellMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClassPathAddMvnCellMagicCommand)1 ClasspathAddJarMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddJarMagicCommand)1 ClasspathAddMvnMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddMvnMagicCommand)1 ClasspathAddRepoMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathAddRepoMagicCommand)1 ClasspathShowMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.ClasspathShowMagicCommand)1 HtmlAliasMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.HtmlAliasMagicCommand)1 HtmlMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.HtmlMagicCommand)1 JSMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.JSMagicCommand)1 JavaScriptMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.JavaScriptMagicCommand)1 LoadMagicMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.LoadMagicMagicCommand)1 LsMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.LsMagicCommand)1 TimeCellModeMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.TimeCellModeMagicCommand)1 TimeItCellModeMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.TimeItCellModeMagicCommand)1 TimeItLineModeMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.TimeItLineModeMagicCommand)1 TimeLineModeMagicCommand (com.twosigma.beakerx.kernel.magic.command.functionality.TimeLineModeMagicCommand)1