Search in sources :

Example 1 with SpreadsheetMetadataExtractor

use of org.teiid.resource.adapter.google.gdata.SpreadsheetMetadataExtractor in project teiid by teiid.

the class MetadataLoadingTest method testMetadata.

@Test
public void testMetadata() {
    SpreadsheetMetadataExtractor extractor = new SpreadsheetMetadataExtractor();
    extractor.setGdataAPI(gdata);
    extractor.setVisualizationAPI(visualizationAPI);
    SpreadsheetInfo metadata = extractor.extractMetadata("integration_tests", false);
    Assert.assertEquals(0, metadata.getWorksheetByName("Sheet1").getColumnCount());
    Assert.assertEquals(2, metadata.getWorksheetByName("Sheet2").getColumnCount());
    metadata = extractor.extractMetadata("people", false);
    Assert.assertEquals(5, metadata.getWorksheetByName("list").getColumnCount());
    Assert.assertEquals(4, metadata.getWorksheetByName("phones").getColumnCount());
}
Also used : SpreadsheetMetadataExtractor(org.teiid.resource.adapter.google.gdata.SpreadsheetMetadataExtractor) SpreadsheetInfo(org.teiid.translator.google.api.metadata.SpreadsheetInfo) Test(org.junit.Test)

Example 2 with SpreadsheetMetadataExtractor

use of org.teiid.resource.adapter.google.gdata.SpreadsheetMetadataExtractor in project teiid by teiid.

the class SpreadsheetConnectionImpl 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();
                metadataExtractor.setGdataAPI(gdata);
                metadataExtractor.setVisualizationAPI(dataProtocol);
                if (config.getSpreadsheetId() == null) {
                    info = metadataExtractor.extractMetadata(config.getSpreadsheetName(), false);
                } else {
                    info = metadataExtractor.extractMetadata(config.getSpreadsheetId(), true);
                }
                spreadsheetInfo.set(info);
            }
        }
    }
    return info;
}
Also used : SpreadsheetMetadataExtractor(org.teiid.resource.adapter.google.gdata.SpreadsheetMetadataExtractor) SpreadsheetInfo(org.teiid.translator.google.api.metadata.SpreadsheetInfo)

Aggregations

SpreadsheetMetadataExtractor (org.teiid.resource.adapter.google.gdata.SpreadsheetMetadataExtractor)2 SpreadsheetInfo (org.teiid.translator.google.api.metadata.SpreadsheetInfo)2 Test (org.junit.Test)1