@Test public void toStringNullValues() { AuditEvent auditEvent = new AuditEvent(START_TIME, QUESTION, getTestFormIndex(), "Old value", null, null); assertNotNull(auditEvent); auditEvent.setLocationCoordinates("", "", ""); assertTrue(auditEvent.isIntervalAuditEventType()); assertFalse(auditEvent.isEndTimeSet()); auditEvent.setEnd(END_TIME); assertTrue(auditEvent.isEndTimeSet()); assertFalse(auditEvent.isLocationAlreadySet()); auditEvent.recordValueChange("New value"); assertEquals("question,/data/text1,1545392727685,1545392728527,,,,Old value,New value", toCSVLine(auditEvent, true, true, false)); }
public static String toCSVLine(AuditEvent auditEvent, boolean isTrackingLocationsEnabled, boolean isTrackingChangesEnabled, boolean isTrackingChangesReasonEnabled) { FormIndex formIndex = auditEvent.getFormIndex(); AuditEvent.AuditEventType auditEventType = auditEvent.getAuditEventType(); long start = auditEvent.getStart(); long end = auditEvent.getEnd(); String latitude = auditEvent.getLatitude(); String longitude = auditEvent.getLongitude(); String accuracy = auditEvent.getAccuracy(); String oldValue = auditEvent.getOldValue(); String newValue = auditEvent.getNewValue(); String user = auditEvent.getUser(); String changeReason = auditEvent.getChangeReason(); String node = formIndex == null || formIndex.getReference() == null ? "" : getXPathPath(formIndex); String string = String.format("%s,%s,%s,%s", auditEventType.getValue(), node, start, end != 0 ? end : ""); if (isTrackingLocationsEnabled) { string += String.format(",%s,%s,%s", latitude, longitude, accuracy); } if (isTrackingChangesEnabled) { string += String.format(",%s,%s", oldValue, newValue); } if (user != null) { if (user.contains(",") || user.contains("\n")) { string += String.format(",%s", getEscapedValueForCsv(user)); } else { string += String.format(",%s", user); } } if (isTrackingChangesReasonEnabled) { if (changeReason != null && (changeReason.contains(",") || changeReason.contains("\n"))) { string += String.format(",%s", getEscapedValueForCsv(changeReason)); } else if (changeReason != null) { string += String.format(",%s", changeReason); } else { string += ","; } } return string; }
AuditEventCSVLine { public static String toCSVLine(AuditEvent auditEvent, boolean isTrackingLocationsEnabled, boolean isTrackingChangesEnabled, boolean isTrackingChangesReasonEnabled) { FormIndex formIndex = auditEvent.getFormIndex(); AuditEvent.AuditEventType auditEventType = auditEvent.getAuditEventType(); long start = auditEvent.getStart(); long end = auditEvent.getEnd(); String latitude = auditEvent.getLatitude(); String longitude = auditEvent.getLongitude(); String accuracy = auditEvent.getAccuracy(); String oldValue = auditEvent.getOldValue(); String newValue = auditEvent.getNewValue(); String user = auditEvent.getUser(); String changeReason = auditEvent.getChangeReason(); String node = formIndex == null || formIndex.getReference() == null ? "" : getXPathPath(formIndex); String string = String.format("%s,%s,%s,%s", auditEventType.getValue(), node, start, end != 0 ? end : ""); if (isTrackingLocationsEnabled) { string += String.format(",%s,%s,%s", latitude, longitude, accuracy); } if (isTrackingChangesEnabled) { string += String.format(",%s,%s", oldValue, newValue); } if (user != null) { if (user.contains(",") || user.contains("\n")) { string += String.format(",%s", getEscapedValueForCsv(user)); } else { string += String.format(",%s", user); } } if (isTrackingChangesReasonEnabled) { if (changeReason != null && (changeReason.contains(",") || changeReason.contains("\n"))) { string += String.format(",%s", getEscapedValueForCsv(changeReason)); } else if (changeReason != null) { string += String.format(",%s", changeReason); } else { string += ","; } } return string; } }
AuditEventCSVLine { public static String toCSVLine(AuditEvent auditEvent, boolean isTrackingLocationsEnabled, boolean isTrackingChangesEnabled, boolean isTrackingChangesReasonEnabled) { FormIndex formIndex = auditEvent.getFormIndex(); AuditEvent.AuditEventType auditEventType = auditEvent.getAuditEventType(); long start = auditEvent.getStart(); long end = auditEvent.getEnd(); String latitude = auditEvent.getLatitude(); String longitude = auditEvent.getLongitude(); String accuracy = auditEvent.getAccuracy(); String oldValue = auditEvent.getOldValue(); String newValue = auditEvent.getNewValue(); String user = auditEvent.getUser(); String changeReason = auditEvent.getChangeReason(); String node = formIndex == null || formIndex.getReference() == null ? "" : getXPathPath(formIndex); String string = String.format("%s,%s,%s,%s", auditEventType.getValue(), node, start, end != 0 ? end : ""); if (isTrackingLocationsEnabled) { string += String.format(",%s,%s,%s", latitude, longitude, accuracy); } if (isTrackingChangesEnabled) { string += String.format(",%s,%s", oldValue, newValue); } if (user != null) { if (user.contains(",") || user.contains("\n")) { string += String.format(",%s", getEscapedValueForCsv(user)); } else { string += String.format(",%s", user); } } if (isTrackingChangesReasonEnabled) { if (changeReason != null && (changeReason.contains(",") || changeReason.contains("\n"))) { string += String.format(",%s", getEscapedValueForCsv(changeReason)); } else if (changeReason != null) { string += String.format(",%s", changeReason); } else { string += ","; } } return string; } private  AuditEventCSVLine(); }
AuditEventCSVLine { public static String toCSVLine(AuditEvent auditEvent, boolean isTrackingLocationsEnabled, boolean isTrackingChangesEnabled, boolean isTrackingChangesReasonEnabled) { FormIndex formIndex = auditEvent.getFormIndex(); AuditEvent.AuditEventType auditEventType = auditEvent.getAuditEventType(); long start = auditEvent.getStart(); long end = auditEvent.getEnd(); String latitude = auditEvent.getLatitude(); String longitude = auditEvent.getLongitude(); String accuracy = auditEvent.getAccuracy(); String oldValue = auditEvent.getOldValue(); String newValue = auditEvent.getNewValue(); String user = auditEvent.getUser(); String changeReason = auditEvent.getChangeReason(); String node = formIndex == null || formIndex.getReference() == null ? "" : getXPathPath(formIndex); String string = String.format("%s,%s,%s,%s", auditEventType.getValue(), node, start, end != 0 ? end : ""); if (isTrackingLocationsEnabled) { string += String.format(",%s,%s,%s", latitude, longitude, accuracy); } if (isTrackingChangesEnabled) { string += String.format(",%s,%s", oldValue, newValue); } if (user != null) { if (user.contains(",") || user.contains("\n")) { string += String.format(",%s", getEscapedValueForCsv(user)); } else { string += String.format(",%s", user); } } if (isTrackingChangesReasonEnabled) { if (changeReason != null && (changeReason.contains(",") || changeReason.contains("\n"))) { string += String.format(",%s", getEscapedValueForCsv(changeReason)); } else if (changeReason != null) { string += String.format(",%s", changeReason); } else { string += ","; } } return string; } private  AuditEventCSVLine(); static String toCSVLine(AuditEvent auditEvent, boolean isTrackingLocationsEnabled, boolean isTrackingChangesEnabled, boolean isTrackingChangesReasonEnabled); }
AuditEventCSVLine { public static String toCSVLine(AuditEvent auditEvent, boolean isTrackingLocationsEnabled, boolean isTrackingChangesEnabled, boolean isTrackingChangesReasonEnabled) { FormIndex formIndex = auditEvent.getFormIndex(); AuditEvent.AuditEventType auditEventType = auditEvent.getAuditEventType(); long start = auditEvent.getStart(); long end = auditEvent.getEnd(); String latitude = auditEvent.getLatitude(); String longitude = auditEvent.getLongitude(); String accuracy = auditEvent.getAccuracy(); String oldValue = auditEvent.getOldValue(); String newValue = auditEvent.getNewValue(); String user = auditEvent.getUser(); String changeReason = auditEvent.getChangeReason(); String node = formIndex == null || formIndex.getReference() == null ? "" : getXPathPath(formIndex); String string = String.format("%s,%s,%s,%s", auditEventType.getValue(), node, start, end != 0 ? end : ""); if (isTrackingLocationsEnabled) { string += String.format(",%s,%s,%s", latitude, longitude, accuracy); } if (isTrackingChangesEnabled) { string += String.format(",%s,%s", oldValue, newValue); } if (user != null) { if (user.contains(",") || user.contains("\n")) { string += String.format(",%s", getEscapedValueForCsv(user)); } else { string += String.format(",%s", user); } } if (isTrackingChangesReasonEnabled) { if (changeReason != null && (changeReason.contains(",") || changeReason.contains("\n"))) { string += String.format(",%s", getEscapedValueForCsv(changeReason)); } else if (changeReason != null) { string += String.format(",%s", changeReason); } else { string += ","; } } return string; } private  AuditEventCSVLine(); static String toCSVLine(AuditEvent auditEvent, boolean isTrackingLocationsEnabled, boolean isTrackingChangesEnabled, boolean isTrackingChangesReasonEnabled);  }