public List<String> getTagsPossibleValues(XWikiContext context) { List<String> list; try { BaseClass tagsClass = context.getWiki().getTagClass(context); String possibleValues = ((StaticListClass) tagsClass.getField(XWikiConstant.TAG_CLASS_PROP_TAGS)).getValues(); return ListClass.getListFromString(possibleValues); } catch (XWikiException e) { LOG.error("Failed to get tag class", e); list = Collections.emptyList(); } return list; }
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())); } } }
result.append("|"); PropertyClass pclass = (PropertyClass) bclass.getField(propertyName); result.append(pclass.getPrettyName());
VelocityContext vcontext = new VelocityContext(); for (String propertyName : bclass.getPropertyList()) { PropertyClass pclass = (PropertyClass) bclass.getField(propertyName); vcontext.put(pclass.getName(), pclass.getPrettyName());
private boolean isValidCustomMapping(String className, Configuration hibconfig, BaseClass bclass) { PersistentClass mapping = hibconfig.getClassMapping(className); if (mapping == null) { return true; } Iterator it = mapping.getPropertyIterator(); while (it.hasNext()) { Property hibprop = (Property) it.next(); String propname = hibprop.getName(); PropertyClass propclass = (PropertyClass) bclass.getField(propname); if (propclass == null) { log.warn("Mapping contains invalid field name " + propname); return false; } boolean result = isValidColumnType(hibprop.getValue().getType().getName(), propclass.getClassName()); if (result == false) { log.warn("Mapping contains invalid type in field " + propname); return false; } } return true; }
@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; }
/** * add tags to the document. */ public void setTags(String tagsStr, XWikiContext context) throws XWikiException { BaseClass tagsClass = context.getWiki().getTagClass(context); StaticListClass tagProp = (StaticListClass) tagsClass.getField(XWikiConstant.TAG_CLASS_PROP_TAGS); BaseObject tags = getObject(XWikiConstant.TAG_CLASS, true, context); tags.safeput(XWikiConstant.TAG_CLASS_PROP_TAGS, tagProp.fromString(tagsStr)); setMetaDataDirty(true); }
@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; }
/** * 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; }
@Override public void hibernateMigrate() throws DataMigrationException, XWikiException { XWikiContext context = getXWikiContext(); BaseClass pcc = context.getWiki().getXClass(this.resolver.resolve("PhenoTips.PhenotypeCategoryClass"), context); DBListClass tpc = (DBListClass) pcc.getField("target_property_category"); getStore().executeWrite(getXWikiContext(), new MigrateCustomPhenotypeCategoryCallback(tpc)); }
PropertyClass avatarProperty = (PropertyClass) userClass.getField("avatar"); userObj.safeput("avatar", avatarProperty.fromString(photoAttachmentFullName)); return true; PropertyClass avatarProperty = (PropertyClass) userClass.getField("avatar"); userObj.safeput("avatar", avatarProperty.fromString("")); return true;
@Override public void hibernateMigrate() throws DataMigrationException, XWikiException { XWikiContext context = getXWikiContext(); BaseClass pcc = context.getWiki().getXClass(this.resolver.resolve("PhenoTips.PhenotypeCategoryClass"), context); DBListClass tpc = (DBListClass) pcc.getField("target_property_category"); getStore().executeWrite(getXWikiContext(), new MigrateCustomPhenotypeCategoryCallback(tpc)); }
BaseProperty oldProperty = (BaseProperty) oldCollection.getFields().get(propertyName); BaseClass bclass = getXClass(context); PropertyClass pclass = (PropertyClass) ((bclass == null) ? null : bclass.getField(propertyName)); String propertyType = (pclass == null) ? "" : StringUtils.substringAfterLast(pclass.getClassType(), "."); BaseProperty oldProperty = (BaseProperty) oldCollection.getFields().get(propertyName); BaseClass bclass = getXClass(context); PropertyClass pclass = (PropertyClass) ((bclass == null) ? null : bclass.getField(propertyName)); String propertyType = (pclass == null) ? "" : StringUtils.substringAfterLast(pclass.getClassType(), ".");
BaseProperty oldProperty = (BaseProperty) oldObject.getField(propertyName); BaseClass bclass = getXClass(context); PropertyClass pclass = (PropertyClass) ((bclass == null) ? null : bclass.getField(propertyName)); String propertyType = (pclass == null) ? "" : StringUtils.substringAfterLast(pclass.getClassType(), "."); BaseProperty oldProperty = (BaseProperty) oldObject.getField(propertyName); BaseClass bclass = getXClass(context); PropertyClass pclass = (PropertyClass) ((bclass == null) ? null : bclass.getField(propertyName)); String propertyType = (pclass == null) ? "" : StringUtils.substringAfterLast(pclass.getClassType(), ".");
needsUpdate |= bclass.addTextAreaField("script", "Job Script", 60, 10); TextAreaClass scriptField = (TextAreaClass) bclass.getField("script");