use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.
the class MongoDBSerializerEngine method serialize.
@Override
public void serialize(List<SerializedData> data, SerializerType serializer) {
if (this.mongoDatabase != null) {
MongoCollection<Document> collection = this.mongoDatabase.getCollection(serializer.getFilename());
List<Document> listDocuments = new ArrayList<>();
for (SerializedData oneData : data) {
Document doc = Document.parse(oneData.getAsJson().toString());
/*try {
collection.insertOne(doc);
} catch (Exception e) {
logger.error("Error while inserting doc",e);
}*/
listDocuments.add(doc);
}
try {
collection.insertMany(listDocuments);
} catch (Exception e) {
logger.error("Error while inserting all documents", e);
}
} else {
logger.error("Mongo connection is null, there was certainly a problem with the connection.");
}
}
use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.
the class GoogleSpreadsheetSerializerEngine method serialize.
@Override
public void serialize(List<SerializedData> data, SerializerType serializer) {
if (this.sheets != null) {
List<List<Object>> allRows = new ArrayList<>();
for (SerializedData oneRow : data) {
allRows.add(oneRow.getAsList());
}
GoogleSpreadSheetFactory.insertData(allRows, this.sheets, serializer.getRange(), this.logger);
} else {
logger.error("Sheets is null, there was certainly an error with connection to API.");
}
}
use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.
the class InspectorTimeSerializer method serializeData.
@Override
public void serializeData(ProjectInspector inspector) {
SerializedData data = new SerializedData(this.serializeAsList(inspector), this.serializeAsJson(inspector));
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 InspectorTimeSerializer 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(), "Duration Data!A:P").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("buildReproductionDate", Utils.getValue(value, 2));
result.addProperty("hostname", Utils.getValue(value, 3));
result.addProperty("totalDuration", Utils.getValue(value, 4));
result.addProperty("clonage", Utils.getValue(value, 5));
result.addProperty("checkoutBuild", Utils.getValue(value, 6));
result.addProperty("build", Utils.getValue(value, 7));
result.addProperty("test", Utils.getValue(value, 8));
result.addProperty("gatherTestInfo", Utils.getValue(value, 9));
result.addProperty("squashRepository", Utils.getValue(value, 10));
result.addProperty("push", Utils.getValue(value, 11));
result.addProperty("computeClasspath", Utils.getValue(value, 12));
result.addProperty("computeSourceDir", Utils.getValue(value, 13));
result.addProperty("repair", Utils.getValue(value, 14));
result.addProperty("runId", Utils.getValue(value, 15));
data.add(new SerializedData(Collections.EMPTY_LIST, result));
}
serializerEngine.serialize(data, SerializerType.TIMES);
}
use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.
the class EndProcessSerializer 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());
}
}
Aggregations