Access 'Items' * ** Locate any keywords for an 'Items' entry via the 'ItemsKeyword' structure * ** A keyword can fall into one of the following categories:- ** A keyword found from 'ItemsKeywords', i.e. an assigned keyword ** which may be:- ** A simple keyword, designated by a 'ParentId' of NULL ** An hierarchical keyword, the "leaf" of an hierarchical keyword (which may be an element of a larger hierarchical keyword) ** and then via the 'Keywords' Table accessed using the 'KeywordId' from 'ItemsKeywords' ** An hierarchical keyword found by a 'ParentId' pointer from another keyword and containing a 'ParentId' ** An hierarchical keyword found by a 'ParentId' pointer from another keyword and containing a 'ParentId' = NULL - i.e. the head of the hierachical keyword * ACCESS 'ItemsKeywords' VIA the 'ItemId' value from 'Items' * ** Start reconstructing any hierarchical keywords and populating the 'dc' and 'hr' fields appropriately * * ** P R O C E S S E A C H A S S I G N E D K E Y W O R D * * FOR EACH entry in 'ItemsKeyword' associated with the 'ItemId' THEN * ** Taking each ASSIGNED keyword in turn (currently EVERY item in 'ItemsKeywords') * ** Locate the entry in the 'Keywords' Table * ACCESS 'Keywords' using the 'KeywordId' value from 'ItemsKeywords' (NOTFOUND = 'Unexpected ERROR') * ** Determine keyword type by it's context, i.e. by the 'ParentId' setting etc. * IF 'ParentId' = 'NULL' THEN * ** P R O C E S S A S I M P L E K E Y W O R D * ADD 'KeywordId' TO 'dc Keywords' * ** Consider whether it is correct to include that keyword in the 'hr' fields as DxPL and others do currently? * (Unconditional): ADD 'KeywordId' TO 'hr Keywords' <--------------------@Joanna (end Unconditional) ELSE * ** 'ParentId' Not NULL so part of an hierarchical keyword (in this case the "leaf" keyword * ** P R O C E S S A L E A F H I E R A R C H I C A L K E Y W O R D E L E M E N T * ** Start a new hierarchical keyword reconstruction from last to first, e.g. |D * SET 'Hierachical Keyword' = 'KeywordId' ADD | TO front of 'Hierarchical keyword' ** This is the "leaf" keyword in the hierarchy, e.g. D in A|B|C|D (A>B>C>D) or an assigned sub-element hierarchy ** The leaf will arguably ALWAYS be considered for the 'dc' keywords even for DxO PL5.2.0 option * (Unconditional): ADD 'KeywordId' TO 'dc Keywords' (end Unconditional) [* ** Optionally add 'KeywordId' to 'hr' Keywords'!? <------@Joanna * (Conditional): ADD 'KeywordId' TO 'hr Keywords' (End-Conditional)] * ** Using the 'ParentId' access the linked keyword in the 'Keywords' Table * FOR each entry in 'Keywords' Table found using the 'ParentId' from a 'Keywords' Table entry ACCESS 'Keywords' VIA 'ParentId' of 'Keywords' Table entry IF 'ParentId' = NULL Then * ** This is the head keyword of the hierarchical keyword * ** P R O C E S S H E A D O F A N H I E R A C H I C A L K E Y W O R D * ** Add keyword to the front of a reconstruction of the hierarchical keyword from leaf to top, i.e. in front of the previous keyword * ADD 'KeywordId' TO front of 'Hierarchical keyword' * ** Reconstruction of hierarchical keyword is now complete and the head node should be added to the 'hr' keywords <-----@Joanna * (Unconditional): ADD 'Hierarchical keyword' TO 'hr Keywords' (end Unconditional) * * Optionally add the keyword to the 'dc' keys this is different between pre PL5.2.0 & post PL5.2.0 * (Conditional): ADD 'KeywordId' TO 'dc Keywords' (End Conditional) * ** Add 'KeywordId' to 'hr Keywords', typically done with the head of an hierarchical keyword <------@Joanna * (Unconditional): ADD 'KeywordId' TO 'hr Keywords' (end Unconditional) ELSE * ** This is an itermediate hierarchical keyword * ** P R O C E S S I N T E R M E D I A T E H I E R A R C H I C A L K E Y W O R D * ADD 'KeywordId' TO front of 'Hierarchical keyword' ADD | TO front of 'Hierarchical keyword' * * Optionally add the keyword to the 'dc' keys - this is different between pre PL5.2.0 & post PL5.2.0 * (Conditional): ADD 'KeywordId' TO 'dc Keys' (End Conditional) [* ** Add 'KeywordId' to 'hr' Keywords', typically done with the head of an hierarchical keyword ** but not necessarily with other keywords * (Conditional): ADD 'KeywordId' TO 'hr Keywords' <------@Joanna (end Conditional)] END-IF REPEAT-FOR UNTIL 'ParentId = NULL' END-IF REPEAT-FOR UNTIL 'NOTFOUND' IN 'ItemsKeywords' * ** Arguably the 'dc' keywords & 'hr' keywords need duplicate entries resolved (de-duping), I believe <-------@Joanna *