Class KernelUtils

  • public class KernelUtils
    extends Object
    Contains several utility methods used in the kernel.
    • Constructor Detail

      • KernelUtils

        public KernelUtils()
        Note this constructor should not be generally used, use instead getInstance()
    • Method Detail

      • getInstance

        public static KernelUtils getInstance()
      • setInstance

        public static void setInstance​(KernelUtils instance)
      • getPropertyFromColumn

        public Property getPropertyFromColumn​(Column column)
      • getPropertyFromColumn

        public Property getPropertyFromColumn​(Column column,
                                              boolean includeIdColumn)
      • createErrorJavaScript

        public String createErrorJavaScript​(Exception e)
        Creates a javascript string which reports an exception to the client.
      • createErrorJSON

        public org.codehaus.jettison.json.JSONObject createErrorJSON​(Exception e)
      • isModulePresent

        public boolean isModulePresent​(String javaPackage)
        Returns "true" if the module given its java package exists and "false" if it doesn't.
        javaPackage - the java package used to read the module
      • getModule

        public Module getModule​(String javaPackage)
        Get a module using its java package, the module is read from the internal cache.
        javaPackage - the java package used to read the module
        a Module
        OBException - if the module can not be found.
      • getModulesOrderedByDependency

        public List<Module> getModulesOrderedByDependency()
        Note the result of this method is cached. If module dependencies change then a system restart is required to refresh this cache.
        the modules in order of their dependencies, so core will be the first module etc.
      • getDependencyTree

        public List<Module> getDependencyTree​(Module module)
        Retrieves all the modules that are part of the dependency tree of the given module. This includes all the modules that depend on the provided module (ancestors) and their ancestors, as well as all the modules the provided module depends on (descendants) and their descendants.
        module - the module to get the dependency tree for
        the full tree of dependencies for the given module
      • computeLowLevelCode

        protected int computeLowLevelCode​(Module module,
                                          List<Module> modules)
      • getParentRecord

        public BaseOBObject getParentRecord​(BaseOBObject object,
                                            Tab tab)
        Returns the parent object for a specified combination of DAL object and tab. For example, returns the corresponding Sales Order header for a Sales Order Line Returns null if there is no parent object.
        object - The object whose parent should be returned
        tab - The tab the object belongs to
        The BaseOBObject of the parent record
      • getParentTab

        public Tab getParentTab​(Tab tab)
        Returns the parent tab of a BaseOBObject which belongs to a given tab
        tab - The tab the object belongs to
        The parent tab of the given tab, null in case the tab is root
      • getTabSubtabs

        public List<Tab> getTabSubtabs​(Tab tab,
                                       boolean onlyFirstLevel)
        Returns the list of subtabs of a given tab
        tab - The tab whose subtabs are to be retrieved
        onlyFirstLevel - Boolean used to determine whether all the descendent tabs should be returned or only the next level ones
        The list of subtabs of the given tab, an empty List if the tab has none
      • getProperty

        public static Property getProperty​(Entity entity,
                                           Field field)
        Compute the property from the field, assuming that the field is defined on the basis of entity.
        The property associated to this field, null if the field is not associated to any property or column
      • getParentColumnName

        public String getParentColumnName​(Tab tab)
        Returns the name of the parent column of the tab
        tab - The tab the object belongs to
        The parent column of the table in the given tab, null in case there is no parent tab
      • hasNullableIdentifierProperties

        public static boolean hasNullableIdentifierProperties​(Entity entity)
        Returns true if any of the identifier properties of the provided entity is nullable
        entity - entity whose identifier might be comprised by nullable properties
        true if at least one of the identifier properties of the provided entity is nullable, false if all of them are mandatory