@Test public void onEventIgnoresEmptyListTest() throws XWikiException { this.xWikiObjects = null; this.patientEmptyObjectsRemover.onEvent(mock(Event.class), this.xWikiDocument, mock(Object.class)); verify(this.xWikiDocument, never()).removeXObject((BaseObject) anyObject()); }
@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; Map<String, EntityReference> refs = new LinkedHashMap<>(); refs.put(GENE_KEY, GENE_CLASS_REFERENCE); refs.put(VARIANT_KEY, VARIANT_CLASS_REFERENCE); for (String key : refs.keySet()) { List<BaseObject> xWikiObjects = doc.getXObjects(refs.get(key)); if (xWikiObjects == null || xWikiObjects.isEmpty()) { continue; } for (BaseObject object : xWikiObjects) { if (object == null) { continue; } BaseStringProperty field = (BaseStringProperty) object.getField(key); if (field == null || StringUtils.isEmpty(field.getValue())) { doc.removeXObject(object); } } } }
PatientEmptyObjectsRemover extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; Map<String, EntityReference> refs = new LinkedHashMap<>(); refs.put(GENE_KEY, GENE_CLASS_REFERENCE); refs.put(VARIANT_KEY, VARIANT_CLASS_REFERENCE); for (String key : refs.keySet()) { List<BaseObject> xWikiObjects = doc.getXObjects(refs.get(key)); if (xWikiObjects == null || xWikiObjects.isEmpty()) { continue; } for (BaseObject object : xWikiObjects) { if (object == null) { continue; } BaseStringProperty field = (BaseStringProperty) object.getField(key); if (field == null || StringUtils.isEmpty(field.getValue())) { doc.removeXObject(object); } } } } }
PatientEmptyObjectsRemover extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; Map<String, EntityReference> refs = new LinkedHashMap<>(); refs.put(GENE_KEY, GENE_CLASS_REFERENCE); refs.put(VARIANT_KEY, VARIANT_CLASS_REFERENCE); for (String key : refs.keySet()) { List<BaseObject> xWikiObjects = doc.getXObjects(refs.get(key)); if (xWikiObjects == null || xWikiObjects.isEmpty()) { continue; } for (BaseObject object : xWikiObjects) { if (object == null) { continue; } BaseStringProperty field = (BaseStringProperty) object.getField(key); if (field == null || StringUtils.isEmpty(field.getValue())) { doc.removeXObject(object); } } } } PatientEmptyObjectsRemover(); }
PatientEmptyObjectsRemover extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; Map<String, EntityReference> refs = new LinkedHashMap<>(); refs.put(GENE_KEY, GENE_CLASS_REFERENCE); refs.put(VARIANT_KEY, VARIANT_CLASS_REFERENCE); for (String key : refs.keySet()) { List<BaseObject> xWikiObjects = doc.getXObjects(refs.get(key)); if (xWikiObjects == null || xWikiObjects.isEmpty()) { continue; } for (BaseObject object : xWikiObjects) { if (object == null) { continue; } BaseStringProperty field = (BaseStringProperty) object.getField(key); if (field == null || StringUtils.isEmpty(field.getValue())) { doc.removeXObject(object); } } } } PatientEmptyObjectsRemover(); @Override void onEvent(Event event, Object source, Object data); }
PatientEmptyObjectsRemover extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; Map<String, EntityReference> refs = new LinkedHashMap<>(); refs.put(GENE_KEY, GENE_CLASS_REFERENCE); refs.put(VARIANT_KEY, VARIANT_CLASS_REFERENCE); for (String key : refs.keySet()) { List<BaseObject> xWikiObjects = doc.getXObjects(refs.get(key)); if (xWikiObjects == null || xWikiObjects.isEmpty()) { continue; } for (BaseObject object : xWikiObjects) { if (object == null) { continue; } BaseStringProperty field = (BaseStringProperty) object.getField(key); if (field == null || StringUtils.isEmpty(field.getValue())) { doc.removeXObject(object); } } } } PatientEmptyObjectsRemover(); @Override void onEvent(Event event, Object source, Object data);  }