/** * {@inheritDoc} * * @see com.xpn.xwiki.objects.ObjectInterface#safeput(java.lang.String, com.xpn.xwiki.objects.PropertyInterface) */ public void safeput(String name, PropertyInterface property) { addField(name, property); if (property instanceof BaseProperty) { ((BaseProperty) property).setObject(this); ((BaseProperty) property).setName(name); } }
/** * {@inheritDoc} * * @see com.xpn.xwiki.objects.classes.StringClass#newProperty() */ @Override public BaseProperty newProperty() { BaseProperty property = new LargeStringProperty(); property.setName(getName()); return property; }
@Override public BaseProperty newProperty() { BaseProperty property = new StringProperty(); property.setName(getName()); return property; }
@Override public BaseProperty newProperty() { BaseProperty property = new IntegerProperty(); property.setName(getName()); return property; }
@Override public BaseProperty newProperty() { BaseProperty property = new DateProperty(); property.setName(getName()); return property; }
public void safeput(String name, PropertyInterface property) { addField("meta" + name, property); if (property instanceof PropertyClass) { ((PropertyClass) property).setObject(this); ((BaseProperty) property).setName(name); } }
@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; }
if (pclass != null) { BaseProperty property = pclass.newPropertyfromXML(pcel); property.setName(name); property.setObject(this); safeput(name, property);
/** * Initialize statistics object from XML schema. * * @param oel the XML root node containing statistics datas. * @throws XWikiException error when parsing XML schema. */ public void fromXML(Element oel) throws XWikiException { Element cel = oel.element("class"); BaseClass bclass = new BaseClass(); if (cel != null) { bclass.fromXML(cel); setClassName(bclass.getName()); } setName(oel.element(XMLNODE_NAME).getText()); List< ? > list = oel.elements(XMLNODE_PROPERTY); for (int i = 0; i < list.size(); i++) { Element pcel = (Element) ((Element) list.get(i)).elements().get(0); String name = pcel.getName(); PropertyClass pclass = (PropertyClass) bclass.get(name); if (pclass != null) { BaseProperty property = pclass.newPropertyfromXML(pcel); property.setName(name); property.setObject(this); safeput(name, property); } } } }
/** * @since 2.2M2 */ public void renameProperties(DocumentReference classReference, Map<String, String> fieldsToRename) { List<BaseObject> objects = getXObjects(classReference); if (objects == null) { return; } for (BaseObject bobject : objects) { if (bobject == null) { continue; } for (Map.Entry<String, String> entry : fieldsToRename.entrySet()) { String origname = entry.getKey(); String newname = entry.getValue(); BaseProperty origprop = (BaseProperty) bobject.safeget(origname); if (origprop != null) { BaseProperty prop = (BaseProperty) origprop.clone(); bobject.removeField(origname); prop.setName(newname); bobject.addField(newname, prop); } } } setContentDirty(true); }
/** * 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; }
property = (BaseProperty) Class.forName(classType).newInstance(); property.setObject(object); property.setName(name); loadXWikiProperty(property, context, false); } catch (Exception e) {
BaseProperty lp1 = lc.newProperty(); lp1.setId(lp.getId()); lp1.setName(lp.getName()); if (lc.isMultiSelect()) { List tmp; BaseProperty np1 = nc.newProperty(); np1.setId(np.getId()); np1.setName(np.getName()); if (nc.getNumberType().equals("integer")) { np1.setValue(Integer.valueOf(((Number) np.getValue()).intValue()));