@Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { Query q = session.createQuery("select p from " + StringListProperty.class.getName() + " as p, BaseObject as o" + " where o.className='PhenoTips.StudyClass' and p.id=o.id"); @SuppressWarnings("unchecked") List<StringListProperty> wrongProperties = q.list(); this.logger.debug("Found {} study properties of type StringListProperty", wrongProperties.size()); for (StringListProperty oldValue : wrongProperties) { DBStringListProperty newValue = new DBStringListProperty(); newValue.setId(oldValue.getId()); newValue.setName(oldValue.getName()); newValue.setValue(oldValue.getList()); session.delete(oldValue); session.save(newValue); } return null; } }
public void setDBStringListValue(String name, List value) { ListProperty property = (ListProperty) safeget(name); if (property == null) { property = new DBStringListProperty(); } property.setValue(value); safeput(name, property); }
@Override public Object doInHibernate(Session session) throws HibernateException, XWikiException { Query q = session.createQuery("select p from " + StringListProperty.class.getName() + " as p, BaseObject as o" + " where o.className='PhenoTips.StudyClass' and p.id=o.id"); @SuppressWarnings("unchecked") List<StringListProperty> wrongProperties = q.list(); this.logger.debug("Found {} study properties of type StringListProperty", wrongProperties.size()); for (StringListProperty oldValue : wrongProperties) { DBStringListProperty newValue = new DBStringListProperty(); newValue.setId(oldValue.getId()); newValue.setName(oldValue.getName()); newValue.setValue(oldValue.getList()); session.delete(oldValue); session.save(newValue); } return null; } }
for (StringProperty oldProperty : properties) { try { DBStringListProperty newProperty = new DBStringListProperty(); newProperty.setName(oldProperty.getName()); newProperty.setId(oldProperty.getId());
for (StringProperty oldProperty : properties) { try { DBStringListProperty newProperty = new DBStringListProperty(); newProperty.setName(oldProperty.getName()); newProperty.setId(oldProperty.getId());
for (StringProperty oldProperty : properties) { try { DBStringListProperty newProperty = new DBStringListProperty(); newProperty.setName(oldProperty.getName()); newProperty.setId(oldProperty.getId());
@Override public BaseProperty newProperty() { BaseProperty lprop; if (isRelationalStorage() && isMultiSelect()) { lprop = new DBStringListProperty(); } else if (isMultiSelect()) { lprop = new StringListProperty(); } else { lprop = new StringProperty(); } return lprop; }
DBStringListProperty newProperty = new DBStringListProperty(); newProperty.setId(oldProperty.getId()); newProperty.setName(oldProperty.getName());
/** * Create and add the main tag property to the provided tag object. The new property corresponds to the definition * in the tag class, but in case of an error, the default type is a relational-stored list. * * @param tagObject the target tag object * @param context the current request context * @return the created property * @see #TAG_PROPERTY */ private BaseProperty createTagProperty(BaseObject tagObject, XWikiContext context) { BaseProperty tagProperty; try { BaseClass tagClass = context.getWiki().getClass(TAG_CLASS, context); PropertyClass tagPropertyDefinition = (PropertyClass) tagClass.getField(TAG_PROPERTY); tagProperty = tagPropertyDefinition.newProperty(); } catch (XWikiException ex) { LOGGER.warn("Failed to properly create tag property for the tag object, creating a default one"); tagProperty = new DBStringListProperty(); } tagProperty.setName(TAG_PROPERTY); tagProperty.setObject(tagObject); tagObject.safeput(TAG_PROPERTY, tagProperty); return tagProperty; }