@Test public void loadReturnsAllData() throws ComponentLookupException { String datum1 = "datum1"; String datum2 = "datum2"; String datum3 = "datum3"; String datum4 = "datum4"; String datum5 = "datum5"; doReturn(datum1).when(this.baseProperty1).getValue(); doReturn(datum2).when(this.baseProperty2).getValue(); doReturn(datum3).when(this.baseProperty3).getValue(); doReturn(datum4).when(this.baseProperty4).getValue(); doReturn(datum5).when(this.baseProperty5).getValue(); PatientData<String> result = this.component.load(this.patient); Assert.assertEquals(datum1, result.get(PROPERTY_1)); Assert.assertEquals(datum2, result.get(PROPERTY_2)); Assert.assertEquals(datum3, result.get(PROPERTY_3)); Assert.assertEquals(datum4, result.get(PROPERTY_4)); Assert.assertEquals(datum5, result.get(PROPERTY_5)); Assert.assertEquals(5, result.size()); }
@Override @SuppressWarnings("unchecked") public PatientData<T> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getXClassReference()); if (data == null) { return null; } Map<String, T> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { BaseProperty<ObjectPropertyReference> field = (BaseProperty<ObjectPropertyReference>) data.getField(propertyName); if (field != null) { Object propertyValue = field.getValue(); if (getCodeFields().contains(propertyName) && isCodeFieldsOnly()) { List<VocabularyProperty> propertyValuesList = new LinkedList<>(); List<String> terms = (List<String>) propertyValue; for (String termId : terms) { propertyValuesList.add(new QuickVocabularyProperty(termId)); } propertyValue = propertyValuesList; } result.put(propertyName, (T) propertyValue); } } return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }
AbstractComplexController implements PatientDataController<T> { @Override @SuppressWarnings("unchecked") public PatientData<T> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getXClassReference()); if (data == null) { return null; } Map<String, T> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { BaseProperty<ObjectPropertyReference> field = (BaseProperty<ObjectPropertyReference>) data.getField(propertyName); if (field != null) { Object propertyValue = field.getValue(); if (getCodeFields().contains(propertyName) && isCodeFieldsOnly()) { List<VocabularyProperty> propertyValuesList = new LinkedList<>(); List<String> terms = (List<String>) propertyValue; for (String termId : terms) { propertyValuesList.add(new QuickVocabularyProperty(termId)); } propertyValue = propertyValuesList; } result.put(propertyName, (T) propertyValue); } } return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; } }
AbstractComplexController implements PatientDataController<T> { @Override @SuppressWarnings("unchecked") public PatientData<T> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getXClassReference()); if (data == null) { return null; } Map<String, T> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { BaseProperty<ObjectPropertyReference> field = (BaseProperty<ObjectPropertyReference>) data.getField(propertyName); if (field != null) { Object propertyValue = field.getValue(); if (getCodeFields().contains(propertyName) && isCodeFieldsOnly()) { List<VocabularyProperty> propertyValuesList = new LinkedList<>(); List<String> terms = (List<String>) propertyValue; for (String termId : terms) { propertyValuesList.add(new QuickVocabularyProperty(termId)); } propertyValue = propertyValuesList; } result.put(propertyName, (T) propertyValue); } } return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  }
AbstractComplexController implements PatientDataController<T> { @Override @SuppressWarnings("unchecked") public PatientData<T> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getXClassReference()); if (data == null) { return null; } Map<String, T> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { BaseProperty<ObjectPropertyReference> field = (BaseProperty<ObjectPropertyReference>) data.getField(propertyName); if (field != null) { Object propertyValue = field.getValue(); if (getCodeFields().contains(propertyName) && isCodeFieldsOnly()) { List<VocabularyProperty> propertyValuesList = new LinkedList<>(); List<String> terms = (List<String>) propertyValue; for (String termId : terms) { propertyValuesList.add(new QuickVocabularyProperty(termId)); } propertyValue = propertyValuesList; } result.put(propertyName, (T) propertyValue); } } return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override @SuppressWarnings("unchecked") PatientData<T> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override void writeJSON(Patient patient, JSONObject json); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override PatientData<T> readJSON(JSONObject json); }
AbstractComplexController implements PatientDataController<T> { @Override @SuppressWarnings("unchecked") public PatientData<T> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getXClassReference()); if (data == null) { return null; } Map<String, T> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { BaseProperty<ObjectPropertyReference> field = (BaseProperty<ObjectPropertyReference>) data.getField(propertyName); if (field != null) { Object propertyValue = field.getValue(); if (getCodeFields().contains(propertyName) && isCodeFieldsOnly()) { List<VocabularyProperty> propertyValuesList = new LinkedList<>(); List<String> terms = (List<String>) propertyValue; for (String termId : terms) { propertyValuesList.add(new QuickVocabularyProperty(termId)); } propertyValue = propertyValuesList; } result.put(propertyName, (T) propertyValue); } } return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override @SuppressWarnings("unchecked") PatientData<T> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override void writeJSON(Patient patient, JSONObject json); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override PatientData<T> readJSON(JSONObject json);  }