use of org.teiid.translator.google.api.metadata.SpreadsheetInfo in project teiid by teiid.
the class SpreadsheetUpdateExecution method executeDelete.
private UpdateResult executeDelete() throws TranslatorException {
SpreadsheetInfo info = connection.getSpreadsheetInfo();
SpreadsheetDeleteVisitor visitor = new SpreadsheetDeleteVisitor(info);
visitor.visit((Delete) command);
checkHeaders(visitor.getWorksheetTitle());
result = connection.deleteRows(visitor.getWorksheetTitle(), visitor.getCriteriaQuery());
return result;
}
use of org.teiid.translator.google.api.metadata.SpreadsheetInfo in project teiid by teiid.
the class TestSQLtoSpreadsheetQuery method createSpreadSheetInfo.
@BeforeClass
public static void createSpreadSheetInfo() {
people = new SpreadsheetInfo("People");
Worksheet worksheet = people.createWorksheet("PeopleList");
worksheet.setHeaderEnabled(true);
for (int i = 1; i <= 4; i++) {
Column newCol = new Column();
newCol.setAlphaName(Util.convertColumnIDtoString(i));
newCol.setLabel(newCol.getAlphaName());
worksheet.addColumn(newCol.getAlphaName(), newCol);
}
worksheet.getColumns().get("C").setDataType(SpreadsheetColumnType.NUMBER);
worksheet.getColumns().get("D").setDataType(SpreadsheetColumnType.BOOLEAN);
}
use of org.teiid.translator.google.api.metadata.SpreadsheetInfo in project teiid by teiid.
the class SpreadsheetConnectionImpl4 method deleteRows.
@Override
public UpdateResult deleteRows(String worksheetTitle, String criteria) {
SpreadsheetInfo info = getV2SpreadsheetInfo();
org.teiid.translator.google.api.metadata.Worksheet sheet = info.getWorksheetByName(worksheetTitle);
if (sheet == null) {
// $NON-NLS-1$
throw new SpreadsheetOperationException(SpreadsheetManagedConnectionFactory.UTIL.getString("not_visible"));
}
return gdata.listFeedDelete(info.getSpreadsheetKey(), sheet.getId(), criteria);
}
use of org.teiid.translator.google.api.metadata.SpreadsheetInfo in project teiid by teiid.
the class SpreadsheetMetadataExtractor method extractMetadata.
public SpreadsheetInfo extractMetadata(String spreadsheetId) {
try {
Spreadsheet spreadsheet = sheetsAPI.getSpreadsheet(spreadsheetId);
SpreadsheetInfo metadata = new SpreadsheetInfo(spreadsheet.getProperties().getTitle());
metadata.setSpreadsheetKey(spreadsheet.getSpreadsheetId());
for (Sheet sheet : spreadsheet.getSheets()) {
String title = sheet.getProperties().getTitle();
Worksheet worksheet = metadata.createWorksheet(title);
worksheet.setId(sheet.getProperties().getSheetId().toString());
List<Column> cols = dataProtocolAPI.getMetadata(spreadsheet.getSpreadsheetId(), title);
if (!cols.isEmpty()) {
if (cols.get(0).getLabel() != null) {
worksheet.setHeaderEnabled(true);
}
}
for (Column c : cols) {
worksheet.addColumn(c.getLabel() != null ? c.getLabel() : c.getAlphaName(), c);
}
}
return metadata;
} catch (IOException ex) {
throw new SpreadsheetOperationException(SpreadsheetManagedConnectionFactory.UTIL.gs("metadata_error"), // $NON-NLS-1$
ex);
}
}
use of org.teiid.translator.google.api.metadata.SpreadsheetInfo in project teiid by teiid.
the class AbstractSpreadsheetExecution method checkHeaders.
void checkHeaders(String worksheetTitle) throws TranslatorException {
SpreadsheetInfo info = connection.getSpreadsheetInfo();
Worksheet worksheet = info.getWorksheetByName(worksheetTitle);
if (worksheet == null) {
// $NON-NLS-1$
throw new SpreadsheetOperationException(SpreadsheetExecutionFactory.UTIL.gs("missing_worksheet", worksheetTitle));
}
if (!worksheet.isHeaderEnabled()) {
// $NON-NLS-1$
throw new TranslatorException(SpreadsheetExecutionFactory.UTIL.gs("headers_required"));
}
}
Aggregations