/// <summary> /// Define accesslist of the document. It is the Channel id. /// </summary> /// <returns>True if succeded</returns> public override bool CalculateRights() { if (!Str.IsEmpty(Connector.DomainPrefix)) { AccessList1 = Str.And(Connector.DomainPrefix, channel.ValueStr("id")); } return(true); }
public void GetPages(List <string> pages, Dictionary <string, string> url2id, Dictionary <string, int> url2idx) { CCIndex index = CC.Current.Indexes[indexname]; EngineClient client = null; try { client = EngineClientsPool.FromPool(index); String sqlquery = Str.And("select id,", column_id, " from ", indexname, " where collection = '", collection, "' and ", column_id, "<> ''"); Sys.Log("processing query for ", sqlquery); Cursor cursor = client.ExecCursor(sqlquery); if (cursor != null) { Sys.Log("Number of rows: ", cursor.CursorRowCount); int duplicates = 0; for (int i = 0; i < cursor.CursorRowCount; i++) { //Sys.Log("doc " + i); string docid = cursor.GetColumn("id"); string pagerankid = cursor.GetColumn(column_id); if (!url2id.ContainsKey(pagerankid)) // Duplicates id are possible... { pages.Add(pagerankid); url2id[pagerankid] = docid; url2idx[pagerankid] = i - duplicates; } else { duplicates++; } //Sys.Log("Added doc " + doc.Id); cursor.MoveNext(); } } else { Sys.Log("No doc"); } } finally { EngineClientsPool.ToPool(client); } }
public void GetLinks(Dictionary <string, int> url2idx, ArrayList matrix) { CCIndex index = CC.Current.Indexes[indexname]; EngineClient client = null; try { client = EngineClientsPool.FromPool(index); String sqlquery = Str.And("select ", column_id, ",", column_links, " from ", indexname, " where collection = '", collection, "' and ", column_id, "<> ''"); Sys.Log("processing query for ", sqlquery); Cursor cursor = client.ExecCursor(sqlquery); if (cursor != null) { Sys.Log("Number of rows: ", cursor.CursorRowCount); for (int i = 0; i < cursor.CursorRowCount; i++) { string pagerankid = cursor.GetColumn(column_id); string links = cursor.GetColumn(column_links); //Sys.Log("doc ", i, " ", pagerankid, " ", url2idx[pagerankid]); List <int> doc = matrix[url2idx[pagerankid]] as List <int>; if (links != null && Str.NEQ(links, "")) { foreach (string link in links.Split(';')) { if (url2idx.ContainsKey(link)) { doc.Add(url2idx[link]); } } } //Sys.Log("Added doc " + url2idx[pagerankid]); cursor.MoveNext(); } } else { Sys.Log("No doc"); } } finally { EngineClientsPool.ToPool(client); } }
// ES-4537 : optimize _SqlRights // @param userListSql : sql string list of user rights ids ::= 'dom|id1'[,'dom|idN']* // @returns denied lists and access lists as SQL String (or null if no rights or access/denied lists count == 0) // rightsAsSqlStr ::= {accesslists} | {deniedlists} and {accesslists} | {deniedlists} private static string RightsAsSqlStr(string userListSql) { if (Str.IsEmpty(userListSql)) { return(null); } int deniedcount = CC.Current.Global.DeniedListCount; int accesscount = CC.Current.Global.AccessListCount; if (accesscount + deniedcount == 0) { return(null); } StringBuilder sb = new StringBuilder(); //deniedlists ::= (not(deniedlist1 in (ids*))) [ and (not(deniedlistN in (ids*)))]* string deniedlistN; for (int deniedindex = 1; deniedindex <= deniedcount; deniedindex++) { deniedlistN = Str.And("deniedlist", deniedindex); if (deniedindex != 1) { Str.Add(sb, " and "); } Str.Add(sb, "(not(", deniedlistN, " in (", userListSql, ")))"); } if ((deniedcount > 0) && (accesscount > 0)) { Str.Add(sb, " and "); } //accesslists ::= (accesslist1 is null or accesslist1 in (ids*)) [ and (accesslist1 is null or accesslist1 in (ids*))]* string accesslistN; for (int accessindex = 1; accessindex <= accesscount; accessindex++) { accesslistN = Str.And("accesslist", accessindex); if (accessindex != 1) { Str.Add(sb, " and "); } Str.Add(sb, "(", accesslistN, " is null or ", accesslistN, " in (", userListSql, "))"); } return(sb.ToString()); }