Search in sources :

Example 6 with SerializedData

use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.

the class MetricsSerializer method serializeData.

@Override
public void serializeData(ProjectInspector inspector) {
    Gson gson = new GsonBuilder().registerTypeAdapter(Metrics.class, new MetricsSerializerAdapter()).create();
    JsonObject element = (JsonObject) gson.toJsonTree(inspector.getJobStatus().getMetrics());
    element.addProperty("runId", RepairnatorConfig.getInstance().getRunId());
    this.addDate(element, "reproductionDate", new Date());
    element.addProperty("buggyBuildId", inspector.getBuggyBuild().getId());
    element.addProperty("buildStatus", inspector.getBuildToBeInspected().getStatus().name());
    if (inspector.getPatchedBuild() != null) {
        element.addProperty("patchedBuildId", inspector.getPatchedBuild().getId());
    }
    element.addProperty("status", this.getPrettyPrintState(inspector));
    List<SerializedData> dataList = new ArrayList<>();
    dataList.add(new SerializedData(new ArrayList<>(), element));
    for (SerializerEngine engine : this.getEngines()) {
        engine.serialize(dataList, this.getType());
    }
}
Also used : Metrics(fr.inria.spirals.repairnator.process.inspectors.Metrics) MetricsSerializerAdapter(fr.inria.spirals.repairnator.process.inspectors.MetricsSerializerAdapter) GsonBuilder(com.google.gson.GsonBuilder) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) Date(java.util.Date)

Example 7 with SerializedData

use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.

the class NPEFixSerializer method serializeData.

@Override
public void serializeData(ProjectInspector inspector) {
    JsonElement result = inspector.getJobStatus().getNpeFixResults();
    if (result != null) {
        List<Object> dataAsList = new ArrayList<>();
        dataAsList.add(Utils.getHostname());
        dataAsList.add(inspector.getBuildToBeInspected().getRunId());
        dataAsList.add(Utils.formatCompleteDate(new Date()));
        dataAsList.add(Utils.formatOnlyDay(new Date()));
        dataAsList.add(inspector.getRepoSlug());
        dataAsList.add(inspector.getBuggyBuild().getId());
        dataAsList.add(result.toString());
        JsonObject dataAsJson = new JsonObject();
        dataAsJson.addProperty("hostname", Utils.getHostname());
        dataAsJson.addProperty("runId", inspector.getBuildToBeInspected().getRunId());
        dataAsJson.addProperty("buildId", inspector.getBuggyBuild().getId());
        dataAsJson.addProperty("repositoryName", inspector.getRepoSlug());
        this.addDate(dataAsJson, "computedDate", new Date());
        dataAsJson.addProperty("computedDateStr", Utils.formatCompleteDate(new Date()));
        dataAsJson.addProperty("computedDay", Utils.formatOnlyDay(new Date()));
        dataAsJson.add("result", result);
        List<SerializedData> serializedData = new ArrayList<>();
        serializedData.add(new SerializedData(dataAsList, dataAsJson));
        for (SerializerEngine engine : this.getEngines()) {
            engine.serialize(serializedData, this.getType());
        }
    }
}
Also used : JsonElement(com.google.gson.JsonElement) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) Date(java.util.Date)

Example 8 with SerializedData

use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.

the class NopolSerializer method serializeData.

@Override
public void serializeData(ProjectInspector inspector) {
    if (inspector.getJobStatus().getNopolInformations() != null) {
        BuildToBeInspected buildToBeInspected = inspector.getBuildToBeInspected();
        List<SerializedData> allDatas = new ArrayList<>();
        for (NopolInformation nopolInformation : inspector.getJobStatus().getNopolInformations()) {
            if (nopolInformation.getPatches().isEmpty()) {
                SerializedData data = new SerializedData(this.serializeNopolInfoAsList(buildToBeInspected, nopolInformation, null, 0), this.serializeNopolInfoAsJson(buildToBeInspected, nopolInformation, null, 0));
                allDatas.add(data);
            } else {
                int patchNumber = 1;
                for (PatchAndDiff patchAndDiff : nopolInformation.getPatches()) {
                    SerializedData data = new SerializedData(this.serializeNopolInfoAsList(buildToBeInspected, nopolInformation, patchAndDiff, patchNumber), this.serializeNopolInfoAsJson(buildToBeInspected, nopolInformation, patchAndDiff, patchNumber));
                    allDatas.add(data);
                    patchNumber++;
                }
            }
            for (SerializerEngine engine : this.getEngines()) {
                engine.serialize(allDatas, this.getType());
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) MongoDBSerializerEngine(fr.inria.spirals.repairnator.serializer.engines.json.MongoDBSerializerEngine) PatchAndDiff(fr.inria.spirals.repairnator.process.nopol.PatchAndDiff) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) NopolInformation(fr.inria.spirals.repairnator.process.nopol.NopolInformation)

Example 9 with SerializedData

use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.

the class PipelineErrorSerializer method serializeData.

@Override
public void serializeData(ProjectInspector inspector) {
    List<Object> dataAsList = new ArrayList<>();
    dataAsList.add(Utils.getHostname());
    dataAsList.add(inspector.getBuildToBeInspected().getRunId());
    dataAsList.add(Utils.formatCompleteDate(new Date()));
    dataAsList.add(Utils.formatOnlyDay(new Date()));
    dataAsList.add(inspector.getRepoSlug());
    dataAsList.add(inspector.getBuggyBuild().getId());
    for (List<String> strings : inspector.getJobStatus().getStepErrors().values()) {
        dataAsList.add(StringUtils.join(strings, "       "));
    }
    JsonObject dataAsJson = new JsonObject();
    dataAsJson.addProperty("hostname", Utils.getHostname());
    dataAsJson.addProperty("runId", inspector.getBuildToBeInspected().getRunId());
    dataAsJson.addProperty("buildId", inspector.getBuggyBuild().getId());
    dataAsJson.addProperty("repositoryName", inspector.getRepoSlug());
    this.addDate(dataAsJson, "computedDate", new Date());
    dataAsJson.addProperty("computedDateStr", Utils.formatCompleteDate(new Date()));
    dataAsJson.addProperty("computedDay", Utils.formatOnlyDay(new Date()));
    for (Map.Entry<String, List<String>> stringListEntry : inspector.getJobStatus().getStepErrors().entrySet()) {
        JsonArray jsonElements = new JsonArray();
        for (String message : stringListEntry.getValue()) {
            jsonElements.add(message);
        }
        dataAsJson.add(stringListEntry.getKey(), jsonElements);
    }
    List<SerializedData> serializedData = new ArrayList<>();
    serializedData.add(new SerializedData(dataAsList, dataAsJson));
    for (SerializerEngine serializerEngine : this.getEngines()) {
        serializerEngine.serialize(serializedData, this.getType());
    }
}
Also used : ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) Date(java.util.Date) JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 10 with SerializedData

use of fr.inria.spirals.repairnator.serializer.engines.SerializedData in project repairnator by Spirals-Team.

the class TreatedBuildTracking 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());
    }
}
Also used : ArrayList(java.util.ArrayList) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine)

Aggregations

SerializedData (fr.inria.spirals.repairnator.serializer.engines.SerializedData)26 ArrayList (java.util.ArrayList)24 SerializerEngine (fr.inria.spirals.repairnator.serializer.engines.SerializerEngine)16 MongoDBSerializerEngine (fr.inria.spirals.repairnator.serializer.engines.json.MongoDBSerializerEngine)12 JsonObject (com.google.gson.JsonObject)10 List (java.util.List)8 Sheets (com.google.api.services.sheets.v4.Sheets)6 MongoConnection (fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection)6 Date (java.util.Date)4 JsonElement (com.google.gson.JsonElement)2 BufferedWriter (java.io.BufferedWriter)2 IOException (java.io.IOException)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 JsonArray (com.google.gson.JsonArray)1 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)1 Metrics (fr.inria.spirals.repairnator.process.inspectors.Metrics)1 MetricsSerializerAdapter (fr.inria.spirals.repairnator.process.inspectors.MetricsSerializerAdapter)1 NopolInformation (fr.inria.spirals.repairnator.process.nopol.NopolInformation)1 PatchAndDiff (fr.inria.spirals.repairnator.process.nopol.PatchAndDiff)1