Class BaseClass

    • Constructor Detail

      • BaseClass

        public BaseClass()
    • Method Detail

      • disableField

        public void disableField​(String name)
        Mark a property as disabled. A disabled property should not be editable, but existing object values are still kept in the database.
        Parameters:
        name - the name of the property to disable
        Since:
        2.4M2
      • enableField

        public void enableField​(String name)
        Re-enable a property. This field will appear again in object instances.
        Parameters:
        name - the name of the property to enable
        Since:
        2.4M2
      • getEnabledProperties

        public List<PropertyClass> getEnabledProperties()
        Get the list of enabled (the default, normal state) property definitions that exist in this class. The resulting list is unmodifiable, but the contained elements are live.
        Returns:
        an unmodifiable list containing the enabled properties of the class
        Since:
        2.4M2
        See Also:
        PropertyClass.isDisabled()
      • getDisabledProperties

        public List<PropertyClass> getDisabledProperties()
        Get the list of disabled property definitions that exist in this class. The resulting list is unmodifiable, but the contained elements are live.
        Returns:
        an unmodifiable list containing the disabled properties of the class
        Since:
        2.4M2
        See Also:
        PropertyClass.isDisabled()
      • getDisabledObjectProperties

        public List<PropertyClass> getDisabledObjectProperties​(BaseObject object)
        Get the list of disabled properties that exist in a given object. This list is a subset of all the disabled properties in a class, since the object could have been created and stored before some of the class properties were added. The resulting list is unmodifiable, but the contained elements are live.
        Parameters:
        object - the instance of this class where the disabled properties must exist
        Returns:
        an unmodifiable list containing the disabled properties of the given object
        Since:
        2.4M2
        See Also:
        PropertyClass.isDisabled()
      • getDeprecatedObjectProperties

        public List<BaseProperty> getDeprecatedObjectProperties​(BaseObject object)
        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.
        Parameters:
        object - the instance of this class where to look for undefined properties
        Returns:
        an unmodifiable list containing the properties of the object which don't exist in the class
        Since:
        2.4M2
      • merge

        public void merge​(BaseClass bclass)
      • addTextField

        public boolean addTextField​(String fieldName,
                                    String fieldPrettyName,
                                    int size)
      • addPasswordField

        public boolean addPasswordField​(String fieldName,
                                        String fieldPrettyName,
                                        int size)
      • addPasswordField

        public boolean addPasswordField​(String fieldName,
                                        String fieldPrettyName,
                                        int size,
                                        String storageType)
      • addEmailField

        public boolean addEmailField​(String fieldName,
                                     String fieldPrettyName,
                                     int size)
      • addTimezoneField

        public boolean addTimezoneField​(String fieldName,
                                        String fieldPrettyName,
                                        int size)
      • addBooleanField

        public boolean addBooleanField​(String fieldName,
                                       String fieldPrettyName)
        Since:
        10.10RC1
      • addBooleanField

        public boolean addBooleanField​(String fieldName,
                                       String fieldPrettyName,
                                       String displayType)
      • addBooleanField

        public boolean addBooleanField​(String fieldName,
                                       String fieldPrettyName,
                                       String displayType,
                                       Boolean def)
      • addBooleanField

        public boolean addBooleanField​(String fieldName,
                                       String fieldPrettyName,
                                       String formType,
                                       String displayType,
                                       Boolean def)
        Since:
        10.7RC1
      • addUsersField

        public boolean addUsersField​(String fieldName,
                                     String fieldPrettyName)
      • addUsersField

        public boolean addUsersField​(String fieldName,
                                     String fieldPrettyName,
                                     boolean multiSelect)
        Since:
        1.1.2, 1.2M2
      • addUsersField

        public boolean addUsersField​(String fieldName,
                                     String fieldPrettyName,
                                     int size)
      • addUsersField

        public boolean addUsersField​(String fieldName,
                                     String fieldPrettyName,
                                     int size,
                                     boolean multiSelect)
        Since:
        1.1.2, 1.2M2
      • addLevelsField

        public boolean addLevelsField​(String fieldName,
                                      String fieldPrettyName)
      • addLevelsField

        public boolean addLevelsField​(String fieldName,
                                      String fieldPrettyName,
                                      int size)
      • addGroupsField

        public boolean addGroupsField​(String fieldName,
                                      String fieldPrettyName)
      • addGroupsField

        public boolean addGroupsField​(String fieldName,
                                      String fieldPrettyName,
                                      int size)
      • addTemplateField

        public boolean addTemplateField​(String fieldName,
                                        String fieldPrettyName)
      • addTextAreaField

        public boolean addTextAreaField​(String fieldName,
                                        String fieldPrettyName,
                                        int cols,
                                        int rows)
      • addTextAreaField

        @Unstable
        public boolean addTextAreaField​(String fieldName,
                                        String fieldPrettyName,
                                        int cols,
                                        int rows,
                                        boolean restricted)
        Since:
        14.10, 14.4.7, 13.10.11
      • addTextAreaField

        public boolean addTextAreaField​(String fieldName,
                                        String fieldPrettyName,
                                        int cols,
                                        int rows,
                                        String editor)
      • addTextAreaField

        @Unstable
        public boolean addTextAreaField​(String fieldName,
                                        String fieldPrettyName,
                                        int cols,
                                        int rows,
                                        String editor,
                                        boolean restricted)
        Since:
        14.10, 14.4.7, 13.10.11
      • addTextAreaField

        public boolean addTextAreaField​(String fieldName,
                                        String fieldPrettyName,
                                        int cols,
                                        int rows,
                                        String editor,
                                        String contenttype)
        Since:
        8.3
      • addTextAreaField

        @Unstable
        public boolean addTextAreaField​(String fieldName,
                                        String fieldPrettyName,
                                        int cols,
                                        int rows,
                                        String editor,
                                        String contenttype,
                                        boolean restricted)
        Since:
        14.10, 14.4.7, 13.10.11
      • addStaticListField

        public boolean addStaticListField​(String fieldName,
                                          String fieldPrettyName,
                                          String values)
      • addStaticListField

        public boolean addStaticListField​(String fieldName,
                                          String fieldPrettyName,
                                          String values,
                                          String defaultValue)
        Since:
        10.9, 10.8.1
      • addStaticListField

        public boolean addStaticListField​(String fieldName,
                                          String fieldPrettyName,
                                          int size,
                                          boolean multiSelect,
                                          String values)
      • addStaticListField

        public boolean addStaticListField​(String fieldName,
                                          String fieldPrettyName,
                                          int size,
                                          boolean multiSelect,
                                          String values,
                                          String displayType)
      • addStaticListField

        public boolean addStaticListField​(String fieldName,
                                          String fieldPrettyName,
                                          int size,
                                          boolean multiSelect,
                                          String values,
                                          String displayType,
                                          String separators)
        Since:
        1.1.2, 1.2M2
      • addStaticListField

        public boolean addStaticListField​(String fieldName,
                                          String fieldPrettyName,
                                          int size,
                                          boolean multiSelect,
                                          boolean relationalStorage,
                                          String values,
                                          String displayType,
                                          String separators)
        Since:
        1.8M1
      • addStaticListField

        public boolean addStaticListField​(String fieldName,
                                          String fieldPrettyName,
                                          int size,
                                          boolean multiSelect,
                                          boolean relationalStorage,
                                          String values,
                                          String displayType,
                                          String separators,
                                          String defaultValue)
        Since:
        10.9, 10.8.1
      • addStaticListField

        public boolean addStaticListField​(String fieldName,
                                          String fieldPrettyName,
                                          int size,
                                          boolean multiSelect,
                                          boolean relationalStorage,
                                          String values,
                                          String displayType,
                                          String separators,
                                          String defaultValue,
                                          String freeText,
                                          boolean largeStorage)
        Since:
        11.5RC1
      • addStaticListField

        public StaticListClass addStaticListField​(String fieldName)
        Adds a new Static List xproperty to this xclass. This allows calling the various methods on the returned StaticListClass.
        Parameters:
        fieldName - the id of the Static List xproperty to add
        Returns:
        the added Static List xproperty or the existing xproperty if it was already existing
        Since:
        12.8RC1
      • addNumberField

        public boolean addNumberField​(String fieldName,
                                      String fieldPrettyName,
                                      int size,
                                      String type)
      • addDateField

        public boolean addDateField​(String fieldName,
                                    String fieldPrettyName)
      • addDateField

        public boolean addDateField​(String fieldName,
                                    String fieldPrettyName,
                                    String dformat)
      • addDateField

        public boolean addDateField​(String fieldName,
                                    String fieldPrettyName,
                                    String dformat,
                                    int emptyIsToday)
      • addDBListField

        public boolean addDBListField​(String fieldName,
                                      String fieldPrettyName,
                                      String sql)
      • addDBListField

        public boolean addDBListField​(String fieldName,
                                      String fieldPrettyName,
                                      int size,
                                      boolean multiSelect,
                                      String sql)
      • addDBListField

        public boolean addDBListField​(String fieldName,
                                      String fieldPrettyName,
                                      int size,
                                      boolean multiSelect,
                                      boolean relationalStorage,
                                      String sql)
        Since:
        1.8M1
      • addDBTreeListField

        public boolean addDBTreeListField​(String fieldName,
                                          String fieldPrettyName,
                                          String sql)
      • addDBTreeListField

        public boolean addDBTreeListField​(String fieldName,
                                          String fieldPrettyName,
                                          int size,
                                          boolean multiSelect,
                                          String sql)
      • addDBTreeListField

        public boolean addDBTreeListField​(String fieldName,
                                          String fieldPrettyName,
                                          int size,
                                          boolean multiSelect,
                                          boolean relationalStorage,
                                          String sql)
        Since:
        1.8M1
      • addPageField

        public boolean addPageField​(String fieldName,
                                    String fieldPrettyName,
                                    int size)
        Adds a page field to the class.

        The input has no multiselect by default.

        Parameters:
        fieldName - the field name
        fieldPrettyName - the shown name
        size - size of the input
        Returns:
        true if the field has been added
        Since:
        10.8RC1
      • addPageField

        public boolean addPageField​(String fieldName,
                                    String fieldPrettyName,
                                    int size,
                                    boolean multiSelect)
        Adds a page field to the class.
        Parameters:
        fieldName - the field name
        fieldPrettyName - the shown name
        size - size of the input
        multiSelect - specifies if there can be several values
        Returns:
        true if the field has been added
        Since:
        10.8RC1
      • addPageField

        public boolean addPageField​(String fieldName,
                                    String fieldPrettyName,
                                    int size,
                                    boolean multiSelect,
                                    boolean relationalStorage,
                                    String hqlQuery)
        Adds a page field to the class.
        Parameters:
        fieldName - the field name
        fieldPrettyName - the shown name
        size - size of the input
        multiSelect - specifies if there can be several values
        relationalStorage - sets the PageClass relationalStorage property metadata with the specified value. See ListClass.setRelationalStorage(boolean) for more details
        hqlQuery - the optional HQL query to execute to return allowed document references. If null or empty, the implicit page query builder is used
        Returns:
        true if the field has been added
        Since:
        10.8RC1
      • addPageField

        public boolean addPageField​(String fieldName,
                                    String fieldPrettyName,
                                    int size,
                                    boolean multiSelect,
                                    boolean relationalStorage,
                                    String hqlQuery,
                                    String className,
                                    String displayType,
                                    boolean hasPicker,
                                    String freeText)
        Adds a page field to the class.
        Parameters:
        fieldName - the field name
        fieldPrettyName - the shown name
        size - size of the input
        multiSelect - specifies if there can be several values
        relationalStorage - sets the PageClass relationalStorage property metadata with the specified value. See ListClass.setRelationalStorage(boolean) for more details
        hqlQuery - the optional HQL query to execute to return allowed document references. If null or empty, the implicit page query builder is used
        className - optional class name used to filter suggested documents containing an object of this class
        displayType - either ListClass.DISPLAYTYPE_CHECKBOX, ListClass.DISPLAYTYPE_INPUT, ListClass.DISPLAYTYPE_RADIO or ListClass.DISPLAYTYPE_SELECT
        hasPicker - enables auto suggestion display
        freeText - indicate how non document reference values are handled (forbidden, discouraged or allowed)
        Returns:
        true if the field has been added
        Since:
        10.8RC1
      • setCustomMapping

        public void setCustomMapping​(String customMapping)
      • getCustomMapping

        public String getCustomMapping()
      • hasCustomMapping

        public boolean hasCustomMapping()
      • hasExternalCustomMapping

        public boolean hasExternalCustomMapping()
      • hasInternalCustomMapping

        public boolean hasInternalCustomMapping()
      • setCustomClass

        public void setCustomClass​(String customClass)
      • getCustomClass

        public String getCustomClass()
      • newCustomClassInstance

        public BaseObject newCustomClassInstance​(boolean fallback)
                                          throws XWikiException
        Parameters:
        fallback - if true, fallback on BaseObject if there is any problem with the configured custom class
        Returns:
        a new Java instance of an object represented by this XWiki class
        Throws:
        XWikiException - if there is a problem when creating an new instance and fallback is false
        Since:
        12.4RC1, 11.10.5
      • newCustomClassInstance

        public static BaseObject newCustomClassInstance​(DocumentReference classReference,
                                                        boolean fallback,
                                                        XWikiContext context)
                                                 throws XWikiException
        Parameters:
        classReference - the reference of the document containing the XWiki class for which to create a new object
        fallback - if true, fallback on BaseObject if there is any problem with the configured custom class
        context - the XWiki context used to load the BaseClass
        Returns:
        a new Java instance of an object represented by this XWiki class
        Throws:
        XWikiException - if there is a problem when creating an new instance and fallback is false
        Since:
        12.4RC1, 11.10.5
      • getDefaultWeb

        public String getDefaultWeb()
      • setDefaultWeb

        public void setDefaultWeb​(String defaultWeb)
      • getDefaultViewSheet

        public String getDefaultViewSheet()
      • setDefaultViewSheet

        public void setDefaultViewSheet​(String defaultViewSheet)
      • getDefaultEditSheet

        public String getDefaultEditSheet()
      • setDefaultEditSheet

        public void setDefaultEditSheet​(String defaultEditSheet)
      • getNameField

        public String getNameField()
      • setNameField

        public void setNameField​(String nameField)
      • setValidationScript

        public void setValidationScript​(String validationScript)
      • getValidationScript

        public String getValidationScript()
      • flushCache

        public void flushCache()
      • merge

        public void merge​(ElementInterface previousElement,
                          ElementInterface newElement,
                          MergeConfiguration configuration,
                          XWikiContext context,
                          MergeResult mergeResult)
        Description copied from interface: ElementInterface
        Apply a 3 ways merge on the current element based on provided previous and new version of the element.

        All 3 elements are supposed to have the same class and reference.

        Specified by:
        merge in interface ElementInterface
        Overrides:
        merge in class BaseCollection<DocumentReference>
        Parameters:
        previousElement - the previous version of the element
        newElement - the next version of the element
        configuration - the configuration of the merge Indicate how to deal with some conflicts use cases, etc.
        context - the XWiki context
        mergeResult - the merge report
      • apply

        public boolean apply​(ElementInterface newElement,
                             boolean clean)
        Description copied from interface: ElementInterface
        Apply the provided element so that the current one contains the same informations and indicate if it was necessary to modify it in any way.
        Specified by:
        apply in interface ElementInterface
        Overrides:
        apply in class BaseCollection<DocumentReference>
        Parameters:
        newElement - the element to apply
        clean - true if informations that are not in the new element should be removed (for example class properties not in the new class)
        Returns:
        true if the element has been modified
      • setDirty

        public void setDirty​(boolean isDirty)
        Parameters:
        isDirty - Indicate if the dirty flag should be set or cleared.
        Since:
        4.3M2