Class OrganizationStructureProvider

  • All Implemented Interfaces:
    OBNotSingleton, OBProvidable

    public class OrganizationStructureProvider
    extends Object
    implements OBNotSingleton
    Builds a tree of organizations to compute the accessible organizations for the current organizations of a user. Is used to check if references from one object to another are correct from an organization structure perspective.

    For example a city refers to a country then: an organization of the country (the refered object) must be in the natural tree of the organization of the city (the referee).

    Author:
    mtaal
    • Constructor Detail

      • OrganizationStructureProvider

        public OrganizationStructureProvider()
    • Method Detail

      • reInitialize

        public void reInitialize()
        Set initialized to false and recompute the organization structures
      • getNaturalTree

        public Set<String> getNaturalTree​(String orgId)
        Returns the natural tree of an organization.
        Parameters:
        orgId - the id of the organization for which the natural tree is determined.
        Returns:
        the natural tree of the organization.
      • isInNaturalTree

        public boolean isInNaturalTree​(Organization org1,
                                       Organization org2)
        Checks if an organization (org2) is in the natural tree of another organization (org1).
        Parameters:
        org1 - the natural tree of this organization is used to check if org2 is present
        org2 - the organization checked in the natural tree of org1
        Returns:
        true if org2 is in the natural tree of org1, false otherwise
      • getParentTree

        public Set<String> getParentTree​(String orgId,
                                         boolean includeOrg)
        Returns the parent organization tree of an organization.
        Parameters:
        orgId - the id of the organization for which the parent organization tree is determined.
        includeOrg - if true, returns also the given organization as part of the tree
        Returns:
        the parent organization tree of the organization.
      • getParentList

        public List<String> getParentList​(String orgId,
                                          boolean includeOrg)
        Returns an ordered list of parents of an organization. The parents are listed from the organization and up (so parent before grand parent).
        Parameters:
        orgId - the id of the organization for which the parent organization tree is determined.
        includeOrg - if true, returns also the given organization as part of the tree
        Returns:
        the parent organization tree of the organization.
      • getParentOrg

        public String getParentOrg​(String orgId)
        Returns the parent organization of an organization.
        Parameters:
        orgId - the id of the organization for which the parent organization is determined.
        Returns:
        the parent organization.
      • getParentOrg

        public Organization getParentOrg​(Organization org)
        Returns the parent organization of an organization.
        Parameters:
        org - the organization for which the parent organization is determined.
        Returns:
        the parent organization.
      • getChildTree

        public Set<String> getChildTree​(String orgId,
                                        boolean includeOrg)
        Returns the child organization tree of an organization.
        Parameters:
        orgId - the id of the organization for which the child organization tree is determined.
        includeOrg - if true, returns also the given organization as part of the tree
        Returns:
        the child organization tree of the organization.
      • getChildOrg

        public Set<String> getChildOrg​(String orgId)
        Returns the child organizations of an organization.
        Parameters:
        orgId - the id of the organization for which the child organizations are determined.
        Returns:
        the child organizations
      • getClientId

        public String getClientId()
      • setClientId

        public void setClientId​(String clientId)
      • getLegalEntitiesListForSelectedClient

        public List<Organization> getLegalEntitiesListForSelectedClient​(String paramClientId)
      • getLegalEntity

        public Organization getLegalEntity​(Organization org)
        Returns the legal entity of the given organization
        Parameters:
        org - organization to get its legal entity
        Returns:
        legal entity (with or without accounting) organization or null if not found
      • getChildLegalEntitesList

        public List<Organization> getChildLegalEntitesList​(Organization org)
        Returns the list of legal entities that are children of the given organization
        Parameters:
        org - organization to get its child legal entities
        Returns:
        legal entity (with or without accounting) organization or null if not found
      • getLegalEntityOrBusinessUnit

        public Organization getLegalEntityOrBusinessUnit​(Organization org)
        Returns the legal entity or Business Unit of the given organization
        Parameters:
        org - organization to get its legal entity or business unit
        Returns:
        legal entity (with or without accounting) organization or null if not found
      • getPeriodControlAllowedOrganization

        public Organization getPeriodControlAllowedOrganization​(Organization org)
        Returns the organization that is period control allowed for the org Organization. If no organization is found, it returns NULL.
        Parameters:
        org - Organization to get its period control allowed organization.
      • getTransactionAllowedOrgs

        public String getTransactionAllowedOrgs​(String orgIds)
        Checks a list of organizations filtering out those ones that do not allow transactions.
        Parameters:
        orgIds - List of organizations to check represented as a comma separated String, elements can be quoted.
        Returns:
        The list of organization from orgIds that allow transactions represented a String of comma separated quoted elements.