Class DatasourceInheritanceHelper


  • public class DatasourceInheritanceHelper
    extends Object
    This is a helper class providing some static methods to process the inheritance of datasource definitions found in a resource. If a datasource id contains the inheritance separator '::' appNG clones the ancestor datasource definition and overrides or adds:
    • datasource id - override
    • title - override
    • parameter - add
    • bind class - override
    • fields - add
    • bean id - override
    • bean options - add
    • linkpanel - override
    • config permissions - override
    • config labels - add
    The simplest usage of this inheritance mechanism can be used to create a clone of an existing datasource definition just with another datasource id to be able to place the datasource a second time with other parameters on the same page.
    Author:
    Claus Stümke, aiticon GmbH, 2016
    • Constructor Detail

      • DatasourceInheritanceHelper

        public DatasourceInheritanceHelper()
    • Method Detail

      • isInheriting

        public static boolean isInheriting​(String datasourceId)
        Returns true if the id contains exactly one inheritance separator string "::"
        Parameters:
        datasourceId -
        Returns:
        true if the id contains an inheritance separator string
      • getDescendantId

        public static String getDescendantId​(String datasourceId)
        returns the part of the datasource id of a datatsource for inheritance which indicates the final id of the descendant
        Parameters:
        datasourceId -
        Returns:
        the descendant's id
      • getAncestorId

        public static String getAncestorId​(String datasourceId)
        returns the part of the datasource id of a datatsource for inheritance which indicates the id of the ancestor datasource
        Parameters:
        datasourceId -
        Returns:
        the ancestor's id
      • inherit

        public static Datasource inherit​(Datasource descendantDefinition,
                                         Datasource ancestor,
                                         MarshallService marshallService)
        clones the ancestor datasource and adds or overrides id, title, parameter, fields, bean options, bean id, bind class and linkpanel. Returns the new datasource.
        Parameters:
        descendantDefinition -
        ancestor -
        Returns:
        the cloned Datasource