Search in sources :

Example 6 with Sheets

use of com.google.api.services.sheets.v4.Sheets in project repairnator by Spirals-Team.

the class NopolSerializer method main.

public static void main(String[] args) throws IOException, GeneralSecurityException {
    GoogleSpreadSheetFactory.initWithFileSecret("client_secret.json");
    GoogleSpreadSheetFactory.setSpreadsheetId(args[1]);
    Sheets sheets = GoogleSpreadSheetFactory.getSheets();
    List<List<Object>> results = sheets.spreadsheets().values().get(GoogleSpreadSheetFactory.getSpreadsheetID(), "Nopol Stats!A:T").execute().getValues();
    MongoConnection mongoConnection = new MongoConnection(args[0], "repairnator");
    if (!mongoConnection.isConnected()) {
        throw new RuntimeException("Error when connection to mongodb");
    }
    MongoDBSerializerEngine serializerEngine = new MongoDBSerializerEngine(mongoConnection);
    List<SerializedData> data = new ArrayList<>();
    for (int i = 1; i < results.size(); i++) {
        List<Object> value = results.get(i);
        JsonObject result = new JsonObject();
        result.addProperty("buildId", Utils.getValue(value, 3));
        result.addProperty("repositoryName", Utils.getValue(value, 4));
        result.addProperty("hostname", Utils.getValue(value, 0));
        result.addProperty("nopolDateEnd", Utils.getValue(value, 1));
        result.addProperty("nopolDayEnd", Utils.getValue(value, 2));
        result.addProperty("testClassLocation", Utils.getValue(value, 5));
        result.addProperty("failures", Utils.getValue(value, 6));
        result.addProperty("allocatedTime", Utils.getValue(value, 7));
        result.addProperty("passingTime", Utils.getValue(value, 8));
        result.addProperty("status", Utils.getValue(value, 9));
        result.addProperty("exceptionDetail", Utils.getValue(value, 10));
        result.addProperty("patchNumber", Utils.getValue(value, 11));
        result.addProperty("patchType", Utils.getValue(value, 12));
        result.addProperty("patch", Utils.getValue(value, 13));
        result.addProperty("patchLocation", Utils.getValue(value, 14));
        result.addProperty("nopolContext", Utils.getValue(value, 15));
        result.addProperty("nbAngelicValues", Utils.getValue(value, 16));
        result.addProperty("nbStatements", Utils.getValue(value, 17));
        result.addProperty("ignoreStatus", Utils.getValue(value, 18));
        result.addProperty("runId", Utils.getValue(value, 19));
        data.add(new SerializedData(Collections.EMPTY_LIST, result));
    }
    serializerEngine.serialize(data, SerializerType.NOPOL);
}
Also used : ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) MongoDBSerializerEngine(fr.inria.spirals.repairnator.serializer.engines.json.MongoDBSerializerEngine) ArrayList(java.util.ArrayList) List(java.util.List) JsonObject(com.google.gson.JsonObject) MongoConnection(fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection) Sheets(com.google.api.services.sheets.v4.Sheets)

Example 7 with Sheets

use of com.google.api.services.sheets.v4.Sheets in project repairnator by Spirals-Team.

the class InspectorSerializer method main.

public static void main(String[] args) throws IOException, GeneralSecurityException {
    GoogleSpreadSheetFactory.initWithFileSecret("client_secret.json");
    GoogleSpreadSheetFactory.setSpreadsheetId(args[1]);
    Sheets sheets = GoogleSpreadSheetFactory.getSheets();
    List<List<Object>> results = sheets.spreadsheets().values().get(GoogleSpreadSheetFactory.getSpreadsheetID(), "All data!A:L").execute().getValues();
    MongoConnection mongoConnection = new MongoConnection(args[0], "repairnator");
    if (!mongoConnection.isConnected()) {
        throw new RuntimeException("Error when connection to mongodb");
    }
    MongoDBSerializerEngine serializerEngine = new MongoDBSerializerEngine(mongoConnection);
    List<SerializedData> data = new ArrayList<>();
    for (int i = 1; i < results.size(); i++) {
        List<Object> value = results.get(i);
        JsonObject result = new JsonObject();
        result.addProperty("buildId", Utils.getValue(value, 0));
        result.addProperty("repositoryName", Utils.getValue(value, 1));
        result.addProperty("status", Utils.getValue(value, 2));
        result.addProperty("prNumber", Utils.getValue(value, 3));
        result.addProperty("buildFinishedDate", Utils.getValue(value, 4));
        result.addProperty("buildFinishedDay", Utils.getValue(value, 5));
        result.addProperty("realStatus", Utils.getValue(value, 6));
        result.addProperty("hostname", Utils.getValue(value, 7));
        result.addProperty("buildReproductionDate", Utils.getValue(value, 8));
        result.addProperty("travisURL", Utils.getValue(value, 9));
        result.addProperty("typeOfFailures", Utils.getValue(value, 10));
        result.addProperty("runId", Utils.getValue(value, 11));
        data.add(new SerializedData(Collections.EMPTY_LIST, result));
    }
    serializerEngine.serialize(data, SerializerType.INSPECTOR);
}
Also used : ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) MongoDBSerializerEngine(fr.inria.spirals.repairnator.serializer.engines.json.MongoDBSerializerEngine) ArrayList(java.util.ArrayList) List(java.util.List) JsonObject(com.google.gson.JsonObject) MongoConnection(fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection) Sheets(com.google.api.services.sheets.v4.Sheets)

Example 8 with Sheets

use of com.google.api.services.sheets.v4.Sheets in project repairnator by Spirals-Team.

the class InspectorSerializer4Bears method main.

public static void main(String[] args) throws IOException, GeneralSecurityException {
    GoogleSpreadSheetFactory.initWithFileSecret("client_secret.json");
    GoogleSpreadSheetFactory.setSpreadsheetId(args[1]);
    Sheets sheets = GoogleSpreadSheetFactory.getSheets();
    List<List<Object>> results = sheets.spreadsheets().values().get(GoogleSpreadSheetFactory.getSpreadsheetID(), "All data!A:Q").execute().getValues();
    MongoConnection mongoConnection = new MongoConnection(args[0], "bears");
    if (!mongoConnection.isConnected()) {
        throw new RuntimeException("Error when connection to mongodb");
    }
    MongoDBSerializerEngine serializerEngine = new MongoDBSerializerEngine(mongoConnection);
    List<SerializedData> data = new ArrayList<>();
    for (int i = 1; i < results.size(); i++) {
        List<Object> value = results.get(i);
        JsonObject result = new JsonObject();
        result.addProperty("buildId", Utils.getValue(value, 0));
        result.addProperty("previousBuildId", Utils.getValue(value, 1));
        result.addProperty("scannedBuildStatus", Utils.getValue(value, 2));
        result.addProperty("status", Utils.getValue(value, 3));
        result.addProperty("realStatus", Utils.getValue(value, 4));
        result.addProperty("checkoutType", Utils.getValue(value, 5));
        result.addProperty("typeOfFailures", Utils.getValue(value, 6));
        result.addProperty("repositoryName", Utils.getValue(value, 7));
        result.addProperty("prNumber", Utils.getValue(value, 8));
        result.addProperty("buildFinishedDate", Utils.getValue(value, 9));
        result.addProperty("buildFinishedDay", Utils.getValue(value, 10));
        result.addProperty("hostname", Utils.getValue(value, 11));
        result.addProperty("buildReproductionDate", Utils.getValue(value, 12));
        result.addProperty("buildTravisUrl", Utils.getValue(value, 13));
        result.addProperty("previousBuildTravisUrl", Utils.getValue(value, 14));
        result.addProperty("committerEmail", Utils.getValue(value, 15));
        result.addProperty("runId", Utils.getValue(value, 16));
        data.add(new SerializedData(Collections.EMPTY_LIST, result));
    }
    serializerEngine.serialize(data, SerializerType.INSPECTOR4BEARS);
}
Also used : ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) MongoDBSerializerEngine(fr.inria.spirals.repairnator.serializer.engines.json.MongoDBSerializerEngine) ArrayList(java.util.ArrayList) List(java.util.List) JsonObject(com.google.gson.JsonObject) MongoConnection(fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection) Sheets(com.google.api.services.sheets.v4.Sheets)

Example 9 with Sheets

use of com.google.api.services.sheets.v4.Sheets in project selenium_java by sergueik.

the class Quickstart method main.

public static void main(String[] args) throws IOException {
    // Build a new authorized API client service.
    Sheets service = getSheetsService();
    // Prints the names and majors of students in a sample spreadsheet:
    // https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit
    String spreadsheetId = "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms";
    String range = "Class Data!A2:E";
    ValueRange response = service.spreadsheets().values().get(spreadsheetId, range).execute();
    List<List<Object>> values = response.getValues();
    if (values == null || values.size() == 0) {
        System.out.println("No data found.");
    } else {
        System.out.println("Name, Major");
        for (List row : values) {
            // Print columns A and E, which correspond to indices 0 and 4.
            System.out.printf("%s, %s\n", row.get(0), row.get(4));
        }
    }
}
Also used : List(java.util.List) Sheets(com.google.api.services.sheets.v4.Sheets)

Aggregations

Sheets (com.google.api.services.sheets.v4.Sheets)8 List (java.util.List)8 JsonObject (com.google.gson.JsonObject)6 SerializedData (fr.inria.spirals.repairnator.serializer.engines.SerializedData)6 MongoDBSerializerEngine (fr.inria.spirals.repairnator.serializer.engines.json.MongoDBSerializerEngine)6 MongoConnection (fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection)6 ArrayList (java.util.ArrayList)6 ValueRange (com.google.api.services.sheets.v4.model.ValueRange)2 AppendValuesResponse (com.google.api.services.sheets.v4.model.AppendValuesResponse)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1