Search in sources :

Example 1 with SpreadsheetUpdateVisitor

use of org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor in project teiid by teiid.

the class TestSQLtoSpreadsheetQuery method testUpdateConversion.

private void testUpdateConversion(String sql, String expectedCriteria) throws Exception {
    Update update = (Update) getCommand(sql);
    SpreadsheetUpdateVisitor spreadsheetVisitor = new SpreadsheetUpdateVisitor(people);
    spreadsheetVisitor.visit(update);
    assertEquals(expectedCriteria, spreadsheetVisitor.getCriteriaQuery());
}
Also used : SpreadsheetUpdateVisitor(org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor) Update(org.teiid.language.Update)

Example 2 with SpreadsheetUpdateVisitor

use of org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor in project teiid by teiid.

the class SpreadsheetUpdateExecution method executeUpdate.

private UpdateResult executeUpdate() throws TranslatorException {
    SpreadsheetInfo info = connection.getSpreadsheetInfo();
    SpreadsheetUpdateVisitor updateVisitor = new SpreadsheetUpdateVisitor(info);
    updateVisitor.visit((Update) command);
    checkHeaders(updateVisitor.getWorksheetTitle());
    result = connection.updateRows(updateVisitor.getWorksheetTitle(), updateVisitor.getCriteriaQuery(), updateVisitor.getChanges());
    return result;
}
Also used : SpreadsheetUpdateVisitor(org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor) SpreadsheetInfo(org.teiid.translator.google.api.metadata.SpreadsheetInfo)

Example 3 with SpreadsheetUpdateVisitor

use of org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor in project teiid by teiid.

the class TestSQLtoSpreadsheetQuery method testUpdateVisitorNull.

@Test
public void testUpdateVisitorNull() throws Exception {
    String sql = "UPDATE PeopleList set A = 'String,String', C = null where A='Str,Str'";
    SpreadsheetUpdateVisitor visitor = new SpreadsheetUpdateVisitor(people);
    visitor.visit((Update) getCommand(sql));
    assertEquals(2, visitor.getChanges().size());
    assertEquals("A", visitor.getChanges().get(0).getColumnID());
    assertEquals("'String,String", visitor.getChanges().get(0).getValue());
    assertEquals("C", visitor.getChanges().get(1).getColumnID());
    assertEquals("", visitor.getChanges().get(1).getValue());
    assertEquals("a = \"Str,Str\"", visitor.getCriteriaQuery());
}
Also used : SpreadsheetUpdateVisitor(org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor) Test(org.junit.Test)

Example 4 with SpreadsheetUpdateVisitor

use of org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor in project teiid by teiid.

the class TestSQLtoSpreadsheetQuery method testUpdateVisitorNullString.

// should fail as the null string would be treated as empty
@Test(expected = SpreadsheetOperationException.class)
public void testUpdateVisitorNullString() throws Exception {
    String sql = "UPDATE PeopleList set A = null where A='Str,Str'";
    SpreadsheetUpdateVisitor visitor = new SpreadsheetUpdateVisitor(people);
    visitor.visit((Update) getCommand(sql));
}
Also used : SpreadsheetUpdateVisitor(org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor) Test(org.junit.Test)

Example 5 with SpreadsheetUpdateVisitor

use of org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor in project teiid by teiid.

the class TestSQLtoSpreadsheetQuery method testUpdateVisitor.

@Test
public void testUpdateVisitor() throws Exception {
    String sql = "UPDATE PeopleList set A = 'String,String', C = 1.5";
    SpreadsheetUpdateVisitor visitor = new SpreadsheetUpdateVisitor(people);
    visitor.visit((Update) getCommand(sql));
    assertEquals(2, visitor.getChanges().size());
    assertEquals("A", visitor.getChanges().get(0).getColumnID());
    assertEquals("'String,String", visitor.getChanges().get(0).getValue());
    assertEquals("C", visitor.getChanges().get(1).getColumnID());
    assertEquals("1.5", visitor.getChanges().get(1).getValue());
    assertNull(visitor.getCriteriaQuery());
}
Also used : SpreadsheetUpdateVisitor(org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor) Test(org.junit.Test)

Aggregations

SpreadsheetUpdateVisitor (org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor)5 Test (org.junit.Test)3 Update (org.teiid.language.Update)1 SpreadsheetInfo (org.teiid.translator.google.api.metadata.SpreadsheetInfo)1