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

export of appointment type added

parent f527251c
No related branches found
No related tags found
1 merge request!1Appointments dev
package smash.appointment.parse;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class AppointmentEntry {
private String day;
private String time;
private String duration;
private Subject subject;
private List<AppointmentType> types = new ArrayList<>();
private Set<AppointmentType> types = new HashSet<>();
private String source;
/**
......@@ -54,7 +55,7 @@ public class AppointmentEntry {
* @return the type
* @see #type
*/
public List<AppointmentType> getTypes() {
public Set<AppointmentType> getTypes() {
return types;
}
......
package smash.appointment.parse;
public class AppointmentSqlExporter extends SqlExporter{
public class AppointmentSqlExporter extends SqlExporter {
public String toSql(AppointmentEntry appointment, boolean isFinished) {
StringBuilder result = new StringBuilder("");
......@@ -12,12 +12,22 @@ public class AppointmentSqlExporter extends SqlExporter{
result.append("visit_id) ");
result.append("values (");
result.append(getStringVal(appointment.getDay()+" "+appointment.getTime()) + ",");
result.append(getStringVal(appointment.getDay() + " " + appointment.getTime()) + ",");
result.append(getStringVal(appointment.getDuration()) + ",");
result.append(isFinished+ ",");
result.append(isFinished + ",");
result.append("(select max(id) from web_visit)");
result.append(");");
for (AppointmentType type : appointment.getTypes()) {
result.append("insert into web_appointment_appointment_types (");
result.append("appointment_id, ");
result.append("appointmenttype_id) ");
result.append("values (");
result.append("(select max(id) from web_appointment),");
result.append("(select id from web_appointmenttype where code=" + getStringVal(type.getAbbreviation()) + ") ");
result.append(");");
}
return result.toString();
}
......
package smash.appointment.parse;
public enum AppointmentType {
LEVEL_BV(90), //
LEVEL_BG(30), //
LEVEL_SB(30), //
LEVEL_BV(90,"BV"), //
LEVEL_BG(30,"BG"), //
LEVEL_SB(30,"SB"), //
LEVEL_A_TQ(120), //
LEVEL_A(120), //
LEVEL_B(90), //
LEVEL_B_M_POWER(70), //
OTHER(60), //
LEVEL_A_TQ(120,"A_TQ"), //
LEVEL_A(120,"A"), //
LEVEL_B(90,"B"), //
LEVEL_B_M_POWER(70,"mPower"), //
OTHER(60,"OTHER"), //
;
private int time;
private String abbreviation;
private AppointmentType(int defaultTime) {
private AppointmentType(int defaultTime, String abbreviation) {
this.time=defaultTime;
this.abbreviation=abbreviation;
}
public int getTime() {
return time;
}
public String getAbbreviation() {
return abbreviation;
}
}
......@@ -78,9 +78,9 @@ public class Main {
appointmentDao.addAppointments(processPrcAppointments(agendaFile, today));
String redCapFile = line.getOptionValue("red-cap");
appointmentDao.addAppointments(processRedCapAppointments(agendaFile));
appointmentDao.addAppointments(processRedCapAppointments(redCapFile));
System.out.println("delete from web_appointment_appointment_types;");
System.out.println("delete from web_subject_languages;");
System.out.println("delete from web_appointment;");
System.out.println("delete from web_visit;");
......
......@@ -6,6 +6,7 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.apache.log4j.Logger;
......@@ -128,7 +129,7 @@ public class CellParserTest extends TestBase {
}
}
private boolean equalTypes(List<AppointmentType> types, List<AppointmentType> types2) {
private boolean equalTypes(List<AppointmentType> types, Collection<AppointmentType> types2) {
for (AppointmentType type : types) {
if (!types2.contains(type)) {
return false;
......
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