Class FilteredFormProcessor<ItemType,​PersistType>

    • Constructor Detail

      • FilteredFormProcessor

        public FilteredFormProcessor()
    • Method Detail

      • setFilterRegistry

        public void setFilterRegistry​(FilterRegistry<ItemType,​PersistType> filterRegistry)
        Sets the filter registry
        Parameters:
        filterRegistry - The FilterRegistry instance
      • setIgnoredFields

        public void setIgnoredFields​(java.util.List<java.lang.String> ignoredFields)
        Parameters:
        ignoredFields - the ignoredFields to set
      • generate

        public Form generate​(Item item,
                             java.util.List<java.lang.String> fields,
                             java.util.List<java.lang.String> forcedFields,
                             java.util.Map<java.lang.String,​java.lang.Object> context)
        Returns a Form representation for an item
        Parameters:
        item - The item to generate a Form object for
        fields - Restricted list of fields to include, null indicates all possible fields for the item should be included
        forcedFields - List of field names from 'fields' list that should be forcibly included, it is up to the form processor implementation to determine how to enforce this
        context - Map representing optional context that can be used during retrieval of the form
        Returns:
        The Form representation
      • internalGenerate

        protected void internalGenerate​(ItemType item,
                                        java.util.List<java.lang.String> fields,
                                        java.util.List<java.lang.String> forcedFields,
                                        Form form,
                                        java.util.Map<java.lang.String,​java.lang.Object> context)
        Generates the form.
        Parameters:
        item - The object to generate a form for
        fields - Restricted list of fields to include
        forcedFields - List of fields to forcibly include
        form - The form object being generated
        context - Map representing optional context that can be used during retrieval of the form
      • populateForm

        protected void populateForm​(Form form,
                                    java.util.List<java.lang.String> fields,
                                    FormCreationData data)
        This method generates all the fields to be added and adds them to the Form, together with the associated field data.
        Parameters:
        form - The Form to which the fields are added.
        fields - The names of all the fields to be added.
        data - FormCreationData used to generate all the fields.
      • generateDefaultFields

        protected java.util.List<Field> generateDefaultFields​(FormCreationData data,
                                                              java.util.List<java.lang.String> fieldsToIgnore)
        Generates a list of default fields to add if no field names are specified.
        Parameters:
        data - Used for field creation.
        fieldsToIgnore - TODO
        Returns:
        a List of Fields which may be empty.
      • generateSelectedFields

        protected java.util.List<Field> generateSelectedFields​(java.util.List<java.lang.String> fields,
                                                               FormCreationData data)
      • setFieldProcessorRegistry

        public void setFieldProcessorRegistry​(FieldProcessorRegistry fieldProcessorRegistry)
        Sets the field processor registry.
        Parameters:
        fieldProcessorRegistry - The FieldProcessorRegistry to use.
      • getTypedItem

        protected abstract ItemType getTypedItem​(Item item)
        Returns a typed Object representing the given item.

        Subclasses that represent a form type will return a typed object that is then passed to each of it's handlers, the handlers can therefore safely cast the Object to the type they expect.

        Parameters:
        item - The item to get a typed object for
        Returns:
        The typed object
      • getLogger

        protected abstract org.apache.commons.logging.Log getLogger()
        Retrieves a logger instance to log to.
        Returns:
        Log instance to log to.
      • getItemType

        protected abstract java.lang.String getItemType​(ItemType item)
        Returns a String describing the type fo the specified item.
        Parameters:
        item - ItemType
        Returns:
        String
      • getItemURI

        protected abstract java.lang.String getItemURI​(ItemType item)
        Returns the URI location of the specified item.
        Parameters:
        item - ItemType
        Returns:
        String
      • internalPersist

        protected abstract PersistType internalPersist​(ItemType item,
                                                       FormData data)
        Persists the form data.
        Parameters:
        item - The object to persist the form for
        data - The data to persist
        Returns:
        The object that got created or modified
      • getDefaultIgnoredFields

        protected abstract java.util.List<java.lang.String> getDefaultIgnoredFields()
        When a Form is generated with no field names specifically set then a default Form is created. The default Form contains all the properties and associations related to the Item, excluding a blacklist of ignored fields which defaults to the return value of this method. The default ignored values can be overridden by setting the property ignoredFields.
        Returns:
        the names of all the fields to be excluded from the default Form if no defaultFields property is explicitly set.