public string Create(string projectId, string title, string expression) { Logger.DebugFormat("BEGIN MandatoryUserFilter.Create ProjectId={0}, Title={1}, Expression={2}", projectId, title, expression); CheckAuthentication(); var url = Url.Combine(Config.Url, Constants.MD_URI, projectId, "obj"); var request = new UserFilterRequest { UserFilter = new UserFilter { Content = new UserFilterContent {Expression = expression}, Meta = new UserFilterMeta {Title = title} } }; var response = PostRequest(url, request); var filterResponse = JsonConvert.DeserializeObject<UriResponse>(response); Logger.DebugFormat("END MandatoryUserFilter.Create"); return filterResponse.Uri; }
public string CreateUserFilter(string projectId, string filterTitle, Dictionary<string,List<string>> fillterCollection, bool inclusive = true) { var items = new Dictionary<string, List<string>>(); var attributes = Query(projectId, ObjectTypes.Attribute); foreach (var item in fillterCollection) { var attribute = FindAttributeByTitle(projectId, item.Key, attributes); if (attribute == null) { Logger.WarnFormat("No attribute found with title {0}", item.Key); return null; } var attributeElements = GetAttributeElements(projectId, attribute); var elements = new List<Element>(); foreach (var elementTitle in item.Value) { var fullAttribute = FindAttributeElementByTitle(projectId, attribute, elementTitle, attributeElements); if (fullAttribute != null) { elements.Add(fullAttribute); } } if (elements.Count == 0) { Logger.WarnFormat("No element {0} found for attribute {1}", string.Join(",", item.Value), attribute.Meta.Identifier); return null; } items.Add(attribute.Meta.Uri,elements.Select(element => element.Uri).ToList()); } var url = Url.Combine(Config.Url, Constants.MD_URI, projectId, "obj"); var payload = new UserFilterRequest(filterTitle, items, inclusive); var response = PostRequest(url, payload); var filterResponse = JsonConvert.DeserializeObject(response, typeof(UriResponse)) as UriResponse; return filterResponse.Uri; }