use of com.teradata.jaqy.interfaces.Display in project jaqy by Teradata.
the class OpenCommand method execute.
@Override
public void execute(String[] args, boolean silent, JaqyInterpreter interpreter) throws Exception {
Session session = interpreter.getSession();
Display display = interpreter.getDisplay();
if (session == null) {
interpreter.error("No active sessions.");
}
if (!session.isClosed()) {
interpreter.error("The current session already has a connection open.");
}
CommandLine cmdLine = getCommandLine(args);
args = cmdLine.getArgs();
if (args.length == 0) {
interpreter.error("invalid command arguments.");
}
Properties prop = new Properties();
cmdLine.getOptions();
boolean hasUser = false;
boolean hasPassword = false;
for (Option option : cmdLine.getOptions()) {
if ("p".equals(option.getOpt())) {
prop.setProperty("password", option.getValue());
hasPassword = true;
} else if ("f".equals(option.getOpt())) {
String password = display.getPassword(interpreter, "Password: ");
prop.setProperty("password", password);
hasPassword = true;
} else if ("u".equals(option.getOpt())) {
prop.setProperty("user", option.getValue());
hasUser = true;
} else if ("D".equals(option.getOpt())) {
String key = option.getValue(0);
String value = option.getValue(1);
prop.setProperty(key, value);
}
}
if (hasUser && !hasPassword) {
// use a blank password if the user is specified and password is not.
prop.setProperty("password", "");
}
session.open(args[0], prop, interpreter, display);
}
use of com.teradata.jaqy.interfaces.Display in project jaqy by Teradata.
the class IfCommand method parse.
@Override
public void parse(String action, Object value, boolean silent, Globals globals, JaqyInterpreter interpreter) throws IOException {
globals.log(Level.INFO, "if condition = " + value);
Display display = interpreter.getDisplay();
if (value != null && (Boolean) value) {
globals.log(Level.INFO, "running if statement");
globals.log(Level.INFO, action);
globals.log(Level.INFO, "end if statement");
interpreter.interpret(new ReaderLineInput(new StringReader(action), interpreter.getDirectory(), false), false);
if (!silent) {
display.echo(interpreter, ".end " + getName(), false);
}
} else {
if (!silent) {
String[] lines = action.split("\n");
for (String line : lines) {
display.echo(interpreter, "-- skip: " + line, false);
}
display.echo(interpreter, ".end " + getName(), false);
}
}
}
use of com.teradata.jaqy.interfaces.Display in project jaqy by Teradata.
the class AliasCommand method parse.
@Override
public void parse(String action, Object value, boolean silent, Globals globals, JaqyInterpreter interpreter) {
if (!silent) {
Display display = interpreter.getDisplay();
display.echo(interpreter, action, false);
display.echo(interpreter, ".end " + getName(), false);
}
globals.getAliasManager().setAlias((String) value, action);
}
use of com.teradata.jaqy.interfaces.Display in project jaqy by Teradata.
the class ExecCommand method parse.
@Override
public void parse(String action, Object value, boolean silent, Globals globals, JaqyInterpreter interpreter) throws Exception {
SessionUtils.checkOpen(interpreter);
if (!silent) {
Display display = interpreter.getDisplay();
display.echo(interpreter, action, false);
}
Session session = interpreter.getSession();
session.executeQuery(action, interpreter, 1);
}
use of com.teradata.jaqy.interfaces.Display in project jaqy by Teradata.
the class RemarkCommand method parse.
@Override
public void parse(String action, Object value, boolean silent, Globals globals, JaqyInterpreter interpreter) throws IOException {
if (!silent) {
Display display = interpreter.getDisplay();
display.echo(interpreter, action, false);
display.echo(interpreter, ".end " + getName(), false);
}
}
Aggregations