Class SearcherImpl

java.lang.Object
cz.metacentrum.perun.core.impl.SearcherImpl
All Implemented Interfaces:
SearcherImplApi

public class SearcherImpl extends Object implements SearcherImplApi
Searcher Class for searching objects by Map of Attributes
Author:
Michal Stava invalid input: '<'stavamichal@gmail.com>
  • Constructor Details

    • SearcherImpl

      public SearcherImpl(DataSource perunPool)
  • Method Details

    • getFacilities

      public List<Facility> getFacilities(PerunSession sess, Map<Attribute,String> attributesWithSearchingValues) throws WrongAttributeValueException
      Description copied from interface: SearcherImplApi
      This method get Map of Attributes with searching values and try to find all facilities, which have specific attributes in format. Better information about format below. When there are more than 1 attribute in Map, it means all must be true "looking for all of them" (AND)

      IMPORTANT: can't get CORE ATTRIBUTES

      Specified by:
      getFacilities in interface SearcherImplApi
      Parameters:
      sess - perun session
      attributesWithSearchingValues - map of attributes when attribute is type String, so value is string and we are looking for total match (Partial is not supported now, will be supported later by symbol *) when attribute is type Integer, so value is integer in String and we are looking for total match when attribute is type List, so value is String and we are looking for at least one total or partial matching element when attribute is type Map so value is String in format "key=value" and we are looking total match of both or if is it "key" so we are looking for total match of key IMPORTANT: In map there is not allowed char '=' in key. First char '=' is delimiter in MAP item key=value!!!
      Returns:
      list of facilities that have attributes with specific values (behavior above) if no such facility exists, return empty list if attributeWithSearchingValues is empty, return all facilities
      Throws:
      WrongAttributeValueException - wrong attribute value
    • getGroups

      public List<Group> getGroups(PerunSession sess, Map<Attribute,String> attributesWithSearchingValues) throws WrongAttributeValueException
      Description copied from interface: SearcherImplApi
      This method get Map of Attributes with searching values and try to find all groups, which have specific attributes in format. Better information about format below. When there are more than 1 attribute in Map, it means all must be true "looking for all of them" (AND)

      IMPORTANT: can't get CORE ATTRIBUTES

      Specified by:
      getGroups in interface SearcherImplApi
      Parameters:
      sess - perun session
      attributesWithSearchingValues - map of attributes when attribute is type String, so value is string and we are looking for total match (Partial is not supported now, will be supported later by symbol *) when attribute is type Integer, so value is integer in String and we are looking for total match when attribute is type List, so value is String and we are looking for at least one total or partial matching element when attribute is type Map so value is String in format "key=value" and we are looking total match of both or if is it "key" so we are looking for total match of key IMPORTANT: In map there is not allowed char '=' in key. First char '=' is delimiter in MAP item key=value!!!
      Returns:
      list of groups who have attributes with specific values (behavior above) if no group exist, return empty list of groups if attributeWithSearchingValues is empty, return all groups
      Throws:
      WrongAttributeValueException - wrong attribute value
    • getGroupsByGroupResourceSetting

      public List<Group> getGroupsByGroupResourceSetting(PerunSession sess, Attribute groupResourceAttribute, Attribute resourceAttribute)
      Description copied from interface: SearcherImplApi
      Return all groups assigned to any resource with following conditions: 1] resource has set "resourceAttribute" attribute with same value 2] group and resource has set "groupResourceAttribute" attribute with same value Attribute values can't be empty. If there is no such group, return empty array.
      Specified by:
      getGroupsByGroupResourceSetting in interface SearcherImplApi
      Parameters:
      sess -
      groupResourceAttribute - expected attribute set between a group and a resource (group need to be assigned to the resource)
      resourceAttribute - expected attribute set for assigned resource
      Returns:
      list of groups with following conditions
    • getGroupsIdsForAppAutoRejection

      public List<Integer> getGroupsIdsForAppAutoRejection()
      Description copied from interface: SearcherImplApi
      Gets groups ids for potential application auto rejection.
      Specified by:
      getGroupsIdsForAppAutoRejection in interface SearcherImplApi
      Returns:
      groups ids
    • getMembersByExpiration

      public List<Member> getMembersByExpiration(PerunSession sess, String operator, LocalDate date, int days)
      Description copied from interface: SearcherImplApi
      Return members with expiration date set, which will expire on date +/- X days. You can specify operator for comparison (by default "=") returning exact match. So you can get all expired members (including today) using "invalid input: '<'=" and zero days shift. or using "invalid input: '<'" and +1 day shift.

      Method ignores current member state, just compares expiration date !

      Specified by:
      getMembersByExpiration in interface SearcherImplApi
      Parameters:
      sess - PerunSession
      operator - One of "=", "invalid input: '<'", ">", "invalid input: '<'=", ">=". If null, "=" is anticipated.
      date - Date to compare expiration with (if null, current date is used).
      days - X days before/after today.
      Returns:
      Members with expiration relative to method params.
    • getMembersByGroupExpiration

      public List<Member> getMembersByGroupExpiration(PerunSession sess, Group group, String operator, LocalDate date, int days)
      Description copied from interface: SearcherImplApi
      Return members who should expire in given group and with expiration date set, which will expire on date +/- X days. You can specify operator for comparison (by default "=") returning exact match. So you can get all expired members (including today) using "invalid input: '<'=" and zero days shift. or using "invalid input: '<'" and +1 day shift.

      Method returns members with its expiration status for given group. Method ignores current member state, just compares expiration date !

      Specified by:
      getMembersByGroupExpiration in interface SearcherImplApi
      Parameters:
      sess - PerunSession
      group - Group where members are searched in
      operator - One of "=", "invalid input: '<'", ">", "invalid input: '<'=", ">=". If null, "=" is anticipated.
      date - Date to compare expiration with (if null, current date is used).
      days - X days before/after today.
      Returns:
      Members with expiration relative to method params.
    • getResources

      public List<Resource> getResources(PerunSession sess, Map<Attribute,String> attributesWithSearchingValues, boolean allowPartialMatchForString) throws WrongAttributeValueException
      Description copied from interface: SearcherImplApi
      This method get Map of Attributes with searching values and try to find all resources, which have specific attributes in format. Better information about format below. When there are more than 1 attribute in Map, it means all must be true "looking for all of them" (AND)

      IMPORTANT: can't get CORE ATTRIBUTES

      Specified by:
      getResources in interface SearcherImplApi
      Parameters:
      sess - perun session
      attributesWithSearchingValues - map of attributes when attribute is type String, so value is string and we are looking for exact or partial match based by parameter 'allowPartialMatchForString' when attribute is type Integer, so value is integer in String and we are looking for total match when attribute is type List, so value is String and we are looking for at least one total or partial matching element when attribute is type Map so value is String in format "key=value" and we are looking total match of both or if is it "key" so we are looking for total match of key IMPORTANT: In map there is not allowed char '=' in key. First char '=' is delimiter in MAP item key=value!!!
      allowPartialMatchForString - if true, we are looking for partial match, if false, we are looking only for exact match (only for STRING type attributes)
      Returns:
      list of resources that have attributes with specific values (behavior above) if no such resource exists, return empty list if attributeWithSearchingValues is empty, return all resources
      Throws:
      WrongAttributeValueException - wrong attribute value
    • getUsers

      public List<User> getUsers(PerunSession sess, Map<Attribute,String> attributesWithSearchingValues) throws WrongAttributeValueException
      Description copied from interface: SearcherImplApi
      This method get Map of Attributes with searching values and try to find all users, which have specific attributes in format. Better information about format below. When there are more than 1 attribute in Map, it means all must be true "looking for all of them" (AND)

      IMPORTANT: can't get CORE ATTRIBUTES

      Specified by:
      getUsers in interface SearcherImplApi
      Parameters:
      sess - perun session
      attributesWithSearchingValues - map of attributes when attribute is type String, so value is string and we are looking for total match (Partial is not supported now, will be supported later by symbol *) when attribute is type Integer, so value is integer in String and we are looking for total match when attribute is type List, so value is String and we are looking for at least one total or partial matching element when attribute is type Map so value is String in format "key=value" and we are looking total match of both or if is it "key" so we are looking for total match of key IMPORTANT: In map there is not allowed char '=' in key. First char '=' is delimiter in MAP item key=value!!!
      Returns:
      list of users who have attributes with specific values (behavior above) if no user exist, return empty list of users if attributeWithSearchingValues is empty, return allUsers
      Throws:
      WrongAttributeValueException - wrong attribute value
    • getMembers

      public List<Member> getMembers(PerunSession sess, Vo vo, Map<String,Map<Attribute,String>> mapOfEntityToMapOfAttrsWithValues) throws WrongAttributeValueException
      Description copied from interface: SearcherImplApi
      This method takes a map of entity (member or user) to maps of Attributes with values to search by, for the members in the given vo.
       E.g.: member -> Attribute(urn:perun:member:attribute-def:def:memAttr1...) -> val1
                       Attribute(urn:perun:member:attribute-def:def:memAttr2...) -> val2
             user ->   Attribute(urn:perun:user:attribute-def:def:userAttr1...) -> val3
                       Attribute(urn:perun:user:attribute-def:def:userAttr2...) -> val4
       
      A member would need to have matching values in both of the member attributes above and its associated user in both the user attributes above in order to be returned.

      IMPORTANT: can't get CORE and VIRTUAL ATTRIBUTES

      Specified by:
      getMembers in interface SearcherImplApi
      Parameters:
      sess - perun session
      mapOfEntityToMapOfAttrsWithValues - map of member and user keys to map of attributes with values to search by in those namespaces. The matching of the attributes by the values works as follows: when attribute is type String, so value is string and we are looking for total match (Partial is not supported now, will be supported later by symbol *) when attribute is type Integer, so value is integer in String and we are looking for total match when attribute is type List, so value is String and we are looking for at least one total or partial matching element when attribute is type Map so value is String in format "key=value" and we are looking total match of both or if is it "key" so we are looking for total match of key IMPORTANT: In map there is not allowed char '=' in key. First char '=' is delimiter in MAP item key=value!!!
      Returns:
      list of users who have attributes with specific values (behavior above) if no user exist, return empty list of users if attributeWithSearchingValues is empty, return allUsers
      Throws:
      WrongAttributeValueException - wrong attribute value
    • getVosIdsForAppAutoRejection

      public List<Integer> getVosIdsForAppAutoRejection()
      Description copied from interface: SearcherImplApi
      Gets VOs ids for potential application auto rejection.
      Specified by:
      getVosIdsForAppAutoRejection in interface SearcherImplApi
      Returns:
      VOs ids