@Test public void readJSONReturnsNullWhenDataContainerIsNotAJSONObject() throws ComponentLookupException { JSONObject json = new JSONObject(); json.put(DATA_NAME, "datum"); Assert.assertNull(this.component.readJSON(json)); }
@Override public PatientData<String> readJSON(JSONObject json) { if (!json.has(this.getJsonPropertyName())) { return null; } Map<String, String> result = new LinkedHashMap<>(); Object jsonBlockObject = json.get(this.getJsonPropertyName()); if (!(jsonBlockObject instanceof JSONObject)) { return null; } JSONObject jsonBlock = (JSONObject) jsonBlockObject; for (String property : this.getProperties()) { if (jsonBlock.has(property)) { result.put(property, jsonBlock.getString(property)); } } return new DictionaryPatientData<>(this.getName(), result); }
AbstractSimpleController implements PatientDataController<String> { @Override public PatientData<String> readJSON(JSONObject json) { if (!json.has(this.getJsonPropertyName())) { return null; } Map<String, String> result = new LinkedHashMap<>(); Object jsonBlockObject = json.get(this.getJsonPropertyName()); if (!(jsonBlockObject instanceof JSONObject)) { return null; } JSONObject jsonBlock = (JSONObject) jsonBlockObject; for (String property : this.getProperties()) { if (jsonBlock.has(property)) { result.put(property, jsonBlock.getString(property)); } } return new DictionaryPatientData<>(this.getName(), result); } }
AbstractSimpleController implements PatientDataController<String> { @Override public PatientData<String> readJSON(JSONObject json) { if (!json.has(this.getJsonPropertyName())) { return null; } Map<String, String> result = new LinkedHashMap<>(); Object jsonBlockObject = json.get(this.getJsonPropertyName()); if (!(jsonBlockObject instanceof JSONObject)) { return null; } JSONObject jsonBlock = (JSONObject) jsonBlockObject; for (String property : this.getProperties()) { if (jsonBlock.has(property)) { result.put(property, jsonBlock.getString(property)); } } return new DictionaryPatientData<>(this.getName(), result); }  }
AbstractSimpleController implements PatientDataController<String> { @Override public PatientData<String> readJSON(JSONObject json) { if (!json.has(this.getJsonPropertyName())) { return null; } Map<String, String> result = new LinkedHashMap<>(); Object jsonBlockObject = json.get(this.getJsonPropertyName()); if (!(jsonBlockObject instanceof JSONObject)) { return null; } JSONObject jsonBlock = (JSONObject) jsonBlockObject; for (String property : this.getProperties()) { if (jsonBlock.has(property)) { result.put(property, jsonBlock.getString(property)); } } return new DictionaryPatientData<>(this.getName(), result); }  @Override PatientData<String> 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<String> readJSON(JSONObject json); }
AbstractSimpleController implements PatientDataController<String> { @Override public PatientData<String> readJSON(JSONObject json) { if (!json.has(this.getJsonPropertyName())) { return null; } Map<String, String> result = new LinkedHashMap<>(); Object jsonBlockObject = json.get(this.getJsonPropertyName()); if (!(jsonBlockObject instanceof JSONObject)) { return null; } JSONObject jsonBlock = (JSONObject) jsonBlockObject; for (String property : this.getProperties()) { if (jsonBlock.has(property)) { result.put(property, jsonBlock.getString(property)); } } return new DictionaryPatientData<>(this.getName(), result); }  @Override PatientData<String> 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<String> readJSON(JSONObject json);  }