@Test public void readWithWrongDataDoesNothing() throws ComponentLookupException { JSONObject json = new JSONObject(); json.put(CONTROLLER_NAME, "No"); PatientData<Gene> result = this.component.readJSON(json); Assert.assertNotNull(result); Assert.assertEquals(0, result.size()); }
@Override public PatientData<Gene> readJSON(JSONObject json) { if (json == null || !(json.has(GENES_STRING) || json.has(JSON_SOLVED_KEY) || json.has(JSON_REJECTEDGENES_KEY))) { return null; } try { List<Gene> accumulatedGenes = new LinkedList<>(); parseGenesJson(json, accumulatedGenes); parseRejectedGenes(json, accumulatedGenes); parseSolvedGene(json, accumulatedGenes); return new IndexedPatientData<>(getName(), accumulatedGenes); } catch (Exception e) { this.logger.error("Could not load genes from JSON: [{}]", e.getMessage(), e); return null; } }
GeneListController implements PatientDataController<Gene> { @Override public PatientData<Gene> readJSON(JSONObject json) { if (json == null || !(json.has(GENES_STRING) || json.has(JSON_SOLVED_KEY) || json.has(JSON_REJECTEDGENES_KEY))) { return null; } try { List<Gene> accumulatedGenes = new LinkedList<>(); parseGenesJson(json, accumulatedGenes); parseRejectedGenes(json, accumulatedGenes); parseSolvedGene(json, accumulatedGenes); return new IndexedPatientData<>(getName(), accumulatedGenes); } catch (Exception e) { this.logger.error("Could not load genes from JSON: [{}]", e.getMessage(), e); return null; } } }
GeneListController implements PatientDataController<Gene> { @Override public PatientData<Gene> readJSON(JSONObject json) { if (json == null || !(json.has(GENES_STRING) || json.has(JSON_SOLVED_KEY) || json.has(JSON_REJECTEDGENES_KEY))) { return null; } try { List<Gene> accumulatedGenes = new LinkedList<>(); parseGenesJson(json, accumulatedGenes); parseRejectedGenes(json, accumulatedGenes); parseSolvedGene(json, accumulatedGenes); return new IndexedPatientData<>(getName(), accumulatedGenes); } catch (Exception e) { this.logger.error("Could not load genes from JSON: [{}]", e.getMessage(), e); return null; } }  }
GeneListController implements PatientDataController<Gene> { @Override public PatientData<Gene> readJSON(JSONObject json) { if (json == null || !(json.has(GENES_STRING) || json.has(JSON_SOLVED_KEY) || json.has(JSON_REJECTEDGENES_KEY))) { return null; } try { List<Gene> accumulatedGenes = new LinkedList<>(); parseGenesJson(json, accumulatedGenes); parseRejectedGenes(json, accumulatedGenes); parseSolvedGene(json, accumulatedGenes); return new IndexedPatientData<>(getName(), accumulatedGenes); } catch (Exception e) { this.logger.error("Could not load genes from JSON: [{}]", e.getMessage(), e); return null; } }  @Override String getName(); @Override PatientData<Gene> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<Gene> readJSON(JSONObject json); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override void writeJSON(Patient patient, JSONObject json); }
GeneListController implements PatientDataController<Gene> { @Override public PatientData<Gene> readJSON(JSONObject json) { if (json == null || !(json.has(GENES_STRING) || json.has(JSON_SOLVED_KEY) || json.has(JSON_REJECTEDGENES_KEY))) { return null; } try { List<Gene> accumulatedGenes = new LinkedList<>(); parseGenesJson(json, accumulatedGenes); parseRejectedGenes(json, accumulatedGenes); parseSolvedGene(json, accumulatedGenes); return new IndexedPatientData<>(getName(), accumulatedGenes); } catch (Exception e) { this.logger.error("Could not load genes from JSON: [{}]", e.getMessage(), e); return null; } }  @Override String getName(); @Override PatientData<Gene> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<Gene> readJSON(JSONObject json); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override void writeJSON(Patient patient, JSONObject json);  }