@Test public void loadWithNoDataReturnsNull() throws XWikiException { when(this.dataHolder.get(XPROPERTY_NAME)).thenReturn(null); PatientData<Disorder> result = this.component.load(this.patient); assertNull(result); }
@Override public IndexedPatientData<Disorder> load(Patient patient) { try { BaseObject data = patient.getXDocument().getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } List<Disorder> disorders = new ArrayList<>(); ListProperty values = (ListProperty) data.get(DIAGNOSIS_PROPERTY); if (values != null) { for (String value : values.getList()) { if (StringUtils.isNotBlank(value)) { disorders.add(new PhenoTipsDisorder(values, value)); } } } if (disorders.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), disorders); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }
ClinicalDiagnosisController implements PatientDataController<Disorder> { @Override public IndexedPatientData<Disorder> load(Patient patient) { try { BaseObject data = patient.getXDocument().getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } List<Disorder> disorders = new ArrayList<>(); ListProperty values = (ListProperty) data.get(DIAGNOSIS_PROPERTY); if (values != null) { for (String value : values.getList()) { if (StringUtils.isNotBlank(value)) { disorders.add(new PhenoTipsDisorder(values, value)); } } } if (disorders.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), disorders); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; } }
ClinicalDiagnosisController implements PatientDataController<Disorder> { @Override public IndexedPatientData<Disorder> load(Patient patient) { try { BaseObject data = patient.getXDocument().getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } List<Disorder> disorders = new ArrayList<>(); ListProperty values = (ListProperty) data.get(DIAGNOSIS_PROPERTY); if (values != null) { for (String value : values.getList()) { if (StringUtils.isNotBlank(value)) { disorders.add(new PhenoTipsDisorder(values, value)); } } } if (disorders.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), disorders); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  }
ClinicalDiagnosisController implements PatientDataController<Disorder> { @Override public IndexedPatientData<Disorder> load(Patient patient) { try { BaseObject data = patient.getXDocument().getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } List<Disorder> disorders = new ArrayList<>(); ListProperty values = (ListProperty) data.get(DIAGNOSIS_PROPERTY); if (values != null) { for (String value : values.getList()) { if (StringUtils.isNotBlank(value)) { disorders.add(new PhenoTipsDisorder(values, value)); } } } if (disorders.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), disorders); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override String getName(); @Override IndexedPatientData<Disorder> load(Patient patient); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override void writeJSON(Patient patient, JSONObject json); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<Disorder> readJSON(JSONObject json); }
ClinicalDiagnosisController implements PatientDataController<Disorder> { @Override public IndexedPatientData<Disorder> load(Patient patient) { try { BaseObject data = patient.getXDocument().getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } List<Disorder> disorders = new ArrayList<>(); ListProperty values = (ListProperty) data.get(DIAGNOSIS_PROPERTY); if (values != null) { for (String value : values.getList()) { if (StringUtils.isNotBlank(value)) { disorders.add(new PhenoTipsDisorder(values, value)); } } } if (disorders.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), disorders); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override String getName(); @Override IndexedPatientData<Disorder> load(Patient patient); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override void writeJSON(Patient patient, JSONObject json); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<Disorder> readJSON(JSONObject json);  }