[Zeitgeist] [Merge] lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird
The proposal to merge lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird has been updated. Status: Needs review = Merged For more details, see: https://code.launchpad.net/~zeitgeist/zeitgeist/some-fixes/+merge/74927 -- https://code.launchpad.net/~zeitgeist/zeitgeist/some-fixes/+merge/74927 Your team Zeitgeist Framework Team is subscribed to branch lp:~zeitgeist/zeitgeist/bluebird. ___ Mailing list: https://launchpad.net/~zeitgeist Post to : zeitgeist@lists.launchpad.net Unsubscribe : https://launchpad.net/~zeitgeist More help : https://help.launchpad.net/ListHelp
[Zeitgeist] [Merge] lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird
Seif Lotfy has proposed merging lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird. Requested reviews: Zeitgeist Framework Team (zeitgeist) For more details, see: https://code.launchpad.net/~zeitgeist/zeitgeist/some-fixes/+merge/74927 -- https://code.launchpad.net/~zeitgeist/zeitgeist/some-fixes/+merge/74927 Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird. === modified file 'src/datamodel.vala' --- src/datamodel.vala 2011-08-30 13:57:04 + +++ src/datamodel.vala 2011-09-11 22:24:23 + @@ -252,6 +252,68 @@ // must be immediately available to the user ANY = 2 // The event subjects may or may not be available } + +// Used by get_where_clause_from_event_templates +/** + * Check if the value starts with the negation operator. If it does, + * remove the operator from the value and return true. Otherwise, + * return false. + */ +public bool parse_negation (ref string val) +{ +if (!val.has_prefix (!)) +return false; +val = val.substring (1); // FIXME: fix for unicode +return true; +} + +// Used by get_where_clause_from_event_templates +/** + * Check if the value ends with the wildcard character. If it does, + * remove the wildcard character from the value and return true. + * Otherwise, return false. + */ +public bool parse_wildcard (ref string val) +{ +if (!val.has_suffix (*)) +return false; +unowned uint8[] val_data = val.data; +val_data[val_data.length-1] = '\0'; +return true; +} + +public bool check_field_match (string property, +string template_property, bool is_symbol = false, +bool can_wildcard = false) +{ +var matches = false; +var temp_string = template_property; +var is_negated = parse_negation(ref temp_string); +var temp_property = template_property; +if (is_negated) +temp_property = temp_property[1:template_property.length]; + +if (temp_property == ) { +return true; +} +else if (temp_property == property) +{ +matches = true; +} +else if (is_symbol +Symbol.get_all_parents (property).index (temp_property ) -1) +{ +matches = true; +} +else if (can_wildcard parse_wildcard(ref temp_string)) +{ +if (property.index_of ( +temp_property [0:temp_property.length-1]) -1) +matches = true; +} +debug (Checking matches for %s, temp_property); +return (is_negated) ? !matches : matches; +} public class Event : Object { @@ -384,42 +446,14 @@ } } -private bool check_field_match (string event_property, -string event_template_property, bool is_symbol = false, -bool can_wildcard = false) -{ -var matches = false; - -// FIXME: use common code! -var is_negated = (event_template_property[0] == '!'); -var template_property = event_template_property; -if (is_negated) -template_property = template_property[1:template_property.length]; - -if (template_property == ) { -return true; -} -else if (template_property == event_property) -{ -matches = true; -} -else if (is_symbol -Symbol.get_all_parents (event_property).index (template_property) -1) -{ -matches = true; -} -else if (can_wildcard template_property.has_suffix(*)) // FIXME: use common code? -{ -if (event_property.index_of ( -template_property[0:template_property.length-1]) -1) -matches = true; -} -debug (Checking matches for %s, event_template_property); -return (is_negated) ? !matches : matches; -} + public bool matches_event (Event event) { +/** +Interpret *this* as the template an match *event* against it. +This method is the dual method of :meth:`matches_template` +*/ return event.matches_template (this); } @@ -451,7 +485,6 @@ if (!check_field_match (this.origin, template_event.origin, false, true)) return false; -//FIXME: Check for subject matching if (template_event.subjects.length == 0) return true; @@ -544,7 +577,7 @@ if (subject_props = 8) current_uri = iter.next_value().get_string
[Zeitgeist] [Merge] lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird
The proposal to merge lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird has been updated. Commit Message changed to: * moved parse_negation and parse_wildcard into the datamodel for unversal usage (not sure this is the right thing to do though) * reduced duplication of check_field_match in datamodel by moving it outside the EVent and Subject classes into Zeitgeist namespace * throw Errors if MOVE_EVENT invalid * throw Error in find_related_uris * remove fixed FIXMEs For more details, see: https://code.launchpad.net/~zeitgeist/zeitgeist/some-fixes/+merge/74927 -- https://code.launchpad.net/~zeitgeist/zeitgeist/some-fixes/+merge/74927 Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird. ___ Mailing list: https://launchpad.net/~zeitgeist Post to : zeitgeist@lists.launchpad.net Unsubscribe : https://launchpad.net/~zeitgeist More help : https://help.launchpad.net/ListHelp
[Zeitgeist] [Merge] lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird
The proposal to merge lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird has been updated. Commit Message changed to: * moved parse_negation and parse_wildcard into the datamodel for unversal usage (not sure this is the right thing to do though) * reduced duplication of check_field_match in datamodel by moving it outside the EVent and Subject classes into Zeitgeist namespace * throw Errors if MOVE_EVENT invalid * throw Error in find_related_uris * remove fixed FIXMEs For more details, see: https://code.launchpad.net/~zeitgeist/zeitgeist/some-fixes/+merge/74927 -- https://code.launchpad.net/~zeitgeist/zeitgeist/some-fixes/+merge/74927 Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird. ___ Mailing list: https://launchpad.net/~zeitgeist Post to : zeitgeist@lists.launchpad.net Unsubscribe : https://launchpad.net/~zeitgeist More help : https://help.launchpad.net/ListHelp
Re: [Zeitgeist] [Merge] lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird
Review: Needs Fixing [Merge line numbers as here on LP] [15,29]: I don't like those methods being public in datamodel, it's an implementation detail. [190,221,247,256]: Missing space before '(' [238]: It doesn't seem to be fixed. :P Not really sure what to do about the first one, I'd rather have it inside Engine (public static) for the time being. -- https://code.launchpad.net/~zeitgeist/zeitgeist/some-fixes/+merge/74927 Your team Zeitgeist Framework Team is subscribed to branch lp:~zeitgeist/zeitgeist/bluebird. ___ Mailing list: https://launchpad.net/~zeitgeist Post to : zeitgeist@lists.launchpad.net Unsubscribe : https://launchpad.net/~zeitgeist More help : https://help.launchpad.net/ListHelp
Re: [Zeitgeist] [Merge] lp:~zeitgeist/zeitgeist/some-fixes into lp:~zeitgeist/zeitgeist/bluebird
Oh and also [19]: it doesn't need any fix, it'll be working fine. -- https://code.launchpad.net/~zeitgeist/zeitgeist/some-fixes/+merge/74927 Your team Zeitgeist Framework Team is subscribed to branch lp:~zeitgeist/zeitgeist/bluebird. ___ Mailing list: https://launchpad.net/~zeitgeist Post to : zeitgeist@lists.launchpad.net Unsubscribe : https://launchpad.net/~zeitgeist More help : https://help.launchpad.net/ListHelp