package cz.metacentrum.perun.rpc.methods;

import cz.metacentrum.perun.core.api.Member;
import java.util.List;

import cz.metacentrum.perun.core.api.User;
import cz.metacentrum.perun.core.api.exceptions.PerunException;
import cz.metacentrum.perun.rpc.ApiCaller;
import cz.metacentrum.perun.rpc.ManagerMethod;
import cz.metacentrum.perun.rpc.deserializer.Deserializer;
import java.util.LinkedHashMap;

public enum SearcherMethod implements ManagerMethod {

	/*#
	 * 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)
	 *
	 * @param attributesWithSearchingValues Map<String,String> map of attributes names
	 *        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<String>, so value is String and we are looking for at least one total or partial matching element
	 *        when attribute is type Map<String> 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!!!
	 * @return List<User> list of users who have attributes with specific values (behaviour above)
	 *        if no user exist, return empty list of users
	 *        if attributeWithSearchingValues is empty, return allUsers
	 */
	getUsers {

		@Override
		public List<User> call(ApiCaller ac, Deserializer parms) throws PerunException {
			ac.stateChangingCheck();

			return ac.getSearcher().getUsers(ac.getSession(),
					parms.read("attributesWithSearchingValues", LinkedHashMap.class));
		}
	},

	/*#
	 * This method get Map of user Attributes with searching values and try to find all members, which have specific attributes in format for specific VO.
	 * 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)
	 *
	 * if principal has no rights for operation, throw exception
	 * if principal has no rights for some attribute on specific user, do not return this user
	 * if attributesWithSearchingValues is null or empty, return all members from vo if principal has rights for this operation
	 *
	 * @param userAttributesWithSearchingValues Map<String,String> map of attributes names
	 *        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<String>, so value is String and we are looking for at least one total or partial matching element
	 *        when attribute is type Map<String> 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!!!
	 * @return List<Member> list of users who have attributes with specific values (behaviour above)
	 *        if no user exist, return empty list of users
	 *        if attributeWithSearchingValues is empty, return allUsers
	 */
	getMembersByUserAttributes {

		@Override
		public List<Member> call(ApiCaller ac, Deserializer parms) throws PerunException {
			ac.stateChangingCheck();

			return ac.getSearcher().getMembersByUserAttributes(ac.getSession(),
					ac.getVoById(parms.readInt("vo")),
					parms.read("userAttributesWithSearchingValues", LinkedHashMap.class));
		}
	};
}

@@ -773,35 +773,16 @@
 ngValues
- Map%3CString,String%3E
  map of 
@@ -789,32 +789,44 @@
 attributes names
+ with values
 %0A%09 *        when
@@ -1535,27 +1535,16 @@
  @return
- List%3CUser%3E
  list of
@@ -2648,27 +2648,8 @@
 lues
- Map%3CString,String%3E
  map
@@ -2668,16 +2668,28 @@
 es names
+ with values
 %0A%09 *    
@@ -3406,29 +3406,16 @@
  @return
- List%3CMember%3E
  list of
@@ -3407,34 +3407,36 @@
 @return list of 
-us
+memb
 ers who have att

Fix javadoc in RPC