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

when merging two subjects update function improved

comparison of values is less strict
parent 8495a220
No related branches found
No related tags found
1 merge request!12Duplicates removal
...@@ -331,7 +331,7 @@ public class Subject { ...@@ -331,7 +331,7 @@ public class Subject {
public void setPhone3(String phone3) { public void setPhone3(String phone3) {
if (phone3 != null && phone3.length() > 20) { if (phone3 != null && phone3.length() > 20) {
logger.warn("Invalid phone. Ignoring: " + phone3); logger.warn("Invalid phone. Ignoring: " + phone3);
} else if (phone3!=null){ } else if (phone3 != null) {
this.phone3 = phone3.replace(",", ""); this.phone3 = phone3.replace(",", "");
} }
} }
...@@ -474,14 +474,14 @@ public class Subject { ...@@ -474,14 +474,14 @@ public class Subject {
setDiagnosisYear(getMergedValue("diagnosisYear", this.getDiagnosisYear(), subject.getDiagnosisYear(), errorPrefix)); setDiagnosisYear(getMergedValue("diagnosisYear", this.getDiagnosisYear(), subject.getDiagnosisYear(), errorPrefix));
setDiagnosis(getMergedValue("diagnosis", this.getDiagnosis(), subject.getDiagnosis(), errorPrefix)); setDiagnosis(getMergedValue("diagnosis", this.getDiagnosis(), subject.getDiagnosis(), errorPrefix));
setReferal(getMergedValue("referal", this.getReferal(), subject.getReferal(), errorPrefix)); setReferal(getMergedValue("referal", this.getReferal(), subject.getReferal(), errorPrefix));
setAddDate(getMergedValue("addDate", this.getAddDate(), subject.getAddDate(), errorPrefix)); setAddDate(getMergedValue("addDate", this.getAddDate(), subject.getAddDate(), errorPrefix, true));
setmPowerId(getMergedValue("mPowerId", this.getmPowerId(), subject.getmPowerId(), errorPrefix)); setmPowerId(getMergedValue("mPowerId", this.getmPowerId(), subject.getmPowerId(), errorPrefix));
setType(getMergedValue("type", this.getType(), subject.getType(), errorPrefix)); setType(getMergedValue("type", this.getType(), subject.getType(), errorPrefix));
setResigned(this.isResigned() || subject.isResigned()); setResigned(this.isResigned() || subject.isResigned());
setDead(this.isDead() || subject.isDead()); setDead(this.isDead() || subject.isDead());
setPostponed(this.isPostponed() || subject.isPostponed()); setPostponed(this.isPostponed() || subject.isPostponed());
// override only when to be seen by flying team // override only when to be seen by flying team
if (subject.getToBeSeenAt()!=null && subject.getToBeSeenAt().equals("F")) { if (subject.getToBeSeenAt() != null && subject.getToBeSeenAt().equals("F")) {
setToBeSeenAt(subject.getToBeSeenAt()); setToBeSeenAt(subject.getToBeSeenAt());
} }
addLanguages(subject.getLanguages()); addLanguages(subject.getLanguages());
...@@ -501,14 +501,22 @@ public class Subject { ...@@ -501,14 +501,22 @@ public class Subject {
} }
private String getMergedValue(String string, String existingValue, String newValue, String errorPrefix) { private String getMergedValue(String string, String existingValue, String newValue, String errorPrefix) {
return getMergedValue(string, existingValue, newValue, errorPrefix, false);
}
private String getMergedValue(String string, String existingValue, String newValue, String errorPrefix, boolean ignoreMessage) {
if (existingValue == null || existingValue.trim().isEmpty()) { if (existingValue == null || existingValue.trim().isEmpty()) {
return newValue; return newValue;
} else if (newValue == null || newValue.trim().isEmpty()) { } else if (newValue == null || newValue.trim().isEmpty()) {
return existingValue; return existingValue;
} else if (existingValue.trim().equalsIgnoreCase(newValue.trim())) { } else if (existingValue.trim().toLowerCase().contains(newValue.trim().toLowerCase())) {
return existingValue; return existingValue;
} else if (newValue.trim().toLowerCase().contains(existingValue.trim().toLowerCase())) {
return newValue;
} else { } else {
logger.warn(errorPrefix + "New " + string + " differs from old one. (new: " + newValue + ", " + existingValue + "). Skipping"); if (!ignoreMessage) {
logger.warn(errorPrefix + "New " + string + " differs from old one. (new: " + newValue + ", " + existingValue + "). Skipping");
}
return existingValue; return existingValue;
} }
} }
......
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