Skip to content
Snippets Groups Projects
Commit 1ca534bb authored by Piotr Gawron's avatar Piotr Gawron
Browse files

export to sql improved (\' character issue)

parent 4bf36d67
No related branches found
No related tags found
1 merge request!1Appointments dev
package smash.appointment.parse; package smash.appointment.parse;
public class AppointmentSqlExporter { public class AppointmentSqlExporter extends SqlExporter{
public String toSql(AppointmentEntry appointment, boolean isFinished) { public String toSql(AppointmentEntry appointment, boolean isFinished) {
StringBuilder result = new StringBuilder(""); StringBuilder result = new StringBuilder("");
...@@ -21,13 +21,4 @@ public class AppointmentSqlExporter { ...@@ -21,13 +21,4 @@ public class AppointmentSqlExporter {
return result.toString(); return result.toString();
} }
private String getStringVal(String arg) {
if (arg == null) {
return "null";
} else if (arg.isEmpty()) {
return "''";
} else {
return "'" + arg + "'";
}
}
} }
package smash.appointment.parse;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class SqlExporter {
private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd");
public SqlExporter() {
super();
}
protected boolean isBefore(AppointmentEntry entry, Calendar minDate) {
String entryDate = entry.getDay();
String beforeDate = DATE_FORMATTER.format(minDate.getTime());
if (entryDate.compareTo(beforeDate) < 0) {
return true;
} else {
return false;
}
}
protected String getStringVal(String arg) {
if (arg == null) {
return "null";
} else if (arg.isEmpty()) {
return "''";
} else {
return "'" + arg.replace("'", "''") + "'";
}
}
protected String getIntVal(String diagnosisYear) {
if (diagnosisYear == null || diagnosisYear.trim().isEmpty()) {
return "0";
} else {
return diagnosisYear;
}
}
protected String getDateVal(String arg) {
if (arg == null) {
return "null";
} else if (arg.isEmpty()) {
return "null";
} else {
return "'" + arg + "'";
}
}
}
\ No newline at end of file
package smash.appointment.parse; package smash.appointment.parse;
public class SubjectSqlExporter { public class SubjectSqlExporter extends SqlExporter{
public String toSql(Subject subject) { public String toSql(Subject subject) {
StringBuilder result = new StringBuilder(""); StringBuilder result = new StringBuilder("");
...@@ -61,30 +61,4 @@ public class SubjectSqlExporter { ...@@ -61,30 +61,4 @@ public class SubjectSqlExporter {
return result.toString(); return result.toString();
} }
private String getIntVal(String diagnosisYear) {
if (diagnosisYear == null || diagnosisYear.trim().isEmpty()) {
return "0";
} else {
return diagnosisYear;
}
}
private String getStringVal(String arg) {
if (arg == null) {
return "null";
} else if (arg.isEmpty()) {
return "''";
} else {
return "'" + arg + "'";
}
}
private String getDateVal(String arg) {
if (arg == null) {
return "null";
} else if (arg.isEmpty()) {
return "null";
} else {
return "'" + arg + "'";
}
}
} }
package smash.appointment.parse; package smash.appointment.parse;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
public class VisitSqlExporter { public class VisitSqlExporter extends SqlExporter {
AppointmentSqlExporter appointmentSqlExporter = new AppointmentSqlExporter(); AppointmentSqlExporter appointmentSqlExporter = new AppointmentSqlExporter();
private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd");
public String toSql(Visit visit, boolean isFinished) throws ParseException { public String toSql(Visit visit, boolean isFinished) throws ParseException {
StringBuilder result = new StringBuilder(""); StringBuilder result = new StringBuilder("");
...@@ -32,24 +29,4 @@ public class VisitSqlExporter { ...@@ -32,24 +29,4 @@ public class VisitSqlExporter {
return result.toString(); return result.toString();
} }
private boolean isBefore(AppointmentEntry entry, Calendar minDate) {
String entryDate = entry.getDay();
String beforeDate = DATE_FORMATTER.format(minDate.getTime());
if (entryDate.compareTo(beforeDate) < 0) {
return true;
} else {
return false;
}
}
private String getStringVal(String arg) {
if (arg == null) {
return "null";
} else if (arg.isEmpty()) {
return "''";
} else {
return "'" + arg + "'";
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment