@Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { Query q = session.createQuery("select hc from BaseObject o, FloatProperty hc" + " where o.className = 'PhenoTips.MeasurementsClass'" + " and hc.id.id = o.id and hc.id.name = 'head_circumference'"); @SuppressWarnings("unchecked") List<FloatProperty> properties = q.list(); for (FloatProperty property : properties) { FloatProperty updated = (FloatProperty) property.clone(); updated.setName("hc"); session.save(updated); session.delete(property); } return null; } });
@Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { Query q = session.createQuery("select hc from BaseObject o, FloatProperty hc" + " where o.className = 'PhenoTips.MeasurementsClass'" + " and hc.id.id = o.id and hc.id.name = 'head_circumference'"); @SuppressWarnings("unchecked") List<FloatProperty> properties = q.list(); for (FloatProperty property : properties) { FloatProperty updated = (FloatProperty) property.clone(); updated.setName("hc"); session.save(updated); session.delete(property); } return null; } });
@Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { String measurementsClassReference = "Phenotips.MeasurementsClass"; Query q = session.createQuery("select p from " + IntegerProperty.class.getName() + " as p, BaseObject as o" + " where o.className='" + measurementsClassReference + "' and p.id.id=o.id and p.id.name='age'"); @SuppressWarnings("unchecked") List<IntegerProperty> oldAgeProperties = q.list(); for (IntegerProperty oldAgeProperty : oldAgeProperties) { FloatProperty newAgeProperty = new FloatProperty(); newAgeProperty.setId(oldAgeProperty.getId()); newAgeProperty.setName(oldAgeProperty.getName()); Integer oldValue = (Integer) oldAgeProperty.getValue(); if (oldValue != null) { newAgeProperty.setValue((float) oldValue); } session.delete(oldAgeProperty); session.save(newAgeProperty); } return null; } }
@Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { String measurementsClassReference = "Phenotips.MeasurementsClass"; Query q = session.createQuery("select p from " + IntegerProperty.class.getName() + " as p, BaseObject as o" + " where o.className='" + measurementsClassReference + "' and p.id.id=o.id and p.id.name='age'"); @SuppressWarnings("unchecked") List<IntegerProperty> oldAgeProperties = q.list(); for (IntegerProperty oldAgeProperty : oldAgeProperties) { FloatProperty newAgeProperty = new FloatProperty(); newAgeProperty.setId(oldAgeProperty.getId()); newAgeProperty.setName(oldAgeProperty.getName()); Integer oldValue = (Integer) oldAgeProperty.getValue(); if (oldValue != null) { newAgeProperty.setValue((float) oldValue); } session.delete(oldAgeProperty); session.save(newAgeProperty); } return null; } }