public Object getCustomMappingValue() { return getValue(); } }
@Override public void write(BaseProperty xclassProperty, Object filter, BasePropertyFilter propertyFilter, DocumentInstanceInputProperties properties) throws WikiStreamException { // * WikiObjectProperty propertyFilter.onWikiObjectProperty(xclassProperty.getName(), xclassProperty.getValue(), FilterEventParameters.EMPTY); } }
if ("author".equals(deletedProperty.getName())) { newProperty = new StringProperty(); } else { newProperty.setValue(deletedPropertyValue); newProperty.setName(deletedProperty.getName()); } else { newProperty = deletedProperty.clone(); newProperty.setId(newComment.getId()); if ("annotation".equals(deletedProperty.getName())) { newProperty.setName("comment"); } else if ("replyto".equals(deletedProperty.getName())) { if (deletedProperty.getValue() != null) { int oldValue = (Integer) deletedProperty.getValue(); int newValue = oldToNewCommentNumberMap.get(oldValue); newProperty.setValue(newValue);
/** * {@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); } }
BaseProperty lp = (BaseProperty) it.next(); BaseProperty lp1 = lc.newProperty(); lp1.setId(lp.getId()); lp1.setName(lp.getName()); if (lc.isMultiSelect()) { List tmp; if (lp.getValue() instanceof List) { tmp = (List) lp.getValue(); } else { tmp = new ArrayList(1); tmp.add(lp.getValue()); lp1.setValue(tmp); } else { Object tmp = lp.getValue(); if (tmp instanceof List && ((List) tmp).size() > 0) { tmp = ((List) tmp).get(0); lp1.setValue(tmp); for (BaseProperty np : (List<BaseProperty>) q.list()) { 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())); } else if (nc.getNumberType().equals("float")) { np1.setValue(Float.valueOf(((Number) np.getValue()).floatValue())); } else if (nc.getNumberType().equals("double")) {
protected Object getBaseProperty(String propertyName, String language, boolean text) throws XWikiException { // First we try to get a translated preference object BaseObject baseObject = getBaseObject(language); if (baseObject != null) { BaseProperty property = (BaseProperty) baseObject.getField(propertyName); return property != null ? (text ? property.toText() : property.getValue()) : null; } return null; }
/** * Get the names of 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. 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 a list of deprecated property names * @see #getDeprecatedObjectProperties(Object) * @since 2.4M2 */ public List<String> getDeprecatedObjectPropertyNames(Object object) { List<BaseProperty> properties = this.getBaseClass().getDeprecatedObjectProperties(object.getBaseObject()); List<String> result = new ArrayList<String>(properties.size()); for (BaseProperty property : properties) { if (property != null) { result.add(property.getName()); } } return result; }
/** * Writes the clinical status {@code value} to {@code isNormal}. * * @param value the value to be saved * @param isNormal the {@link BaseProperty} object where the value will be written */ private void setClinicalStatusValue( @Nullable final String value, @Nonnull final BaseProperty<ObjectPropertyReference> isNormal) { if (StringUtils.equals(value, VALUE_AFFECTED)) { isNormal.setValue(0); } else if (StringUtils.equals(value, VALUE_UNAFFECTED)) { isNormal.setValue(1); } }
EntityReference classReference = property.getObject().getRelativeXClassReference(); EntityReference propertyReference = new EntityReference(property.getName(), EntityType.CLASS_PROPERTY, classReference); String serializedPropertyReference = fieldNameEncoder.encode(fieldNameSerializer.serialize(propertyReference)); String prefix = "property." + serializedPropertyReference;
/** * 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); }
property.setObject(object); property.setName(name); loadXWikiProperty(property, context, false); } catch (Exception e) { property2.setName(name); loadXWikiProperty(property2, context, false); property.setValue(property2.getValue()); property2.setName(name); loadXWikiProperty(property2, context, false); property.setValue(property2.getValue());
/** * {@inheritDoc} * * @see com.xpn.xwiki.objects.classes.StringClass#newProperty() */ @Override public BaseProperty newProperty() { BaseProperty property = new LargeStringProperty(); property.setName(getName()); return 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); }
public String toString(BaseProperty property) { return property.toText(); }
/** * {@inheritDoc} * * @see com.xpn.xwiki.objects.BaseProperty#clone() */ @Override public Object clone() { ListProperty property = (ListProperty) super.clone(); List<String> list = new ArrayList<String>(); for (String entry : getList()) { list.add(entry); } property.setValue(list); return property; }
protected Object getBaseProperty(String propertyName, boolean text) throws XWikiException { BaseObject baseObject = getBaseObject(); if (baseObject != null) { BaseProperty property = (BaseProperty) baseObject.getField(propertyName); Object value = property != null ? (text ? property.toText() : property.getValue()) : null; // TODO: In the future we would need the notion of initialized/not-initialized property values in the wiki. // When this is implemented modify the code below. if (isEmpty(value)) { value = null; } return value; } return null; }
/** * Remove deprecated fields (properties deleted from the XClass) from an object. * * @param object the object to synchronize * @param context the current request context */ private void synchronizeObject(BaseObject object, XWikiContext context) { for (BaseProperty property : object.getXClass(context).getDeprecatedObjectProperties(object)) { object.removeField(property.getName()); } } }
@Override public BaseProperty fromString(String value) { BaseProperty property = newProperty(); property.setValue(value); return property; }