public String displayView(String name, String prefix, XWikiContext context) { StringBuffer buffer = new StringBuffer(); ((PropertyClass) getXClass(context).get(name)).displayView(buffer, name, prefix, this, context); return buffer.toString(); }
public String displayEdit(String name, String prefix, XWikiContext context) { StringBuffer buffer = new StringBuffer(); ((PropertyClass) getXClass(context).get(name)).displayEdit(buffer, name, prefix, this, context); return buffer.toString(); }
public String displayHidden(String name, String prefix, XWikiContext context) { StringBuffer buffer = new StringBuffer(); ((PropertyClass) getXClass(context).get(name)).displayHidden(buffer, name, prefix, this, context); return buffer.toString(); }
public void displayEdit(StringBuffer buffer, String name, String prefix, XWikiContext context) { ((PropertyClass) getXClass(context).get(name)).displayEdit(buffer, name, prefix, this, context); }
/** * @since 2.2M1 */ public List<BaseClass> getXClasses(XWikiContext context) { List<BaseClass> list = new ArrayList<BaseClass>(); // getXObjects() is a TreeMap, with elements sorted by className reference for (DocumentReference classReference : getXObjects().keySet()) { BaseClass bclass = null; List<BaseObject> objects = getXObjects(classReference); for (BaseObject obj : objects) { if (obj != null) { bclass = obj.getXClass(context); if (bclass != null) { break; } } } if (bclass != null) { list.add(bclass); } } return list; }
private void set(List<XWikiLDAPSearchAttribute> searchAttributes, Map<String, String> userMappings, BaseObject userObject, XWikiContext xcontext) throws XWikiException { if (searchAttributes != null) { // Convert LDAP attributes to a map usable with BaseClass#fromValueMap Map<String, Object> map = toMap(searchAttributes, userMappings, xcontext); // Set properties in the user object userObject.getXClass(xcontext).fromValueMap(map, userObject); } }
public void displayHidden(StringBuffer buffer, String name, String prefix, XWikiContext context) { ((PropertyClass) getXClass(context).get(name)).displayHidden(buffer, name, prefix, this, context); }
public void displayView(StringBuffer buffer, String name, String prefix, XWikiContext context) { ((PropertyClass) getXClass(context).get(name)).displayView(buffer, name, prefix, this, context); }
public BaseObject getFirstObject(String fieldname, XWikiContext context) { Collection<List<BaseObject>> objectscoll = getXObjects().values(); if (objectscoll == null) { return null; } for (List<BaseObject> objects : objectscoll) { for (BaseObject obj : objects) { if (obj != null) { BaseClass bclass = obj.getXClass(context); if (bclass != null) { Set<String> set = bclass.getPropertyList(); if ((set != null) && set.contains(fieldname)) { return obj; } } Set<String> set = obj.getPropertyList(); if ((set != null) && set.contains(fieldname)) { return obj; } } } } return null; }
protected void mergeObject(XObject xobject, BaseObject baseObject, XWikiContext context) { BaseClass bclass = baseObject.getXClass(context); Object[] propnames = bclass.getPropertyNames(); for (int i = 0; i < propnames.length; i++) { String propname = (String) propnames[i]; Object propdata = xobject.getProperty(propname); baseObject.set(propname, propdata, context); } }
private void getObjectContentAsText(StringBuilder contentText, BaseObject baseObject, String property, XWikiContext context) { BaseProperty baseProperty = (BaseProperty) baseObject.getField(property); // FIXME Can baseProperty really be null? if (baseProperty != null && baseProperty.getValue() != null) { if (!(baseObject.getXClass(context).getField(property) instanceof PasswordClass)) { contentText.append(StringUtils.lowerCase(baseProperty.getValue().toString())); } } }
/** * 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()); } } }
public String displayTooltip(String fieldname, BaseObject obj, XWikiContext context) { String result = ""; try { PropertyClass pclass = (PropertyClass) obj.getXClass(context).get(fieldname); String tooltip = pclass.getTooltip(context); if ((tooltip != null) && (!tooltip.trim().equals(""))) { String img = "<img src=\"" + context.getWiki().getSkinFile("info.gif", context) + "\" class=\"tooltip_image\" align=\"middle\" />"; result = context.getWiki().addTooltip(img, tooltip, context); } } catch (Exception e) { } return result; }
public boolean injectCustomMappings(XWikiDocument doc, XWikiContext context) throws XWikiException { // If we haven't turned of dynamic custom mappings we should not inject them if (context.getWiki().hasDynamicCustomMappings() == false) { return false; } boolean result = false; for (List<BaseObject> objectsOfType : doc.getXObjects().values()) { for (BaseObject object : objectsOfType) { if (object != null) { result |= injectCustomMapping(object.getXClass(context), context); // Each class must be mapped only once break; } } } return result; }
@Override public String getDescription() { String result; BaseObject obj = this.document.getXObject(getType()); BaseClass cls = obj.getXClass(getXContext()); if (cls.getField(JSON_KEY_DESCRIPTION) != null) { result = obj.getLargeStringValue(JSON_KEY_DESCRIPTION); } else { result = this.document.getContent(); } return result; }
/** * Adds object from an new object creation form. * * @since 2.2.3 */ public BaseObject addXObjectFromRequest(EntityReference classReference, String prefix, int num, XWikiContext context) throws XWikiException { BaseObject object = newXObject(classReference, context); BaseClass baseclass = object.getXClass(context); String newPrefix = prefix + this.localEntityReferenceSerializer.serialize(resolveClassReference(classReference)) + "_" + num; baseclass.fromMap(Util.getObject(context.getRequest(), newPrefix), object); return object; }
@Override public String getDescription() { String result; BaseObject obj = this.document.getXObject(getType()); BaseClass cls = obj.getXClass(getXContext()); if (cls.getField(JSON_KEY_DESCRIPTION) != null) { result = obj.getLargeStringValue(JSON_KEY_DESCRIPTION); } else { result = this.document.getContent(); } return result; }
public void set(String fieldname, java.lang.Object value, XWikiContext context) { BaseClass bclass = getXClass(context); PropertyClass pclass = (PropertyClass) bclass.get(fieldname); BaseProperty prop = (BaseProperty) safeget(fieldname); if ((value instanceof String) && (pclass != null)) { prop = pclass.fromString((String) value); } else { if ((prop == null) && (pclass != null)) { prop = pclass.newProperty(); } if (prop != null) { prop.setValue(value); } } if (prop != null) { safeput(fieldname, prop); } }
public String displayPrettyName(String fieldname, boolean showMandatory, boolean before, BaseObject obj, XWikiContext context) { try { PropertyClass pclass = (PropertyClass) obj.getXClass(context).get(fieldname); String dprettyName = ""; if (showMandatory) { dprettyName = context.getWiki().addMandatory(context); } if (before) { return dprettyName + pclass.getPrettyName(context); } else { return pclass.getPrettyName(context) + dprettyName; } } catch (Exception e) { return ""; } }
/** * Adds an object from an new object creation form. * * @since 2.2M2 */ public BaseObject addXObjectFromRequest(XWikiContext context) throws XWikiException { // Read info in object ObjectAddForm form = new ObjectAddForm(); form.setRequest((HttpServletRequest) context.getRequest()); form.readRequest(); EntityReference classReference = this.xClassEntityReferenceResolver.resolve(form.getClassName(), EntityType.DOCUMENT, getDocumentReference()); BaseObject object = newXObject(classReference, context); BaseClass baseclass = object.getXClass(context); baseclass.fromMap( form.getObject(this.localEntityReferenceSerializer.serialize(resolveClassReference(classReference))), object); return object; }