Class RightsModelUtil


  • public class RightsModelUtil
    extends Object
    Rights model util.
    • Field Detail

      • SUPPORTED_RIGHT_ECLASSES

        public static final com.google.common.collect.ImmutableSet<org.eclipse.emf.ecore.EClass> SUPPORTED_RIGHT_ECLASSES
        Supported right top Md object EClass'es
      • ALL_SUPPORTED_RIGHT_ECLASSES

        public static final com.google.common.collect.ImmutableSet<org.eclipse.emf.ecore.EClass> ALL_SUPPORTED_RIGHT_ECLASSES
        Supported right all Md object EClass'es
    • Constructor Detail

      • RightsModelUtil

        public RightsModelUtil()
    • Method Detail

      • changeObjectRight

        public static void changeObjectRight​(RightValue newValue,
                                             RightValue defaultRightValue,
                                             ObjectRights objectRights,
                                             Right right)
        Changes object right.
        Parameters:
        newValue - the new right value
        defaultRightValue - the default right value
        affectedObjects - the affected objects
        objectRights - the object rights, can not be null
        right - the right, can not be null
      • filterCheckDependeces

        public static Collection<Right> filterCheckDependeces​(Right right,
                                                              Collection<Right> rights)
        Filters check right dependences.
        Parameters:
        right - the checked right, can not be null
        rights - the all rights, can not be null
        Returns:
        the depended on check rights, can not be null
      • filterObjectRightByRight

        public static ObjectRight filterObjectRightByRight​(Right right,
                                                           List<ObjectRight> objectRights)
        Filters object right by right.
        Parameters:
        right - the right, can not be null
        objectRights - the object rights, can not be null
        Returns:
        the object right or null if not found
      • filterObjectRightsByEObjectFastly

        public static ObjectRights filterObjectRightsByEObjectFastly​(org.eclipse.emf.ecore.EObject eObject,
                                                                     RoleDescription roleDescription)
        Filters object rights by the EObject fastly.
        Parameters:
        eObject - the EObject, can not be null
        roleDescription - the role description, can not be null
        Returns:
        the object rights or null if not found
      • filterObjectRightsByEObject

        public static ObjectRights filterObjectRightsByEObject​(org.eclipse.emf.ecore.EObject eObject,
                                                               List<ObjectRights> objectRights)
        Filters object rights by the EObject.
        Parameters:
        eObject - the EObject, can not be null
        objectRights - the object rights, can not be null
        Returns:
        the object rights or null if not found
      • filterObjectRightsByEObject

        public static ObjectRights filterObjectRightsByEObject​(List<Pair<org.eclipse.emf.ecore.EObject,​ObjectRights>> objectsToRightsMap,
                                                               org.eclipse.emf.ecore.EObject eObject)
        Filters object rights by eObject.
        Parameters:
        objectsToRightsMap - the mapping from objects to their rights for the specific role description, can not be null
        eObject - the eObject, can not be null
        Returns:
        the object rights or null if not found
      • filterObjectRightsByEObjects

        public static Collection<ObjectRights> filterObjectRightsByEObjects​(List<org.eclipse.emf.ecore.EObject> eObjects,
                                                                            List<Pair<org.eclipse.emf.ecore.EObject,​ObjectRights>> objectsToRightsMap)
        Filters object righs by eObjects
        Parameters:
        eObjects - the eObjects, can not be null
        objectsToRightsMap - the mapping from objects to their rights for the specific role description, can not be null
        Returns:
        the object rights collections, can not be null
      • filterUncheckDependeces

        public static Collection<Right> filterUncheckDependeces​(Right right,
                                                                Collection<Right> rights)
        Filters uncheck right dependences.
        Parameters:
        right - the unchecked right, can not be null
        rights - the all rights, can not be null
        Returns:
        the depended on uncheck rights, can not be null
      • getDefaultRightValue

        public static RightValue getDefaultRightValue​(org.eclipse.emf.ecore.EObject object,
                                                      Role role)
        Gets the object default right value.
        Parameters:
        object - the object to get default right value for, cannot be null
        role - the role, cannot be null
        Returns:
        the default value, cannot be null
      • getEClass

        public static org.eclipse.emf.ecore.EClass getEClass​(org.eclipse.emf.ecore.EObject eObject)
        Gets eObject EClass. If eObject is proxy EClass detects from proxy URI fragment.
        Parameters:
        eObject - the eObject, can't be null
        Returns:
        the EClass
      • getOrCreateObjectRights

        public static ObjectRights getOrCreateObjectRights​(org.eclipse.emf.ecore.EObject eObject,
                                                           RoleDescription roleDescription)
        Gets or creates object rights by eObject from role description.
        Parameters:
        eObject - the eObject, can not be null
        roleDescription - the role description, can not be null
        Returns:
        the object rights, can not be null
      • getSubobjectEClasses

        public static Set<org.eclipse.emf.ecore.EClass> getSubobjectEClasses​(org.eclipse.emf.ecore.EObject eObject)
        Gets eObject subobject eClases.
        Parameters:
        eObject - the eObject, can not be null
        Returns:
        the subobject eClases, can not be null
      • getTemplateParametersCount

        public static int getTemplateParametersCount​(RestrictionTemplate template)
        Counts template parameters.
        Parameters:
        template - the template, can not be null
        Returns:
        the count parameters
      • isMdObjectHasRights

        public static boolean isMdObjectHasRights​(Object mdObject)
        Is object has rights.
        Parameters:
        mdObject - the object, can not be null
        Returns:
        true if has rights
      • isRightContains

        public static boolean isRightContains​(Right right,
                                              Collection<Right> rights)
        Checks is right contains in right collection, compares right by name.
        Parameters:
        right - the right, can not be null
        rights - the right collection, can not be null
        Returns:
        true if contains
      • isRightsContainsEObjectRls

        public static boolean isRightsContainsEObjectRls​(ObjectRights objectRights)
        Is role description contains RLS on selected e-object.
        Parameters:
        objectRights - the rights of the e-object, may be null
        Returns:
        true is contains
      • isSameObject

        public static boolean isSameObject​(org.eclipse.emf.ecore.EObject object1,
                                           org.eclipse.emf.ecore.EObject object2)
        Determines whether two possibly-null objects are same.
        • Returns false if object1 or object2 is null.
        • else if object1 and object2 are both proxy returns true if their proxy URI's are identical, returns false otherwise;
        • else returns true if object1 and object2 are both non-null and they are equal according to Object.equals(Object).
        • Returns false in all other situations.
        Parameters:
        object1 - the first instance, may be null
        object2 - the second instance, may be null
      • isSameRights

        public static boolean isSameRights​(Right right1,
                                           Right right2)
        Compares two rights by name.
        Parameters:
        right1 - the first rights, may be null
        right2 - the second rights, may be null
        Returns:
        true if equals
      • isSubobject

        public static boolean isSubobject​(org.eclipse.emf.ecore.EObject eObject)
        Is subobject.
        Parameters:
        eObject - the eObject, can not be null
        Returns:
        is eObject is subobject
      • isSubobjectEClassHasRights

        public static boolean isSubobjectEClassHasRights​(org.eclipse.emf.ecore.EObject eParent,
                                                         org.eclipse.emf.ecore.EClass eSubobjectEClass)
        Is subobject e-class has rights.
        Parameters:
        eParent - the parent object, can not be null
        eSubobjectEClass - the subobject e-class, can not be null
        Returns:
        true is subobject e-class has rights
      • removeEmptyObjectRights

        public static void removeEmptyObjectRights​(RoleDescription roleDescription,
                                                   ObjectRights objectRights)
        Removes empty object rights from model.
        Parameters:
        roleDescription - the role description, can not be null
        objectRights - the object rights, may be null
      • getObjectsToRightsMap

        public static List<Pair<org.eclipse.emf.ecore.EObject,​ObjectRights>> getObjectsToRightsMap​(RoleDescription roleDescription)
        Reads rights and its e-object and stores it to the list.
        Parameters:
        roleDescription - the role description, can not be null
        Returns:
        the list of pairs if rights and its e-object, can not be null
      • fillObjectsToRightsMap

        public static void fillObjectsToRightsMap​(RoleDescription roleDescription,
                                                  List<Pair<org.eclipse.emf.ecore.EObject,​ObjectRights>> objectsToRightsMap)
        Reads rights and its EObject and stores it to the list.
        Parameters:
        roleDescription - the role description, can not be null
        objectsToRightsMap - the mapping from objects to their rights for the specific role description, can not be null
      • getTopObjectsToRightsMap

        public static Map<org.eclipse.emf.ecore.EObject,​Pair<ObjectRights,​Boolean>> getTopObjectsToRightsMap​(RoleDescription roleDescription,
                                                                                                                         org.eclipse.emf.ecore.EObject objectContext)
        Reads rights and its e-object and stores top objects to the map.
        Parameters:
        roleDescription - the role description, can not be null
        objectContext - the context object whose resource set is used for the resolve, can not be null
        Returns:
        the mapping from a top object to its rights, can not be null
      • getTopObjectsToRightsMap

        public static Map<org.eclipse.emf.ecore.EObject,​Pair<ObjectRights,​Boolean>> getTopObjectsToRightsMap​(RoleDescription roleDescription,
                                                                                                                         org.eclipse.emf.ecore.EObject objectContext,
                                                                                                                         String topObjectFqn)
        Reads rights and its e-object and stores top objects to the map.
        Parameters:
        roleDescription - the role description, can not be null
        objectContext - the context object whose resource set is used for the resolve, can not be null
        topObjectFqn - the FQN of the top object that rights will be found for, may be null; if the FQN is null then rights will be found for all objects for the given role description
        Returns:
        the mapping from a top object to its rights, can not be null
      • getOwnerEObject

        public static org.eclipse.emf.ecore.EObject getOwnerEObject​(org.eclipse.emf.ecore.EObject eObject)
        Gets the owner of the given EObject;
        Parameters:
        eObject - the given EObject, can not be null
        Returns:
        the owner of the given EObject, may be null
      • getRightValue

        public static RightValue getRightValue​(boolean rightValue)
        Gets RightValue from the boolean value.
        Parameters:
        rightValue - the boolean right value
        Returns:
        RightValue, can not be null
      • getBooleanRightValue

        public static boolean getBooleanRightValue​(RightValue rightValue)
        Gets the boolean from the given RightValue.
        Parameters:
        rightValue - the given RightValue, can not be null
        Returns:
        true if the giveb RightValue is RightValue#SET SET and false otherwise
      • isAdoptedMdObject

        public static boolean isAdoptedMdObject​(org.eclipse.emf.ecore.EObject object)
        Checks whether the given object or its container is an adopted model object.
        Parameters:
        object - the object, can not be null
        Returns:
        true if the object or its container is an adopted model object, false otherwise
      • getOwner

        public static Role getOwner​(RoleDescription roleDescription,
                                    IBmModel bmModel)
        Returns the owner of the given roleDescription.
        Parameters:
        roleDescription - the RoleDescription instance, cannot be null
        bmModel - the BM model, can not be null
        Returns:
        the owner of the given roleDescription
      • getCheckDependeces

        public static Set<RightName> getCheckDependeces​(Right right)
        Returns all check dependeces right names for the given right.
        Parameters:
        right - the right to get check dependeces for, cannot be null
        Returns:
        check dependeces, never null
      • getUncheckDependeces

        public static Set<RightName> getUncheckDependeces​(Right right)
        Returns all uncheck dependeces right names for the given right.
        Parameters:
        right - the right to get uncheck dependeces for, cannot be null
        Returns:
        uncheck dependeces, never null
      • useSetRightsForAttributesAndTabularSectionsByDefault

        public static boolean useSetRightsForAttributesAndTabularSectionsByDefault​(org.eclipse.emf.ecore.EObject eObject)
        Tells whether to use "Set rights for attributes and tabular sections by default" flag to define right values by default for the specified object.
        Parameters:
        eObject - the sepcified object to define right values by default, cannot be null
        Returns:
        true if need to use "Set rights for attributes and tabular sections by default" flag to define right values by default, false if need to use "Set rights for new objects" flag to define right values by default
      • useSetRightsForAttributesAndTabularSectionsByDefault

        public static boolean useSetRightsForAttributesAndTabularSectionsByDefault​(org.eclipse.emf.ecore.EClass eClass)
        Tells whether to use "Set rights for attributes and tabular sections by default" flag to define right values by default for the specified EClass
        Parameters:
        eClass - the sepcified EClass to define right values by default, cannot be null
        Returns:
        true if need to use "Set rights for attributes and tabular sections by default" flag to define right values by default, false if need to use "Set rights for new objects" flag to define right values by default