Search in sources :

Example 66 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class StringClass method fromString.

@Override
public BaseProperty fromString(String value) {
    BaseProperty property = newProperty();
    property.setValue(value);
    return property;
}
Also used : BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 67 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class UsersClass method fromStringArray.

@Override
public BaseProperty fromStringArray(String[] strings) {
    List<String> list = new ArrayList<>();
    for (int i = 0; i < strings.length; i++) {
        if (!StringUtils.isBlank(strings[i])) {
            list.add(strings[i]);
        }
    }
    BaseProperty prop = newProperty();
    prop.setValue(StringUtils.join(list, ','));
    return prop;
}
Also used : ArrayList(java.util.ArrayList) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 68 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class UsersClass method newProperty.

@Override
public BaseProperty newProperty() {
    BaseProperty property = new LargeStringProperty();
    property.setName(getName());
    return property;
}
Also used : LargeStringProperty(com.xpn.xwiki.objects.LargeStringProperty) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 69 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class BaseClass method fromValueMap.

public BaseCollection fromValueMap(Map<String, ?> map, BaseCollection object) {
    for (PropertyClass property : (Collection<PropertyClass>) getFieldList()) {
        String name = property.getName();
        Object formvalue = map.get(name);
        if (formvalue != null) {
            BaseProperty objprop;
            objprop = property.fromValue(formvalue);
            if (objprop != null) {
                objprop.setObject(object);
                object.safeput(name, objprop);
            }
        }
    }
    return object;
}
Also used : BaseCollection(com.xpn.xwiki.objects.BaseCollection) Collection(java.util.Collection) BaseObject(com.xpn.xwiki.objects.BaseObject) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 70 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class BaseClass method validateObject.

public boolean validateObject(BaseObject obj, XWikiContext context) throws XWikiException {
    boolean isValid = true;
    Object[] props = getPropertyNames();
    for (Object prop : props) {
        String propname = (String) prop;
        BaseProperty property = (BaseProperty) obj.get(propname);
        PropertyClass propclass = (PropertyClass) get(propname);
        isValid &= propclass.validateProperty(property, context);
    }
    String validSript = getValidationScript();
    if ((validSript != null) && (!validSript.trim().equals(""))) {
        isValid &= executeValidationScript(obj, validSript, context);
    }
    return isValid;
}
Also used : BaseObject(com.xpn.xwiki.objects.BaseObject) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Aggregations

BaseProperty (com.xpn.xwiki.objects.BaseProperty)87 BaseObject (com.xpn.xwiki.objects.BaseObject)26 ArrayList (java.util.ArrayList)16 XWikiException (com.xpn.xwiki.XWikiException)14 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)12 XMLAttributeValueFilter (com.xpn.xwiki.internal.xml.XMLAttributeValueFilter)12 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)11 XWikiContext (com.xpn.xwiki.XWikiContext)10 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)9 DocumentReference (org.xwiki.model.reference.DocumentReference)9 StringProperty (com.xpn.xwiki.objects.StringProperty)8 ListProperty (com.xpn.xwiki.objects.ListProperty)7 XWiki (com.xpn.xwiki.XWiki)5 BaseCollection (com.xpn.xwiki.objects.BaseCollection)5 LargeStringProperty (com.xpn.xwiki.objects.LargeStringProperty)5 List (java.util.List)5 Test (org.junit.Test)5 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)5 DBStringListProperty (com.xpn.xwiki.objects.DBStringListProperty)4 PropertyClass (com.xpn.xwiki.objects.classes.PropertyClass)4