Class RightsModelUtil
- java.lang.Object
-
- com._1c.g5.v8.dt.rights.model.util.RightsModelUtil
-
public class RightsModelUtil extends Object
Rights model util.
-
-
Field Summary
Fields Modifier and Type Field Description static com.google.common.collect.ImmutableSet<org.eclipse.emf.ecore.EClass>
ALL_SUPPORTED_RIGHT_ECLASSES
Supported right all Md objectEClass
'esstatic com.google.common.collect.ImmutableSet<org.eclipse.emf.ecore.EClass>
SUPPORTED_RIGHT_ECLASSES
Supported right top Md objectEClass
'es
-
Constructor Summary
Constructors Constructor Description RightsModelUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
changeObjectRight(RightValue newValue, RightValue defaultRightValue, ObjectRights objectRights, Right right)
Changes object right.static void
fillObjectsToRightsMap(RoleDescription roleDescription, List<Pair<org.eclipse.emf.ecore.EObject,ObjectRights>> objectsToRightsMap)
Reads rights and itsEObject
and stores it to the list.static Collection<Right>
filterCheckDependeces(Right right, Collection<Right> rights)
Filters check right dependences.static ObjectRight
filterObjectRightByRight(Right right, List<ObjectRight> objectRights)
Filters object right by right.static ObjectRights
filterObjectRightsByEObject(List<Pair<org.eclipse.emf.ecore.EObject,ObjectRights>> objectsToRightsMap, org.eclipse.emf.ecore.EObject eObject)
Filters object rights by eObject.static ObjectRights
filterObjectRightsByEObject(org.eclipse.emf.ecore.EObject eObject, List<ObjectRights> objectRights)
Filters object rights by theEObject
.static ObjectRights
filterObjectRightsByEObjectFastly(org.eclipse.emf.ecore.EObject eObject, RoleDescription roleDescription)
Filters object rights by theEObject
fastly.static Collection<ObjectRights>
filterObjectRightsByEObjects(List<org.eclipse.emf.ecore.EObject> eObjects, List<Pair<org.eclipse.emf.ecore.EObject,ObjectRights>> objectsToRightsMap)
Filters object righs by eObjectsstatic Collection<Right>
filterUncheckDependeces(Right right, Collection<Right> rights)
Filters uncheck right dependences.static boolean
getBooleanRightValue(RightValue rightValue)
Gets the boolean from the givenRightValue
.static Set<RightName>
getCheckDependeces(Right right)
Returns all check dependeces right names for the given right.static RightValue
getDefaultRightValue(org.eclipse.emf.ecore.EObject object, Role role)
Gets the object default right value.static org.eclipse.emf.ecore.EClass
getEClass(org.eclipse.emf.ecore.EObject eObject)
Gets eObject EClass.static List<ObjectRight>
getObjectRight(RoleDescription roleDescription, org.eclipse.emf.ecore.EClass eClass, String rightName)
static List<Pair<org.eclipse.emf.ecore.EObject,ObjectRights>>
getObjectsToRightsMap(RoleDescription roleDescription)
Reads rights and its e-object and stores it to the list.static ObjectRights
getOrCreateObjectRights(org.eclipse.emf.ecore.EObject eObject, RoleDescription roleDescription)
Gets or creates object rights by eObject from role description.static Role
getOwner(RoleDescription roleDescription, IBmModel bmModel)
Returns the owner of the givenroleDescription
.static org.eclipse.emf.ecore.EObject
getOwnerEObject(org.eclipse.emf.ecore.EObject eObject)
Gets the owner of the givenEObject
;static RightValue
getRightValue(boolean rightValue)
GetsRightValue
from the boolean value.static Set<org.eclipse.emf.ecore.EClass>
getSubobjectEClasses(org.eclipse.emf.ecore.EObject eObject)
Gets eObject subobject eClases.static int
getTemplateParametersCount(RestrictionTemplate template)
Counts template parameters.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.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.static Set<RightName>
getUncheckDependeces(Right right)
Returns all uncheck dependeces right names for the given right.static boolean
isAdoptedMdObject(org.eclipse.emf.ecore.EObject object)
Checks whether the given object or its container is an adopted model object.static boolean
isMdObjectHasRights(Object mdObject)
Is object has rights.static boolean
isRightContains(Right right, Collection<Right> rights)
Checks is right contains in right collection, compares right by name.static boolean
isRightsContainsEObjectRls(ObjectRights objectRights)
Is role description contains RLS on selected e-object.static boolean
isSameObject(org.eclipse.emf.ecore.EObject object1, org.eclipse.emf.ecore.EObject object2)
Determines whether two possibly-null objects are same.static boolean
isSameRights(Right right1, Right right2)
Compares two rights by name.static boolean
isSubobject(org.eclipse.emf.ecore.EObject eObject)
Is subobject.static boolean
isSubobjectEClassHasRights(org.eclipse.emf.ecore.EObject eParent, org.eclipse.emf.ecore.EClass eSubobjectEClass)
Is subobject e-class has rights.static void
removeEmptyObjectRights(RoleDescription roleDescription, ObjectRights objectRights)
Removes empty object rights from model.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 specifiedEClass
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.
-
-
-
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 objectEClass
'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 objectEClass
'es
-
-
Method Detail
-
changeObjectRight
public static void changeObjectRight(RightValue newValue, RightValue defaultRightValue, ObjectRights objectRights, Right right)
Changes object right.- Parameters:
newValue
- the new right valuedefaultRightValue
- the default right valueaffectedObjects
- the affected objectsobjectRights
- the object rights, can not benull
right
- the right, can not benull
-
filterCheckDependeces
public static Collection<Right> filterCheckDependeces(Right right, Collection<Right> rights)
Filters check right dependences.- Parameters:
right
- the checked right, can not benull
rights
- the all rights, can not benull
- 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 benull
objectRights
- the object rights, can not benull
- 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 theEObject
fastly.- Parameters:
eObject
- theEObject
, can not benull
roleDescription
- the role description, can not benull
- 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 theEObject
.- Parameters:
eObject
- theEObject
, can not benull
objectRights
- the object rights, can not benull
- 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 benull
eObject
- the eObject, can not benull
- 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 benull
objectsToRightsMap
- the mapping from objects to their rights for the specific role description, can not benull
- 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 benull
rights
- the all rights, can not benull
- 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 benull
role
- the role, cannot benull
- 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 benull
- 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 benull
roleDescription
- the role description, can not benull
- 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 benull
- Returns:
- the subobject eClases, can not be
null
-
getTemplateParametersCount
public static int getTemplateParametersCount(RestrictionTemplate template)
Counts template parameters.- Parameters:
template
- the template, can not benull
- Returns:
- the count parameters
-
isMdObjectHasRights
public static boolean isMdObjectHasRights(Object mdObject)
Is object has rights.- Parameters:
mdObject
- the object, can not benull
- 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 benull
rights
- the right collection, can not benull
- 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 benull
- 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
ifobject1
orobject2
is null. - else if
object1
andobject2
are both proxy returnstrue
if their proxy URI's are identical, returnsfalse
otherwise; - else returns
true
ifobject1
andobject2
are both non-null and they are equal according toObject.equals(Object)
. - Returns
false
in all other situations.
- Parameters:
object1
- the first instance, may benull
object2
- the second instance, may benull
- Returns
-
isSameRights
public static boolean isSameRights(Right right1, Right right2)
Compares two rights by name.- Parameters:
right1
- the first rights, may benull
right2
- the second rights, may benull
- Returns:
- true if equals
-
isSubobject
public static boolean isSubobject(org.eclipse.emf.ecore.EObject eObject)
Is subobject.- Parameters:
eObject
- the eObject, can not benull
- 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 benull
eSubobjectEClass
- the subobject e-class, can not benull
- 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 benull
objectRights
- the object rights, may benull
-
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 benull
- 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 itsEObject
and stores it to the list.- Parameters:
roleDescription
- the role description, can not benull
objectsToRightsMap
- the mapping from objects to their rights for the specific role description, can not benull
-
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 benull
objectContext
- the context object whose resource set is used for the resolve, can not benull
- 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 benull
objectContext
- the context object whose resource set is used for the resolve, can not benull
topObjectFqn
- the FQN of the top object that rights will be found for, may benull
; if the FQN isnull
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 givenEObject
;- Parameters:
eObject
- the givenEObject
, can not benull
- Returns:
- the owner of the given
EObject
, may benull
-
getRightValue
public static RightValue getRightValue(boolean rightValue)
GetsRightValue
from the boolean value.- Parameters:
rightValue
- the boolean right value- Returns:
RightValue
, can not benull
-
getBooleanRightValue
public static boolean getBooleanRightValue(RightValue rightValue)
Gets the boolean from the givenRightValue
.- Parameters:
rightValue
- the givenRightValue
, can not benull
- Returns:
true
if the givebRightValue
isRightValue#SET SET
andfalse
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 benull
- 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 givenroleDescription
.- Parameters:
roleDescription
- theRoleDescription
instance, cannot benull
bmModel
- the BM model, can not benull
- 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 benull
- 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 benull
- Returns:
- uncheck dependeces, never
null
-
getObjectRight
public static List<ObjectRight> getObjectRight(RoleDescription roleDescription, org.eclipse.emf.ecore.EClass eClass, String rightName)
- Parameters:
roleDescription
-RoleDescription
for gettingObjectRight
, cannot benull
eClass
-EClass
ofObjectRights.getObject()
for gettinObjectRight
, cannot benull
rightName
- name of theRight
inObjectRight
, cannot benull
- Returns:
- list of all
ObjectRight
fromRoleDescription
for concreteEClass
object and concrete name ofRight
, nevernull
-
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 benull
- 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 specifiedEClass
- Parameters:
eClass
- the sepcifiedEClass
to define right values by default, cannot benull
- 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
-
-