@Test public void loadCatchesExceptionFromDocumentAccess() throws Exception { Exception exception = new RuntimeException(); doThrow(exception).when(this.patient).getXDocument(); PatientData<Gene> result = this.component.load(this.patient); Assert.assertNull(result); verify(this.mocker.getMockedLogger()).error(eq(PatientDataController.ERROR_MESSAGE_LOAD_FAILED), anyString()); }
@Override public PatientData<Gene> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); List<BaseObject> geneXWikiObjects = doc.getXObjects(Gene.GENE_CLASS); if (geneXWikiObjects == null || geneXWikiObjects.isEmpty()) { return null; } List<Gene> allGenes = new LinkedList<>(); for (BaseObject geneObject : geneXWikiObjects) { if (geneObject == null || geneObject.getFieldList().isEmpty()) { continue; } String id = getFieldValue(geneObject, INTERNAL_GENE_KEY); String status = getFieldValue(geneObject, INTERNAL_STATUS_KEY); Collection<String> strategy = getFieldListValue(geneObject, INTERNAL_STRATEGY_KEY); String comment = getFieldValue(geneObject, INTERNAL_COMMENTS_KEY); Gene gene = new PhenoTipsGene(id, null, status, strategy, comment); allGenes.add(gene); } if (allGenes.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), allGenes); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }
GeneListController implements PatientDataController<Gene> { @Override public PatientData<Gene> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); List<BaseObject> geneXWikiObjects = doc.getXObjects(Gene.GENE_CLASS); if (geneXWikiObjects == null || geneXWikiObjects.isEmpty()) { return null; } List<Gene> allGenes = new LinkedList<>(); for (BaseObject geneObject : geneXWikiObjects) { if (geneObject == null || geneObject.getFieldList().isEmpty()) { continue; } String id = getFieldValue(geneObject, INTERNAL_GENE_KEY); String status = getFieldValue(geneObject, INTERNAL_STATUS_KEY); Collection<String> strategy = getFieldListValue(geneObject, INTERNAL_STRATEGY_KEY); String comment = getFieldValue(geneObject, INTERNAL_COMMENTS_KEY); Gene gene = new PhenoTipsGene(id, null, status, strategy, comment); allGenes.add(gene); } if (allGenes.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), allGenes); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; } }
GeneListController implements PatientDataController<Gene> { @Override public PatientData<Gene> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); List<BaseObject> geneXWikiObjects = doc.getXObjects(Gene.GENE_CLASS); if (geneXWikiObjects == null || geneXWikiObjects.isEmpty()) { return null; } List<Gene> allGenes = new LinkedList<>(); for (BaseObject geneObject : geneXWikiObjects) { if (geneObject == null || geneObject.getFieldList().isEmpty()) { continue; } String id = getFieldValue(geneObject, INTERNAL_GENE_KEY); String status = getFieldValue(geneObject, INTERNAL_STATUS_KEY); Collection<String> strategy = getFieldListValue(geneObject, INTERNAL_STRATEGY_KEY); String comment = getFieldValue(geneObject, INTERNAL_COMMENTS_KEY); Gene gene = new PhenoTipsGene(id, null, status, strategy, comment); allGenes.add(gene); } if (allGenes.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), allGenes); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  }
GeneListController implements PatientDataController<Gene> { @Override public PatientData<Gene> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); List<BaseObject> geneXWikiObjects = doc.getXObjects(Gene.GENE_CLASS); if (geneXWikiObjects == null || geneXWikiObjects.isEmpty()) { return null; } List<Gene> allGenes = new LinkedList<>(); for (BaseObject geneObject : geneXWikiObjects) { if (geneObject == null || geneObject.getFieldList().isEmpty()) { continue; } String id = getFieldValue(geneObject, INTERNAL_GENE_KEY); String status = getFieldValue(geneObject, INTERNAL_STATUS_KEY); Collection<String> strategy = getFieldListValue(geneObject, INTERNAL_STRATEGY_KEY); String comment = getFieldValue(geneObject, INTERNAL_COMMENTS_KEY); Gene gene = new PhenoTipsGene(id, null, status, strategy, comment); allGenes.add(gene); } if (allGenes.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), allGenes); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } 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> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); List<BaseObject> geneXWikiObjects = doc.getXObjects(Gene.GENE_CLASS); if (geneXWikiObjects == null || geneXWikiObjects.isEmpty()) { return null; } List<Gene> allGenes = new LinkedList<>(); for (BaseObject geneObject : geneXWikiObjects) { if (geneObject == null || geneObject.getFieldList().isEmpty()) { continue; } String id = getFieldValue(geneObject, INTERNAL_GENE_KEY); String status = getFieldValue(geneObject, INTERNAL_STATUS_KEY); Collection<String> strategy = getFieldListValue(geneObject, INTERNAL_STRATEGY_KEY); String comment = getFieldValue(geneObject, INTERNAL_COMMENTS_KEY); Gene gene = new PhenoTipsGene(id, null, status, strategy, comment); allGenes.add(gene); } if (allGenes.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), allGenes); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } 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);  }