Class EntityDescriptionManager


  • public class EntityDescriptionManager
    extends Object
    This handles all the methods related to generating descriptions for entities, html and xml currently supported
    Author:
    Aaron Zeckoski (azeckoski @ gmail.com)
    • Method Detail

      • init

        public void init()
      • destroy

        public void destroy()
      • setEntityProviderManager

        public void setEntityProviderManager​(EntityProviderManager entityProviderManager)
      • setEntityBrokerManager

        public void setEntityBrokerManager​(EntityBrokerManager entityBrokerManager)
      • setEntityProviderMethodStore

        public void setEntityProviderMethodStore​(EntityProviderMethodStore entityProviderMethodStore)
      • makeDescribeAll

        public String makeDescribeAll​(String format,
                                      Locale locale)
        Generate a description of all entities in the system, this is only available as XML and XHTML
        Parameters:
        format - XML or HTML (default is HTML)
        locale - the locale to use for any translations
        Returns:
        the description string for all known entities
      • makeDescribeEntity

        public String makeDescribeEntity​(String prefix,
                                         String id,
                                         String format,
                                         Locale locale)
        Generate a description of an entity type
        Parameters:
        prefix - an entity prefix
        id - the entity id to use for generating URLs
        format - a format to output, HTML and XML supported
        locale - the locale to use for translations
        Returns:
        the description string
        Throws:
        IllegalArgumentException - if the entity does not exist
      • describeEntity

        protected String describeEntity​(StringBuilder sb,
                                        String prefix,
                                        String id,
                                        String format,
                                        boolean extra,
                                        List<Class<? extends EntityProvider>> caps,
                                        Locale locale)
        This is reducing code duplication
        Parameters:
        sb -
        prefix -
        id -
        format -
        extra -
        caps -
        locale - used for translations
        Returns:
        the entity description
      • generateMethodDetails

        protected String generateMethodDetails​(String methodType,
                                               Locale locale)
        Generates the details listing which shows the response types for a view method
        Parameters:
        methodType - the view method (new, show, list, delete, edit)
        locale - the locale
        Returns:
        the html string to place on the description page
      • replacePrefix

        protected String replacePrefix​(String outgoingTemplate,
                                       String prefix)
        Replaces the {prefix} value in the template with the actual prefix, allows nulls to pass through
      • makeRedirectLink

        protected String makeRedirectLink​(String redirect,
                                          String prefixURL)
        Turn a redirect template into html for a link if it has no variables in it, otherwise output the text of the template in a span with bold
      • makeActionURL

        protected String makeActionURL​(EntityView ev,
                                       CustomAction customAction)
        Parameters:
        ev - the entity view
        customAction - the custom action
        Returns:
        a URL for triggering the custom action (without http://server/direct)
      • makeEntityURL

        protected String makeEntityURL​(EntityView ev,
                                       String viewType)
        Parameters:
        ev - entity view
        viewType - the type of view
        Returns:
        a URL for triggering the entity action (without http://server/direct)
      • makeCustomActionKeyMethodText

        protected String makeCustomActionKeyMethodText​(CustomAction customAction)
        Create text to display for the CA key and method
        Parameters:
        customAction -
        Returns:
      • getFormats

        protected String[] getFormats​(String prefix,
                                      boolean output)
        Returns:
        all the format extensions handled by this, null if none handled, empty if all
      • makeFormatsUrlHtml

        protected String makeFormatsUrlHtml​(String url,
                                            String[] formats)
      • makeArrayIntoString

        protected String makeArrayIntoString​(Object[] array)
      • getEntityDescription

        protected String getEntityDescription​(String prefix,
                                              String descriptionkey,
                                              Locale locale)
        Get the descriptions for an entity OR its capabilities OR custom actions
        Parameters:
        prefix - an entity prefix
        descriptionkey - (optional) the key (simplename for capability, action.actionkey for actions)
        locale - the Locale to use for translations
        Returns:
        the description (may be blank) OR null if there is none