@Test public void doInHibernateDoesNothingWhenXWikiExceptionIsThrownForEachFamily() throws XWikiException { when(this.query.list()).thenReturn(Collections.singletonList(FAMILY_1)); when(this.xwiki.getDocument(this.documentReference1, this.context)).thenThrow(new XWikiException()); this.component.doInHibernate(this.session); verify(this.xwiki, times(1)).getDocument(any(DocumentReference.class), any(XWikiContext.class)); verify(this.logger, times(1)).error(eq(ERROR_READING_DATA), eq(FAMILY_1), any()); verifyNoMoreInteractions(this.xwiki); }
@Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { XWikiContext context = getXWikiContext(); XWiki xwiki = context.getWiki(); Query q = session.createQuery("select distinct o.name from BaseObject o where o.className = '" + this.serializer.serialize(PEDIGREE_CLASS_REFERENCE) + "' and o.name <> 'PhenoTips.FamilyTemplate'"); @SuppressWarnings("unchecked") List<String> docs = q.list(); this.logger.debug("Found {} documents", docs.size()); for (String docName : docs) { XWikiDocument xDocument; BaseObject pedigreeXObject; try { xDocument = xwiki.getDocument(this.resolver.resolve(docName), context); if (xDocument == null) { continue; } pedigreeXObject = xDocument.getXObject(PEDIGREE_CLASS_REFERENCE); if (pedigreeXObject == null) { continue; } } catch (Exception e) { this.logger.error("Error checking pedigree data for document {}: [{}]", docName, e.getMessage()); continue; } try { this.logger.debug("Updating pedigree for document {}.", docName); if (!this.updatePedigree(pedigreeXObject, context, docName)) { continue; } xDocument.setComment(this.getDescription()); xDocument.setMinorEdit(true); } catch (Exception e) { this.logger.error("Error updating pedigree data format for document {}: [{}]", docName, e.getMessage()); continue; } try { session.clear(); ((XWikiHibernateStore) getStore()).saveXWikiDoc(xDocument, context, false); session.flush(); } catch (DataMigrationException e) { this.logger.error("Error when saving XWiki document {}: [{}]", docName, e.getMessage()); } } return null; }
R71507PhenoTips3423DataMigration extends AbstractHibernateDataMigration implements
    HibernateCallback<Object> { @Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { XWikiContext context = getXWikiContext(); XWiki xwiki = context.getWiki(); Query q = session.createQuery("select distinct o.name from BaseObject o where o.className = '" + this.serializer.serialize(PEDIGREE_CLASS_REFERENCE) + "' and o.name <> 'PhenoTips.FamilyTemplate'"); @SuppressWarnings("unchecked") List<String> docs = q.list(); this.logger.debug("Found {} documents", docs.size()); for (String docName : docs) { XWikiDocument xDocument; BaseObject pedigreeXObject; try { xDocument = xwiki.getDocument(this.resolver.resolve(docName), context); if (xDocument == null) { continue; } pedigreeXObject = xDocument.getXObject(PEDIGREE_CLASS_REFERENCE); if (pedigreeXObject == null) { continue; } } catch (Exception e) { this.logger.error("Error checking pedigree data for document {}: [{}]", docName, e.getMessage()); continue; } try { this.logger.debug("Updating pedigree for document {}.", docName); if (!this.updatePedigree(pedigreeXObject, context, docName)) { continue; } xDocument.setComment(this.getDescription()); xDocument.setMinorEdit(true); } catch (Exception e) { this.logger.error("Error updating pedigree data format for document {}: [{}]", docName, e.getMessage()); continue; } try { session.clear(); ((XWikiHibernateStore) getStore()).saveXWikiDoc(xDocument, context, false); session.flush(); } catch (DataMigrationException e) { this.logger.error("Error when saving XWiki document {}: [{}]", docName, e.getMessage()); } } return null; } }
R71507PhenoTips3423DataMigration extends AbstractHibernateDataMigration implements
    HibernateCallback<Object> { @Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { XWikiContext context = getXWikiContext(); XWiki xwiki = context.getWiki(); Query q = session.createQuery("select distinct o.name from BaseObject o where o.className = '" + this.serializer.serialize(PEDIGREE_CLASS_REFERENCE) + "' and o.name <> 'PhenoTips.FamilyTemplate'"); @SuppressWarnings("unchecked") List<String> docs = q.list(); this.logger.debug("Found {} documents", docs.size()); for (String docName : docs) { XWikiDocument xDocument; BaseObject pedigreeXObject; try { xDocument = xwiki.getDocument(this.resolver.resolve(docName), context); if (xDocument == null) { continue; } pedigreeXObject = xDocument.getXObject(PEDIGREE_CLASS_REFERENCE); if (pedigreeXObject == null) { continue; } } catch (Exception e) { this.logger.error("Error checking pedigree data for document {}: [{}]", docName, e.getMessage()); continue; } try { this.logger.debug("Updating pedigree for document {}.", docName); if (!this.updatePedigree(pedigreeXObject, context, docName)) { continue; } xDocument.setComment(this.getDescription()); xDocument.setMinorEdit(true); } catch (Exception e) { this.logger.error("Error updating pedigree data format for document {}: [{}]", docName, e.getMessage()); continue; } try { session.clear(); ((XWikiHibernateStore) getStore()).saveXWikiDoc(xDocument, context, false); session.flush(); } catch (DataMigrationException e) { this.logger.error("Error when saving XWiki document {}: [{}]", docName, e.getMessage()); } } return null; }  }
R71507PhenoTips3423DataMigration extends AbstractHibernateDataMigration implements
    HibernateCallback<Object> { @Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { XWikiContext context = getXWikiContext(); XWiki xwiki = context.getWiki(); Query q = session.createQuery("select distinct o.name from BaseObject o where o.className = '" + this.serializer.serialize(PEDIGREE_CLASS_REFERENCE) + "' and o.name <> 'PhenoTips.FamilyTemplate'"); @SuppressWarnings("unchecked") List<String> docs = q.list(); this.logger.debug("Found {} documents", docs.size()); for (String docName : docs) { XWikiDocument xDocument; BaseObject pedigreeXObject; try { xDocument = xwiki.getDocument(this.resolver.resolve(docName), context); if (xDocument == null) { continue; } pedigreeXObject = xDocument.getXObject(PEDIGREE_CLASS_REFERENCE); if (pedigreeXObject == null) { continue; } } catch (Exception e) { this.logger.error("Error checking pedigree data for document {}: [{}]", docName, e.getMessage()); continue; } try { this.logger.debug("Updating pedigree for document {}.", docName); if (!this.updatePedigree(pedigreeXObject, context, docName)) { continue; } xDocument.setComment(this.getDescription()); xDocument.setMinorEdit(true); } catch (Exception e) { this.logger.error("Error updating pedigree data format for document {}: [{}]", docName, e.getMessage()); continue; } try { session.clear(); ((XWikiHibernateStore) getStore()).saveXWikiDoc(xDocument, context, false); session.flush(); } catch (DataMigrationException e) { this.logger.error("Error when saving XWiki document {}: [{}]", docName, e.getMessage()); } } return null; }  @Override String getDescription(); @Override XWikiDBVersion getVersion(); @Override void hibernateMigrate(); @Override Object doInHibernate(Session session); }
R71507PhenoTips3423DataMigration extends AbstractHibernateDataMigration implements
    HibernateCallback<Object> { @Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { XWikiContext context = getXWikiContext(); XWiki xwiki = context.getWiki(); Query q = session.createQuery("select distinct o.name from BaseObject o where o.className = '" + this.serializer.serialize(PEDIGREE_CLASS_REFERENCE) + "' and o.name <> 'PhenoTips.FamilyTemplate'"); @SuppressWarnings("unchecked") List<String> docs = q.list(); this.logger.debug("Found {} documents", docs.size()); for (String docName : docs) { XWikiDocument xDocument; BaseObject pedigreeXObject; try { xDocument = xwiki.getDocument(this.resolver.resolve(docName), context); if (xDocument == null) { continue; } pedigreeXObject = xDocument.getXObject(PEDIGREE_CLASS_REFERENCE); if (pedigreeXObject == null) { continue; } } catch (Exception e) { this.logger.error("Error checking pedigree data for document {}: [{}]", docName, e.getMessage()); continue; } try { this.logger.debug("Updating pedigree for document {}.", docName); if (!this.updatePedigree(pedigreeXObject, context, docName)) { continue; } xDocument.setComment(this.getDescription()); xDocument.setMinorEdit(true); } catch (Exception e) { this.logger.error("Error updating pedigree data format for document {}: [{}]", docName, e.getMessage()); continue; } try { session.clear(); ((XWikiHibernateStore) getStore()).saveXWikiDoc(xDocument, context, false); session.flush(); } catch (DataMigrationException e) { this.logger.error("Error when saving XWiki document {}: [{}]", docName, e.getMessage()); } } return null; }  @Override String getDescription(); @Override XWikiDBVersion getVersion(); @Override void hibernateMigrate(); @Override Object doInHibernate(Session session);  }