use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class DDLStringVisitor method visit.
public void visit(Database database) {
append(NEWLINE);
append("/*").append(NEWLINE);
append("###########################################").append(NEWLINE);
append("# START DATABASE ").append(database.getName()).append(NEWLINE);
append("###########################################").append(NEWLINE);
append("*/").append(NEWLINE);
append(CREATE).append(SPACE).append(DATABASE).append(SPACE).append(SQLStringVisitor.escapeSinglePart(database.getName())).append(SPACE).append(VERSION).append(SPACE).append(new Constant(database.getVersion()));
appendOptions(database);
append(SEMICOLON);
append(NEWLINE);
append(USE).append(SPACE).append(DATABASE).append(SPACE);
append(SQLStringVisitor.escapeSinglePart(database.getName())).append(SPACE);
append(VERSION).append(SPACE).append(new Constant(database.getVersion()));
append(SEMICOLON);
append(NEWLINE);
boolean outputDt = false;
for (Datatype dt : database.getMetadataStore().getDatatypes().values()) {
if (dt.getType() == Datatype.Type.Domain) {
outputDt = true;
break;
}
}
if (outputDt) {
append(NEWLINE);
append("--############ Domains ############");
append(NEWLINE);
for (Datatype dt : database.getMetadataStore().getDatatypes().values()) {
if (dt.isBuiltin()) {
continue;
}
visit(dt);
append(NEWLINE);
append(NEWLINE);
}
}
if (!database.getDataWrappers().isEmpty()) {
append(NEWLINE);
append("--############ Translators ############");
append(NEWLINE);
for (DataWrapper dw : database.getDataWrappers()) {
visit(dw);
append(NEWLINE);
append(NEWLINE);
}
}
if (!database.getServers().isEmpty()) {
append(NEWLINE);
append("--############ Servers ############");
append(NEWLINE);
for (Server server : database.getServers()) {
visit(server);
append(NEWLINE);
append(NEWLINE);
}
}
if (!database.getSchemas().isEmpty()) {
append(NEWLINE);
append("--############ Schemas ############");
append(NEWLINE);
for (Schema schema : database.getSchemas()) {
append(CREATE);
if (!schema.isPhysical()) {
append(SPACE).append(VIRTUAL);
}
append(SPACE).append(SCHEMA).append(SPACE).append(SQLStringVisitor.escapeSinglePart(schema.getName()));
if (!schema.getServers().isEmpty()) {
append(SPACE).append(SERVER);
boolean first = true;
for (Server s : schema.getServers()) {
if (first) {
first = false;
} else {
append(COMMA);
}
append(SPACE).append(SQLStringVisitor.escapeSinglePart(s.getName()));
}
}
appendOptions(schema);
append(SEMICOLON);
append(NEWLINE);
append(NEWLINE);
createdSchmea(schema);
}
}
if (!database.getRoles().isEmpty()) {
append(NEWLINE);
append("--############ Roles ############");
append(NEWLINE);
for (Role role : database.getRoles()) {
visit(role);
append(NEWLINE);
append(NEWLINE);
}
}
for (Schema schema : database.getSchemas()) {
append(NEWLINE);
append("--############ Schema:").append(schema.getName()).append(" ############");
append(NEWLINE);
append(SET).append(SPACE).append(SCHEMA).append(SPACE);
append(SQLStringVisitor.escapeSinglePart(schema.getName())).append(SEMICOLON);
append(NEWLINE);
append(NEWLINE);
visit(schema);
}
if (!database.getRoles().isEmpty()) {
append(NEWLINE);
append("--############ Grants ############");
append(NEWLINE);
for (Grant grant : database.getGrants()) {
visit(grant);
append(NEWLINE);
}
}
append(NEWLINE);
append("/*").append(NEWLINE);
append("###########################################").append(NEWLINE);
append("# END DATABASE ").append(database.getName()).append(NEWLINE);
append("###########################################").append(NEWLINE);
append("*/").append(NEWLINE);
append(NEWLINE);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class DDLStringVisitor method visit.
private void visit(Server server) {
append(CREATE).append(SPACE).append(SERVER).append(SPACE).append(SQLStringVisitor.escapeSinglePart(server.getName()));
if (!server.isVirtual()) {
append(SPACE).append(TYPE).append(SPACE).append(new Constant(server.getType()));
}
if (server.getVersion() != null) {
append(SPACE).append(VERSION).append(SPACE).append(new Constant(server.getVersion()));
}
append(SPACE).append(FOREIGN).append(SPACE).append(DATA).append(SPACE).append(WRAPPER).append(SPACE);
append(SQLStringVisitor.escapeSinglePart(server.getDataWrapper()));
appendOptions(server);
append(SEMICOLON);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestConnectorWorkItem method testProcedureBatching.
@Test
public void testProcedureBatching() throws Exception {
ProcedureExecution exec = new FakeProcedureExecution(2, 1);
// this has two result set columns and 1 out parameter
int total_columns = 3;
// $NON-NLS-1$
StoredProcedure command = (StoredProcedure) helpGetCommand("{call pm2.spTest8(?)}", EXAMPLE_BQT);
command.getInputParameters().get(0).setExpression(new Constant(1));
Call proc = new LanguageBridgeFactory(EXAMPLE_BQT).translate(command);
ProcedureBatchHandler pbh = new ProcedureBatchHandler(proc, exec);
assertEquals(total_columns, pbh.padRow(Arrays.asList(null, null)).size());
List params = pbh.getParameterRow();
assertEquals(total_columns, params.size());
// check the parameter value
assertEquals(Integer.valueOf(0), params.get(2));
try {
pbh.padRow(Arrays.asList(1));
// $NON-NLS-1$
fail("Expected exception from resultset mismatch");
} catch (TranslatorException err) {
assertEquals("TEIID30479 Could not process stored procedure results for EXEC spTest8(1). Expected 2 result set columns, but was 1. Please update your models to allow for stored procedure results batching.", // $NON-NLS-1$
err.getMessage());
}
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestInsertImpl method helpExample.
public static org.teiid.query.sql.lang.Insert helpExample(String groupName) {
GroupSymbol group = TestGroupImpl.helpExample(groupName);
ArrayList<ElementSymbol> elements = new ArrayList<ElementSymbol>();
// $NON-NLS-1$
elements.add(TestElementImpl.helpExample(groupName, "e1"));
// $NON-NLS-1$
elements.add(TestElementImpl.helpExample(groupName, "e2"));
// $NON-NLS-1$
elements.add(TestElementImpl.helpExample(groupName, "e3"));
// $NON-NLS-1$
elements.add(TestElementImpl.helpExample(groupName, "e4"));
ArrayList<Constant> values = new ArrayList<Constant>();
values.add(TestLiteralImpl.helpExample(1));
values.add(TestLiteralImpl.helpExample(2));
values.add(TestLiteralImpl.helpExample(3));
values.add(TestLiteralImpl.helpExample(4));
return new org.teiid.query.sql.lang.Insert(group, elements, values);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestLikeCriteriaImpl method helpExample.
public static MatchCriteria helpExample(String right, char escape, boolean negated) {
// $NON-NLS-1$ //$NON-NLS-2$
ElementSymbol e1 = TestElementImpl.helpExample("vm1.g1", "e1");
MatchCriteria match = new MatchCriteria(e1, new Constant(right), escape);
match.setNegated(negated);
return match;
}
Aggregations