Class AbstractModule

  • All Implemented Interfaces:
    Module

    public abstract class AbstractModule
    extends java.lang.Object
    implements Module
    AbstractModule: default Module implementation and subclass can override methods as needed.
    Since:
    1.2
    • Field Detail

      • PERMISSION_MODULE_VIEW

        protected static final java.lang.String PERMISSION_MODULE_VIEW
        The permission name to view module
        See Also:
        Constant Field Values
      • LICENSE_FEATURE_MODULE

        protected static final java.lang.String LICENSE_FEATURE_MODULE
        The name of license feature required to use module
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractModule

        public AbstractModule()
    • Method Detail

      • getVisibleName

        public java.lang.String getVisibleName()
        Default: visible name is same as name
        Specified by:
        getVisibleName in interface Module
        Returns:
        visible name
      • getVersion

        public java.lang.String getVersion()
        Description copied from interface: Module
        Get module version. Version format: major.minor[.maintenance]. For example, 1.0, 1.0.1
        Specified by:
        getVersion in interface Module
        Returns:
        module version
      • getModuleViewPermission

        public ModuleScopedName getModuleViewPermission()
        Default module view permission: [moduleName].ModuleView
        Specified by:
        getModuleViewPermission in interface Module
        Returns:
        ModuleScopedName (module and permissionName)
      • getLicenseFeatureRequired

        public ModuleScopedName getLicenseFeatureRequired()
        Description copied from interface: Module
        Get license feature required to use this module. Naming convention is [moduleName].Module.
        Specified by:
        getLicenseFeatureRequired in interface Module
        Returns:
        null, license is not required by default.
      • getLicenseIssuerDomain

        public java.lang.String getLicenseIssuerDomain()
        Description copied from interface: Module
        Get the license issuer domain name on CMobileCom License Cloud that can issue license for this module.
        Specified by:
        getLicenseIssuerDomain in interface Module
        Returns:
        null, license is not required by default
      • getSeedSqlList

        public java.util.List<java.lang.String> getSeedSqlList​(DataAccessUnit dataAccessUnit)
        Default: seed.sql.
        Specified by:
        getSeedSqlList in interface Module
        Parameters:
        dataAccessUnit - the instanceType or instance for which the seed sql list will be seeded
        Returns:
        a list of sql file names, such as {seed1.sql, seed2.sql}
      • createMenuNodeFactory

        public MenuNodeFactory createMenuNodeFactory​(MenuBean menuBean,
                                                     MenuViewConfig viewConfig,
                                                     ModuleNode moduleNode,
                                                     java.lang.String factoryName)
        Description copied from interface: Module
        Create a MenuNodeFactory that is to create menu for this Module associated with the moduleNode.
        Specified by:
        createMenuNodeFactory in interface Module
        Parameters:
        menuBean - the MenuBean of the factory
        viewConfig - factory ViewConfig
        moduleNode - the module node with which the MenuNodeFactory is associated
        factoryName - factory name
        Returns:
        MenuNodeFactory instance
      • getEntityBackingBeanMap

        public java.util.Map<java.lang.Class<? extends PersistenceEntity>,​java.lang.Class<? extends EntityBackingBean>> getEntityBackingBeanMap()
        Description copied from interface: Module
        Get the EntityBackingBean mapping for entity types. An EntityBackingBean subclass must be registered for an entity type to be managed for entity presentation on device and user interaction.
        Specified by:
        getEntityBackingBeanMap in interface Module
        Returns:
        a map from entity type to EntityBackingBean type.
      • getEntityListBackingBeanMap

        public java.util.Map<java.lang.Class<? extends PersistenceEntity>,​java.lang.Class<? extends EntityListBackingBean>> getEntityListBackingBeanMap()
        Description copied from interface: Module
        Get the EntityListBackingBean mapping for entity types. If there is no EntityListBackingBean registered for an entity type or any of its super type, default to EntityListBackingBean.class.
        Specified by:
        getEntityListBackingBeanMap in interface Module
        Returns:
        a map from entity type to EntityListBackingBean type.
      • getPersistenceEntityManagerMap

        public java.util.Map<java.lang.Class<? extends PersistenceEntity>,​java.lang.Class<? extends PersistenceEntityManager>> getPersistenceEntityManagerMap()
        Description copied from interface: Module
        Get PersistenceEntityManager mapping. If not defined, use default.
        Specified by:
        getPersistenceEntityManagerMap in interface Module
        Returns:
        a map from entityType -> PersistenceEntityManager type
      • getEntityTypeNameMap

        public java.util.Map<java.lang.Class,​TypeMapping.EntityTypeName> getEntityTypeNameMap()
        Description copied from interface: Module
        Get type name mapping. The names are not localized, and resource bundle will be used for displaying entity type names.

        Default singular name is entity name that is annotated in @Entity(name="Employee"). Default plural name is singular name + s ("ies" for ending y, "es" for ending h/s/x).

        Specified by:
        getEntityTypeNameMap in interface Module
        Returns:
        a map from entity type to (entity singular name, entity plural name)
      • getFormDesignDescriptorMap

        public java.util.Map<java.lang.Class,​FormDesignDescriptor> getFormDesignDescriptorMap()
        Description copied from interface: Module
        Entity types that support form designs
        Specified by:
        getFormDesignDescriptorMap in interface Module
        Returns:
        map from entity type to FormDesignDescriptor
      • getIdRuleSupportEntityTypes

        public java.util.Map<java.lang.Class,​IdRule> getIdRuleSupportEntityTypes​(InstanceType instanceType)
        Description copied from interface: Module
        Get the entity types that support id rules.
        Specified by:
        getIdRuleSupportEntityTypes in interface Module
        Parameters:
        instanceType - the instanceType for which IdRule(s) are supported
        Returns:
        a map from entity types(that support IdRule) to default IdRule objects.
      • getQuotaListForEvaluateLicense

        public java.util.List<Quota> getQuotaListForEvaluateLicense()
        Description copied from interface: Module
        For evaluation license, limit the quantity of entities that can be created.
        Specified by:
        getQuotaListForEvaluateLicense in interface Module
        Returns:
        quota list
      • getEntityTypeImplClassMap

        public java.util.Map<java.lang.Class<? extends PersistenceEntity>,​java.lang.Class<? extends PersistenceEntityBase>> getEntityTypeImplClassMap()
        Description copied from interface: Module
        Get interface implementation class
        Specified by:
        getEntityTypeImplClassMap in interface Module
        Returns:
        a map from interface(PersistenceEntity) to implementation class
      • getSelectItemListMap

        public java.util.Map<ChoiceType,​NameValuePair[]> getSelectItemListMap()
        Description copied from interface: Module
        Get predefined select items mapping
        Specified by:
        getSelectItemListMap in interface Module
        Returns:
        a map from choiceType to name/value pairs as select items
      • getSystemPropertyRequired

        public java.lang.String getSystemPropertyRequired()
        Description copied from interface: Module
        Get the system property that must be defined to enable this module. If null, not required. The module will not be loaded if the property is not defined.
        Specified by:
        getSystemPropertyRequired in interface Module
        Returns:
        system property name
      • broadcastEvent

        public void broadcastEvent​(ModuleEvent event)
                            throws SystemException
        Description copied from interface: Module
        Broadcast the event to all the modules in current InstanceType. A Module can handle the event if interested.
        Specified by:
        broadcastEvent in interface Module
        Parameters:
        event - the event to broadcast
        Throws:
        SystemException - throw if an error occurs when the event is being handled
      • getShortcutMenuNodes

        public java.util.List<MenuNode> getShortcutMenuNodes​(MenuBean menuBean,
                                                             Module.ShortcutType type,
                                                             ShortcutMenuNodeFactory factory)
                                                      throws SystemException
        Description copied from interface: Module
        Get module shortcut menu nodes that are shown on toolbar.
        Specified by:
        getShortcutMenuNodes in interface Module
        Parameters:
        menuBean - menuBean of shortcut menu nodes
        type - the type of shortcuts to create
        factory - shortcut menuNodeFactory
        Returns:
        a list of module shortcut menu nodes, null if the module does not support toolbar shortcuts. the menuNode in the list can be null if permission is denied.
        Throws:
        SystemException - throw if an error occurs in creating shortcuts
      • processRequestParameters

        public void processRequestParameters​(ContainerBean containerBean)
                                      throws SystemException
        Description copied from interface: Module
        Process module specific request parameters. This method is called in the FacesServlet for a GET request, and the FacesContext instance is available.

        For example, the parameter RequestHelper.REQUEST_PARAM_ENTITY to show entity is not module specific, and will be processed by framework.

        Specified by:
        processRequestParameters in interface Module
        Parameters:
        containerBean - the ContainerBean of the beans created if any
        Throws:
        SystemException - throw if an error occurs
      • getPropertySelectItems

        public <T extends ModuleAwareEntity> java.util.List<SelectItem> getPropertySelectItems​(java.lang.Class<T> entityType,
                                                                                               java.lang.String property)
        By default, the entity type is not supported by this module.
        Specified by:
        getPropertySelectItems in interface Module
        Parameters:
        entityType - entity type
        property - property name
        Returns:
        a list of select items. return null if the entity type is not supported by this module.
      • getTextExpressionResolver

        public TextExpressionResolver getTextExpressionResolver​(DataAccessUnit dataAccessUnit)
        Description copied from interface: Module
        Get the TextExpressionResolver that will be used to resolve expressions in the parameter values.
        Specified by:
        getTextExpressionResolver in interface Module
        Parameters:
        dataAccessUnit - the associated DataAccessUnit
        Returns:
        a TextExpressionResolver instance. can be null.
      • createEmbeddedObject

        public BackingBean createEmbeddedObject​(Component parentComponent,
                                                java.lang.String objectType,
                                                org.w3c.dom.Element objectElem,
                                                java.util.List<TextExpressionResolver> textExprResolvers,
                                                ContainerBean containerBean)
                                         throws SystemException
        Description copied from interface: Module
        Create the embedded object for objectType
        Specified by:
        createEmbeddedObject in interface Module
        Parameters:
        parentComponent - the parent component of the object to be created.
        objectType - object type
        objectElem - object element
        textExprResolvers - resolvers for resolving expressions in the XML configuration of the embedded object.
        containerBean - containerBean
        Returns:
        embedded object. return null if the object name is unknown for the module
        Throws:
        SystemException - throw if an error occurs in creating embedded object
      • offload

        public void offload​(DataAccessUnit dataAccessUnit)
                     throws SystemException
        Description copied from interface: Module
        Offload the resources related to the DataAccessUnit. The offloaded resources should be able to be regained on demand such as data cache.
        Specified by:
        offload in interface Module
        Parameters:
        dataAccessUnit - instanceType or instance
        Throws:
        SystemException - throw if an error occurs
      • registerPersistenceEntityManagers

        public void registerPersistenceEntityManagers()
        Description copied from interface: Module
        Register PersistenceEntityManager related objects, including extended PersistenceEntityManager implementations, and JPAEntityManagerAccessor.
        Specified by:
        registerPersistenceEntityManagers in interface Module
      • format

        public java.lang.Object format​(java.lang.Object value,
                                       DataAccessUnit dataAccessUnit)
                                throws SystemException
        Description copied from interface: Module
        Format a value to a string, I18NName or ParameterizedMessage that can be displayed by current locale.

        For example, the parameters of an exception may need to be formatted before showing to users.

        Specified by:
        format in interface Module
        Parameters:
        value - the value to format
        dataAccessUnit - dataAccessUnit
        Returns:
        null, indicating this module does not know how to format it.
        Throws:
        SystemException - throw if an error occurs
      • addMenuNodesToUserAccount

        public void addMenuNodesToUserAccount​(MenuNode parentMenuNode)
                                       throws SystemException
        Description copied from interface: Module
        Add menu nodes to the user account menu of current authenticated user
        Specified by:
        addMenuNodesToUserAccount in interface Module
        Parameters:
        parentMenuNode - the parent menu node under which to add nodes
        Throws:
        SystemException - throw if an error occurs
      • getParameter

        public java.lang.String getParameter​(java.lang.String name)
        Description copied from interface: Module
        Get the parameter value configured for this module.
        Specified by:
        getParameter in interface Module
        Parameters:
        name - parameter name
        Returns:
        parameter value
      • setParameter

        public void setParameter​(java.lang.String name,
                                 java.lang.String value)
        Description copied from interface: Module
        Set the parameter value for this module.
        Specified by:
        setParameter in interface Module
        Parameters:
        name - parameter name
        value - parameter value
      • initialize

        public void initialize​(InstanceType instanceType,
                               Instance instance)
                        throws SystemException
        Seed IdGen for mapped entity types, module defined permissions, and mailTemplates for system instance or instanceType.
        Specified by:
        initialize in interface Module
        Parameters:
        instanceType - the InstanceType that contains this module.
        instance - the created instance of the instanceType.
        Throws:
        SystemException - throw if an error occurs
      • getPersistenceEntityManager

        protected <P extends PersistenceEntityManager> P getPersistenceEntityManager​(DataAccessUnit dataAccessUnit)
        Get the entity manager for the dataAccessUnit.
        Parameters:
        dataAccessUnit - dataAccessUnit
        Returns:
        entity manager
        Since:
        5.14
      • getPersistenceEntityManager

        protected <P extends PersistenceEntityManager> P getPersistenceEntityManager​(java.lang.Class<P> type,
                                                                                     DataAccessUnit dataAccessUnit)
        Get the entity manager for the dataAccessUnit.
        Parameters:
        type - PersistenceEntityManager type
        dataAccessUnit - dataAccessUnit
        Returns:
        entity manager
        Since:
        5.14
      • getMappedEntityTypes

        public java.util.List<java.lang.Class> getMappedEntityTypes​(InstanceType instanceType)
        Description copied from interface: Module
        Get the entity Types that are mapped to persistence
        Specified by:
        getMappedEntityTypes in interface Module
        Parameters:
        instanceType - the instanceType for which the entity types of this module are mapped
        Returns:
        a list of entity types
      • deleteData

        public void deleteData​(InstanceType instanceType,
                               Instance instance)
                        throws SystemException
        Default implementation. Delete all the entities of all mapped entity types. getMappedEntityTypes(InstanceType) returns the mapped entity types of this module.

        The dependency between entity types are calculated. For circular dependency, set nullable references to null to break the circular references. Throw exception if circular references can not be broken.

        Entities of ChildEntity type will be deleted by cascading deletion of its parent entity.

        getEntityTypesExcludedFromDeletion(InstanceType) return the entity types whose entities shall not be deleted.

        Specified by:
        deleteData in interface Module
        Parameters:
        instanceType - the InstanceType that contains this module.
        instance - the created instance of the instanceType. Null for system.
        Throws:
        SystemException - throw if an error occurs
      • getEntityTypesExcludedFromDeletion

        protected java.util.Set<java.lang.Class> getEntityTypesExcludedFromDeletion​(InstanceType instanceType)
        Get the entity types excluded from deletion by deleteData(InstanceType, Instance). So this method is called in case of single table multitenancy when its subsystem is deleted. Default: return null, no types are excluded.

        For example, in case of multitenant single identity, users must not be deleted.

        Parameters:
        instanceType - the InstanceType that contains this module
        Returns:
        true if the entities of the entityType are excluded from deletion, return false otherwise.
      • createPageHeaderMenuNodes

        public MenuNode createPageHeaderMenuNodes​(MenuBean pageHeaderMenuBean)
                                           throws SystemException
        Description copied from interface: Module
        Create a tree of menu nodes that will be added into the page header menu. The root of the menu nodes will be added as a top menu node of the page header menu.
        Specified by:
        createPageHeaderMenuNodes in interface Module
        Parameters:
        pageHeaderMenuBean - the page header menu bean
        Returns:
        root menu node
        Throws:
        SystemException - throw if an error occurs
      • preRenderView

        public void preRenderView​(ContainerBean containerBean)
                           throws SystemException
        Description copied from interface: Module
        preRenderView: called before rendering response for GET requests. This method will not be called for post back.
        Specified by:
        preRenderView in interface Module
        Parameters:
        containerBean - the current page ContainerBean
        Throws:
        SystemException - throw if an error occurs
      • getPermissionNames

        public static <T extends PersistenceEntity> java.util.List<java.lang.String> getPermissionNames​(DataType<T> dataType,
                                                                                                        boolean manage,
                                                                                                        AccessType... accessTypes)
        Create the standard permission names to access entities of the data type. For example, CreateEMP, SearchEMP.
        Parameters:
        manage - whether to add manage permission such as ManageEMP
        accessTypes - a list of access types
        dataType - dataType
        Returns:
        a list of permission names without module name.
        Since:
        5.6
      • getPermissionNames

        public static <T extends PersistenceEntity> java.util.List<java.lang.String> getPermissionNames​(DataType<T> dataType,
                                                                                                        java.lang.String... actions)
        Create the standard permission names to access entities of the data type. For example, PromoteEMP. Permission names are action names followed by dataType name. For example, PromoteEMP, ApproveEC.
        Parameters:
        dataType - dataType
        actions - a list of action names
        Returns:
        a list of permission names without module name.
        Since:
        5.6
      • getFormDesigns

        public java.util.List<FormDesign> getFormDesigns​(java.lang.Class<FormDesign> formDesignImplClass,
                                                         DataType entityType,
                                                         java.util.List<java.lang.String> formIds,
                                                         java.util.Collection<java.lang.String> excludeFormIds,
                                                         java.lang.Boolean hidden,
                                                         java.lang.Integer maxResults,
                                                         boolean initialize,
                                                         DataAccessUnit dataAccessUnit)
                                                  throws SystemException
        Description copied from interface: Module
        Get all the form designs for the specified entityType and formId(s). FormDesign implementation class needs to be registered with FormDesignBean.
        Specified by:
        getFormDesigns in interface Module
        entityType - the entity type that is mapped to DataTypeAware.getEntityType() for query.
        formIds - a list of FormDesign formId(s) to get, null for all forms
        excludeFormIds - the formDesign formId(s) to exclude, null for none
        hidden - hidden or not, include both if null
        maxResults - if not null, max number of formDesigns returned
        initialize - whether to initialize form designs if they are partially initialized
        dataAccessUnit - the associated DataAccessUnit
        Returns:
        a list of FormDesign entities
        Throws:
        SystemException - throw if an error occurs in accessing persistence
      • createMailTemplates

        protected void createMailTemplates​(InstanceType instanceType,
                                           PersistenceEntityManager peManager)
        Create mail templates for all supported locales.
        Parameters:
        instanceType - instance type
        peManager - entity manager
        Since:
        5.14