From 9089df0af2af4263542862942793217f5fc0ff1c Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Fri, 24 Feb 2017 18:21:12 +0100 Subject: [PATCH] subject has a type --- .../appointment/parse/PrcSubjectsParser.java | 5 + .../java/smash/appointment/parse/Subject.java | 110 +++++++++++------- .../appointment/parse/SubjectParser.java | 9 +- .../smash/appointment/parse/SubjectType.java | 5 + 4 files changed, 87 insertions(+), 42 deletions(-) create mode 100644 appointment-import/src/main/java/smash/appointment/parse/SubjectType.java diff --git a/appointment-import/src/main/java/smash/appointment/parse/PrcSubjectsParser.java b/appointment-import/src/main/java/smash/appointment/parse/PrcSubjectsParser.java index 155399ce..21a38c19 100644 --- a/appointment-import/src/main/java/smash/appointment/parse/PrcSubjectsParser.java +++ b/appointment-import/src/main/java/smash/appointment/parse/PrcSubjectsParser.java @@ -124,4 +124,9 @@ public class PrcSubjectsParser extends SubjectParser { return getString(row.getCell(12)); } + @Override + protected SubjectType parseType(Row row) { + return SubjectType.SUBJECT; + } + } diff --git a/appointment-import/src/main/java/smash/appointment/parse/Subject.java b/appointment-import/src/main/java/smash/appointment/parse/Subject.java index 70d87334..d678b8d7 100644 --- a/appointment-import/src/main/java/smash/appointment/parse/Subject.java +++ b/appointment-import/src/main/java/smash/appointment/parse/Subject.java @@ -6,30 +6,31 @@ import java.util.List; import org.apache.log4j.Logger; public class Subject { - Logger logger = Logger.getLogger(Subject .class); - - private String name; - private String surname; - private String ndNumber; - private String screeningNumber; - private String sex; - private String remarks; - private String birthDate; - private String address; - private String zipCode; - private String country; - private String city; - private String phone1; - private String phone2; - private String phone3; - private String mail; - private String diagnosisYear; - private String diagnosis; - private String referal; - private String addDate; - private String mPowerId; - - private List<String> languages = new ArrayList<>(); + Logger logger = Logger.getLogger(Subject.class); + + private String name; + private String surname; + private String ndNumber; + private String screeningNumber; + private String sex; + private String remarks; + private String birthDate; + private String address; + private String zipCode; + private String country; + private String city; + private String phone1; + private String phone2; + private String phone3; + private String mail; + private String diagnosisYear; + private String diagnosis; + private String referal; + private String addDate; + private String mPowerId; + private SubjectType type; + + private List<String> languages = new ArrayList<>(); public Subject(String name, String surname, String ndNumber, String screeningNumber) { this.name = name; @@ -160,7 +161,8 @@ public class Subject { } /** - * @param languages the languages to set + * @param languages + * the languages to set * @see #languages */ public void setLanguages(List<String> languages) { @@ -176,7 +178,8 @@ public class Subject { } /** - * @param remarks the remarks to set + * @param remarks + * the remarks to set * @see #remarks */ public void setRemarks(String remarks) { @@ -192,7 +195,8 @@ public class Subject { } /** - * @param address the address to set + * @param address + * the address to set * @see #address */ public void setAddress(String address) { @@ -208,7 +212,8 @@ public class Subject { } /** - * @param zipCode the zipCode to set + * @param zipCode + * the zipCode to set * @see #zipCode */ public void setZipCode(String zipCode) { @@ -224,7 +229,8 @@ public class Subject { } /** - * @param country the country to set + * @param country + * the country to set * @see #country */ public void setCountry(String country) { @@ -240,7 +246,8 @@ public class Subject { } /** - * @param city the city to set + * @param city + * the city to set * @see #city */ public void setCity(String city) { @@ -256,7 +263,8 @@ public class Subject { } /** - * @param phone1 the phone1 to set + * @param phone1 + * the phone1 to set * @see #phone1 */ public void setPhone1(String phone1) { @@ -272,7 +280,8 @@ public class Subject { } /** - * @param phone2 the phone2 to set + * @param phone2 + * the phone2 to set * @see #phone2 */ public void setPhone2(String phone2) { @@ -288,7 +297,8 @@ public class Subject { } /** - * @param phone3 the phone3 to set + * @param phone3 + * the phone3 to set * @see #phone3 */ public void setPhone3(String phone3) { @@ -304,7 +314,8 @@ public class Subject { } /** - * @param mail the mail to set + * @param mail + * the mail to set * @see #mail */ public void setMail(String mail) { @@ -320,7 +331,8 @@ public class Subject { } /** - * @param diagnosisYear the diagnosisYear to set + * @param diagnosisYear + * the diagnosisYear to set * @see #diagnosisYear */ public void setDiagnosisYear(String diagnosisYear) { @@ -336,7 +348,8 @@ public class Subject { } /** - * @param diagnosis the diagnosis to set + * @param diagnosis + * the diagnosis to set * @see #diagnosis */ public void setDiagnosis(String diagnosis) { @@ -352,7 +365,8 @@ public class Subject { } /** - * @param referal the referal to set + * @param referal + * the referal to set * @see #referal */ public void setReferal(String referal) { @@ -368,7 +382,8 @@ public class Subject { } /** - * @param mPowerId the mPowerId to set + * @param mPowerId + * the mPowerId to set * @see #mPowerId */ public void setmPowerId(String mPowerId) { @@ -384,11 +399,28 @@ public class Subject { } /** - * @param addDate the addDate to set + * @param addDate + * the addDate to set * @see #addDate */ public void setAddDate(String addDate) { this.addDate = addDate; } + /** + * @return the type + * @see #type + */ + public SubjectType getType() { + return type; + } + + /** + * @param type the type to set + * @see #type + */ + public void setType(SubjectType type) { + this.type = type; + } + } diff --git a/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java b/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java index 498dc960..9ba59255 100644 --- a/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java +++ b/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java @@ -22,9 +22,9 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; public abstract class SubjectParser { - private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); - Logger logger = Logger.getLogger(SubjectParser.class); - DataFormatter df = new DataFormatter(); + private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); + Logger logger = Logger.getLogger(SubjectParser.class); + DataFormatter df = new DataFormatter(); public List<Subject> processExcel(String filename) throws EncryptedDocumentException, InvalidFormatException, IOException, ParseException { List<Subject> result = new ArrayList<>(); @@ -81,10 +81,13 @@ public abstract class SubjectParser { result.setAddDate(parseAddDate(row)); result.setmPowerId(parsemPowerId(row)); result.setBirthDate(parseBirthDate(row)); + result.setType(parseType(row)); return result; } + protected abstract SubjectType parseType(Row row); + protected abstract String parseBirthDate(Row row); protected abstract String parsemPowerId(Row row); diff --git a/appointment-import/src/main/java/smash/appointment/parse/SubjectType.java b/appointment-import/src/main/java/smash/appointment/parse/SubjectType.java new file mode 100644 index 00000000..24f7bf9f --- /dev/null +++ b/appointment-import/src/main/java/smash/appointment/parse/SubjectType.java @@ -0,0 +1,5 @@ +package smash.appointment.parse; + +public enum SubjectType { + SUBJECT, CONTROL; +} -- GitLab