public void setFloatValue(String name, float value) { NumberProperty property = new FloatProperty(); property.setName(name); property.setValue(new Float(value)); safeput(name, property); }
@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; } }
@Override public BaseProperty newProperty() { String ntype = getNumberType(); BaseProperty property; if (ntype.equals("integer")) { property = new IntegerProperty(); } else if (ntype.equals("float")) { property = new FloatProperty(); } else if (ntype.equals("double")) { property = new DoubleProperty(); } else { property = new LongProperty(); } property.setName(getName()); return property; }