16 using System.Collections.Generic;
20 using erminas.SmartAPI.Exceptions;
21 using erminas.SmartAPI.Utils;
22 using erminas.SmartAPI.Utils.CachedCollections;
24 namespace erminas.SmartAPI.CMS.Project.Keywords
29 IKeyword CreateOrGet(
string keywordName);
30 void Delete(
string keywordName);
31 void DeleteForcibly(
string keywordName);
46 RetrieveFunc = GetKeywords;
51 public IKeyword CreateOrGet(
string keywordName)
53 const string SAVE_KEYWORD =
@"<CATEGORY guid=""{0}""><KEYWORD action=""save"" value=""{1}""/></CATEGORY>";
56 Category.
Project.
ExecuteRQL(SAVE_KEYWORD.RQLFormat(Category, HttpUtility.HtmlEncode(keywordName)),
58 var keyword = (XmlElement) xmlDoc.SelectSingleNode(
"/IODATA/KEYWORD");
62 string.Format(
"Could not create the keyword '{0}'", keywordName));
66 return new Keyword(Category.Project, keyword);
69 public void Delete(
string keywordName)
72 if (!TryGetByName(keywordName, out keyword))
81 public void DeleteForcibly(
string keywordName)
84 if (!TryGetByName(keywordName, out keyword))
97 get {
return Project.Session; }
100 private List<IKeyword> GetKeywords()
102 const string LIST_KEYWORDS =
103 @"<PROJECT><CATEGORY guid=""{0}""><KEYWORDS action=""load"" /></CATEGORY></PROJECT>";
104 XmlDocument xmlDoc = Category.Project.
ExecuteRQL(LIST_KEYWORDS.RQLFormat(Category));
105 XmlNodeList xmlNodes = xmlDoc.GetElementsByTagName(
"KEYWORD");
107 var kategoryKeyword =
new List<Keyword>
109 new Keyword(Category.Project, Category.Guid) {Name =
"[category]", Category = Category}
112 (from XmlElement curNode in xmlNodes
113 select (IKeyword)
new Keyword(Category.Project, curNode) {Category = Category}).Union(kategoryKeyword)