This commit is contained in:
@@ -35,6 +35,10 @@ IMMEDIATE ITEMS:
|
|||||||
- Add code to do actual search and return results and routes (tags need support too as per search specs)
|
- Add code to do actual search and return results and routes (tags need support too as per search specs)
|
||||||
- Add tests for searching and routes
|
- Add tests for searching and routes
|
||||||
|
|
||||||
|
- EventLogProcessor.AddEntry: CHANGE this to save the context itself and then change all callers to handle that (remove save)
|
||||||
|
- I originally didn't have the save in there because I thought subsequent code might all share in the single context save,
|
||||||
|
however that's impossible as things like the search indexing require a save to harvest id's so it's not actually saving any time just adding complexity
|
||||||
|
where it shouldn't (in the caller)
|
||||||
|
|
||||||
- Auto visible id number assigning code
|
- Auto visible id number assigning code
|
||||||
- Give widgets a visible ID number scheme and add to tests
|
- Give widgets a visible ID number scheme and add to tests
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
{
|
{
|
||||||
//Log
|
//Log
|
||||||
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, AyaType.Widget, AyaEvent.Modified), ct);
|
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, AyaType.Widget, AyaEvent.Modified), ct);
|
||||||
Search.ProcessUpdatedObjectKeywords(ct, LocaleIdFromContext.Id(HttpContext.Items), o.Id, AyaType.Widget, o.Name, o.Notes);
|
Search.ProcessUpdatedObjectKeywords(ct, LocaleIdFromContext.Id(HttpContext.Items), o.Id, AyaType.Widget, o.Name, o.Notes, o.Name);
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
catch (DbUpdateConcurrencyException)
|
catch (DbUpdateConcurrencyException)
|
||||||
@@ -287,8 +287,11 @@ namespace AyaNova.Api.Controllers
|
|||||||
{
|
{
|
||||||
//Log
|
//Log
|
||||||
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, AyaType.Widget, AyaEvent.Modified), ct);
|
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, AyaType.Widget, AyaEvent.Modified), ct);
|
||||||
Search.ProcessUpdatedObjectKeywords(ct, LocaleIdFromContext.Id(HttpContext.Items), o.Id, AyaType.Widget, o.Name, o.Notes);
|
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
|
|
||||||
|
//this will save the context as part of it's operations
|
||||||
|
Search.ProcessUpdatedObjectKeywords(ct, LocaleIdFromContext.Id(HttpContext.Items), o.Id, AyaType.Widget, o.Name, o.Notes, o.Name);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (DbUpdateConcurrencyException)
|
catch (DbUpdateConcurrencyException)
|
||||||
{
|
{
|
||||||
@@ -352,9 +355,12 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
//Log now that we have the Id
|
//Log now that we have the Id
|
||||||
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, AyaType.Widget, AyaEvent.Created), ct);
|
EventLogProcessor.AddEntry(new Event(biz.userId, o.Id, AyaType.Widget, AyaEvent.Created), ct);
|
||||||
Search.ProcessNewObjectKeywords(ct, LocaleIdFromContext.Id(HttpContext.Items), o.Id, AyaType.Widget, o.Name, o.Notes);
|
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
|
|
||||||
|
//this will save the context as part of it's operations
|
||||||
|
Search.ProcessNewObjectKeywords(ct, LocaleIdFromContext.Id(HttpContext.Items), o.Id, AyaType.Widget, o.Name, o.Notes, o.Name);
|
||||||
|
|
||||||
|
|
||||||
//return success and link
|
//return success and link
|
||||||
return CreatedAtAction("GetWidget", new { id = o.Id }, new ApiCreatedResponse(o));
|
return CreatedAtAction("GetWidget", new { id = o.Id }, new ApiCreatedResponse(o));
|
||||||
}
|
}
|
||||||
@@ -406,9 +412,12 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
//Log
|
//Log
|
||||||
EventLogProcessor.DeleteObject(biz.userId, AyaType.Widget, dbObj.Id, dbObj.Name, ct);
|
EventLogProcessor.DeleteObject(biz.userId, AyaType.Widget, dbObj.Id, dbObj.Name, ct);
|
||||||
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, AyaType.Widget);
|
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
|
|
||||||
|
//This will directly execute and is not part of context for saving purposes
|
||||||
|
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, AyaType.Widget);
|
||||||
|
|
||||||
|
|
||||||
//Delete children / attached objects
|
//Delete children / attached objects
|
||||||
biz.DeleteChildren(dbObj);
|
biz.DeleteChildren(dbObj);
|
||||||
|
|
||||||
|
|||||||
@@ -44,16 +44,11 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Process the keywords into the dictionary
|
/// Process the keywords into the dictionary
|
||||||
|
/// NOTE: NAME parameter is in ADDITION to the NAME also being on of the strings passed in text parameter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void ProcessKeywords(AyContext ct, long localeId, long objectID, AyaType objectType, bool newRecord, string name, params string[] text)
|
private static void ProcessKeywords(AyContext ct, long localeId, long objectID, AyaType objectType, bool newRecord, string name, params string[] text)
|
||||||
{
|
{
|
||||||
|
|
||||||
//TODO: Code this, using method idea from v7 code and adding the handling of the new InName flag and Name separately.
|
|
||||||
//Note that as initially coded in widget test class the context will be saved by the controller as it is also done with the event log
|
|
||||||
//So theoretically I don't save here, but it may turn out that the code requires a save so in that case need to re-do the WidgetController calls to here to
|
|
||||||
//account for the save
|
|
||||||
|
|
||||||
|
|
||||||
//IF NOT NEW, DELETE ALL EXISTING ENTRIES FOR OBJECT TYPE AND ID
|
//IF NOT NEW, DELETE ALL EXISTING ENTRIES FOR OBJECT TYPE AND ID
|
||||||
if (!newRecord)
|
if (!newRecord)
|
||||||
{
|
{
|
||||||
@@ -63,6 +58,9 @@ namespace AyaNova.Biz
|
|||||||
//BREAK STRING ARRAY INTO KEYWORD LIST
|
//BREAK STRING ARRAY INTO KEYWORD LIST
|
||||||
List<string> KeyWordList = Break(localeId, text);
|
List<string> KeyWordList = Break(localeId, text);
|
||||||
|
|
||||||
|
//BREAK NAME STRING
|
||||||
|
List<string> NameKeyWordList = Break(localeId, name);
|
||||||
|
|
||||||
//EARLY EXIT IF NO KEYWORDS OR NAME RECORD TO PROCESS
|
//EARLY EXIT IF NO KEYWORDS OR NAME RECORD TO PROCESS
|
||||||
if (KeyWordList.Count == 0 && string.IsNullOrWhiteSpace(name))
|
if (KeyWordList.Count == 0 && string.IsNullOrWhiteSpace(name))
|
||||||
{
|
{
|
||||||
@@ -88,16 +86,26 @@ namespace AyaNova.Biz
|
|||||||
ct.SearchDictionary.Add(new SearchDictionary() { Word = KeyWord });
|
ct.SearchDictionary.Add(new SearchDictionary() { Word = KeyWord });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save the context in order to get the id's of the new words added
|
//Save the context in order to get the id's of the new words added
|
||||||
ct.SaveChanges();
|
ct.SaveChanges();
|
||||||
//Now add the id's of the newly created words to the matching keyword id list for this object
|
|
||||||
foreach (SearchDictionary SD in ct.SearchDictionary.Local)
|
//Now add the id's of the newly created words to the matching keyword id list for this object
|
||||||
{
|
//OLD BORING WAY:
|
||||||
MatchingKeywordIdList.Add(SD.Id);
|
// foreach (SearchDictionary SD in ct.SearchDictionary.Local)
|
||||||
}
|
// {
|
||||||
|
// MatchingKeywordIdList.Add(SD.Id);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//Linq all the things! (I'm so clever)
|
||||||
|
MatchingKeywordIdList.AddRange(ct.SearchDictionary.Local.Select(m => m.Id).ToList());
|
||||||
|
|
||||||
//CREATE THE SEARCHKEY RECORDS FOR ALL THE KEYWORDS
|
//CREATE THE SEARCHKEY RECORDS FOR ALL THE KEYWORDS
|
||||||
|
foreach (long KeyWordId in MatchingKeywordIdList)
|
||||||
|
{
|
||||||
|
if ()
|
||||||
|
ct.SearchDictionary.Add(new SearchKey() { Word = KeyWord });
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user