/** * {@inheritDoc} * * @see com.xpn.xwiki.objects.BaseCollection#get(java.lang.String) */ @Override public PropertyInterface get(String name) { return safeget(name); }
public PropertyInterface safeget(String name) { return super.safeget("meta" + name); }
/** * Re-enable a property. This field will appear again in object instances. * * @param name the name of the property to enable * @since 2.4M2 */ public void enableField(String name) { PropertyClass pclass = (PropertyClass) safeget(name); if (pclass != null) { pclass.setDisabled(false); } }
/** * Mark a property as disabled. A disabled property should not be editable, but existing object values are still * kept in the database. * * @param name the name of the property to disable * @since 2.4M2 */ public void disableField(String name) { PropertyClass pclass = (PropertyClass) safeget(name); if (pclass != null) { pclass.setDisabled(true); } }
public void fromXML(Element pcel) throws XWikiException { List list = pcel.elements(); BaseClass bclass = getxWikiClass(); for (int i = 0; i < list.size(); i++) { Element ppcel = (Element) list.get(i); String name = ppcel.getName(); if (bclass == null) { Object[] args = {getClass().getName()}; throw new XWikiException(XWikiException.MODULE_XWIKI_CLASSES, XWikiException.ERROR_XWIKI_CLASSES_PROPERTY_CLASS_IN_METACLASS, "Cannot find property class {0} in MetaClass object", null, args); } PropertyClass pclass = (PropertyClass) bclass.safeget(name); if (pclass != null) { BaseProperty bprop = pclass.newPropertyfromXML(ppcel); bprop.setObject(this); safeput(name, bprop); } } }
/** * Retrieves deprecated properties of the given object compared to the class. A deprecated property is a property * which exists in the Object but doesn't exist anymore in the Class, or which has the wrong data type. This is used * for synchronization of existing or imported Objects with respect to the modifications of their associated Class. * * @param object the instance of this class where to look for undefined properties * @return an unmodifiable list containing the properties of the object which don't exist in the class * @since 2.4M2 */ public List<BaseProperty> getDeprecatedObjectProperties(BaseObject object) { @SuppressWarnings("unchecked") Collection<BaseProperty> objectProperties = object.getFieldList(); if (objectProperties == null) { return Collections.emptyList(); } List<BaseProperty> deprecatedObjectProperties = new ArrayList<BaseProperty>(); for (BaseProperty property : objectProperties) { if (safeget(property.getName()) == null) { deprecatedObjectProperties.add(property); } else { String propertyClass = ((PropertyClass) safeget(property.getName())).newProperty().getClassType(); String objectPropertyClass = property.getClassType(); if (!propertyClass.equals(objectPropertyClass)) { deprecatedObjectProperties.add(property); } } } return Collections.unmodifiableList(deprecatedObjectProperties); }
@Override public void onWikiObjectProperty(String name, Object value, FilterEventParameters parameters) throws WikiStreamException { PropertyClassInterface propertyclass = (PropertyClassInterface) getCurrentXClass().safeget(name); if (propertyclass != null) { // Bulletproofing using PropertyClassInterface#fromString when a String is passed (in case it's not really a // String property) PropertyInterface property = value instanceof String ? propertyclass.fromString((String) value) : propertyclass.fromValue(value); this.currentXObject.safeput(name, property); } else { // TODO: Log something ? } } }