use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.
the class WatchedBuildSerializer method serialize.
public void serialize(Build build) {
SerializedData data = new SerializedData(this.serializeAsList(build), this.serializeAsJson(build));
List<SerializedData> allData = new ArrayList<>();
allData.add(data);
for (SerializerEngine engine : this.getEngines()) {
engine.serialize(allData, this.getType());
}
}
use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.
the class ScannerSerializer 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(), "Scanner Data!A:M").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("hostname", Utils.getValue(value, 0));
result.addProperty("dateBegin", Utils.getValue(value, 1));
result.addProperty("dateLimit", Utils.getValue(value, 2));
result.addProperty("totalRepoNumber", Utils.getValue(value, 3));
result.addProperty("totalRepoUsingTravis", Utils.getValue(value, 4));
result.addProperty("totalScannedBuilds", Utils.getValue(value, 5));
result.addProperty("totalJavaBuilds", Utils.getValue(value, 6));
result.addProperty("totalJavaPassingBuilds", Utils.getValue(value, 7));
result.addProperty("totalJavaFailingBuilds", Utils.getValue(value, 8));
result.addProperty("totalJavaFailingBuildsWithFailingTests", Utils.getValue(value, 9));
result.addProperty("totalPRBuilds", Utils.getValue(value, 10));
result.addProperty("dayLimit", Utils.getValue(value, 11));
result.addProperty("duration", Utils.getValue(value, 12));
result.addProperty("runId", Utils.getValue(value, 13));
data.add(new SerializedData(Collections.EMPTY_LIST, result));
}
serializerEngine.serialize(data, SerializerType.SCANNER);
}
use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.
the class ScannerSerializer4Bears method serialize.
public void serialize() {
SerializedData data = new SerializedData(this.serializeAsList(), this.serializeAsJson());
List<SerializedData> allData = new ArrayList<>();
allData.add(data);
for (SerializerEngine engine : this.getEngines()) {
engine.serialize(allData, this.getType());
}
}
use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.
the class ScannerSerializer4Bears 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(), "Scanner Data!A:M").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("hostname", Utils.getValue(value, 0));
result.addProperty("dateBegin", Utils.getValue(value, 1));
result.addProperty("dateEnd", Utils.getValue(value, 2));
result.addProperty("duration", Utils.getValue(value, 3));
result.addProperty("dateLookedFrom", Utils.getValue(value, 4));
result.addProperty("dateLookedTo", Utils.getValue(value, 5));
result.addProperty("totalRepoNumber", Utils.getValue(value, 6));
result.addProperty("totalRepoUsingTravis", Utils.getValue(value, 7));
result.addProperty("totalScannedBuilds", Utils.getValue(value, 8));
result.addProperty("totalJavaBuilds", Utils.getValue(value, 9));
result.addProperty("totalJavaPassingBuilds", Utils.getValue(value, 10));
result.addProperty("totalJavaFailingBuilds", Utils.getValue(value, 11));
result.addProperty("totalJavaFailingBuildsWithFailingTests", Utils.getValue(value, 12));
result.addProperty("totalPRBuilds", Utils.getValue(value, 13));
result.addProperty("totalFailingAndPassingBuildPairs", Utils.getValue(value, 14));
result.addProperty("totalPassingAndPassingBuildPairs", Utils.getValue(value, 15));
result.addProperty("totalPairOfBuilds", Utils.getValue(value, 16));
result.addProperty("runId", Utils.getValue(value, 17));
data.add(new SerializedData(Collections.EMPTY_LIST, result));
}
serializerEngine.serialize(data, SerializerType.SCANNER4BEARS);
}
use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.
the class JSONFileSerializerEngine method serialize.
@Override
public void serialize(List<SerializedData> data, SerializerType serializer) {
String filename = serializer.getFilename() + FILE_EXTENSION;
BufferedWriter writer = this.openFile(filename);
if (writer != null) {
try {
for (SerializedData oneData : data) {
writer.write(oneData.getAsJson().toString());
writer.newLine();
writer.flush();
}
writer.close();
} catch (IOException e) {
logger.error("Error while writing json serialization", e);
}
}
}
Aggregations