In this article I'm starting a discussion, what has to be done, that
JPhotoTagger supports ("really") hierarchical keywords.
1. Database structure
---------------------
1.1 Dropping table "xmp_dc_subjects"
1.2 Adding table "hierarchical_subject_xmp"
That table resolves the n:m relation of a hierarchical keyword
(HK) to
XMP metadata: 1 HK can be in multiple XMP, 1 XMP can have multiple
HKs.
It has two foreign key columns: "id_xmp" and
"id_hierarchical_subject".
2. Migrating old DC subjects
----------------------------
1. If JPhotoTagger starts and the table xmp_dc_subject does exist:
1.1 Copy all distinct DC subjects as root hierarchical keywords (if
they does not already exist)
1.2 Relate them to their XMP ("xmp_dc_subjects.id_xmp") in table
"hierarchical_subject_xmp"
1.3 If successfully, drop table "xmp_dc_subjects"
1.4 The names of saved searches having "xmp_dc_subjects" in their
query
string will be prefixed with an exclamation mark to give a hint,
that they will produce invalid queries
3. Creating XMP namespace
-------------------------
The Dublin Core XMP namespace can't be used for hierarchical subjects.
The Adobe Photoshop Lightroom's XMP namespace can't be used, because
it does not distinguish between real and helper keywords. So
JPhotoTagger has to create and register it's own namespace.
Hierarchical keywords are delimited (as Lightroom does) by the pipe
character "|". The input verifyers are ensuring, that a keyword does
not contain that delimiter. Every Keyword has the prefix "R:" or "H:"
with the meaning "Real" or "Helper" which will be removed for
displaying and storage into the database.
4. Reading XMP
--------------
1. If the XMP has a JPhotoTagger namespace, only that keywords will be
read.
2. If the XMP has no JPhotoTagger namespace, but Adobe Photoshop
hierarchical
keywords, they will be used
3. If neither JPhotoTagger nor Lightroom keywords do exist, DC
subjects will
be used
5. Writing XMP
--------------
1. Write hierarchical keywords into JPhotoTagger's namespace with
"R:" and "H:" prefixes
2. Write hierarchical keywords into Adobe Photoshop Lightrooms
namespace
without "R:" and "H:" prefixes
3. Write distinct keywords as flat DC subjects
6. Editing
----------
When adding a hierarcical keyword to an image, in the database only
one ID pair has to be stored whithin the table
"hierarchical_subject_xmp".
The edit panel list of subjects does display the hierarchy e.g.
"Keyword1 > Keyword2" as item 1 and "Keyword3 > Keyword4 > Keyword5"
as item 2 and so on. It's items are Keyword objects containing all
it's parents for writing XMP.
The editor ensures that the same HK can't be added more than one
times.
How to handle the input text field?
* Do not longer use it
* Use ist with a helper dialog displaying all possible hierarchies of
a typed
keyword for selecting
* Use it only for adding not existing keywords as new root keywords
6. Queries
----------
If a keyword is selected in the tree, all images containing that
hierarchy will be displayed. Thus means, all paths with that keyword
as parent has to be resolved. To do that: What is the best strategy in
a relational database (a hierarchical database would be a better
solution for such queries).
How to handle saved searches? E.g. using ">" as "is parent keyword
of"?
7. Other questions
------------------
Removing the "flat" list would save work.
* Tree remains an input help
* Probably, with exception of Lightroom, no other application will
support hierarchical keywords in future as an "open" standard,
so that Application A writes keywords hierarchies into XMP and
other applications reads the written keywords as the same
hierarchy with the same meaning
* Complex on changes
* Time consuming for users to keep hierarchies