Search in sources :

Example 6 with SpreadsheetInfo

use of org.teiid.translator.google.api.metadata.SpreadsheetInfo in project teiid by teiid.

the class SpreadsheetConnectionImpl method updateRows.

@Override
public UpdateResult updateRows(String worksheetTitle, String criteria, List<UpdateSet> set) {
    SpreadsheetInfo info = getSpreadsheetInfo();
    org.teiid.translator.google.api.metadata.Worksheet sheet = info.getWorksheetByName(worksheetTitle);
    return gdata.listFeedUpdate(info.getSpreadsheetKey(), sheet.getId(), criteria, set, sheet.getColumnsAsList());
}
Also used : SpreadsheetInfo(org.teiid.translator.google.api.metadata.SpreadsheetInfo)

Example 7 with SpreadsheetInfo

use of org.teiid.translator.google.api.metadata.SpreadsheetInfo in project teiid by teiid.

the class SpreadsheetConnectionImpl4 method updateRows.

@Override
public UpdateResult updateRows(String worksheetTitle, String criteria, List<UpdateSet> set) {
    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.listFeedUpdate(info.getSpreadsheetKey(), sheet.getId(), criteria, set, sheet.getColumnsAsList());
}
Also used : SpreadsheetInfo(org.teiid.translator.google.api.metadata.SpreadsheetInfo) SpreadsheetOperationException(org.teiid.translator.google.api.SpreadsheetOperationException)

Example 8 with SpreadsheetInfo

use of org.teiid.translator.google.api.metadata.SpreadsheetInfo in project teiid by teiid.

the class SpreadsheetConnectionImpl4 method getV2SpreadsheetInfo.

public SpreadsheetInfo getV2SpreadsheetInfo() {
    SpreadsheetInfo info = v2spreadsheetInfo.get();
    if (info == null) {
        synchronized (v2spreadsheetInfo) {
            info = v2spreadsheetInfo.get();
            if (info == null) {
                org.teiid.resource.adapter.google.gdata.SpreadsheetMetadataExtractor metadataExtractor = new org.teiid.resource.adapter.google.gdata.SpreadsheetMetadataExtractor();
                metadataExtractor.setVisualizationAPI(googleDataProtocolAPI);
                metadataExtractor.setGdataAPI(gdata);
                info = metadataExtractor.extractMetadata(config.getSpreadsheetId(), true);
                v2spreadsheetInfo.set(info);
            }
        }
    }
    return info;
}
Also used : SpreadsheetMetadataExtractor(org.teiid.resource.adapter.google.v4.SpreadsheetMetadataExtractor) SpreadsheetInfo(org.teiid.translator.google.api.metadata.SpreadsheetInfo)

Example 9 with SpreadsheetInfo

use of org.teiid.translator.google.api.metadata.SpreadsheetInfo in project teiid by teiid.

the class SpreadsheetConnectionImpl4 method getSpreadsheetInfo.

@Override
public SpreadsheetInfo getSpreadsheetInfo() {
    SpreadsheetInfo info = spreadsheetInfo.get();
    if (info == null) {
        synchronized (spreadsheetInfo) {
            info = spreadsheetInfo.get();
            if (info == null) {
                SpreadsheetMetadataExtractor metadataExtractor = new SpreadsheetMetadataExtractor(sheetsAPI, googleDataProtocolAPI);
                info = metadataExtractor.extractMetadata(config.getSpreadsheetId());
                spreadsheetInfo.set(info);
            }
        }
    }
    return info;
}
Also used : SpreadsheetMetadataExtractor(org.teiid.resource.adapter.google.v4.SpreadsheetMetadataExtractor) SpreadsheetInfo(org.teiid.translator.google.api.metadata.SpreadsheetInfo)

Example 10 with SpreadsheetInfo

use of org.teiid.translator.google.api.metadata.SpreadsheetInfo 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)

Aggregations

SpreadsheetInfo (org.teiid.translator.google.api.metadata.SpreadsheetInfo)15 SpreadsheetOperationException (org.teiid.translator.google.api.SpreadsheetOperationException)5 Worksheet (org.teiid.translator.google.api.metadata.Worksheet)5 Column (org.teiid.translator.google.api.metadata.Column)4 IOException (java.io.IOException)2 Test (org.junit.Test)2 SpreadsheetMetadataExtractor (org.teiid.resource.adapter.google.gdata.SpreadsheetMetadataExtractor)2 SpreadsheetMetadataExtractor (org.teiid.resource.adapter.google.v4.SpreadsheetMetadataExtractor)2 Sheet (com.google.api.services.sheets.v4.model.Sheet)1 Spreadsheet (com.google.api.services.sheets.v4.model.Spreadsheet)1 SpreadsheetEntry (com.google.gdata.data.spreadsheet.SpreadsheetEntry)1 WorksheetEntry (com.google.gdata.data.spreadsheet.WorksheetEntry)1 ServiceException (com.google.gdata.util.ServiceException)1 Properties (java.util.Properties)1 BeforeClass (org.junit.BeforeClass)1 MetadataFactory (org.teiid.metadata.MetadataFactory)1 Table (org.teiid.metadata.Table)1 TranslatorException (org.teiid.translator.TranslatorException)1 GoogleSpreadsheetConnection (org.teiid.translator.google.api.GoogleSpreadsheetConnection)1 SpreadsheetDeleteVisitor (org.teiid.translator.google.visitor.SpreadsheetDeleteVisitor)1