private List<Object> serializeAsList(BuildToBeInspected buildToBeInspected, RepairPatch patch) { Build build = buildToBeInspected.getBuggyBuild(); List<Object> result = new ArrayList<>(); result.add(Utils.formatCompleteDate(new Date())); result.add(buildToBeInspected.getRunId()); result.add(build.getId()); result.add(patch.getToolname()); result.add(patch.getDiff()); result.add(patch.getFilePath()); result.add(Utils.getHostname()); return result; }
private JsonElement serializeAsJson(BuildToBeInspected buildToBeInspected, RepairPatch patch) { Build build = buildToBeInspected.getBuggyBuild(); JsonObject data = new JsonObject(); data.addProperty("dateStr", Utils.formatCompleteDate(new Date())); this.addDate(data, "date", new Date()); data.addProperty("runId", buildToBeInspected.getRunId()); data.addProperty("buildId", build.getId()); data.addProperty("toolname", patch.getToolname()); data.addProperty("diff", patch.getDiff()); data.addProperty("filepath", patch.getFilePath()); data.addProperty("hostname", Utils.getHostname()); return data; }
private List<File> serializePatches(List<RepairPatch> patchList) throws IOException { File parentDirectory = new File(this.getInspector().getRepoToPushLocalPath(), DEFAULT_DIR_PATCHES); if (!parentDirectory.exists()) { parentDirectory.mkdirs(); } File toolDirectory = new File(parentDirectory, this.getRepairToolName()); toolDirectory.mkdirs(); List<File> serializedPatches = new ArrayList<>(); int i = 1; String dirPath = DEFAULT_DIR_PATCHES + "/" + this.getRepairToolName() + "/"; for (RepairPatch repairPatch : patchList) { File patchFile = new File(toolDirectory, "patch_" + (i++) + ".patch"); BufferedWriter bufferedWriter = Files.newBufferedWriter(patchFile.toPath()); bufferedWriter.write(repairPatch.getDiff()); bufferedWriter.close(); this.getInspector().getJobStatus().addFileToPush(dirPath + patchFile.getName()); serializedPatches.add(patchFile); } return serializedPatches; }
text += "\t" + patches.get(i).getDiff() + "\n\n";